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
Per W25 spec docs/w25-hbb-canonicalization.md (theologian, gatekeeper
APPROVED, supervisor signoff [chat L2068]). Atomic single-commit Step A
per spec §3: replaces the dual-typedef HirBasicBlock + HirCFG with
forward struct decls in hir_c_api.h + struct-pointer signatures across
the API surface and §1a callers.
ARCHITECTURAL FIX (Alex Option B "clear the debt now. Then we stop
building new code on top of debt"):
Pre-W25: hir_c_api.h declared 'typedef void* HirBasicBlock' +
'typedef void* HirCFG'. hir_basic_block_c.h declared the same names
as struct typedefs. A single TU could not include both headers
(typedef collision). 24 TUs worked around this with local extern
decls — a 24-site signature-drift timebomb (push 51 root-cause
class).
Post-W25 Step A: hir_c_api.h replaces the void* typedefs with forward
struct decls. API signatures use struct-pointer (struct HirCFG *,
struct HirBasicBlock *). hir_basic_block_c.h's full struct
definitions remain canonical. Both headers now coexist in any TU
without conflict — but local extern decls in 24 §1b TUs still need
deletion (Step B) before drift surface fully closes.
CHANGES (10 files, +100/-82):
Python/jit/hir/hir_c_api.h:
- typedef void* HirBasicBlock + HirCFG REMOVED
- struct HirBasicBlock + struct HirCFG forward decls ADDED
- ~10 API signatures updated to struct-pointer form:
hir_func_cfg, hir_cfg_get_rpo, hir_cfg_blocks_first/next,
hir_block_empty/id/first/next/terminator/append/pop_front/
in_edges_count/fixup_phis, hir_instr_successor, hir_branch_target,
hir_block_back, hir_remove_trampoline_blocks
Python/jit/hir/hir_c_api.cpp:
- as_cfg/as_block: signatures updated, static_cast → reinterpret_cast
(struct-pointer to BasicBlock*/CFG* requires reinterpret)
- NEW to_cfg/to_block helpers for return-direction conversion
- All API impl signatures updated to match header
- Legacy void*-arg wrappers (hir_cfg_blocks_first_ptr etc) use
explicit static_cast to canonical struct-pointer (iter 1 fix per
testkeeper [chat L2086] catch — C++ does not implicit-convert
void* to struct pointer types)
Python/jit/hir/clean_cfg.c (§1a per spec):
- HirBasicBlock value → struct HirBasicBlock *
- sizeof(HirBasicBlock) → sizeof(struct HirBasicBlock *) (array-of-
pointers sizing — 8B → 8B, semantic preserved per spec line 134)
Python/jit/hir/dead_code_elimination.c (§1a per spec)
Python/jit/hir/dynamic_comparison_elimination.c (§1a per spec)
Python/jit/hir/func_type_checks_c.c (§1a per spec)
Python/jit/hir/guard_removal.c (§1a per spec)
Python/jit/hir/copy_propagation.c (EXTRA §1a-class, spec §1a missed)
Python/jit/hir/hir_stats_c.c (EXTRA §1a-class, spec §1a missed)
Python/jit/hir/phi_elimination.c (EXTRA §1a-class, spec §1a missed)
EXTRA TU rationale: spec §1a listed 5 TUs; my grep for callers of
hir_cfg_*/hir_block_first/etc found 8 §1a-class TUs total. Per spec
§4 'authoritative from grep', I included the 3 extras (testkeeper
[chat L2090] confirmed — same discipline as their §4 inventory
expansion 17 vs 24). Spec amendment to follow.
UNCHANGED in Step A: 24 §1b TUs (assignment_c.c, dominator_c.c,
refcount_env_c.c, builder_emit_c.c, etc.) keep their local extern
decls. Their void* extern is ABI-compatible with my new canonical
struct-pointer signature at link time. Step B will delete the local
externs and add #include "hir_c_api.h".
testkeeper x86_64 compile-only PASS verified pre-commit at binary
timestamp 1776884355 (chat L2090). Iter 1 needed explicit-cast fix
in 2 legacy wrappers; iter 2 clean.
Falsification §5.1 (dual-include compile test) deferred to next small
commit per spec §5 — requires CMakeLists.txt update for build
inclusion. Step B and §5 falsification follow this commit per spec §9.
Authorization chain:
- W25 spec publication: chat L2017 (theologian)
- gatekeeper APPROVED implementation: chat L2065
- supervisor metadata signoff + GREEN LIGHT: chat L2068
- Alex Option B directive: chat L2046
- testkeeper x86_64 compile PASS iter 2: chat L2090
0 commit comments