summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2017-09-06 04:43:08 (GMT)
committerGitHub <noreply@github.com>2017-09-06 04:43:08 (GMT)
commit05351c1bd8b70d1878527762174cdaaba3572395 (patch)
treee97ef4ba0ae7ffe5bd2c8969199616bffbbc4d6f /Objects/object.c
parent833860615bedfd2484ac0623d6f01ff0578ba09f (diff)
downloadcpython-05351c1bd8b70d1878527762174cdaaba3572395.zip
cpython-05351c1bd8b70d1878527762174cdaaba3572395.tar.gz
cpython-05351c1bd8b70d1878527762174cdaaba3572395.tar.bz2
Revert "bpo-30860: Consolidate stateful runtime globals." (#3379)
Windows buildbots started failing due to include-related errors.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 68a90c2..2ba6e57 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -2028,6 +2028,14 @@ finally:
/* Trashcan support. */
+/* Current call-stack depth of tp_dealloc calls. */
+int _PyTrash_delete_nesting = 0;
+
+/* List of objects that still need to be cleaned up, singly linked via their
+ * gc headers' gc_prev pointers.
+ */
+PyObject *_PyTrash_delete_later = NULL;
+
/* Add op to the _PyTrash_delete_later list. Called when the current
* call-stack depth gets large. op must be a currently untracked gc'ed
* object, with refcount 0. Py_DECREF must already have been called on it.
@@ -2038,8 +2046,8 @@ _PyTrash_deposit_object(PyObject *op)
assert(PyObject_IS_GC(op));
assert(_PyGC_REFS(op) == _PyGC_REFS_UNTRACKED);
assert(op->ob_refcnt == 0);
- _Py_AS_GC(op)->gc.gc_prev = (PyGC_Head *)_PyRuntime.gc.trash_delete_later;
- _PyRuntime.gc.trash_delete_later = op;
+ _Py_AS_GC(op)->gc.gc_prev = (PyGC_Head *)_PyTrash_delete_later;
+ _PyTrash_delete_later = op;
}
/* The equivalent API, using per-thread state recursion info */
@@ -2060,11 +2068,11 @@ _PyTrash_thread_deposit_object(PyObject *op)
void
_PyTrash_destroy_chain(void)
{
- while (_PyRuntime.gc.trash_delete_later) {
- PyObject *op = _PyRuntime.gc.trash_delete_later;
+ while (_PyTrash_delete_later) {
+ PyObject *op = _PyTrash_delete_later;
destructor dealloc = Py_TYPE(op)->tp_dealloc;
- _PyRuntime.gc.trash_delete_later =
+ _PyTrash_delete_later =
(PyObject*) _Py_AS_GC(op)->gc.gc_prev;
/* Call the deallocator directly. This used to try to
@@ -2074,9 +2082,9 @@ _PyTrash_destroy_chain(void)
* up distorting allocation statistics.
*/
assert(op->ob_refcnt == 0);
- ++_PyRuntime.gc.trash_delete_nesting;
+ ++_PyTrash_delete_nesting;
(*dealloc)(op);
- --_PyRuntime.gc.trash_delete_nesting;
+ --_PyTrash_delete_nesting;
}
}