GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-144688: Fix refleaks in JIT when optimization fails (GH-145420) · python/cpython@27c4970

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Python
    • optimizer.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Python/optimizer.c‎

Copy file name to clipboardExpand all lines: Python/optimizer.c
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,12 +1076,19 @@ _PyJit_FinalizeTracing(PyThreadState *tstate, int err)
10761076
exit->temperature = initial_temperature_backoff_counter(&tstate->interp->opt_config);
10771077
}
10781078
}
1079+
// Clear all recorded values
1080+
_PyJitUopBuffer *buffer = &tracer->code_buffer;
1081+
for (_PyUOpInstruction *inst = buffer->start; inst < buffer->next; inst++) {
1082+
if (_PyUop_Flags[inst->opcode] & HAS_RECORDS_VALUE_FLAG) {
1083+
Py_XDECREF((PyObject *)(uintptr_t)inst->operand0);
1084+
}
1085+
}
10791086
Py_CLEAR(tracer->initial_state.code);
10801087
Py_CLEAR(tracer->initial_state.func);
10811088
Py_CLEAR(tracer->initial_state.executor);
10821089
Py_CLEAR(tracer->prev_state.instr_code);
10831090
Py_CLEAR(tracer->prev_state.recorded_value);
1084-
uop_buffer_init(&tracer->code_buffer, &tracer->uop_array[0], UOP_MAX_TRACE_LENGTH);
1091+
uop_buffer_init(buffer, &tracer->uop_array[0], UOP_MAX_TRACE_LENGTH);
10851092
tracer->is_tracing = false;
10861093
}
10871094

@@ -1521,6 +1528,11 @@ uop_optimize(
15211528
}
15221529
assert(_PyOpcode_uop_name[buffer[pc].opcode]);
15231530
}
1531+
// We've cleaned up the references in the buffer, so discard the code buffer
1532+
// to avoid doing it again during tracer cleanup
1533+
_PyJitUopBuffer *code_buffer = &_tstate->jit_tracer_state->code_buffer;
1534+
code_buffer->next = code_buffer->start;
1535+
15241536
OPT_HIST(effective_trace_length(buffer, length), optimized_trace_length_hist);
15251537
_PyUOpInstruction *output = &_tstate->jit_tracer_state->uop_array[0];
15261538
length = stack_allocate(buffer, output, length);

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.