summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-11-20 11:25:50 (GMT)
committerGitHub <noreply@github.com>2019-11-20 11:25:50 (GMT)
commit7247407c35330f3f6292f1d40606b7ba6afd5700 (patch)
treefa9307b2cdbf41bf30c90daf12c76dd439949cfd /Objects/object.c
parent488d02a24142948bfb1fafd19fa48e61fcbbabc5 (diff)
downloadcpython-7247407c35330f3f6292f1d40606b7ba6afd5700.zip
cpython-7247407c35330f3f6292f1d40606b7ba6afd5700.tar.gz
cpython-7247407c35330f3f6292f1d40606b7ba6afd5700.tar.bz2
bpo-36854: Move _PyRuntimeState.gc to PyInterpreterState (GH-17287)
* Rename _PyGC_InitializeRuntime() to _PyGC_InitState() * finalize_interp_clear() now also calls _PyGC_Fini() in subinterpreters (clear the GC state).
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 3e61282..6fc1146 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -2131,11 +2131,14 @@ finally:
void
_PyTrash_deposit_object(PyObject *op)
{
+ PyThreadState *tstate = _PyThreadState_GET();
+ struct _gc_runtime_state *gcstate = &tstate->interp->gc;
+
_PyObject_ASSERT(op, PyObject_IS_GC(op));
_PyObject_ASSERT(op, !_PyObject_GC_IS_TRACKED(op));
_PyObject_ASSERT(op, op->ob_refcnt == 0);
- _PyGCHead_SET_PREV(_Py_AS_GC(op), _PyRuntime.gc.trash_delete_later);
- _PyRuntime.gc.trash_delete_later = op;
+ _PyGCHead_SET_PREV(_Py_AS_GC(op), gcstate->trash_delete_later);
+ gcstate->trash_delete_later = op;
}
/* The equivalent API, using per-thread state recursion info */
@@ -2156,11 +2159,14 @@ _PyTrash_thread_deposit_object(PyObject *op)
void
_PyTrash_destroy_chain(void)
{
- while (_PyRuntime.gc.trash_delete_later) {
- PyObject *op = _PyRuntime.gc.trash_delete_later;
+ PyThreadState *tstate = _PyThreadState_GET();
+ struct _gc_runtime_state *gcstate = &tstate->interp->gc;
+
+ while (gcstate->trash_delete_later) {
+ PyObject *op = gcstate->trash_delete_later;
destructor dealloc = Py_TYPE(op)->tp_dealloc;
- _PyRuntime.gc.trash_delete_later =
+ gcstate->trash_delete_later =
(PyObject*) _PyGCHead_PREV(_Py_AS_GC(op));
/* Call the deallocator directly. This used to try to
@@ -2170,9 +2176,9 @@ _PyTrash_destroy_chain(void)
* up distorting allocation statistics.
*/
_PyObject_ASSERT(op, op->ob_refcnt == 0);
- ++_PyRuntime.gc.trash_delete_nesting;
+ ++gcstate->trash_delete_nesting;
(*dealloc)(op);
- --_PyRuntime.gc.trash_delete_nesting;
+ --gcstate->trash_delete_nesting;
}
}