Skip to content

Commit

Permalink
Executors in the COLD_EXITS array are not GC'able
Browse files Browse the repository at this point in the history
Implement a `tp_is_gc` slot that tests for this.
  • Loading branch information
gvanrossum committed Apr 20, 2024
1 parent b624490 commit f2e10eb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,15 @@ executor_traverse(PyObject *o, visitproc visit, void *arg)
return 0;
}

static int
executor_is_gc(PyObject *o)
{
if ((void*)COLD_EXITS <= (void*)o && (void*)o < (void*)COLD_EXITS + UOP_MAX_TRACE_LENGTH) {
return 0;
}
return 1;
}

PyTypeObject _PyUOpExecutor_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "uop_executor",
Expand All @@ -405,6 +414,7 @@ PyTypeObject _PyUOpExecutor_Type = {
.tp_methods = executor_methods,
.tp_traverse = executor_traverse,
.tp_clear = executor_clear,
.tp_is_gc = executor_is_gc,
};

/* TO DO -- Generate these tables */
Expand Down

0 comments on commit f2e10eb

Please sign in to comment.