Pointer-machine heaps in word memory #
A node occupies a fixed block of words. Null is zero; node a starts at
1 + stride L * a. Pointer fields precede data fields. The register layout keeps the source
banks, the next free address, a zero register, and four temporary registers.
Repr describes the represented state without constraining temporary registers or unused
memory. The update lemmas connect source register and field updates to word-memory updates.
Source register banks, next-free and zero registers, and four temporary registers.
The first address after all allocated records.
A register that remains zero.
Temporary address register.
Temporary value register.
Each node occupies at least one cell, even when it has no fields.
The base address of node a, reserving zero for null.
Null becomes zero and nonnull pointers become node base addresses.
Address of offset f within node a. Pointer offsets precede data offsets.
A source state represented in target registers and allocated memory.
Pointer register contents.
Data register contents.
The next free address.
Null comparison register.
- heapPtr (a : ℕ) (n : Record M L) : x.heap[a]? = some n → ∀ (f : Fin L.ptrFields), y.mem (cellAddr L a ↑f) = ptrWord L (n.ptr f)
Pointer fields of allocated records.
- heapData (a : ℕ) (n : Record M L) : x.heap[a]? = some n → ∀ (f : Fin L.dataFields), y.mem (cellAddr L a (L.ptrFields + ↑f)) = e (n.data f)
Data fields of allocated records.
The next-free address and every represented datum fit in a word. Validity separately ensures pointer words and occupied cell addresses are below the next-free address.
The first free address fits in a word.
Every scalar register fits in a word.
- heapData (n : Record M L) : n ∈ x.heap → ∀ (f : Fin L.dataFields), Cslib.WordRAM.Fits w (e (n.data f))
Every allocated scalar field fits in a word.
Data fields follow the pointer fields within their node's block.
Pointer words retain pointer equality, including null.
Occupied field addresses fit whenever the next-free address does.
Null or a pointer to an allocated record fits in the target word size.
Changing temporary registers preserves the represented state.
Transfer a scalar result while allowing temporary registers to change.
Storing a data field is a single word-memory update.
Appending an initialized record preserves representation. The implementation must preserve old occupied cells, initialize the new fields, and advance the next-free register.