mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 18:51:13 +08:00
feat: mapped arguments defineProperty 后参数与 arguments 再同步
This commit is contained in:
@@ -332,9 +332,14 @@ impl Vm {
|
||||
// 压帧时固化 callee 的 upvalue 表(非闭包为 null 空切片):热路径免
|
||||
// 每指令重查 callee 对象,指针跨 GC 恒有效(callee 是 GC 根)。
|
||||
let up = obj.upvalues_slice() as *const [*mut Cell];
|
||||
// 帧身份单调递增:mapped arguments 状态盒按 (帧下标, 帧身份) 判定创建帧
|
||||
// 是否仍在栈上,帧弹出后身份不复用,映射随之失效。
|
||||
self.next_frame_id += 1;
|
||||
let frame_id = self.next_frame_id;
|
||||
self.frames.push(CallFrame {
|
||||
return_addr: self.pc,
|
||||
function_name,
|
||||
frame_id,
|
||||
caller_reg_limit,
|
||||
caller_active_reg_limit,
|
||||
saved_reg_offset,
|
||||
@@ -344,6 +349,7 @@ impl Vm {
|
||||
saved_this,
|
||||
saved_new_target,
|
||||
callee,
|
||||
arguments_obj: JsValue::undefined(),
|
||||
construct_result_reg,
|
||||
constructed_this,
|
||||
is_derived_constructor: obj.is_derived_constructor(),
|
||||
|
||||
@@ -44,6 +44,9 @@ impl FrameArgs<'_> {
|
||||
pub struct CallFrame {
|
||||
pub return_addr: usize,
|
||||
pub function_name: u32,
|
||||
/// 帧身份(VM 级单调计数器,压帧时分配):mapped arguments 状态盒按此判定
|
||||
/// 创建帧是否仍在栈上(帧弹出后映射失效)。
|
||||
pub frame_id: u64,
|
||||
/// 压帧保存的调用方寄存器窗口长度(= save_stack 中本帧段大小)。
|
||||
/// 普通字节码调用按调用点存活上界截断;运行时发起(accessor/内联)为
|
||||
/// 调用方 `active_reg_limit` 全量。
|
||||
@@ -61,6 +64,9 @@ pub struct CallFrame {
|
||||
pub saved_this: JsValue,
|
||||
pub saved_new_target: JsValue,
|
||||
pub callee: JsValue,
|
||||
/// 本帧的 mapped arguments 对象(参数寄存器与存储值双向同步的锚点);
|
||||
/// 无 mapped arguments 时为 undefined。GC 根(帧遍历期标记)。
|
||||
pub arguments_obj: JsValue,
|
||||
pub construct_result_reg: Option<u8>,
|
||||
pub constructed_this: Option<JsValue>,
|
||||
pub is_derived_constructor: bool,
|
||||
|
||||
@@ -75,6 +75,7 @@ impl Vm {
|
||||
f(RootGroup::Frames, frame.saved_this);
|
||||
f(RootGroup::Frames, frame.saved_new_target);
|
||||
f(RootGroup::Frames, frame.callee);
|
||||
f(RootGroup::Frames, frame.arguments_obj);
|
||||
f(RootGroup::Frames, frame.constructed_this.unwrap_or(JsValue::undefined()));
|
||||
}
|
||||
for &v in &self.save_stack {
|
||||
|
||||
@@ -201,6 +201,9 @@ pub struct Vm {
|
||||
/// 用胖 `*const`:常量 Vec 归表代际所有且 OnceLock 只填一次(堆分配地址稳定)。
|
||||
pub(crate) active_immutables: *const [JsValue],
|
||||
pub(crate) frames: SmallVec<[CallFrame; 16]>,
|
||||
/// 帧身份单调计数器:压帧时分配 `CallFrame.frame_id`(mapped arguments 状态盒
|
||||
/// 按此判定创建帧是否仍在栈上)。
|
||||
pub(crate) next_frame_id: u64,
|
||||
pub(crate) kernel_core: Arc<KernelCore>,
|
||||
/// 动态编译服务句柄:`Function` 构造器 / eval / `$262.evalScript` 经它编译
|
||||
/// 源码(`dynamic.rs` 三方法)。缺省为 no-op stub(返 `Err`),生产 entry
|
||||
|
||||
@@ -215,6 +215,9 @@ impl oxide_runtime_api::VmHost for Vm {
|
||||
fn get_own_property_slot(&self, obj: &JsObject, prop_name_si: u32) -> Option<u32> {
|
||||
self.get_own_property_slot(obj, prop_name_si)
|
||||
}
|
||||
fn arguments_mapping_alive(&self, state: &oxide_types::arguments_map::ArgumentsMapState) -> bool {
|
||||
self.arguments_mapping_alive(state)
|
||||
}
|
||||
fn ordinary_get(&mut self, obj: &JsObject, prop_name_si: u32, receiver: JsValue) -> Result<JsValue, String> {
|
||||
self.ordinary_get(obj, prop_name_si, receiver)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user