Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 2 additions & 3 deletions Include/internal/pycore_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ typedef struct _PyJitTracerInitialState {
PyFunctionObject *func; // Strong
struct _PyExecutorObject *executor; // Strong
_Py_CODEUNIT *start_instr;
_Py_CODEUNIT *close_loop_instr;
_Py_CODEUNIT *jump_backward_instr;
} _PyJitTracerInitialState;

Expand Down Expand Up @@ -470,8 +469,8 @@ PyAPI_FUNC(int) _PyJit_translate_single_bytecode_to_trace(PyThreadState *tstate,

PyAPI_FUNC(int)
_PyJit_TryInitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame,
_Py_CODEUNIT *curr_instr, _Py_CODEUNIT *start_instr,
_Py_CODEUNIT *close_loop_instr, _PyStackRef *stack_pointer, int chain_depth, _PyExitData *exit,
_Py_CODEUNIT *curr_instr, _PyStackRef *stack_pointer,
int chain_depth, _PyExitData *exit,
int oparg, _PyExecutorObject *current_executor);

PyAPI_FUNC(void) _PyJit_FinalizeTracing(PyThreadState *tstate, int err);
Expand Down
18 changes: 4 additions & 14 deletions Modules/_testinternalcapi/test_cases.c.h

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

11 changes: 3 additions & 8 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3373,13 +3373,8 @@ dummy_func(
(this_instr->op.code == JUMP_BACKWARD_JIT || is_resume)) &&
next_instr->op.code != ENTER_EXECUTOR) {
/* Back up over EXTENDED_ARGs so executor is inserted at the correct place */
_Py_CODEUNIT *insert_exec_at = this_instr;
while (oparg > 255) {
oparg >>= 8;
insert_exec_at--;
}
int succ = _PyJit_TryInitializeTracing(tstate, frame, this_instr, insert_exec_at,
is_resume ? insert_exec_at : next_instr, stack_pointer, 0, NULL, oparg, NULL);
int succ = _PyJit_TryInitializeTracing(
tstate, frame, this_instr, stack_pointer, 0, NULL, oparg, NULL);
if (succ) {
ENTER_TRACING();
}
Expand Down Expand Up @@ -6066,7 +6061,7 @@ dummy_func(
// Note: it's safe to use target->op.arg here instead of the oparg given by EXTENDED_ARG.
// The invariant in the optimizer is the deopt target always points back to the first EXTENDED_ARG.
// So setting it to anything else is wrong.
int succ = _PyJit_TryInitializeTracing(tstate, frame, target, target, target, stack_pointer, chain_depth, exit, target->op.arg, previous_executor);
int succ = _PyJit_TryInitializeTracing(tstate, frame, target, stack_pointer, chain_depth, exit, target->op.arg, previous_executor);
exit->temperature = restart_backoff_counter(exit->temperature);
if (succ) {
GOTO_TIER_ONE_CONTINUE_TRACING(target);
Expand Down
2 changes: 1 addition & 1 deletion Python/executor_cases.c.h

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

18 changes: 4 additions & 14 deletions Python/generated_cases.c.h

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

16 changes: 7 additions & 9 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,7 @@ _PyJit_translate_single_bytecode_to_trace(
_Py_FALLTHROUGH;
case JUMP_BACKWARD_NO_INTERRUPT:
{
if ((next_instr != tracer->initial_state.close_loop_instr) &&
(next_instr != tracer->initial_state.start_instr) &&
if ((next_instr != tracer->initial_state.start_instr) &&
uop_buffer_length(&tracer->code_buffer) > CODE_SIZE_NO_PROGRESS &&
// For side exits, we don't want to terminate them early.
tracer->initial_state.exit == NULL &&
Expand All @@ -840,8 +839,8 @@ _PyJit_translate_single_bytecode_to_trace(
OPT_STAT_INC(inner_loop);
ADD_TO_TRACE(_EXIT_TRACE, 0, 0, target);
uop_buffer_last(trace)->operand1 = true; // is_control_flow
DPRINTF(2, "JUMP_BACKWARD not to top ends trace %p %p %p\n", next_instr,
tracer->initial_state.close_loop_instr, tracer->initial_state.start_instr);
DPRINTF(2, "JUMP_BACKWARD not to top ends trace %p %p\n", next_instr,
tracer->initial_state.start_instr);
goto done;
}
break;
Expand Down Expand Up @@ -977,8 +976,7 @@ _PyJit_translate_single_bytecode_to_trace(
}
}
// Loop back to the start
int is_first_instr = tracer->initial_state.close_loop_instr == next_instr ||
tracer->initial_state.start_instr == next_instr;
int is_first_instr = tracer->initial_state.start_instr == next_instr;
if (is_first_instr && uop_buffer_length(trace) > CODE_SIZE_NO_PROGRESS) {
if (needs_guard_ip) {
ADD_TO_TRACE(_SET_IP, 0, (uintptr_t)next_instr, 0);
Expand All @@ -1002,7 +1000,7 @@ _PyJit_translate_single_bytecode_to_trace(
Py_NO_INLINE int
_PyJit_TryInitializeTracing(
PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *curr_instr,
_Py_CODEUNIT *start_instr, _Py_CODEUNIT *close_loop_instr, _PyStackRef *stack_pointer, int chain_depth,
_PyStackRef *stack_pointer, int chain_depth,
_PyExitData *exit, int oparg, _PyExecutorObject *current_executor)
{
_PyThreadStateImpl *_tstate = (_PyThreadStateImpl *)tstate;
Expand All @@ -1022,6 +1020,7 @@ _PyJit_TryInitializeTracing(
if (oparg > 0xFFFF) {
return 0;
}
_Py_CODEUNIT *start_instr = curr_instr - (oparg > 0xFF);
PyObject *func = PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
if (func == NULL || !PyFunction_Check(func)) {
return 0;
Expand All @@ -1038,7 +1037,7 @@ _PyJit_TryInitializeTracing(
PyUnicode_AsUTF8(code->co_qualname),
PyUnicode_AsUTF8(code->co_filename),
code->co_firstlineno,
2 * INSTR_IP(close_loop_instr, code),
2 * INSTR_IP(curr_instr, code),
chain_depth);
#endif
/* Set up tracing buffer*/
Expand All @@ -1048,7 +1047,6 @@ _PyJit_TryInitializeTracing(
ADD_TO_TRACE(_MAKE_WARM, 0, 0, 0);

tracer->initial_state.start_instr = start_instr;
tracer->initial_state.close_loop_instr = close_loop_instr;
tracer->initial_state.code = (PyCodeObject *)Py_NewRef(code);
tracer->initial_state.func = (PyFunctionObject *)Py_NewRef(func);
tracer->initial_state.executor = (_PyExecutorObject *)Py_XNewRef(current_executor);
Expand Down
Loading