Visitar URL original
Batch 1 #4: emitUnpackSequence PARTIAL→STUB · SonicField/cpython@388cdcd · GitHub
Skip to content

Commit 388cdcd

Browse files
committed
Batch 1 python#4: emitUnpackSequence PARTIAL→STUB
Per supervisor L2565 + theologian L2569 ACK. Reduces C++ stub from ~16 lines to 7 lines (qualifies as STUB). Strategy: move jit_get_config()->specialized_opcodes gating from C++ stub into C body. C body now overrides specialized_op to -1 inline if config disables specialized opcodes. C++ stub passes bc_instr.specializedOpcode() unconditionally. ZERO new bridges (jit_get_config() already accessible in C body — multiple existing callers at line 423/431/1137). Verification: cmake --build target jit/phoenix_jit clean (BUILD_EXIT=0). Pure-C++ count unchanged (still 0); PARTIAL count drops 8→7.
1 parent b962148 commit 388cdcd

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

‎Python/jit/hir/builder.cpp‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4325,19 +4325,11 @@ void HIRBuilder::emitUnpackSequence(
43254325
CFG& /*cfg*/,
43264326
TranslationContext& tc,
43274327
const jit::BytecodeInstruction& bc_instr) {
4328-
// CFG& cfg unused — C body uses hir_cfg_alloc_block(func) instead.
4329-
// specialized_op = -1 signals C body to skip the P0 dispatch entirely
4330-
// (matches jit_get_config()->specialized_opcodes==false in C++ original).
4331-
int specialized_op = jit_get_config()->specialized_opcodes
4332-
? bc_instr.specializedOpcode()
4333-
: -1;
43344328
hir_builder_emit_unpack_sequence_c(
4335-
static_cast<void*>(&tc),
4336-
static_cast<void*>(current_func_),
4337-
static_cast<void*>(this),
4329+
&tc, current_func_, this,
43384330
bc_instr.oparg(),
43394331
bc_instr.baseOffset().value(),
4340-
specialized_op);
4332+
bc_instr.specializedOpcode());
43414333
}
43424334

43434335
extern "C" void hir_builder_emit_setup_finally_c(void *tc, int handler_off);

‎Python/jit/hir/builder_emit_c.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2987,7 +2987,13 @@ void hir_builder_emit_unpack_sequence_c(
29872987
/* P0: PEEK seq (do not pop yet — see PA). */
29882988
void *seq = tc->frame.stack.data[tc->frame.stack.count - 1];
29892989

2990-
/* P0 specialized-opcode dispatch (skipped if stub passed -1). */
2990+
/* Batch 1 #4 PARTIAL→STUB: gate specialized_op consumption on
2991+
* jit_get_config()->specialized_opcodes here (was in C++ stub). */
2992+
if (!jit_get_config()->specialized_opcodes) {
2993+
specialized_op = -1;
2994+
}
2995+
2996+
/* P0 specialized-opcode dispatch (skipped if disabled or stub passed -1). */
29912997
if (specialized_op >= 0) {
29922998
phx_tc_emit(tc, hir_c_create_snapshot(&tc->frame));
29932999
switch (specialized_op) {

0 commit comments

Comments
 (0)