A small callee in a program with a large unrelated frame #
The fixed main program reads a word into register 0, keeps 99 in register 1, calls a one-local increment function into register 2, and writes all three registers. The callee overwrites register 0: its restoration is observable in the first output. Register 1 lies above the callee's local bound: its preservation is observable in the second output.
A second, uncalled function has an arbitrary local bound. Enlarging that function or the reserved-register boundary changes neither the executed source program nor its 36 actual RAM transitions. The linked code includes the uncalled function once, so its static size does grow. Counts below are derived from the generated instruction lists and closed compiler simulation. The increment is word arithmetic, including modular wraparound.
Equations
- Ram.Examples.LocalCalls.increment = { params := 1, locals := 1, body := Ram.Stmt.assign 0 (Ram.Expr.bin Ram.BinOp.add (Ram.Expr.var 0) (Ram.Expr.const 1)), results := [Ram.Expr.var 0] }
Instances For
Equations
- Ram.Examples.LocalCalls.unused spareLocals = { params := 0, locals := spareLocals, body := Ram.Stmt.skip, results := [Ram.Expr.const 0] }
Instances For
Equations
- Ram.Examples.LocalCalls.program spareLocals = [Ram.Examples.LocalCalls.increment, Ram.Examples.LocalCalls.unused spareLocals]
Instances For
Neither the input word nor either register bound occurs in this AST.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
The callee actually changes its parameter; this is not a no-op call.
The number comes from actual save/initialize/restore instruction lists, the compiled assignment, and both control transfers.
Source execution is constructed from ordinary read, assignment, call, and write rules, not by evaluating a bounded machine runner.
This code is fixed before the input word is supplied.
Equations
- Ram.Examples.LocalCalls.code control spareLocals = Ram.LocalCompiler.rawLink control (Ram.Examples.LocalCalls.program spareLocals) Ram.Examples.LocalCalls.main
Instances For
Uncalled functions still occupy code memory, even though they contribute no runtime frame work. The two quantities are deliberately kept separate.
Exact full execution for arbitrary word input and arbitrary unrelated function size. The first input word is the ordinary counted ABI heap header. Only the sufficient address-space conditions depend on the reserved bound.
In particular, reserving at least 200 registers because of an unrelated function does not make the one-local call save or restore 200 registers.