mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-36854: gcmodule.c gets its state from tstate (GH-17285)
* Add GCState type for readability * gcmodule.c now gets its gcstate from tstate * _PyGC_DumpShutdownStats() now expects tstate rather than runtime * Rename "state" to "gcstate" for readability: to avoid confusion between "state" and "tstate" for example. * collect() now only expects tstate: it gets gcstate from tstate. * Pass tstate to _PyErr_xxx() functions
This commit is contained in:
parent
9da7430675
commit
67e0de6f0b
4 changed files with 192 additions and 163 deletions
|
@ -18,7 +18,7 @@ PyAPI_FUNC(int) _PyDict_CheckConsistency(PyObject *mp, int check_content);
|
|||
* NB: While the object is tracked by the collector, it must be safe to call the
|
||||
* ob_traverse method.
|
||||
*
|
||||
* Internal note: _PyRuntime.gc.generation0->_gc_prev doesn't have any bit flags
|
||||
* Internal note: interp->gc.generation0->_gc_prev doesn't have any bit flags
|
||||
* because it's not object header. So we don't use _PyGCHead_PREV() and
|
||||
* _PyGCHead_SET_PREV() for it to avoid unnecessary bitwise operations.
|
||||
*
|
||||
|
@ -37,11 +37,13 @@ static inline void _PyObject_GC_TRACK_impl(const char *filename, int lineno,
|
|||
"object is in generation which is garbage collected",
|
||||
filename, lineno, "_PyObject_GC_TRACK");
|
||||
|
||||
PyGC_Head *last = (PyGC_Head*)(_PyRuntime.gc.generation0->_gc_prev);
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
PyGC_Head *generation0 = tstate->interp->runtime->gc.generation0;
|
||||
PyGC_Head *last = (PyGC_Head*)(generation0->_gc_prev);
|
||||
_PyGCHead_SET_NEXT(last, gc);
|
||||
_PyGCHead_SET_PREV(gc, last);
|
||||
_PyGCHead_SET_NEXT(gc, _PyRuntime.gc.generation0);
|
||||
_PyRuntime.gc.generation0->_gc_prev = (uintptr_t)gc;
|
||||
_PyGCHead_SET_NEXT(gc, generation0);
|
||||
generation0->_gc_prev = (uintptr_t)gc;
|
||||
}
|
||||
|
||||
#define _PyObject_GC_TRACK(op) \
|
||||
|
|
|
@ -89,7 +89,7 @@ extern void _PyWarnings_Fini(PyInterpreterState *interp);
|
|||
extern void _PyGILState_Init(PyThreadState *tstate);
|
||||
extern void _PyGILState_Fini(PyThreadState *tstate);
|
||||
|
||||
PyAPI_FUNC(void) _PyGC_DumpShutdownStats(struct pyruntimestate *runtime);
|
||||
PyAPI_FUNC(void) _PyGC_DumpShutdownStats(PyThreadState *tstate);
|
||||
|
||||
PyAPI_FUNC(PyStatus) _Py_PreInitializeFromPyArgv(
|
||||
const PyPreConfig *src_config,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue