int jit_tracer_initial_chain_depth;
PyCodeObject *jit_tracer_initial_code; // Borrowed
PyFunctionObject *jit_tracer_initial_func; // Borrowed
- int jit_tracer_seen_initial_before;
+ struct _PyExitData *jit_tracer_previous_exit;
bool jit_completed_loop;
bool jit;
bool compiling;
int jump_taken);
void
-_PyJIT_InitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *next_instr, int curr_stackdepth, int chain_depth);
+_PyJIT_InitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *next_instr, int curr_stackdepth, int chain_depth, _PyExitData *exit);
#ifdef __cplusplus
}
#endif
DISPATCH();
}
}
- _PyJIT_InitializeTracing(tstate, frame, next_instr, STACK_LEVEL(), 0);
+ _PyJIT_InitializeTracing(tstate, frame, next_instr, STACK_LEVEL(), 0, NULL);
ENTER_TRACING();
// Don't add the JUMP_BACKWARD_JIT instruction to the trace.
DISPATCH();
_PyExecutorObject *previous_executor = _PyExecutor_FromExit(exit);
assert(tstate->current_executor == (PyObject *)previous_executor);
int chain_depth = is_dynamic ? 0 : current_executor->vm_data.chain_depth + 1;
- _PyJIT_InitializeTracing(tstate, frame, target, STACK_LEVEL(), chain_depth);
+ _PyJIT_InitializeTracing(tstate, frame, target, STACK_LEVEL(), chain_depth, exit);
GOTO_TIER_ONE(target, 1);
}
}
_PyExecutorObject *previous_executor = _PyExecutor_FromExit(exit);
assert(tstate->current_executor == (PyObject *)previous_executor);
int chain_depth = is_dynamic ? 0 : current_executor->vm_data.chain_depth + 1;
- _PyJIT_InitializeTracing(tstate, frame, target, STACK_LEVEL(), chain_depth);
+ _PyJIT_InitializeTracing(tstate, frame, target, STACK_LEVEL(), chain_depth, exit);
GOTO_TIER_ONE(target, 1);
}
break;
next_instr = this_instr;
DISPATCH_GOTO();
}
- OPT_STAT_INC(traces_executed); \
- next_instr = _Py_jit_entry((executor), frame, stack_pointer, tstate); \
- frame = tstate->current_frame; \
- stack_pointer = _PyFrame_GetStackPointer(frame); \
- int keep_tracing_bit = (uintptr_t)next_instr & 1; \
- next_instr = (_Py_CODEUNIT *)(((uintptr_t)next_instr) >> 1 << 1); \
- if (next_instr == NULL) { \
- next_instr = frame->instr_ptr; \
- JUMP_TO_LABEL(error); \
- } \
- if (keep_tracing_bit) { \
- assert(next_instr->op.code != ENTER_EXECUTOR); \
- assert(tstate->interp->jit_tracer_code_curr_size == 2); \
- ENTER_TRACING(); \
- } \
- else { \
- LEAVE_TRACING(); \
- } \
- DISPATCH();
+ TIER1_TO_TIER2(executor);
#else
Py_FatalError("ENTER_EXECUTOR is not supported in this build");
#endif /* _Py_TIER2 */
DISPATCH();
}
}
- _PyJIT_InitializeTracing(tstate, frame, next_instr, STACK_LEVEL(), 0);
+ _PyJIT_InitializeTracing(tstate, frame, next_instr, STACK_LEVEL(), 0, NULL);
ENTER_TRACING();
DISPATCH();
}
TRACING_DISPATCH();
}
}
- _PyJIT_InitializeTracing(tstate, frame, next_instr, STACK_LEVEL(), 0);
+ _PyJIT_InitializeTracing(tstate, frame, next_instr, STACK_LEVEL(), 0, NULL);
ENTER_TRACING();
TRACING_DISPATCH();
}
else {
executor->vm_data.code = NULL;
}
+ if (chain_depth > 0) {
+ _PyExitData *prev_exit = tstate->interp->jit_tracer_previous_exit;
+ assert(prev_exit != NULL);
+ prev_exit->executor = executor;;
+ }
executor->vm_data.chain_depth = chain_depth;
assert(executor->vm_data.valid);
interp->compiling = false;
}
void
-_PyJIT_InitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *next_instr, int curr_stackdepth, int chain_depth)
+_PyJIT_InitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *next_instr, int curr_stackdepth, int chain_depth, _PyExitData *exit)
{
PyCodeObject *code = _PyFrame_GetCode(frame);
#ifdef Py_DEBUG
tstate->interp->jit_tracer_initial_instr = next_instr;
tstate->interp->jit_tracer_initial_code = code;
tstate->interp->jit_tracer_initial_func = _PyFrame_GetFunction(frame);
- tstate->interp->jit_tracer_seen_initial_before = 0;
+ tstate->interp->jit_tracer_previous_exit = exit;
memset(&tstate->interp->jit_tracer_dependencies.bits, 0, sizeof(tstate->interp->jit_tracer_dependencies.bits));
tstate->interp->jit_completed_loop = false;
tstate->interp->jit_tracer_initial_stack_depth = curr_stackdepth;