diff options
author | Sam Gross <colesbury@gmail.com> | 2024-01-25 18:27:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-25 18:27:36 (GMT) |
commit | b52fc70d1ab3be7866ab71065bae61a03a28bfae (patch) | |
tree | f364d714c70229ad70b6138aac6181d1ee375363 /Python/gc.c | |
parent | 4850410b60183dac021ded219a49be140fe5fefe (diff) | |
download | cpython-b52fc70d1ab3be7866ab71065bae61a03a28bfae.zip cpython-b52fc70d1ab3be7866ab71065bae61a03a28bfae.tar.gz cpython-b52fc70d1ab3be7866ab71065bae61a03a28bfae.tar.bz2 |
gh-112529: Implement GC for free-threaded builds (#114262)
* gh-112529: Implement GC for free-threaded builds
This implements a mark and sweep GC for the free-threaded builds of
CPython. The implementation relies on mimalloc to find GC tracked
objects (i.e., "containers").
Diffstat (limited to 'Python/gc.c')
-rw-r--r-- | Python/gc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/gc.c b/Python/gc.c index 1487050..4664676 100644 --- a/Python/gc.c +++ b/Python/gc.c @@ -15,6 +15,8 @@ #include "pycore_weakref.h" // _PyWeakref_ClearRef() #include "pydtrace.h" +#ifndef Py_GIL_DISABLED + typedef struct _gc_runtime_state GCState; #ifdef Py_DEBUG @@ -964,10 +966,10 @@ finalize_garbage(PyThreadState *tstate, PyGC_Head *collectable) PyGC_Head *gc = GC_NEXT(collectable); PyObject *op = FROM_GC(gc); gc_list_move(gc, &seen); - if (!_PyGCHead_FINALIZED(gc) && + if (!_PyGC_FINALIZED(op) && (finalize = Py_TYPE(op)->tp_finalize) != NULL) { - _PyGCHead_SET_FINALIZED(gc); + _PyGC_SET_FINALIZED(op); Py_INCREF(op); finalize(op); assert(!_PyErr_Occurred(tstate)); @@ -1942,3 +1944,5 @@ PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg) done: gcstate->enabled = origenstate; } + +#endif // Py_GIL_DISABLED |