Skip to content

Commit fd3bb48

Browse files
Point to previous executor when side-exiting
1 parent fac8c74 commit fd3bb48

File tree

6 files changed

+15
-28
lines changed

6 files changed

+15
-28
lines changed

Include/internal/pycore_interp_structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ struct _is {
953953
int jit_tracer_initial_chain_depth;
954954
PyCodeObject *jit_tracer_initial_code; // Borrowed
955955
PyFunctionObject *jit_tracer_initial_func; // Borrowed
956-
int jit_tracer_seen_initial_before;
956+
struct _PyExitData *jit_tracer_previous_exit;
957957
bool jit_completed_loop;
958958
bool jit;
959959
bool compiling;

Include/internal/pycore_optimizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ _PyJIT_translate_single_bytecode_to_trace(
371371
int jump_taken);
372372

373373
void
374-
_PyJIT_InitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *next_instr, int curr_stackdepth, int chain_depth);
374+
_PyJIT_InitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *next_instr, int curr_stackdepth, int chain_depth, _PyExitData *exit);
375375
#ifdef __cplusplus
376376
}
377377
#endif

Python/bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,7 +2978,7 @@ dummy_func(
29782978
DISPATCH();
29792979
}
29802980
}
2981-
_PyJIT_InitializeTracing(tstate, frame, next_instr, STACK_LEVEL(), 0);
2981+
_PyJIT_InitializeTracing(tstate, frame, next_instr, STACK_LEVEL(), 0, NULL);
29822982
ENTER_TRACING();
29832983
// Don't add the JUMP_BACKWARD_JIT instruction to the trace.
29842984
DISPATCH();
@@ -5456,7 +5456,7 @@ dummy_func(
54565456
_PyExecutorObject *previous_executor = _PyExecutor_FromExit(exit);
54575457
assert(tstate->current_executor == (PyObject *)previous_executor);
54585458
int chain_depth = is_dynamic ? 0 : current_executor->vm_data.chain_depth + 1;
5459-
_PyJIT_InitializeTracing(tstate, frame, target, STACK_LEVEL(), chain_depth);
5459+
_PyJIT_InitializeTracing(tstate, frame, target, STACK_LEVEL(), chain_depth, exit);
54605460
GOTO_TIER_ONE(target, 1);
54615461
}
54625462
}

Python/executor_cases.c.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

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

Python/optimizer.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ _PyOptimizer_Optimize(
161161
else {
162162
executor->vm_data.code = NULL;
163163
}
164+
if (chain_depth > 0) {
165+
_PyExitData *prev_exit = tstate->interp->jit_tracer_previous_exit;
166+
assert(prev_exit != NULL);
167+
prev_exit->executor = executor;;
168+
}
164169
executor->vm_data.chain_depth = chain_depth;
165170
assert(executor->vm_data.valid);
166171
interp->compiling = false;
@@ -808,7 +813,7 @@ _PyJIT_translate_single_bytecode_to_trace(
808813
}
809814

810815
void
811-
_PyJIT_InitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *next_instr, int curr_stackdepth, int chain_depth)
816+
_PyJIT_InitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *next_instr, int curr_stackdepth, int chain_depth, _PyExitData *exit)
812817
{
813818
PyCodeObject *code = _PyFrame_GetCode(frame);
814819
#ifdef Py_DEBUG
@@ -831,7 +836,7 @@ _PyJIT_InitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_
831836
tstate->interp->jit_tracer_initial_instr = next_instr;
832837
tstate->interp->jit_tracer_initial_code = code;
833838
tstate->interp->jit_tracer_initial_func = _PyFrame_GetFunction(frame);
834-
tstate->interp->jit_tracer_seen_initial_before = 0;
839+
tstate->interp->jit_tracer_previous_exit = exit;
835840
memset(&tstate->interp->jit_tracer_dependencies.bits, 0, sizeof(tstate->interp->jit_tracer_dependencies.bits));
836841
tstate->interp->jit_completed_loop = false;
837842
tstate->interp->jit_tracer_initial_stack_depth = curr_stackdepth;

0 commit comments

Comments
 (0)