Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comments
  • Loading branch information
markshannon committed May 3, 2025
commit f938d68f6d525e7239ea7270488cdd3937af58b8
6 changes: 0 additions & 6 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2924,7 +2924,6 @@ dummy_func(
else {
this_instr[1].counter = initial_jump_backoff_counter();
assert(tstate->current_executor == NULL);
tstate->current_executor = (PyObject *)executor;
GOTO_TIER_TWO(executor);
}
}
Expand Down Expand Up @@ -2989,7 +2988,6 @@ dummy_func(
}
DISPATCH_GOTO();
}
tstate->current_executor = (PyObject *)executor;
GOTO_TIER_TWO(executor);
#else
Py_FatalError("ENTER_EXECUTOR is not supported in this build");
Expand Down Expand Up @@ -5264,7 +5262,6 @@ dummy_func(
exit->temperature = initial_temperature_backoff_counter();
Py_CLEAR(exit->executor);
}
tstate->current_executor = NULL;
if (exit->executor == NULL) {
_Py_BackoffCounter temperature = exit->temperature;
if (!backoff_counter_triggers(temperature)) {
Expand All @@ -5287,7 +5284,6 @@ dummy_func(
}
exit->executor = executor;
}
tstate->current_executor = (PyObject *)exit->executor;
GOTO_TIER_TWO(exit->executor);
}

Expand Down Expand Up @@ -5346,12 +5342,10 @@ dummy_func(
}

tier2 op(_DEOPT, (--)) {
tstate->current_executor = NULL;
GOTO_TIER_ONE(_PyFrame_GetBytecode(frame) + CURRENT_TARGET());
}

tier2 op(_ERROR_POP_N, (target/2 --)) {
tstate->current_executor = NULL;
assert(oparg == 0);
frame->instr_ptr = _PyFrame_GetBytecode(frame) + target;
SYNC_SP();
Expand Down
7 changes: 5 additions & 2 deletions Python/ceval_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ _PyFrame_SetStackPointer(frame, stack_pointer)
do { \
OPT_STAT_INC(traces_executed); \
_PyExecutorObject *_executor = (EXECUTOR); \
assert(tstate->current_executor == _executor); \
tstate->current_executor = (PyObject *)_executor; \
jit_func jitted = _executor->jit_code; \
/* Keep the shim frame alive via the executor: */ \
Py_INCREF(_executor); \
Expand All @@ -378,7 +378,9 @@ do { \
#define GOTO_TIER_TWO(EXECUTOR) \
do { \
OPT_STAT_INC(traces_executed); \
next_uop = (EXECUTOR)->trace; \
_PyExecutorObject *_executor = (EXECUTOR); \
tstate->current_executor = (PyObject *)_executor; \
next_uop = _executor->trace; \
assert(next_uop->opcode == _START_EXECUTOR); \
goto enter_tier_two; \
} while (0)
Expand All @@ -387,6 +389,7 @@ do { \
#define GOTO_TIER_ONE(TARGET) \
do \
{ \
tstate->current_executor = NULL; \
next_instr = (TARGET); \
assert(tstate->current_executor == NULL); \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: this seems redundant, given that we're setting it one line above.

OPT_HIST(trace_uop_execution_counter, trace_run_length_hist); \
Expand Down
4 changes: 0 additions & 4 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ _Py_ClearExecutorDeletionList(PyInterpreterState *interp)
while (ts) {
_PyExecutorObject *current = (_PyExecutorObject *)ts->current_executor;
if (current != NULL) {
/* Anything in this list will be unlinked, so we can reuse the
* linked field as a reachability marker. */
current->vm_data.linked = 1;
}
HEAD_LOCK(runtime);
Expand Down
5 changes: 4 additions & 1 deletion Tools/jit/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@
#define GOTO_TIER_TWO(EXECUTOR) \
do { \
OPT_STAT_INC(traces_executed); \
jit_func_preserve_none jitted = (EXECUTOR)->jit_side_entry; \
_PyExecutorObject *_executor = (EXECUTOR); \
tstate->current_executor = (PyObject *)_executor; \
jit_func_preserve_none jitted = _executor->jit_side_entry; \
__attribute__((musttail)) return jitted(frame, stack_pointer, tstate); \
} while (0)

#undef GOTO_TIER_ONE
#define GOTO_TIER_ONE(TARGET) \
do { \
tstate->current_executor = NULL; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can either do this here, or in the second half of the _Py_JIT implementation of GOTO_TIER_TWO in ceval_macros.h, after the JIT code returns. No need to do it in both places.

_PyFrame_SetStackPointer(frame, stack_pointer); \
return TARGET; \
} while (0)
Expand Down