Skip to content

Commit 9cf2ede

Browse files
Add a stop_tracing field
1 parent 0db663d commit 9cf2ede

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

Include/internal/pycore_tstate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ typedef struct _PyJitTracerPreviousState {
4848
} _PyJitTracerPreviousState;
4949

5050
typedef struct _PyJitTracerState {
51+
bool is_tracing;
5152
_PyUOpInstruction *code_buffer;
5253
_PyJitTracerInitialState initial_state;
5354
_PyJitTracerPreviousState prev_state;

Python/optimizer.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,9 +1014,7 @@ _PyJit_TryInitializeTracing(
10141014
{
10151015
_PyThreadStateImpl *_tstate = (_PyThreadStateImpl *)tstate;
10161016
// A recursive trace.
1017-
// Don't trace into the inner call because it will stomp on the previous trace, causing endless retraces.
1018-
if (_tstate->jit_tracer_state.prev_state.code_curr_size > CODE_SIZE_EMPTY ||
1019-
_tstate->jit_tracer_state.initial_state.func != NULL) {
1017+
if (_tstate->jit_tracer_state.is_tracing) {
10201018
return 0;
10211019
}
10221020
if (oparg > 0xFFFF) {
@@ -1075,6 +1073,8 @@ _PyJit_TryInitializeTracing(
10751073
close_loop_instr[1].counter = trigger_backoff_counter();
10761074
}
10771075
_Py_BloomFilter_Init(&_tstate->jit_tracer_state.prev_state.dependencies);
1076+
1077+
_tstate->jit_tracer_state.is_tracing = true;
10781078
return 1;
10791079
}
10801080

@@ -1087,6 +1087,7 @@ _PyJit_ResetTracing(PyThreadState *tstate)
10871087
Py_CLEAR(_tstate->jit_tracer_state.prev_state.instr_code);
10881088
_tstate->jit_tracer_state.prev_state.code_curr_size = CODE_SIZE_EMPTY;
10891089
_tstate->jit_tracer_state.prev_state.code_max_size = UOP_MAX_TRACE_LENGTH/2 - 1;
1090+
_tstate->jit_tracer_state.is_tracing = false;
10901091
}
10911092

10921093

0 commit comments

Comments
 (0)