refactor: realm 与 Vm 生命周期解耦,Vm 持 Arc<Realm>

This commit is contained in:
2026-10-07 01:35:16 +00:00
parent 14ef287a75
commit c6bc93a076
39 changed files with 796 additions and 676 deletions
+6 -3
View File
@@ -455,10 +455,11 @@ pub fn map_size<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
pub fn map_entries<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
let this_val = vm.reg(if args.is_empty() { 0 } else { args[0] });
let _inner = native_try!(get_map_inner(vm, this_val));
let proto_ptr = vm.session().builtin_world().map_iterator_proto.as_ptr() as *mut JsObject;
NativeResult::Ok(crate::iterator::make_collection_iterator(
vm,
this_val,
JsValue::from_js_object(vm.session().builtin_world().map_iterator_proto.as_ptr() as *mut JsObject),
JsValue::from_js_object(proto_ptr),
crate::iterator::MapSetMode::MapEntries,
))
}
@@ -467,10 +468,11 @@ pub fn map_entries<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
pub fn map_values<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
let this_val = vm.reg(if args.is_empty() { 0 } else { args[0] });
let _inner = native_try!(get_map_inner(vm, this_val));
let proto_ptr = vm.session().builtin_world().map_iterator_proto.as_ptr() as *mut JsObject;
NativeResult::Ok(crate::iterator::make_collection_iterator(
vm,
this_val,
JsValue::from_js_object(vm.session().builtin_world().map_iterator_proto.as_ptr() as *mut JsObject),
JsValue::from_js_object(proto_ptr),
crate::iterator::MapSetMode::MapValues,
))
}
@@ -479,10 +481,11 @@ pub fn map_values<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
pub fn map_keys<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
let this_val = vm.reg(if args.is_empty() { 0 } else { args[0] });
let _inner = native_try!(get_map_inner(vm, this_val));
let proto_ptr = vm.session().builtin_world().map_iterator_proto.as_ptr() as *mut JsObject;
NativeResult::Ok(crate::iterator::make_collection_iterator(
vm,
this_val,
JsValue::from_js_object(vm.session().builtin_world().map_iterator_proto.as_ptr() as *mut JsObject),
JsValue::from_js_object(proto_ptr),
crate::iterator::MapSetMode::MapKeys,
))
}