pr 28
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user