}
assert(executor != tstate->interp->cold_executor);
tstate->jit_exit = NULL;
- TIER1_TO_TIER2(executor);
+ if (IS_JIT_TRACING()) {
+ RECORD_TRACE();
+ BAIL_TRACING_NO_DISPATCH();
+ }
+ TIER1_TO_TIER2(executor, 1);
#else
Py_FatalError("ENTER_EXECUTOR is not supported in this build");
#endif /* _Py_TIER2 */
# define IS_JIT_TRACING() (DISPATCH_TABLE_VAR == TRACING_DISPATCH_TABLE)
# define ENTER_TRACING() DISPATCH_TABLE_VAR = TRACING_DISPATCH_TABLE;
# define LEAVE_TRACING() DISPATCH_TABLE_VAR = DISPATCH_TABLE;
-# define BAIL_TRACING() \
+# define BAIL_TRACING_NO_DISPATCH() \
LEAVE_TRACING(); \
int err = _PyOptimizer_Optimize(frame, tstate); \
tstate->interp->jit_tracer_code_curr_size = 0; \
if (err < 0) { \
JUMP_TO_LABEL(error); \
- } \
+ }
+# define BAIL_TRACING() \
+ BAIL_TRACING_NO_DISPATCH() \
DISPATCH();
# define RECORD_TRACE() do { \
frame->instr_ptr = next_instr; \
/* Tier-switching macros. */
-#define TIER1_TO_TIER2(EXECUTOR) \
+#define TIER1_TO_TIER2(EXECUTOR, IN_ENTER_EXECUTOR) \
do { \
OPT_STAT_INC(traces_executed); \
next_instr = _Py_jit_entry((EXECUTOR), frame, stack_pointer, tstate); \
next_instr = frame->instr_ptr; \
JUMP_TO_LABEL(error); \
} \
- if (keep_tracing_bit) { \
+ if (!IN_ENTER_EXECUTOR && keep_tracing_bit) { \
ENTER_TRACING(); \
_PyJIT_InitializeTracing(tstate, frame, next_instr, STACK_LEVEL(), 0); \
} \
}
assert(executor != tstate->interp->cold_executor);
tstate->jit_exit = NULL;
- TIER1_TO_TIER2(executor);
+ if (IS_JIT_TRACING()) {
+ RECORD_TRACE();
+ BAIL_TRACING_NO_DISPATCH();
+ }
+ TIER1_TO_TIER2(executor, 1);
#else
Py_FatalError("ENTER_EXECUTOR is not supported in this build");
#endif /* _Py_TIER2 */
}
assert(executor != tstate->interp->cold_executor);
tstate->jit_exit = NULL;
- TIER1_TO_TIER2(executor);
+ if (IS_JIT_TRACING()) {
+ RECORD_TRACE();
+ BAIL_TRACING_NO_DISPATCH();
+ }
+ TIER1_TO_TIER2(executor, 1);
#else
Py_FatalError("ENTER_EXECUTOR is not supported in this build");
#endif /* _Py_TIER2 */
if (opcode == EXTENDED_ARG) {
return 1;
}
- assert(opcode != ENTER_EXECUTOR && opcode != EXTENDED_ARG);
if (opcode == NOP) {
return 1;
}
goto full;
}
+ assert(opcode != ENTER_EXECUTOR && opcode != EXTENDED_ARG);
+
bool needs_guard_ip = _PyOpcode_NeedsGuardIp[opcode] &&
!(opcode == FOR_ITER_RANGE || opcode == FOR_ITER_LIST || opcode == FOR_ITER_TUPLE) &&
!(opcode == JUMP_BACKWARD_NO_INTERRUPT || opcode == JUMP_BACKWARD || opcode == JUMP_BACKWARD_JIT) &&