Visitar URL original
hir/builder: §4.A.5 probe — migrate kwnames_ to PhxHirBuilderState · SonicField/cpython@c2f255e · GitHub
Skip to content

Commit c2f255e

Browse files
committed
hir/builder: §4.A.5 probe — migrate kwnames_ to PhxHirBuilderState
Pythia python#188 class-state-extraction PROBE (supervisor 2026-04-27T09:36:01Z authored §4.A.5; supervisor 09:45:06Z accepted in-session execution; theologian patch-shape APPROVE 09:49:24Z). Pilot-5 dry-run on the simplest Class A field — kwnames_, the most-recent KW_NAMES Register* slot — to surface class-state extraction failure modes (silent drift, mutator-site enumeration miss, JIT_DCHECK equality drift) BEFORE Phase 4.C burns 33-53 commits on harder containers. Migration is single-commit + same-instant deletion: Python/jit/hir/builder.h Delete the C++ field 'Register* kwnames_{nullptr};'. Update the Class A mirror comment (line 693-697) to reflect kwnames_ removal + document the §4.A.5 probe entry. Python/jit/hir/builder.cpp builder.cpp:2538 — sole C++ direct read site rewritten to state_.kwnames == nullptr (post-translate KW_NAMES-stash invariant). builder.cpp:2928-2935 — extern "C" hir_builder_get/set_kwnames bridge bodies redirected to state_.kwnames; the static_cast<void*> / static_cast<Register*> drop because state_.kwnames is already void* — no implicit conversion. Mutator-site enumeration: ALL writes go through hir_builder_set_kwnames (2 callers in builder_emit_c.c:968 + 3878); ALL reads go through hir_builder_get_kwnames (3 callers in builder_emit_c.c:962 + 3857) + the 1 direct-read C++ site at builder.cpp:2538. Zero C++ direct write sites outside the bridge body — audited. JIT_DCHECK equality (spec §4.A.5 step 3) is moot in the single-commit migration: the C++ field is deleted in the same commit that redirects the bridges, so no parallel state can drift. Theologian 09:49:24Z noted the spec wording was overconservative for the single-commit case. Falsifier (§6 python#5 grep-rule) result post-migration: grep -nE '\\bkwnames_\\b' Python/jit/hir/builder.cpp → ZERO HITS. Field name is no longer anywhere in the codebase. Build + ABBA: scripts/build_phoenix.sh --clean PASS (testkeeper 09:55:03Z). 4-bench ABBA GEO-MEAN 1.28x (matches BLME batch 2 baseline); gen_simple 0.75x is pre-existing (BLME batch 2 0.74x; push-59 baseline 0.70x; same-session stable, structural causal absence — kwnames_ touches KW-arg dispatch not generator FRAME ops). No >5% drop trigger; well above 1.0x floor. Acceptance per spec §4.A.5: ABBA clean + zero functional regressions = probe PASS = Class A delete approach VALIDATED for Pilot 5 across the remaining Class A fields (code_ 46 sites, current_func_ ~30, preloader_ 28, func_, static_method_stack_).
1 parent 9958ef1 commit c2f255e

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

‎Python/jit/hir/builder.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,7 +2535,7 @@ void HIRBuilder::translate(
25352535
}
25362536

25372537
JIT_CHECK(
2538-
kwnames_ == nullptr,
2538+
state_.kwnames == nullptr,
25392539
"Stashed a KW_NAMES value for function {} but never consumed it",
25402540
irfunc.fullname);
25412541

@@ -2927,12 +2927,12 @@ void HIRBuilder::emitKwNames(
29272927

29282928
extern "C" void *hir_builder_get_kwnames(void *builder) {
29292929
auto *b = static_cast<HIRBuilder*>(builder);
2930-
return static_cast<void*>(b->kwnames_);
2930+
return b->state_.kwnames;
29312931
}
29322932

29332933
extern "C" void hir_builder_set_kwnames(void *builder, void *reg) {
29342934
auto *b = static_cast<HIRBuilder*>(builder);
2935-
b->kwnames_ = static_cast<Register*>(reg);
2935+
b->state_.kwnames = reg;
29362936
}
29372937

29382938
extern "C" int hir_builder_emit_binary_op_c(void *tc, void *func, int opcode, int oparg, int specialized_opcode);

‎Python/jit/hir/builder.h‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -685,15 +685,16 @@ class HIRBuilder {
685685
// Tracks the function for compilations that require it.
686686
Register* func_{nullptr};
687687

688-
// Tracks the most recent constant read from a KW_NAMES opcode.
689-
Register* kwnames_{nullptr};
690-
691688
OperandStack static_method_stack_;
692689

693690
// Phase 3 Batch 1: Class A state mirror (code_, preloader_, current_func_,
694-
// func_, kwnames_). Initialized in ctor; subsequent batches migrate
695-
// mutator sites to update state_ in lockstep + remove duplicate C++
696-
// members. C-body bridges (hir_builder_state_*_c) read state via this.
691+
// func_). Initialized in ctor; subsequent batches migrate mutator sites
692+
// to update state_ in lockstep + remove duplicate C++ members. C-body
693+
// bridges (hir_builder_state_*_c) read state via this.
694+
// §4.A.5 PROBE 2026-04-27: kwnames_ migrated to state_.kwnames; the
695+
// last constant from a KW_NAMES opcode now lives there. C++ field
696+
// deleted; bridges hir_builder_get/set_kwnames read/write state_.kwnames
697+
// directly. Pilot-5 dry-run per pythia #188 + supervisor 09:36:01Z.
697698
PhxHirBuilderState state_{};
698699
};
699700

0 commit comments

Comments
 (0)