Figure 16 — Church Numeral Method Dispatch

Method dispatch via Church numeral encoding eliminates all branch instructions. A data register value is converted to a Church numeral (SUCC/ZERO), which naturally indexes into a c-list of method entries. TPERM sets permissions, then LAMBDA applies the selected method. The numeral itself is the dispatch — no comparisons, no jump tables, no branches.

Church Numeral Dispatch Flow DR1 value becomes the dispatch mechanism itself — no branch instructions anywhere in the pipeline 1 DR1 = method index e.g. DR1 = 3 (select method #3) Integer in data register, from caller convert 2 Church Numeral Conversion (SUCC / ZERO) DR1 = 3 becomes SUCC(SUCC(SUCC(ZERO))) ZERO SUCC SUCC SUCC Each SUCC applies its argument once more — the numeral is a function that applies N times index 3 C-List Indexing (Church numeral selects entry) The numeral naturally walks the c-list N positions slot 0 add() GT + seal slot 1 sub() GT + seal slot 2 mul() GT + seal slot 3 div() ← SELECTED slot 4 mod() GT + seal DR1=3 SUCC(SUCC(SUCC(ZERO))) applies SUCC three times to the base — walks to slot 3 with zero comparisons GT loaded 4 TPERM (Set Permissions) TPERM CR0, X Grant eXecute permission on the selected GT for LAMBDA dispatch X perm set 5 LAMBDA (In-Scope Apply) LAMBDA CR0 Execute div() in caller's scope — ~3 cycles, no stack frame push, machine-status fast path RETURN Result in DR1 Method executed and returned, zero branches used Zero Branch Instructions No CMP, no BEQ/BNE, no jump table, no switch/case, no indirect branch prediction. The Church numeral IS the dispatch. It applies its function argument exactly N times. Slot N is reached by construction. Conventional vs. Church Numeral Dispatch Conventional: Branch-Based CMP R0, #0 / BEQ handler_add CMP R0, #1 / BEQ handler_sub CMP R0, #2 / BEQ handler_mul CMP R0, #3 / BEQ handler_div ← 4 compares! N methods = N comparisons worst case Branch misprediction penalties, speculative execution risk Spectre/Meltdown attack surface via branch predictor Church: Numeral-Based SUCC(SUCC(SUCC(ZERO))) → walks c-list to slot 3 TPERM CR0, X LAMBDA CR0 → 0 compares! N methods = O(N) walk, zero comparisons No branch predictor needed, no misprediction Spectre/Meltdown impossible: no speculative execution
DR1 input (method index)
Church numeral conversion
C-list indexing
TPERM (permission grant)
LAMBDA (in-scope apply)
Result / RETURN