mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 18:51:13 +08:00
fix: 未声明标识符读写混合解析——读侧登记的全局槽写不穿透全局对象
未声明名由首次引用侧登记全局槽:读侧(LOAD_GLOBAL 槽)登记后, 后的写点只查写侧集合,补全局对象属性写被跳过——条件读走全局 属性、写落脚本内寄存器,脱节成死循环;更新式/复合式/逻辑赋值的 旧值又取自入口快照槽(读从不刷新槽),先读后写算出陈旧值。 写点隐式全局判定改读写登记集合取并(7 处),RMW 旧值读前经 LOAD_GLOBAL_TYPEOF 从全局对象取当前值(缺失按 undefined,sloppy 未解析引用 GetBaseValue 语义),读侧登记集合随继承绑定传入子 函数 ctx。
This commit is contained in:
@@ -632,11 +632,23 @@ impl Emitter {
|
||||
ctx.inst(Inst::new(op, Operand::Reg(tmp_reg), Operand::Reg(result_reg), Operand::Reg(result_reg)));
|
||||
return Ok(result_reg);
|
||||
}
|
||||
let is_implicit = ctx.implicit_global_writes.contains(&var_reg);
|
||||
let is_implicit = ctx.is_implicit_global_reg(var_reg);
|
||||
if is_implicit && ctx.is_strict {
|
||||
// 严格模式未声明更新写:值无关抛 ReferenceError。
|
||||
return self.emit_strict_undeclared_write(name, ctx);
|
||||
}
|
||||
// 未声明名槽是入口快照(读侧登记的槽从不被读刷新,同脚本后续写
|
||||
// 可使其脱节):RMW 前从全局对象属性取旧值,属性缺失按 undefined
|
||||
// (sloppy 未解析引用 GetBaseValue 语义,不抛)。
|
||||
if is_implicit {
|
||||
let key_idx = ctx.add_constant(Constant::String(name.to_string()));
|
||||
ctx.inst(Inst::new(
|
||||
OpCode::LOAD_GLOBAL_TYPEOF,
|
||||
Operand::Reg(var_reg),
|
||||
Operand::Const(key_idx),
|
||||
Operand::None,
|
||||
));
|
||||
}
|
||||
let result_reg = ctx.alloc_reg();
|
||||
let op = match (update.operator, update.prefix) {
|
||||
(UpdateOperator::Increment, true) => OpCode::INC_PRE,
|
||||
|
||||
Reference in New Issue
Block a user