Skip to content

Commit c4a6bee

Browse files
end trace earlier when full
1 parent b1e4adf commit c4a6bee

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Python/optimizer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,10 @@ _PyJit_translate_single_bytecode_to_trace(
827827
// We don't want to continue tracing as we might get stuck in the
828828
// inner loop. Instead, end the trace where the executor of the
829829
// inner loop might start and let the traces rejoin.
830-
if (_tstate->jit_tracer_state.prev_state.jump_backward_seen >= 1) {
830+
if (_tstate->jit_tracer_state.prev_state.jump_backward_seen >= 1 ||
831+
// Also end the trace early if we probably have no more space left, as it's better
832+
// to link to another backwards jump trace.
833+
trace_length >= (_tstate->jit_tracer_state.prev_state.code_max_size / 2)) {
831834
OPT_STAT_INC(inner_loop);
832835
ADD_TO_TRACE(_EXIT_TRACE, 0, 0, target);
833836
trace[trace_length-1].operand1 = true; // is_control_flow

0 commit comments

Comments
 (0)