From fd125ac8eae94c3d3de9d4c17c7130b506b56bbe Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Sun, 13 Sep 2026 07:35:10 +0000 Subject: [PATCH] =?UTF-8?q?test:=20boolean/Map/Set=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=BE=85=E5=8A=A9=E5=8D=A0=E4=BD=8D=E5=AF=B9=E8=B1=A1=E6=94=B9?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=85=A5=E5=8F=A3=E5=88=86=E9=85=8D=E2=80=94?= =?UTF-8?q?=E2=80=94epoch=20=E7=BD=AE=E4=BD=8D=E4=B8=8E=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E8=A1=A8=E7=99=BB=E8=AE=B0=E4=B8=80=E6=AD=A5=E9=97=AD=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_vm/tests/builtins_boolean_tests.rs | 4 +++- crates/oxide_vm/tests/builtins_map_tests.rs | 6 +++--- crates/oxide_vm/tests/builtins_set_tests.rs | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/oxide_vm/tests/builtins_boolean_tests.rs b/crates/oxide_vm/tests/builtins_boolean_tests.rs index bcb6bf50..51b02b43 100644 --- a/crates/oxide_vm/tests/builtins_boolean_tests.rs +++ b/crates/oxide_vm/tests/builtins_boolean_tests.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use oxide_builtins::boolean::{boolean_constructor, boolean_prototype_to_string, boolean_prototype_value_of}; use oxide_compiler::compiler::Compiler; +use oxide_runtime_api::VmHost; use oxide_types::object::JsObject; use oxide_types::value::JsValue; use oxide_vm::vm::Vm; @@ -29,7 +30,8 @@ fn bool_ctor_call(vm: &mut Vm, arg: JsValue) -> JsValue { fn bool_ctor_new(vm: &mut Vm, arg: JsValue) -> JsValue { let proto_ptr = vm.session().builtin_world().boolean_proto.as_ptr() as *mut JsObject; let wrapper = JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::from_js_object(proto_ptr)); - let ptr = vm.epoch().alloc(wrapper); + // 统一入口分配:epoch 置位与对象表登记一步闭合,执行期晋升收集按表取活。 + let ptr = vm.alloc_object(wrapper); let val = JsValue::from_js_object(ptr); vm.set_reg(0, val); vm.set_reg(1, arg); diff --git a/crates/oxide_vm/tests/builtins_map_tests.rs b/crates/oxide_vm/tests/builtins_map_tests.rs index c7d0d701..379c0592 100644 --- a/crates/oxide_vm/tests/builtins_map_tests.rs +++ b/crates/oxide_vm/tests/builtins_map_tests.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use oxide_builtins::map::{map_clear, map_constructor as new_map, map_delete, map_get, map_has, map_set, map_size}; use oxide_compiler::compiler::Compiler; use oxide_kernel::shape_forge::EMPTY_SHAPE_ID; +use oxide_runtime_api::VmHost; use oxide_types::object::JsObject; use oxide_types::value::JsValue; use oxide_vm::vm::Vm; @@ -21,9 +22,8 @@ fn str_val(vm: &Vm, val: JsValue) -> String { /// 分配一个原型指向 Map.prototype 的占位对象并写入 reg 0,作为构造器调用的 `this`。 fn map_this(vm: &mut Vm) -> JsValue { let proto = vm.session().builtin_world().map_proto.as_ptr() as *mut JsObject; - let obj = vm - .epoch() - .alloc(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::from_js_object(proto))); + // 统一入口分配:epoch 置位与对象表登记一步闭合,执行期晋升收集按表取活。 + let obj = vm.alloc_object(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::from_js_object(proto))); let val = JsValue::from_js_object(obj); vm.set_reg(0, val); val diff --git a/crates/oxide_vm/tests/builtins_set_tests.rs b/crates/oxide_vm/tests/builtins_set_tests.rs index d4708bc1..6306cbf7 100644 --- a/crates/oxide_vm/tests/builtins_set_tests.rs +++ b/crates/oxide_vm/tests/builtins_set_tests.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use oxide_builtins::set::{set_add, set_clear, set_constructor as new_set, set_delete, set_has, set_size}; use oxide_compiler::compiler::Compiler; use oxide_kernel::shape_forge::EMPTY_SHAPE_ID; +use oxide_runtime_api::VmHost; use oxide_types::object::JsObject; use oxide_types::value::JsValue; use oxide_vm::vm::Vm; @@ -17,9 +18,8 @@ fn eval(vm: &mut Vm, source: &str) -> Result { /// 分配一个原型指向 Set.prototype 的占位对象并写入 reg 0,作为构造器调用的 `this`。 fn set_this(vm: &mut Vm) -> JsValue { let proto = vm.session().builtin_world().set_proto.as_ptr() as *mut JsObject; - let obj = vm - .epoch() - .alloc(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::from_js_object(proto))); + // 统一入口分配:epoch 置位与对象表登记一步闭合,执行期晋升收集按表取活。 + let obj = vm.alloc_object(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::from_js_object(proto))); let val = JsValue::from_js_object(obj); vm.set_reg(0, val); val