Skip to content

Commit 7c0c815

Browse files
committed
don't track escape in init shim frame
1 parent da39868 commit 7c0c815

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Python/optimizer_analysis.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,10 @@ optimize_uops(
491491

492492
int oparg = this_instr->oparg;
493493
opcode = this_instr->opcode;
494+
495+
bool was_init_shim = CURRENT_FRAME_IS_INIT_SHIM();
494496

495-
if (!CURRENT_FRAME_IS_INIT_SHIM()) {
497+
if (!was_init_shim) {
496498
stack_pointer = ctx->frame->stack_pointer;
497499
}
498500

@@ -501,7 +503,7 @@ optimize_uops(
501503
printf("%4d abs: ", (int)(this_instr - trace));
502504
_PyUOpPrint(this_instr);
503505
printf(" \n");
504-
if (get_lltrace() >= 5 && !CURRENT_FRAME_IS_INIT_SHIM()) {
506+
if (get_lltrace() >= 5 && !was_init_shim) {
505507
dump_abstract_stack(ctx->frame, stack_pointer);
506508
}
507509
}
@@ -517,16 +519,21 @@ optimize_uops(
517519
DPRINTF(1, "\nUnknown opcode in abstract interpreter\n");
518520
Py_UNREACHABLE();
519521
}
522+
523+
bool is_init_shim = CURRENT_FRAME_IS_INIT_SHIM();
524+
520525
// If no ADD_OP was called during this iteration, copy the original instruction
521526
if (ctx->out_buffer.next == out_ptr) {
522527
*(ctx->out_buffer.next++) = *this_instr;
523528
}
524-
// Track escapes
525-
if (_PyUop_Flags[out_ptr->opcode] & HAS_ESCAPES_FLAG) {
529+
// Track escapes - but skip when in/from init shim frame, since self hasn't escaped yet
530+
if ((_PyUop_Flags[out_ptr->opcode] & HAS_ESCAPES_FLAG) &&
531+
!was_init_shim && !is_init_shim)
532+
{
526533
ctx->last_escape_index = uop_buffer_length(&ctx->out_buffer) - 1;
527534
}
528535
assert(ctx->frame != NULL);
529-
if (!CURRENT_FRAME_IS_INIT_SHIM() && !ctx->done) {
536+
if (!is_init_shim && !ctx->done) {
530537
DPRINTF(3, " stack_level %d\n", STACK_LEVEL());
531538
ctx->frame->stack_pointer = stack_pointer;
532539
assert(STACK_LEVEL() >= 0);

0 commit comments

Comments
 (0)