Native stack calls for Chan–He traversal records #
Traversal keeps a seven-word record in registers 64–70 and its word stack in registers 96–104. Registers below 64 remain available to the complete modulus and node programs. Each record contains fuel followed by three base/length pairs. The stack stores words, so a record is pushed in reverse order and popped in forward order.
The word stack is a fixed nine-register program, WordStack.program, that dispatches on an
operation tag: push = 0, pop = 1, size = 2. It occupies a fixed consecutive memory block, with
its top at the highest live address; a pop leaves the old cell in place. Traversal's time bound
adds up exact instruction counts, so the two calls it makes, a push with spare capacity and a pop
from a nonempty stack, are proved instruction by instruction. The library's bounded stack is
Stack.Memory, which Stack.Native runs on the word RAM; this dispatcher is part of the
hand-stepped traversal and goes with it. Argument delivery and result copies here are actual
native instructions and are charged.
Fixed-length records are transferred through the same dispatcher. Pushing visits a register bank
in reverse order; popping visits it in forward order, restoring the same record order. A final
self-copy on idle supplies the empty-bank case. The reserved stack memory may be dirty outside
its live prefix, and popped cells are not cleared.
Main definitions #
WordStack.program,WordStack.prepare: the dispatcher and its argument delivery.WordStack.Rep,WordStack.footprint: the top-first list representation and the reserved memory block.WordStack.pushRecord,WordStack.popRecord: native transfers of a finite register bank.slot: the seven persistent traversal-record registers.registers: the nine-register stack dispatcher inside the 128-register controller.pushFrame,popFrame: the seven-word traversal-record transfers.
Main results #
WordStack.exec_push,WordStack.exec_pop: a push in seven instructions and a nonempty pop in eleven.WordStack.pushRecord_exec,WordStack.popRecord_exec: pushnwords in9 * n + 1instructions and pop them in14 * n + 1, with exact stack, memory and register frames.pushFrame_exec,popFrame_exec: complete seven-word record transfers in 64 and 99 instructions.
The native controller and its composition proofs are original.
References #
Encoded operation tag: push = 0, pop = 1, size = 2.
Caller-supplied push value.
Persistent number of live entries.
Persistent base address of the reserved region.
Temporary cell address.
Returned value.
Constant zero.
Constant one.
Presence bit distinguishing none from a returned zero word.
Fixed operation dispatch. No code is generated from an operation or its payload.
Deliver an operation tag and a push value.
Persistent register, bounded-word, and live array invariants. Cells above the live prefix may contain old popped values; they are part of the reserved footprint.
- bounded : WordRAM.Data.Bounded w x
Reserved memory footprint; it stays fixed through pushes and pops.
A push with spare capacity writes the value above the top in seven instructions.
A pop from a nonempty stack returns its top in eleven instructions and leaves memory outside the reserved block unchanged.
Push a register bank in reverse order, leaving its words in forward order at the stack top. The terminal self-copy preserves the entire state, including for a zero-length record.
Pop into successive record registers, charging dispatch and delivery for every word. The terminal self-copy supplies the zero-length case.
Push all record words with exact instruction cost, preserving caller registers and memory outside the reserved stack. Repeated source registers are permitted.
Pop a complete record into distinct registers with exact cost. Memory outside the reserved stack and registers outside the dispatcher and destination bank are preserved.
Fuel and the three base/length pairs, retained across both 64-register native kernels.
Pointer word of the selected pending set.
Length word of the selected pending set.
The existing stack's workspace lies above every 64-register node-kernel register.
Caller-owned registers outside the stack dispatcher.
Push all seven record words in reverse order through the record transfers.
The complete native frame push charges all seven dispatches and argument delivery. There is no host-level record write, and the exact seven-word sequence is at the stack top.
Pop all seven record words in forward order through the record transfers.
The complete record pop charges every argument, dispatch and result-copy instruction. The seven restored words have their original order; other caller registers are preserved.
Record transfers do not inspect the physical word width.