Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Include/internal/pycore_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ PyAPI_FUNC(_PyExecutorObject*) _Py_GetExecutor(PyCodeObject *code, int offset);

void _Py_ExecutorInit(_PyExecutorObject *, const _PyBloomFilter *);
void _Py_ExecutorDetach(_PyExecutorObject *);
int _Py_ExecutorClear(PyObject *);
void _Py_BloomFilter_Init(_PyBloomFilter *);
void _Py_BloomFilter_Add(_PyBloomFilter *bloom, void *obj);
PyAPI_FUNC(void) _Py_Executor_DependsOn(_PyExecutorObject *executor, void *obj);
Expand Down
2 changes: 1 addition & 1 deletion Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ clear_executors(PyCodeObject *co)
assert(co->co_executors);
for (int i = 0; i < co->co_executors->size; i++) {
if (co->co_executors->executors[i]) {
_Py_ExecutorDetach(co->co_executors->executors[i]);
_Py_ExecutorClear(co->co_executors->executors[i]);
assert(co->co_executors->executors[i] == NULL);
}
}
Expand Down
14 changes: 12 additions & 2 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ uop_dealloc(PyObject *op) {
_PyObject_GC_UNTRACK(self);
assert(self->vm_data.code == NULL);
unlink_executor(self);
for (uint32_t i = 0; i < self->exit_count; i++) {
self->exits[i].temperature = initial_unreachable_backoff_counter();
Py_CLEAR(self->exits[i].executor);
}
#ifdef _Py_JIT
_PyJIT_Free(self);
#endif
Expand Down Expand Up @@ -1424,8 +1428,8 @@ _Py_ExecutorDetach(_PyExecutorObject *executor)
Py_DECREF(executor);
}

static int
executor_clear(PyObject *op)
int
_Py_ExecutorClear(PyObject *op)
{
_PyExecutorObject *executor = _PyExecutorObject_CAST(op);
if (!executor->vm_data.valid) {
Expand All @@ -1448,6 +1452,12 @@ executor_clear(PyObject *op)
return 0;
}

static int
executor_clear(PyObject *executor)
{
return _Py_ExecutorClear(executor);
}

void
_Py_Executor_DependsOn(_PyExecutorObject *executor, void *obj)
{
Expand Down
Loading