Skip to content

Commit e05a358

Browse files
committed
Phase 1 python#8: emitSetupWithCommon dead-code delete
Phase 1 python#6 (emitBeforeWith) + python#7 (emitSetupWith) both folded their PY_VERSION_HEX conditional + C++ wrapper logic INTO the C body, and their callers now invoke hir_builder_emit_setup_with_common_c (the internal C-bridge helper) directly from C — bypassing the C++ method HIRBuilder::emitSetupWithCommon entirely. That made the C++ wrapper DEAD: zero production callers. Delete: builder.cpp: -21L (15L method def + 3L extern decl + 3L blanks) builder.h: -10L (decl removed) builder_emit_c.c: +4 -5 (stale doc comment refresh — drop W27c tag + C++ method back-reference) NET: -32L pure deletion (no fold-into-C, no sig mutation). The C body hir_builder_emit_setup_with_common_c is RETAINED — used internally by hir_builder_emit_setup_with_c (Phase 1 python#7) and hir_builder_emit_before_with_c (Phase 1 python#6) as a .c→.c helper. Authorization: theologian 22:49:41Z (cross-check PASS, exhaustive caller enumeration via grep -rnE '\bemitSetupWithCommon\b' Python Include Lib/test → 0 production callers) + supervisor 22:49:52Z (GO Step B). W45 fixture exemption justified per theologian 22:49:41Z: shepard 22:46:33Z discipline applies to fold-into-C / sig-mutation; delete-of-dead-code is neither (same precedent as Phase 1 python#1 INVOKE_* delegation-stub deletes). W44 gate: PASS (2 markers, 0 production callers).
1 parent 5c91add commit e05a358

3 files changed

Lines changed: 4 additions & 36 deletions

File tree

Python/jit/hir/builder.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4267,27 +4267,6 @@ void HIRBuilder::emitGetANext(TranslationContext& tc) {
42674267
static_cast<void*>(&tc), static_cast<void*>(current_func_));
42684268
}
42694269

4270-
extern "C" void hir_builder_emit_setup_with_common_c(
4271-
void *tc, void *builder, void *enter_id, void *exit_id,
4272-
int is_async, void **out_enter_result);
4273-
4274-
Register* HIRBuilder::emitSetupWithCommon(
4275-
TranslationContext& tc,
4276-
#if PY_VERSION_HEX < 0x030C0000
4277-
_Py_Identifier* enter_id,
4278-
_Py_Identifier* exit_id,
4279-
#else
4280-
PyObject* enter_id,
4281-
PyObject* exit_id,
4282-
#endif
4283-
bool is_async) {
4284-
void *enter_result = nullptr;
4285-
hir_builder_emit_setup_with_common_c(
4286-
&tc, this, (void*)enter_id, (void*)exit_id, is_async ? 1 : 0,
4287-
&enter_result);
4288-
return static_cast<Register*>(enter_result);
4289-
}
4290-
42914270
extern "C" void hir_builder_emit_setup_async_with_c(void *tc, int handler_off);
42924271

42934272
void HIRBuilder::emitSetupAsyncWith(

Python/jit/hir/builder.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -471,16 +471,6 @@ class HIRBuilder {
471471
void emitEndAsyncFor(TranslationContext& tc);
472472
void emitGetAIter(TranslationContext& tc);
473473
void emitGetANext(TranslationContext& tc);
474-
Register* emitSetupWithCommon(
475-
TranslationContext& tc,
476-
#if PY_VERSION_HEX < 0x030C0000
477-
_Py_Identifier* enter_id,
478-
_Py_Identifier* exit_id,
479-
#else
480-
PyObject* enter_id,
481-
PyObject* exit_id,
482-
#endif
483-
bool is_async);
484474
void emitSetupAsyncWith(
485475
TranslationContext& tc,
486476
const jit::BytecodeInstruction& bc_instr);

Python/jit/hir/builder_emit_c.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4093,13 +4093,12 @@ void hir_builder_emit_primitive_load_const_c(
40934093
(void)func; /* unused; tc owns the emission */
40944094
}
40954095

4096-
/* W27c #1: emitSetupWithCommon — helper for emitSetupWith + emitBeforeWith.
4097-
* Mirrors C++ HIRBuilder::emitSetupWithCommon @ builder.cpp:4534.
4096+
/* emitSetupWithCommon — helper for emitSetupWith + emitBeforeWith.
40984097
*
40994098
* Loads __enter__ + __exit__ via emitLoadAttrSpecial, pushes exit, emits
4100-
* VectorCall(enter), returns enter_result via out-param. PY_VERSION_HEX
4101-
* conditional (_Py_Identifier vs PyObject*) folded in C++ stub: ids are
4102-
* passed as opaque void*. is_async selects the error message text. */
4099+
* VectorCall(enter), returns enter_result via out-param. enter_id +
4100+
* exit_id are passed as opaque void* (caller picks _Py_Identifier* on
4101+
* pre-3.12 vs PyObject* on 3.12+). is_async selects error message text. */
41034102
void hir_builder_emit_setup_with_common_c(
41044103
PhxTranslationContext *tc,
41054104
void *builder,

0 commit comments

Comments
 (0)