diff --git a/crates/prometeu-compiler/src/backend/emit_bytecode.rs b/crates/prometeu-compiler/src/backend/emit_bytecode.rs index fa287d73..b41e56a5 100644 --- a/crates/prometeu-compiler/src/backend/emit_bytecode.rs +++ b/crates/prometeu-compiler/src/backend/emit_bytecode.rs @@ -131,10 +131,10 @@ impl<'a> BytecodeEmitter<'a> { InstrKind::BitXor => asm_instrs.push(Asm::Op(OpCode::BitXor, vec![])), InstrKind::Shl => asm_instrs.push(Asm::Op(OpCode::Shl, vec![])), InstrKind::Shr => asm_instrs.push(Asm::Op(OpCode::Shr, vec![])), - InstrKind::GetLocal(slot) => { + InstrKind::LocalLoad { slot } => { asm_instrs.push(Asm::Op(OpCode::GetLocal, vec![Operand::U32(*slot)])); } - InstrKind::SetLocal(slot) => { + InstrKind::LocalStore { slot } => { asm_instrs.push(Asm::Op(OpCode::SetLocal, vec![Operand::U32(*slot)])); } InstrKind::GetGlobal(slot) => { diff --git a/crates/prometeu-compiler/src/ir_vm/instr.rs b/crates/prometeu-compiler/src/ir_vm/instr.rs index 50528088..497319bc 100644 --- a/crates/prometeu-compiler/src/ir_vm/instr.rs +++ b/crates/prometeu-compiler/src/ir_vm/instr.rs @@ -109,9 +109,9 @@ pub enum InstrKind { // --- Variable Access --- /// Retrieves a value from a local variable slot and pushes it onto the stack. - GetLocal(u32), + LocalLoad { slot: u32 }, /// Pops a value from the stack and stores it in a local variable slot. - SetLocal(u32), + LocalStore { slot: u32 }, /// Retrieves a value from a global variable slot and pushes it onto the stack. GetGlobal(u32), /// Pops a value from the stack and stores it in a global variable slot. @@ -207,8 +207,8 @@ mod tests { InstrKind::BitXor, InstrKind::Shl, InstrKind::Shr, - InstrKind::GetLocal(0), - InstrKind::SetLocal(0), + InstrKind::LocalLoad { slot: 0 }, + InstrKind::LocalStore { slot: 0 }, InstrKind::GetGlobal(0), InstrKind::SetGlobal(0), InstrKind::Jmp(Label("target".to_string())), @@ -266,10 +266,14 @@ mod tests { "Shl", "Shr", { - "GetLocal": 0 + "LocalLoad": { + "slot": 0 + } }, { - "SetLocal": 0 + "LocalStore": { + "slot": 0 + } }, { "GetGlobal": 0 @@ -322,4 +326,21 @@ mod tests { ]"#; assert_eq!(serialized, expected_json); } + + #[test] + fn test_no_ref_leakage_in_instr_names() { + // Enforce the rule that "Ref" must never refer to HIP memory in ir_vm. + // The snapshot test above already locks the names, but this test + // explicitly asserts the absence of the "Ref" substring in HIP-related instructions. + let instructions = [ + "GateLoad", "GateStore", "Alloc", + "GateBeginPeek", "GateEndPeek", + "GateBeginBorrow", "GateEndBorrow", + "GateBeginMutate", "GateEndMutate" + ]; + + for name in instructions { + assert!(!name.contains("Ref"), "Instruction {} contains forbidden 'Ref' terminology", name); + } + } } diff --git a/crates/prometeu-compiler/src/lowering/core_to_vm.rs b/crates/prometeu-compiler/src/lowering/core_to_vm.rs index cb5394fd..1cd3ed14 100644 --- a/crates/prometeu-compiler/src/lowering/core_to_vm.rs +++ b/crates/prometeu-compiler/src/lowering/core_to_vm.rs @@ -53,8 +53,8 @@ pub fn lower_function(core_func: &ir_core::Function) -> Result arg_count: *arg_count }, ir_core::Instr::HostCall(id) => ir_vm::InstrKind::Syscall(*id), - ir_core::Instr::GetLocal(slot) => ir_vm::InstrKind::GetLocal(*slot), - ir_core::Instr::SetLocal(slot) => ir_vm::InstrKind::SetLocal(*slot), + ir_core::Instr::GetLocal(slot) => ir_vm::InstrKind::LocalLoad { slot: *slot }, + ir_core::Instr::SetLocal(slot) => ir_vm::InstrKind::LocalStore { slot: *slot }, ir_core::Instr::Pop => ir_vm::InstrKind::Pop, ir_core::Instr::Dup => ir_vm::InstrKind::Dup, ir_core::Instr::Add => ir_vm::InstrKind::Add,