Visitar URL original
Batch 1 #3: emitInvokeMethodVectorCall PARTIAL→STUB · SonicField/cpython@b962148 · GitHub
Skip to content

Commit b962148

Browse files
committed
Batch 1 python#3: emitInvokeMethodVectorCall PARTIAL→STUB
Per supervisor L2565 + theologian L2569 ACK. Reduces C++ stub from ~13 lines to 8 lines (qualifies as STUB). Strategy: change bridge convention from caller-allocates-out to callee-allocates-out. C body of bridge now allocates 'out' internally via hir_builder_temps_alloc_stack. Both call sites (C++ stub at builder.cpp + C-body call from emit_any_call_c) updated to drop the explicit out alloc. Bridge sig change: void *out param removed (was 4th arg). Falsification discipline: change is mechanically validated by build (callers updated in same commit) — no signature drift surface beyond the tightening. Verification: cmake --build target jit/phoenix_jit clean (BUILD_EXIT=0). Pure-C++ count unchanged (still 0); PARTIAL count drops 9→8.
1 parent 4f2b39d commit b962148

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

‎Python/jit/hir/builder.cpp‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3367,7 +3367,7 @@ bool HIRBuilder::emitInvokeNative(
33673367
}
33683368

33693369
extern "C" void hir_builder_emit_invoke_method_vector_call_c(
3370-
void* tc, void* builder, void* out,
3370+
void* tc, void* builder,
33713371
void** arg_regs_data, size_t arg_regs_count,
33723372
int is_awaited, HirType ret_type);
33733373

@@ -3376,11 +3376,8 @@ void HIRBuilder::emitInvokeMethodVectorCall(
33763376
bool is_awaited,
33773377
std::vector<Register*>& arg_regs,
33783378
const InvokeTarget& target) {
3379-
Register* out = temps_.AllocateStack();
33803379
hir_builder_emit_invoke_method_vector_call_c(
3381-
static_cast<void*>(&tc),
3382-
static_cast<void*>(this),
3383-
static_cast<void*>(out),
3380+
&tc, this,
33843381
reinterpret_cast<void**>(arg_regs.data()),
33853382
arg_regs.size(),
33863383
is_awaited ? 1 : 0,

‎Python/jit/hir/builder_emit_c.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,11 +2394,13 @@ extern void hir_builder_fix_static_return_c(
23942394
void hir_builder_emit_invoke_method_vector_call_c(
23952395
PhxTranslationContext *tc,
23962396
void *builder,
2397-
void *out,
23982397
void **arg_regs_data,
23992398
size_t arg_regs_count,
24002399
int is_awaited,
24012400
HirType ret_type) {
2401+
/* Allocate out internally (was caller-allocated; moved into bridge per
2402+
* Batch 1 #3 PARTIAL→STUB cleanup so C++ stub can drop temps_.AllocateStack). */
2403+
void *out = hir_builder_temps_alloc_stack(builder);
24022404
uint32_t flags = is_awaited ? 2u : 0u; /* CallFlags::Awaited = 1<<1 */
24032405
void *call = hir_c_create_vectorcall_reg(arg_regs_count, out, flags);
24042406
for (size_t i = 0; i < arg_regs_count; i++) {
@@ -2599,10 +2601,9 @@ bool hir_builder_emit_invoke_method_c(
25992601
phx_ptr_arr_push(&tc->frame.stack, out);
26002602
} else {
26012603
/* Dynamic dispatch via existing emitInvokeMethodVectorCall bridge.
2602-
* out is allocated INSIDE that bridge per its convention. */
2603-
void *out = hir_builder_temps_alloc_stack(builder);
2604+
* out is allocated INSIDE that bridge per Batch 1 #3 convention change. */
26042605
hir_builder_emit_invoke_method_vector_call_c(
2605-
tc, builder, out, arg_regs, arg_regs_count, is_awaited, return_type);
2606+
tc, builder, arg_regs, arg_regs_count, is_awaited, return_type);
26062607
}
26072608
return true;
26082609
}

0 commit comments

Comments
 (0)