mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 18:51:13 +08:00
fix: URI 四函数正确性修复并新增 AsyncIteratorPrototype 原型
This commit is contained in:
@@ -371,7 +371,7 @@ pub(crate) fn wire_builtin_world_links(world: &BuiltinWorld) {
|
||||
}
|
||||
|
||||
let obj_proto_val = JsValue::from_js_object(world.object_proto.as_ptr() as *mut JsObject);
|
||||
let non_object_protos: [&P<JsObject>; 27] = [
|
||||
let non_object_protos: [&P<JsObject>; 28] = [
|
||||
&world.array_proto,
|
||||
&world.function_proto,
|
||||
&world.string_proto,
|
||||
@@ -399,6 +399,7 @@ pub(crate) fn wire_builtin_world_links(world: &BuiltinWorld) {
|
||||
&world.bigint_proto,
|
||||
&world.disposable_stack_proto,
|
||||
&world.async_disposable_stack_proto,
|
||||
&world.async_iterator_proto,
|
||||
];
|
||||
for proto in &non_object_protos {
|
||||
set_proto_if_changed(proto, obj_proto_val);
|
||||
@@ -553,6 +554,7 @@ impl BuiltinWorld {
|
||||
let set_iterator_proto = P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null()));
|
||||
let string_iterator_proto = P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null()));
|
||||
let regexp_string_iterator_proto = P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null()));
|
||||
let async_iterator_proto = P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null()));
|
||||
let iterator_helper_proto = P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null()));
|
||||
let disposable_stack_proto = P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null()));
|
||||
let async_disposable_stack_proto = P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null()));
|
||||
@@ -664,6 +666,7 @@ impl BuiltinWorld {
|
||||
set_iterator_proto,
|
||||
string_iterator_proto,
|
||||
regexp_string_iterator_proto,
|
||||
async_iterator_proto,
|
||||
iterator_helper_proto,
|
||||
disposable_stack_proto,
|
||||
async_disposable_stack_proto,
|
||||
|
||||
@@ -456,6 +456,7 @@ impl BuiltinWorld {
|
||||
set_iterator_proto,
|
||||
string_iterator_proto,
|
||||
regexp_string_iterator_proto,
|
||||
async_iterator_proto,
|
||||
iterator_helper_proto,
|
||||
disposable_stack_proto,
|
||||
async_disposable_stack_proto,
|
||||
@@ -470,6 +471,7 @@ impl BuiltinWorld {
|
||||
P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null())),
|
||||
P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null())),
|
||||
P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null())),
|
||||
P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null())),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
@@ -479,6 +481,7 @@ impl BuiltinWorld {
|
||||
current.set_iterator_proto.clone(),
|
||||
current.string_iterator_proto.clone(),
|
||||
current.regexp_string_iterator_proto.clone(),
|
||||
current.async_iterator_proto.clone(),
|
||||
current.iterator_helper_proto.clone(),
|
||||
current.disposable_stack_proto.clone(),
|
||||
current.async_disposable_stack_proto.clone(),
|
||||
@@ -594,6 +597,7 @@ impl BuiltinWorld {
|
||||
set_iterator_proto,
|
||||
string_iterator_proto,
|
||||
regexp_string_iterator_proto,
|
||||
async_iterator_proto,
|
||||
iterator_helper_proto,
|
||||
disposable_stack_proto,
|
||||
async_disposable_stack_proto,
|
||||
|
||||
@@ -134,6 +134,9 @@ pub struct BuiltinWorld {
|
||||
pub string_default_iterator: std::cell::Cell<*const JsObject>,
|
||||
/// `%RegExpStringIteratorPrototype%`:matchAll 返回的迭代器。
|
||||
pub regexp_string_iterator_proto: P<JsObject>,
|
||||
/// `%AsyncIteratorPrototype%`:异步迭代器原型(链到 Object.prototype),
|
||||
/// 持有 `@@asyncIterator`/`@@asyncDispose`;`%AsyncGeneratorPrototype%` 链到它。
|
||||
pub async_iterator_proto: P<JsObject>,
|
||||
/// `%IteratorHelperPrototype%`:Iterator helpers 结果对象的共享原型,链到 %IteratorPrototype%。
|
||||
pub iterator_helper_proto: P<JsObject>,
|
||||
/// `DisposableStack.prototype`:同步资源栈原型(链到 Object.prototype),
|
||||
@@ -350,7 +353,7 @@ impl BuiltinWorld {
|
||||
/// session 收尾(`teardown_heap_data`)与选择性重建收尾(`retire_replaced`)
|
||||
/// 的 P 字段枚举唯一入口:`BuiltinWorld` 新增 P 字段须在此同步补一行,否则
|
||||
/// 收尾时该字段属性区无法释放、重建原型槽改写/释放漏掉该字段。
|
||||
pub(crate) fn all_p_fields(&self) -> [&P<JsObject>; 107] {
|
||||
pub(crate) fn all_p_fields(&self) -> [&P<JsObject>; 108] {
|
||||
[
|
||||
&self.object_proto,
|
||||
&self.array_proto,
|
||||
@@ -455,6 +458,7 @@ impl BuiltinWorld {
|
||||
&self.set_iterator_proto,
|
||||
&self.string_iterator_proto,
|
||||
&self.regexp_string_iterator_proto,
|
||||
&self.async_iterator_proto,
|
||||
&self.iterator_helper_proto,
|
||||
&self.disposable_stack_proto,
|
||||
&self.async_disposable_stack_proto,
|
||||
@@ -604,6 +608,7 @@ impl BuiltinWorld {
|
||||
BuiltinId::BigIntConstructor => &self.bigint_constructor,
|
||||
BuiltinId::BigIntProto => &self.bigint_proto,
|
||||
BuiltinId::Console => &self.console_object,
|
||||
BuiltinId::AsyncIteratorProto => &self.async_iterator_proto,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! 内置对象 id 枚举(`BuiltinId` 96 变体 + `ALL` 顺序钉表)、世代快照
|
||||
//! 内置对象 id 枚举(`BuiltinId` 98 变体 + `ALL` 顺序钉表)、世代快照
|
||||
//! (`BuiltinSnapshot`)与按家族划分的脏标记位集(`BuiltinDirtySet`);
|
||||
//! `NUM_BUILTINS` 文档承载"新增 BuiltinWorld 字段须同步"四处约束注记。
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::builtin::BuiltinWorld;
|
||||
/// 维护注意:每个新增的 `BuiltinWorld` 对象字段都必须加到这里以及
|
||||
/// `KernelSession::dirty_since_snapshot()`,以便选择性重置重建正确的
|
||||
/// builtin 家族。
|
||||
pub const NUM_BUILTINS: usize = 97;
|
||||
pub const NUM_BUILTINS: usize = 98;
|
||||
|
||||
/// 内置对象枚举 id,与 `BuiltinWorld` 中的存储槽一一对应。
|
||||
///
|
||||
@@ -118,6 +118,7 @@ pub enum BuiltinId {
|
||||
SharedArrayBufferProto = 94,
|
||||
SharedArrayBufferConstructor = 95,
|
||||
AtomicsObject = 96,
|
||||
AsyncIteratorProto = 97,
|
||||
}
|
||||
|
||||
impl BuiltinId {
|
||||
@@ -222,6 +223,7 @@ impl BuiltinId {
|
||||
BuiltinId::SharedArrayBufferProto,
|
||||
BuiltinId::SharedArrayBufferConstructor,
|
||||
BuiltinId::AtomicsObject,
|
||||
BuiltinId::AsyncIteratorProto,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -369,19 +371,20 @@ impl BuiltinDirtySet {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// 槽对齐面:表尾追加 Atomics 单例后总槽数 97,既有 96 个判别值零位移,
|
||||
/// 快照数组随 NUM_BUILTINS 自动扩维、逐槽对齐。
|
||||
/// 槽对齐面:表尾追加 AsyncIteratorPrototype 后总槽数 98,既有 97 个
|
||||
/// 判别值零位移,快照数组随 NUM_BUILTINS 自动扩维、逐槽对齐。
|
||||
#[test]
|
||||
fn builtin_snapshot_all_slots_aligned() {
|
||||
assert_eq!(NUM_BUILTINS, 97);
|
||||
assert_eq!(NUM_BUILTINS, 98);
|
||||
assert_eq!(BuiltinId::ALL.len(), NUM_BUILTINS);
|
||||
// 前 96 项判别值 0-95 逐项不变(尾追加零位移)。
|
||||
for i in 0..96usize {
|
||||
// 前 97 项判别值 0-96 逐项不变(尾追加零位移)。
|
||||
for i in 0..97usize {
|
||||
assert_eq!(BuiltinId::ALL[i] as usize, i);
|
||||
}
|
||||
assert_eq!(BuiltinId::ALL[94], BuiltinId::SharedArrayBufferProto);
|
||||
assert_eq!(BuiltinId::ALL[95], BuiltinId::SharedArrayBufferConstructor);
|
||||
assert_eq!(BuiltinId::ALL[96], BuiltinId::AtomicsObject);
|
||||
assert_eq!(BuiltinId::ALL[97], BuiltinId::AsyncIteratorProto);
|
||||
|
||||
// 快照经 session 全量构造路径采集,generations 数组维度 = 槽数。
|
||||
use crate::kernel::{KernelConfig, KernelCore, KernelSession};
|
||||
|
||||
Reference in New Issue
Block a user