You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closes the SECOND pilot. Migrates the BasicBlock* → BytecodeInstructionBlock
mapping from std::unordered_map to a dense array indexed by BasicBlock::id,
exploiting the production-validated invariant that ids are
allocation-monotonic from 0 (cfg.h:139-144 `id = next_block_id_++`). Choice
of B-γ (dense array) over B-α (parallel hash) per theologian 11:13:21Z:
no hash, no collisions, no resize-on-load-factor — three classes of bug
B-α can have, B-γ cannot. Pattern is new (id-indexed dense array vs hash)
but well-suited to the data shape.
Combined with Phase A (push 39, 72bb8e9), block_map_ is ENTIRELY
migrated to PhxHirBuilderState. The wrapping BlockMap C++ struct + the
block_map_ C++ field are DELETED.
Net bridges: 0 (no new bridges; bc_blocks had zero C-side callers per
inventory). Per theologian 11:19:42Z: §5 python#11 prevents UNCONTROLLED bridge
growth, so a net-0 pilot is neither violation nor satisfaction — Phase B's
substantive deliverable is std::unordered_map elimination, which advances
the ZERO-C++ terminal goal equivalent to bridge subtraction.
PyCodeObject* code is constant per-compile and lives on
PhxHirBuilderState.code (set in HIRBuilder ctor), so it is not stored
per-array-slot — saves 8 bytes per block.
Three invariants asserted (theologian 11:13:21Z):
- I1 (JIT_DCHECK at createBlocks return): bc_block_array.count ==
block_map_phx.count. The two are populated in lockstep on every loop
iteration; counts must agree.
- I2 (JIT_DCHECK at buildHIRImpl read): tc.block->id <
bc_block_array.count. Catches HIR-pass-created blocks accidentally
being looked up; should never happen but assert it.
- I3 (documented, not asserted): BasicBlock::id is read-only post-
allocation. No HIR pass renumbers ids; if any future pass does, B-γ
is wrong. RPO and other passes traverse, never renumber. Runtime
sentinel would defeat the dense-array O(1) win.
Lazy-grow uses single-realloc max(old_cap*2, block_id+1) per theologian
11:19:42Z verification (block_id=1000 with old_cap=16 is 1 alloc, not
7 doublings).
CALLER REWRITES (2 functional sites):
- builder.cpp createBlocks: writes both state_.block_map_phx (Phase A)
and state_.bc_block_array_phx (Phase B) in lockstep. Return type
void (was BlockMap).
- builder.cpp buildHIRImpl: read site reconstructs BytecodeInstructionBlock
value from {code_, BCIndex{start}, BCIndex{end}} using array entry +
state_.code (constant per-compile). Subsequent .begin/.end/iteration
works on the local value identically to the old map-reference.
UNIT TESTS: +6 PhxBcBlockArray tests (init/insert+at/lazy-grow/n300/
clear/overwrite-same-id) appended to test_phx_block_map.c. Existing 8
PhxBlockMap tests unchanged.
GATE COVERAGE: the existing block_map_resize_chain wiring fixture (Phase A
push 39) exercises createBlocks which now populates BOTH structures in
lockstep, so PhxBcBlockArray growth is implicitly covered. Pythia python#119
(a) n=294 coverage extension is a separate followup commit (theologian
11:20:24Z + supervisor 11:20:43Z DEFERRED — sequence-isolated, not
bundled).
Auth chain: theologian B-γ pick 11:13:21Z + patch-shape APPROVE 11:19:42Z
(2 verifications applied at 11:20:15Z); supervisor 11:13:46Z + 11:18:54Z
+ 11:20:43Z; shepard sequence-isolation 11:11:59Z; librarian §5 python#11
non-violation framing 11:15:58Z.
0 commit comments