pr 20
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
# PBS ⇄ VM Alignment — Junie PRs (HIP Semantics Hardening)
|
||||
|
||||
> **Purpose:** fix semantic mismatches between the PBS frontend (Core IR) and the VM **before** any VM heap/gate implementation.
|
||||
>
|
||||
> These PRs are **surgical**, **mandatory**, and **non-creative**.
|
||||
> Junie must follow them **exactly**.
|
||||
|
||||
> **Context:**
|
||||
>
|
||||
> * PBS frontend is implemented and produces Core IR.
|
||||
> * Bytecode stability is a hard requirement.
|
||||
> * VM currently has stack + const pool; heap exists but is unused.
|
||||
> * HIP semantics (gates/storage) are currently **incorrectly lowered**.
|
||||
> * `ir_vm` is feature-frozen at the moment. we are going to validate only `ir_core`
|
||||
> * Lowering is the only place `ir_core` and `ir_vm` touch each other.
|
||||
> - VM IR is never imported from Core IR.
|
||||
> - Core IR never imports VM IR.
|
||||
|
||||
---
|
||||
|
||||
## Global Rules (Read Before Any PR)
|
||||
|
||||
1. **No new features.** Only semantic correction.
|
||||
2. **No new VM opcodes yet.** VM changes come later.
|
||||
3. **No fallback values** (e.g. `FunctionId(0)`). Fail with diagnostics.
|
||||
4. **Every PR must include tests** (golden or unit).
|
||||
5. **Core IR is the source of semantic truth.**
|
||||
@@ -1,84 +1,3 @@
|
||||
# PBS ⇄ VM Alignment — Junie PRs (HIP Semantics Hardening)
|
||||
|
||||
> **Purpose:** fix semantic mismatches between the PBS frontend (Core IR) and the VM **before** any VM heap/gate implementation.
|
||||
>
|
||||
> These PRs are **surgical**, **mandatory**, and **non-creative**.
|
||||
> Junie must follow them **exactly**.
|
||||
|
||||
> **Context:**
|
||||
>
|
||||
> * PBS frontend is implemented and produces Core IR.
|
||||
> * Bytecode stability is a hard requirement.
|
||||
> * VM currently has stack + const pool; heap exists but is unused.
|
||||
> * HIP semantics (gates/storage) are currently **incorrectly lowered**.
|
||||
> * `ir_vm` is feature-frozen at the moment. we are going to validate only `ir_core`
|
||||
> * Lowering is the only place `ir_core` and `ir_vm` touch each other.
|
||||
> - VM IR is never imported from Core IR.
|
||||
> - Core IR never imports VM IR.
|
||||
|
||||
---
|
||||
|
||||
## Global Rules (Read Before Any PR)
|
||||
|
||||
1. **No new features.** Only semantic correction.
|
||||
2. **No new VM opcodes yet.** VM changes come later.
|
||||
3. **No fallback values** (e.g. `FunctionId(0)`). Fail with diagnostics.
|
||||
4. **Every PR must include tests** (golden or unit).
|
||||
5. **Core IR is the source of semantic truth.**
|
||||
|
||||
---
|
||||
|
||||
# PR-20 — Core IR: Make HIP Semantics Explicit (No Handle Loss)
|
||||
|
||||
### Goal
|
||||
|
||||
Fix the Core IR so HIP operations never lose the destination gate.
|
||||
|
||||
### Problem (Current Bug)
|
||||
|
||||
Current lowering evaluates a gate, reads storage, stores the result in a local, and later attempts to write back **without having the gate anymore**.
|
||||
|
||||
This violates PBS semantics: storage access must always be mediated by the **original gate**.
|
||||
|
||||
### Required Changes
|
||||
|
||||
#### 1. Extend Core IR instructions
|
||||
|
||||
Add explicit HIP instructions:
|
||||
|
||||
```rust
|
||||
enum CoreInstr {
|
||||
// existing …
|
||||
|
||||
Alloc { ty: TypeId, slots: u32 },
|
||||
|
||||
BeginPeek { gate: ValueId },
|
||||
BeginBorrow { gate: ValueId },
|
||||
BeginMutate { gate: ValueId },
|
||||
|
||||
EndPeek,
|
||||
EndBorrow,
|
||||
EndMutate,
|
||||
}
|
||||
```
|
||||
|
||||
Rules:
|
||||
|
||||
* `Begin*` instructions **do not consume** the gate.
|
||||
* Gate identity must remain available until the matching `End*`.
|
||||
|
||||
#### 2. Remove any lowering that copies HIP storage into locals
|
||||
|
||||
* No `ReadGate → SetLocal` pattern.
|
||||
* Storage views are **not locals**.
|
||||
|
||||
### Tests (Mandatory)
|
||||
|
||||
* Golden Core IR test showing `BeginMutate(gate)` … `EndMutate` wrapping body
|
||||
* Test asserting gate is still live at `EndMutate`
|
||||
|
||||
---
|
||||
|
||||
# PR-21 — Distinguish `peek`, `borrow`, and `mutate` in Core IR
|
||||
|
||||
### Goal
|
||||
Reference in New Issue
Block a user