mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-30860: Consolidate stateful runtime globals. (#3397)
* group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
This commit is contained in:
parent
bab21faded
commit
2ebc5ce42a
72 changed files with 2746 additions and 1312 deletions
|
|
@ -1,6 +1,7 @@
|
|||
/* Type object implementation */
|
||||
|
||||
#include "Python.h"
|
||||
#include "internal/pystate.h"
|
||||
#include "frameobject.h"
|
||||
#include "structmember.h"
|
||||
|
||||
|
|
@ -1157,10 +1158,10 @@ subtype_dealloc(PyObject *self)
|
|||
/* UnTrack and re-Track around the trashcan macro, alas */
|
||||
/* See explanation at end of function for full disclosure */
|
||||
PyObject_GC_UnTrack(self);
|
||||
++_PyTrash_delete_nesting;
|
||||
++_PyRuntime.gc.trash_delete_nesting;
|
||||
++ tstate->trash_delete_nesting;
|
||||
Py_TRASHCAN_SAFE_BEGIN(self);
|
||||
--_PyTrash_delete_nesting;
|
||||
--_PyRuntime.gc.trash_delete_nesting;
|
||||
-- tstate->trash_delete_nesting;
|
||||
|
||||
/* Find the nearest base with a different tp_dealloc */
|
||||
|
|
@ -1254,10 +1255,10 @@ subtype_dealloc(PyObject *self)
|
|||
Py_DECREF(type);
|
||||
|
||||
endlabel:
|
||||
++_PyTrash_delete_nesting;
|
||||
++_PyRuntime.gc.trash_delete_nesting;
|
||||
++ tstate->trash_delete_nesting;
|
||||
Py_TRASHCAN_SAFE_END(self);
|
||||
--_PyTrash_delete_nesting;
|
||||
--_PyRuntime.gc.trash_delete_nesting;
|
||||
-- tstate->trash_delete_nesting;
|
||||
|
||||
/* Explanation of the weirdness around the trashcan macros:
|
||||
|
|
@ -1297,7 +1298,7 @@ subtype_dealloc(PyObject *self)
|
|||
a subtle disaster.
|
||||
|
||||
Q. Why the bizarre (net-zero) manipulation of
|
||||
_PyTrash_delete_nesting around the trashcan macros?
|
||||
_PyRuntime.trash_delete_nesting around the trashcan macros?
|
||||
|
||||
A. Some base classes (e.g. list) also use the trashcan mechanism.
|
||||
The following scenario used to be possible:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue