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