mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 11:11:11 +08:00
refactor: 对象分配统一入口并新增会话分配入口
This commit is contained in:
@@ -104,7 +104,7 @@ impl Vm {
|
||||
&mut self, callee: JsValue, this_value: JsValue, args: &[JsValue],
|
||||
) -> Result<JsValue, String> {
|
||||
let gen_proto_val = JsValue::from_js_object(self.async_generator_proto.as_ptr() as *mut JsObject);
|
||||
let obj = self.epoch.alloc(JsObject::new_empty(EMPTY_SHAPE_ID, gen_proto_val));
|
||||
let obj = self.alloc_object(JsObject::new_empty(EMPTY_SHAPE_ID, gen_proto_val));
|
||||
let obj_ref = unsafe { &mut *obj };
|
||||
obj_ref.type_tag = JsObject::OBJ_TYPE_ASYNC_GENERATOR;
|
||||
let state = Box::new(AsyncGeneratorState {
|
||||
@@ -119,7 +119,6 @@ impl Vm {
|
||||
suspended: crate::suspended::SuspendedFrame::new_empty(),
|
||||
});
|
||||
obj_ref.set_native_data(Box::into_raw(state) as *mut u8);
|
||||
self.gc_state.track_epoch_object(obj);
|
||||
let gen_val = JsValue::from_js_object(obj);
|
||||
// 调用时参数初始化(含默认值/解构/arguments 创建):副作用与异常在 `g()` 时刻生效。
|
||||
self.initialize_async_generator(gen_val)?;
|
||||
|
||||
Reference in New Issue
Block a user