This commit is contained in:
Nilton Constantino
2026-01-30 12:37:46 +00:00
parent 9189d2a023
commit 25482e865f
3 changed files with 37 additions and 36 deletions
@@ -156,6 +156,16 @@ pub enum InstrKind {
GateEndMutate,
}
/// List of instructions that are sensitive to Reference Counting (RC).
/// These instructions must trigger retain/release operations on gate handles.
pub const RC_SENSITIVE_OPS: &[&str] = &[
"LocalStore",
"GateStore",
"Pop",
"Ret",
"FrameSync",
];
#[cfg(test)]
mod tests {
use super::*;
@@ -343,4 +353,15 @@ mod tests {
assert!(!name.contains("Ref"), "Instruction {} contains forbidden 'Ref' terminology", name);
}
}
#[test]
fn test_rc_sensitive_list_exists() {
// Required by PR-06: Documentation test or unit assertion that the RC-sensitive list exists
assert!(!RC_SENSITIVE_OPS.is_empty(), "RC-sensitive instructions list must not be empty");
let expected = ["LocalStore", "GateStore", "Pop", "Ret", "FrameSync"];
for op in expected {
assert!(RC_SENSITIVE_OPS.contains(&op), "RC-sensitive list must contain {}", op);
}
}
}
+16
View File
@@ -7,6 +7,22 @@
//! * Heap is never directly addressable.
//! * All HIP (Heap) access is mediated via Gate Pool resolution.
//! * `Gate(GateId)` is the only HIP pointer form in `ir_vm`.
//!
//! ## Reference Counting (RC)
//!
//! The VM uses Reference Counting to manage HIP memory.
//!
//! ### RC Rules:
//! * **Retain**: Increment `strong_rc` when a gate handle is copied.
//! * **Release**: Decrement `strong_rc` when a gate handle is overwritten or dropped.
//!
//! ### RC-Sensitive Instructions:
//! The following instructions are RC-sensitive and must trigger RC updates:
//! * `LocalStore`: Release old value, retain new value.
//! * `GateStore`: Release old value, retain new value.
//! * `Pop`: Release the popped value.
//! * `Ret`: Release all live locals in the frame.
//! * `FrameSync`: Safe point; reclamation occurs after this point.
pub mod types;
pub mod module;