Skip to content

Commit 64857d8

Browse files
authored
GH-122294: Burn in the addresses of side exits (GH-122295)
1 parent db2d8b6 commit 64857d8

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

Include/internal/pycore_uop_metadata.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4609,8 +4609,8 @@ dummy_func(
46094609
#endif
46104610
}
46114611

4612-
tier2 op(_EXIT_TRACE, (--)) {
4613-
_PyExitData *exit = &current_executor->exits[oparg];
4612+
tier2 op(_EXIT_TRACE, (exit_p/4 --)) {
4613+
_PyExitData *exit = (_PyExitData *)exit_p;
46144614
PyCodeObject *code = _PyFrame_GetCode(frame);
46154615
_Py_CODEUNIT *target = _PyCode_CODE(code) + exit->target;
46164616
#if defined(Py_DEBUG) && !defined(_Py_JIT)
@@ -4619,7 +4619,7 @@ dummy_func(
46194619
printf("SIDE EXIT: [UOp ");
46204620
_PyUOpPrint(&next_uop[-1]);
46214621
printf(", exit %u, temp %d, target %d -> %s]\n",
4622-
oparg, exit->temperature.as_counter,
4622+
exit - current_executor->exits, exit->temperature.as_counter,
46234623
(int)(target - _PyCode_CODE(code)),
46244624
_PyOpcode_OpName[target->op.code]);
46254625
}
@@ -4698,17 +4698,17 @@ dummy_func(
46984698
exe->count++;
46994699
}
47004700

4701-
tier2 op(_DYNAMIC_EXIT, (--)) {
4701+
tier2 op(_DYNAMIC_EXIT, (exit_p/4 --)) {
47024702
tstate->previous_executor = (PyObject *)current_executor;
4703-
_PyExitData *exit = (_PyExitData *)&current_executor->exits[oparg];
4703+
_PyExitData *exit = (_PyExitData *)exit_p;
47044704
_Py_CODEUNIT *target = frame->instr_ptr;
47054705
#if defined(Py_DEBUG) && !defined(_Py_JIT)
47064706
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
47074707
if (lltrace >= 2) {
47084708
printf("DYNAMIC EXIT: [UOp ");
47094709
_PyUOpPrint(&next_uop[-1]);
47104710
printf(", exit %u, temp %d, target %d -> %s]\n",
4711-
oparg, exit->temperature.as_counter,
4711+
exit - current_executor->exits, exit->temperature.as_counter,
47124712
(int)(target - _PyCode_CODE(_PyFrame_GetCode(frame))),
47134713
_PyOpcode_OpName[target->op.code]);
47144714
}

Python/executor_cases.c.h

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,13 +1153,15 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil
11531153
*dest = buffer[i];
11541154
assert(opcode != _POP_JUMP_IF_FALSE && opcode != _POP_JUMP_IF_TRUE);
11551155
if (opcode == _EXIT_TRACE) {
1156-
executor->exits[next_exit].target = buffer[i].target;
1157-
dest->oparg = next_exit;
1156+
_PyExitData *exit = &executor->exits[next_exit];
1157+
exit->target = buffer[i].target;
1158+
dest->operand = (uint64_t)exit;
11581159
next_exit--;
11591160
}
11601161
if (opcode == _DYNAMIC_EXIT) {
1161-
executor->exits[next_exit].target = 0;
1162-
dest->oparg = next_exit;
1162+
_PyExitData *exit = &executor->exits[next_exit];
1163+
exit->target = 0;
1164+
dest->operand = (uint64_t)exit;
11631165
next_exit--;
11641166
}
11651167
}

Python/optimizer_bytecodes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,8 @@ dummy_func(void) {
788788
ctx->done = true;
789789
}
790790

791-
op(_EXIT_TRACE, (--)) {
791+
op(_EXIT_TRACE, (exit_p/4 --)) {
792+
(void)exit_p;
792793
ctx->done = true;
793794
}
794795

Python/optimizer_cases.c.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)