feat(vm): arguments 对象绑定(CREATE_ARGUMENTS + 帧实参 spill 区)
This commit is contained in:
@@ -199,6 +199,7 @@ impl Inst {
|
||||
| OpCode::VOID
|
||||
| OpCode::NEW_OBJECT
|
||||
| OpCode::NEW_ARRAY
|
||||
| OpCode::CREATE_ARGUMENTS
|
||||
| OpCode::NOP => {}
|
||||
// 变量读写:LOAD_VAR/STORE_VAR/CELL_GET 读 a(None→0)
|
||||
OpCode::LOAD_VAR | OpCode::STORE_VAR | OpCode::CELL_GET => {
|
||||
@@ -256,7 +257,6 @@ impl Inst {
|
||||
}
|
||||
// 占位 opcode(emit 不产):按无 use 保守处理,不影响合法产物
|
||||
OpCode::SWITCH_TABLE
|
||||
| OpCode::PROFILE_TYPE
|
||||
| OpCode::PROFILE_SHAPE
|
||||
| OpCode::PROFILE_BRANCH
|
||||
| OpCode::PROFILE_CALL
|
||||
@@ -530,6 +530,17 @@ mod tests {
|
||||
assert_eq!(inst.use_regs().as_slice(), &[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_arguments_defs_rd_no_register_use_impure() {
|
||||
// CREATE_ARGUMENTS 写 rd;实参从 spill 栈读取,无寄存器 use;
|
||||
// 创建对象有观察副作用(分配的 arguments 可被外部观察到),不可删除。
|
||||
let inst = Inst::create_arguments(Operand::Reg(6));
|
||||
assert_eq!(inst.def_reg(), Some(6));
|
||||
assert!(inst.use_regs().is_empty());
|
||||
let f = IRFunction::new();
|
||||
assert!(!inst.is_pure(&f));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn for_in_next_defs_rd_no_use() {
|
||||
let inst = Inst::new(OpCode::FOR_IN_NEXT, Operand::Reg(0), Operand::None, Operand::None);
|
||||
|
||||
@@ -178,6 +178,12 @@ impl Inst {
|
||||
Self::new(OpCode::CREATE_CLOSURE, dst, Operand::Imm(sub_idx), Operand::None)
|
||||
}
|
||||
|
||||
/// 创建 arguments 对象:`dst = 当前帧的实参列表`。运行时从当前帧
|
||||
/// (CallFrame 或 inline 同步调用)的实参区构建,无寄存器 use。
|
||||
pub fn create_arguments(dst: Operand) -> Self {
|
||||
Self::new(OpCode::CREATE_ARGUMENTS, dst, Operand::None, Operand::None)
|
||||
}
|
||||
|
||||
// ── 跳转族:label 放 b 槽,offset 计算是 lowering 职责 ──
|
||||
|
||||
/// 无条件跳转。label 放 b 槽,offset 由 lowering 回填。
|
||||
@@ -311,6 +317,13 @@ mod tests {
|
||||
assert_eq!(cc.a, Operand::Imm(5));
|
||||
assert_eq!(cc.b, Operand::None);
|
||||
assert!(cc.ext.is_empty());
|
||||
|
||||
let ca = Inst::create_arguments(Operand::Reg(6));
|
||||
assert_eq!(ca.op, OpCode::CREATE_ARGUMENTS);
|
||||
assert_eq!(ca.rd, Operand::Reg(6));
|
||||
assert_eq!(ca.a, Operand::None);
|
||||
assert_eq!(ca.b, Operand::None);
|
||||
assert!(ca.ext.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user