D-522 stage 1: shared FP-bridge bodies — jit_host_bridge −82% (binary −21%)#145
Merged
Conversation
t1fp/t2fp previously inlined the payload-lookup + marshalling + invokeCb body into every (kinds x ret x slot) instantiation: ~300 B x 3,840 thunks. The bodies now live in noinline fpBridge1/fpBridge2, monomorphized per (kinds, ret) only — 60 shared bodies; each per-slot thunk is reduced to arg forwarding (~23 B). Measured (ReleaseSafe arm64 CLI): api.jit_host_bridge 1,311 KB -> 232 KB (-82%); whole binary 5,282,584 -> 4,173,736 B (-21%). No ABI change: the thunk C-ABI signatures and the planted fn-ptr table shape are untouched. Covered by test-c-api-conformance (jit_callback_fp / _args / jit_callback).
…e; size rows - D-522: stage 1 DONE (jit_host_bridge 1,311 KB -> 232 KB ReleaseSafe; ReleaseFast base/lean each -321 KB, rows recorded). Stage 2 (slot-axis collapse) re-scored to ~200 KB recoverable vs JIT call-sequence risk -> demand-driven, re-score after D-521. - D-521: root cause sharpened — dispatch_collector.dispatch() inline-for inlines all 409 registered arm64 handler bodies into emit.compile and dispatches via an O(n) compare chain. Stage A = comptime fn-pointer table (O(1), kills the inline duplication); stage B = migrate the remaining switch ops, delete the switch.
chaploud
enabled auto-merge (squash)
July 16, 2026 03:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Binary-size campaign (ADR-0204 D1) stage 1.
t1fp/t2fphost-call thunks previously inlined the payload-lookup + marshalling +invokeCbbody into every(kinds × ret × slot)instantiation (~300 B × 3,840 thunks). The bodies now live innoinline fpBridge1/fpBridge2, monomorphized per(kinds, ret)only — 60 shared bodies; each per-slot thunk reduces to arg forwarding (~23 B).Measured (arm64)
api.jit_host_bridge(ReleaseSafe)Safety
callconv(.c), param/return types) and the planted fn-ptr table shape untouched; all three trap paths (null payload base, arity mismatch, callback trap) preserved in the shared bodies.zig build test+test-c-api-conformance(jit_callback / _args / _fp) green; independent Devil's-Advocate critique 20/20 PASS (READY TO SHIP).Also in this PR
dispatch()inline-for inlines all 409 registered handler bodies intoemit.compile+ O(n) dispatch — stage A = comptime fn-pointer table.