fix(emit): 顶层模块 param_layout.base 改 0 防父槽误判 + regalloc/VM 诊断日志

This commit is contained in:
爱特每羊队
2026-08-07 17:13:57 +08:00
parent 70536e3e2f
commit accc677769
4 changed files with 43 additions and 3 deletions
+19
View File
@@ -235,6 +235,25 @@ fn rewrite_inst(
}
}
let _ = f;
// 防御:imm16 编码位的操作数必须是 Imm/None,不得是 Reg——
// 否则会被上面的 Reg 重写改号,VM 侧 imm16 读到错值(历史 B020 根因)。
match inst.op {
OpCode::LOAD_UPVALUE | OpCode::CREATE_CLOSURE => {
debug_assert!(
matches!(a, Operand::Imm(_) | Operand::None),
"{}: a 槽是 imm16 编码位,不得为 Reg",
inst.op
);
}
OpCode::MAKE_CELL | OpCode::CELL_GET | OpCode::CELL_SET | OpCode::STORE_UPVALUE => {
debug_assert!(
matches!(b, Operand::Imm(_) | Operand::None),
"{}: b 槽是 imm16 编码位,不得为 Reg",
inst.op
);
}
_ => {}
}
(Inst { op: inst.op, rd, a, b, ext }, arg_movs)
}