refactor: 扁平化对象属性存储并优化常量池与 IC 热路径

This commit is contained in:
2026-06-13 23:59:47 +08:00
parent 7b13bbbd7d
commit 551695bfad
26 changed files with 307 additions and 87 deletions
+5 -5
View File
@@ -26,19 +26,19 @@ fn bind_error_subtype_constructor(
let ctor_shape1 = sh.make_shape(EMPTY_SHAPE_ID, si_prototype);
let ctor_shape2 = sh.make_shape(ctor_shape1, si_name);
ctor.set_shape_id(ctor_shape2);
ctor.ensure_hash_props().push(Box::new(JsValue::from_js_object(proto_ptr)));
ctor.ensure_hash_props().push(Box::new(JsValue::string(name_si, 0)));
ctor.ensure_hash_props().push(JsValue::from_js_object(proto_ptr));
ctor.ensure_hash_props().push(JsValue::string(name_si, 0));
let ctor_ptr = Box::into_raw(ctor);
let proto = unsafe { &mut *proto_ptr };
let proto_ctor_shape = sh.make_shape(proto.shape_id(), sf.intern("constructor").0);
proto.set_shape_id(proto_ctor_shape);
proto.ensure_hash_props().push(Box::new(JsValue::from_js_object(ctor_ptr)));
proto.ensure_hash_props().push(JsValue::from_js_object(ctor_ptr));
let global_shape = sh.make_shape(global.shape_id(), name_si);
global.set_shape_id(global_shape);
global.ensure_hash_props().push(Box::new(JsValue::from_js_object(ctor_ptr)));
global.ensure_hash_props().push(JsValue::from_js_object(ctor_ptr));
global.bump_generation();
}
@@ -64,7 +64,7 @@ pub fn bind_error(kernel: &Arc<OxideKernel>, global: &mut JsObject) {
let err_shape = kernel.shape_forge().make_shape(global.shape_id(), si_err);
let err_val = JsValue::from_js_object(kernel.builtin_world().error_constructor.as_ptr() as *mut JsObject);
global.set_shape_id(err_shape);
global.ensure_hash_props().push(Box::new(err_val));
global.ensure_hash_props().push(err_val);
global.bump_generation();
bind_error_subtype_constructor(