diff --git a/crates/prometeu-compiler/src/ir_vm/instr.rs b/crates/prometeu-compiler/src/ir_vm/instr.rs index 497319bc..cd4d0c4f 100644 --- a/crates/prometeu-compiler/src/ir_vm/instr.rs +++ b/crates/prometeu-compiler/src/ir_vm/instr.rs @@ -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); + } + } } diff --git a/crates/prometeu-compiler/src/ir_vm/mod.rs b/crates/prometeu-compiler/src/ir_vm/mod.rs index 43ff1bfa..6132ef92 100644 --- a/crates/prometeu-compiler/src/ir_vm/mod.rs +++ b/crates/prometeu-compiler/src/ir_vm/mod.rs @@ -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; diff --git a/docs/specs/pbs/files/PRs para Junie.md b/docs/specs/pbs/files/PRs para Junie.md index 278a0554..e69de29b 100644 --- a/docs/specs/pbs/files/PRs para Junie.md +++ b/docs/specs/pbs/files/PRs para Junie.md @@ -1,36 +0,0 @@ -# PR-06 — RC Hooks Documentation (No RC Yet) - -### Goal - -Prepare the VM for RC without implementing it yet. - -### Required Changes - -* Document which VM instructions are RC-sensitive: - - * `LocalStore` - * `GateStore` - * stack pop / drop (if present) - * frame end / `FrameSync` as safe points - -* Document RC rules: - - * retain on handle copy - * release on overwrite/drop - -### Tests - -* Documentation test or unit assertion that the RC-sensitive list exists - ---- - -## STOP POINT - -After PR-06: - -* `ir_core` and `ir_vm` are fully decoupled -* Lowering is deterministic and placeholder-free -* VM ISA v0 is defined and stable -* VM runtime work may begin safely - -**Any VM changes before this point must be rejected.**