Skip to content

Commit 7bfb7d1

Browse files
committed
builder: emitLoadAttr → C orchestrator (W27c python#1 Cat A)
Per theologian W27c audit 00:06:36Z + supervisor 00:07:10Z (a) local-accumulate posture; conversion python#1 in the 5-method PARTIAL backlog. Cat A pure dispatch-glue: C++ wrapper becomes 10-line BytecodeInstruction-extraction stub; new C orchestrator hir_builder_emit_load_attr_c wires together the existing C sub-functions (load_attr_slot_c, load_attr_module_c, load_attr_instance_value_c, load_attr_generic_c, load_method_c) that already live in builder_emit_c.c. Honest ratio framing per librarian D-1776879377 / D-1776880214: post-conversion 96/100 PURE-CONVERTED + 4 PARTIAL Cat-B remaining (was 95/100 + 5 PARTIAL). emitLoadAttr is now a delegation stub, not pure-C++-eliminated; same metric reading as the established honest-scope record. Cat A nature: zero behavior change, pure C++→C dispatch move. Snapshot-before-pop discipline preserved (Bug 7 / Phoenix-introduced fix carried over). VERIFICATION (testkeeper 00:48:33Z, x86_64 release at this HEAD): - Build: PASS (binary 1777076003) - JIT smoke (force_compile add/mul/fib): PASS - nbody crash check (3 iters identical): PASS - W-RE-PARSER substrate-stability check (per generalist 00:19:14Z + pythia python#133 python#2 challenge): OUTCOME 1 confirmed — sentinel fingerprint preserved (same Tokenizer.__next + Tokenizer.match + SubPattern.__getitem__ + SubPattern.getwidth detach sequence → SEGV). Substrate stable; W-RE-PARSER repro replayable on post-W27c-python#1 HEAD. Pythia python#133 python#2 substrate-shift risk FALSIFIED at this commit. DEFERRED VERIFICATION: - Full Phoenix test suite + ABBA 4-bench gate: BLOCKED on system load (avg 170-300, 132 python processes from team-parallel builds; per feedback_benchmark_protocol.md no benchmarks under contention). testkeeper to re-run when load drops. PUSH DEFERRED: per supervisor 00:07:10Z (α) ARM64-debt-cap discipline (currently 4/5 from pushes 50/51/52/53). Bundle with future W27c python#2/python#3 commits once devgpu004 SSH-2FA infra restored + system load returns to normal + full ABBA verifies perf floor. Auth chain: theologian audit + APPROVE 00:11:50Z; supervisor authorization 00:07:10Z (α) local-accumulate; testkeeper verification 00:48:33Z (4 checks PASS, 2 deferred under load).
1 parent ebec018 commit 7bfb7d1

2 files changed

Lines changed: 62 additions & 58 deletions

File tree

Python/jit/hir/builder.cpp

Lines changed: 7 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3642,69 +3642,18 @@ void HIRBuilder::emitDeleteAttr(
36423642
hir_builder_emit_delete_attr_c(static_cast<void*>(&tc), bc_instr.oparg());
36433643
}
36443644

3645-
extern "C" void hir_builder_emit_load_attr_generic_c(void *tc, void *func, void *receiver, int name_idx);
3646-
extern "C" int hir_builder_emit_load_attr_slot_c(void *tc, void *func, void *builder, void *receiver, PyCodeObject *code, int name_idx, int instr_idx);
3647-
extern "C" int hir_builder_emit_load_attr_module_c(void *tc, void *func, void *builder, void *receiver, PyCodeObject *code, int name_idx, int instr_idx);
3648-
extern "C" int hir_builder_emit_load_attr_instance_value_c(void *tc, void *func, void *builder, void *receiver, PyCodeObject *code, int name_idx, int instr_idx);
3645+
extern "C" void hir_builder_emit_load_attr_c(
3646+
void *tc, void *func, void *builder,
3647+
PyCodeObject *code, int oparg, int specialized_op, int instr_idx);
36493648

36503649
void HIRBuilder::emitLoadAttr(
36513650
TranslationContext& tc,
36523651
const jit::BytecodeInstruction& bc_instr) {
3653-
int oparg = bc_instr.oparg();
3654-
int name_idx = loadAttrIndex(oparg);
3655-
3656-
// In 3.12 LOAD_METHOD has been merged into LOAD_ATTR, and the oparg tells you
3657-
// which one it should be.
3658-
if constexpr (PY_VERSION_HEX >= 0x030C0000) {
3659-
if (oparg & 1) {
3660-
emitLoadMethod(tc, name_idx);
3661-
return;
3662-
}
3663-
}
3664-
3665-
if (jit_get_config()->specialized_opcodes) {
3666-
// Bug 7 fix: Snapshot BEFORE popping operands — deopt re-executes instruction
3667-
tc.emitSnapshot();
3668-
}
3669-
Register* receiver = static_cast<Register*>(phx_ptr_arr_pop(&tc.frame.stack));
3670-
3671-
if (jit_get_config()->specialized_opcodes) {
3672-
switch (bc_instr.specializedOpcode()) {
3673-
case LOAD_ATTR_MODULE: {
3674-
if (hir_builder_emit_load_attr_module_c(
3675-
static_cast<void*>(&tc), static_cast<void*>(current_func_),
3676-
static_cast<void*>(this), static_cast<void*>(receiver),
3677-
code_, name_idx, bc_instr.opcodeIndex().value())) {
3678-
return;
3679-
}
3680-
break;
3681-
}
3682-
case LOAD_ATTR_SLOT: {
3683-
if (hir_builder_emit_load_attr_slot_c(
3684-
static_cast<void*>(&tc), static_cast<void*>(current_func_),
3685-
static_cast<void*>(this), static_cast<void*>(receiver),
3686-
code_, name_idx, bc_instr.opcodeIndex().value())) {
3687-
return;
3688-
}
3689-
break;
3690-
}
3691-
case LOAD_ATTR_INSTANCE_VALUE: {
3692-
if (hir_builder_emit_load_attr_instance_value_c(
3693-
static_cast<void*>(&tc), static_cast<void*>(current_func_),
3694-
static_cast<void*>(this), static_cast<void*>(receiver),
3695-
code_, name_idx, bc_instr.opcodeIndex().value())) {
3696-
return;
3697-
}
3698-
break;
3699-
}
3700-
default:
3701-
break;
3702-
}
3703-
}
3704-
3705-
hir_builder_emit_load_attr_generic_c(
3652+
hir_builder_emit_load_attr_c(
37063653
static_cast<void*>(&tc), static_cast<void*>(current_func_),
3707-
static_cast<void*>(receiver), name_idx);
3654+
static_cast<void*>(this), code_,
3655+
bc_instr.oparg(), bc_instr.specializedOpcode(),
3656+
bc_instr.opcodeIndex().value());
37083657
}
37093658

37103659
extern "C" void hir_builder_emit_load_method_c(void *tc, void *func, int name_idx);

Python/jit/hir/builder_emit_c.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,61 @@ void hir_builder_emit_load_attr_generic_c(PhxTranslationContext *tc, void *func,
10851085
phx_ptr_arr_push(&tc->frame.stack, result);
10861086
}
10871087

1088+
/* emitLoadAttr — orchestrator (W27c CatA conversion per theologian
1089+
* 00:06:36Z + supervisor 00:07:10Z). Replaces builder.cpp emitLoadAttr
1090+
* dispatch glue. Caller passes oparg + specialized_op + instr_idx so
1091+
* this function owns: name_idx derivation, 3.12 LOAD_METHOD-merged-into-
1092+
* LOAD_ATTR routing, specialized-path dispatch, generic fallback. */
1093+
void hir_builder_emit_load_attr_c(
1094+
PhxTranslationContext *tc, void *func, void *builder,
1095+
PyCodeObject *code, int oparg, int specialized_op, int instr_idx) {
1096+
#if PY_VERSION_HEX >= 0x030C0000
1097+
int name_idx = oparg >> 1;
1098+
/* In 3.12 LOAD_METHOD has been merged into LOAD_ATTR; oparg low bit
1099+
* routes to LoadMethod. */
1100+
if (oparg & 1) {
1101+
hir_builder_emit_load_method_c(tc, func, name_idx);
1102+
return;
1103+
}
1104+
#else
1105+
int name_idx = oparg;
1106+
#endif
1107+
1108+
if (jit_get_config()->specialized_opcodes) {
1109+
/* Snapshot BEFORE popping operands -- deopt re-executes
1110+
* instruction (Bug 7 / Phoenix-introduced fix preserved). */
1111+
phx_tc_emit(tc, hir_c_create_snapshot(&tc->frame));
1112+
}
1113+
void *receiver = phx_ptr_arr_pop(&tc->frame.stack);
1114+
1115+
if (jit_get_config()->specialized_opcodes) {
1116+
switch (specialized_op) {
1117+
case LOAD_ATTR_MODULE:
1118+
if (hir_builder_emit_load_attr_module_c(
1119+
tc, func, builder, receiver, code, name_idx, instr_idx)) {
1120+
return;
1121+
}
1122+
break;
1123+
case LOAD_ATTR_SLOT:
1124+
if (hir_builder_emit_load_attr_slot_c(
1125+
tc, func, builder, receiver, code, name_idx, instr_idx)) {
1126+
return;
1127+
}
1128+
break;
1129+
case LOAD_ATTR_INSTANCE_VALUE:
1130+
if (hir_builder_emit_load_attr_instance_value_c(
1131+
tc, func, builder, receiver, code, name_idx, instr_idx)) {
1132+
return;
1133+
}
1134+
break;
1135+
default:
1136+
break;
1137+
}
1138+
}
1139+
1140+
hir_builder_emit_load_attr_generic_c(tc, func, receiver, name_idx);
1141+
}
1142+
10881143
/* emitBinaryOp — specialized guards + oparg dispatch + BinaryOp/InPlaceOp */
10891144

10901145
static int32_t get_binary_op_kind_from_oparg_c(int oparg) {

0 commit comments

Comments
 (0)