feat: Event 体系内核接线九 P 字段加 BuiltinId 加脏位加 ProtoKind

This commit is contained in:
2026-10-10 08:02:05 +00:00
parent ab16e9ce79
commit 9ecd573526
11 changed files with 224 additions and 28 deletions
+48 -3
View File
@@ -1,5 +1,5 @@
//! 注册表职责:BuiltinWorld 结构(99 固定 P 字段 + stub 族 + Box::into_raw
//! 登记表)、get_by_id 派发、all_p_fields 99 元组枚举(新增 P 字段四处同步
//! 注册表职责:BuiltinWorld 结构(108 固定 P 字段 + stub 族 + Box::into_raw
//! 登记表)、get_by_id 派发、all_p_fields 108 元组枚举(新增 P 字段四处同步
//! 约束载体)与登记表 track/find/inherit/teardown。
use oxide_types::mem::P;
@@ -150,6 +150,33 @@ pub struct BuiltinWorld {
/// `BroadcastChannel` 构造器槽位:纯内核接线占位(空对象),真实构造器
/// 本体由绑定层后续任务填充。
pub broadcast_channel_constructor: P<JsObject>,
/// `Event.prototype` 槽位:纯内核接线占位(空对象),真实原型本体
/// 与构造器对由绑定层后续任务填充;脏家族位为 `event`。
pub event_proto: P<JsObject>,
/// `Event` 构造器槽位:纯内核接线占位(空对象),真实构造器本体由
/// 绑定层后续任务填充。
pub event_constructor: P<JsObject>,
/// `MessageEvent.prototype` 槽位:纯内核接线占位(空对象),真实原型
/// 本体与构造器对由绑定层后续任务填充。
pub message_event_proto: P<JsObject>,
/// `MessageEvent` 构造器槽位:纯内核接线占位(空对象),真实构造器
/// 本体由绑定层后续任务填充。
pub message_event_constructor: P<JsObject>,
/// `ErrorEvent.prototype` 槽位:纯内核接线占位(空对象),真实原型
/// 本体与构造器对由绑定层后续任务填充。
pub error_event_proto: P<JsObject>,
/// `ErrorEvent` 构造器槽位:纯内核接线占位(空对象),真实构造器
/// 本体由绑定层后续任务填充。
pub error_event_constructor: P<JsObject>,
/// `CustomEvent.prototype` 槽位:纯内核接线占位(空对象),真实原型
/// 本体与构造器对由绑定层后续任务填充。
pub custom_event_proto: P<JsObject>,
/// `CustomEvent` 构造器槽位:纯内核接线占位(空对象),真实构造器
/// 本体由绑定层后续任务填充。
pub custom_event_constructor: P<JsObject>,
/// `EventTarget.prototype` 槽位:纯内核接线占位(空对象),真实原型
/// 本体由绑定层后续任务填充(EventTarget 无构造器,仅暴露原型)。
pub event_target_proto: P<JsObject>,
/// 释放登记表(`Box::into_raw` 对象的清单,session 收尾统一释放,非内存泄漏):
/// 绑定层经 `Box::into_raw` 持有的函数/宿主对象(方法 wrapper、访问器、
/// 错误构造器、Reflect/Iterator、内建原型构造器、`$262` 宿主等)。
@@ -380,7 +407,7 @@ impl BuiltinWorld {
/// session 收尾(`teardown_heap_data`)与选择性重建收尾(`retire_replaced`)
/// 的 P 字段枚举唯一入口:`BuiltinWorld` 新增 P 字段须在此同步补一行,否则
/// 收尾时该字段属性区无法释放、重建原型槽改写/释放漏掉该字段。
pub(crate) fn all_p_fields(&self) -> [&P<JsObject>; 99] {
pub(crate) fn all_p_fields(&self) -> [&P<JsObject>; 108] {
[
&self.object_proto,
&self.array_proto,
@@ -481,6 +508,15 @@ impl BuiltinWorld {
&self.message_channel_constructor,
&self.broadcast_channel_proto,
&self.broadcast_channel_constructor,
&self.event_proto,
&self.event_constructor,
&self.message_event_proto,
&self.message_event_constructor,
&self.error_event_proto,
&self.error_event_constructor,
&self.custom_event_proto,
&self.custom_event_constructor,
&self.event_target_proto,
]
}
@@ -618,6 +654,15 @@ impl BuiltinWorld {
BuiltinId::MessageChannelCtor => &self.message_channel_constructor,
BuiltinId::BroadcastChannelProto => &self.broadcast_channel_proto,
BuiltinId::BroadcastChannelCtor => &self.broadcast_channel_constructor,
BuiltinId::EventProto => &self.event_proto,
BuiltinId::EventCtor => &self.event_constructor,
BuiltinId::MessageEventProto => &self.message_event_proto,
BuiltinId::MessageEventCtor => &self.message_event_constructor,
BuiltinId::ErrorEventProto => &self.error_event_proto,
BuiltinId::ErrorEventCtor => &self.error_event_constructor,
BuiltinId::CustomEventProto => &self.custom_event_proto,
BuiltinId::CustomEventCtor => &self.custom_event_constructor,
BuiltinId::EventTargetProto => &self.event_target_proto,
}
}
}