@@ -88,15 +88,11 @@ static inline void _PyObject_GC_SET_SHARED(PyObject *op) {
8888
8989/* Bit flags for _gc_prev */
9090/* Bit 0 is set when tp_finalize is called */
91- #define _PyGC_PREV_MASK_FINALIZED 1
91+ #define _PyGC_PREV_MASK_FINALIZED (1)
9292/* Bit 1 is set when the object is in generation which is GCed currently. */
93- #define _PyGC_PREV_MASK_COLLECTING 2
94-
95- /* Bit 0 is set if the object belongs to old space 1 */
96- #define _PyGC_NEXT_MASK_OLD_SPACE_1 1
97-
93+ #define _PyGC_PREV_MASK_COLLECTING (2)
9894/* The (N-2) most significant bits contain the real address. */
99- #define _PyGC_PREV_SHIFT 2
95+ #define _PyGC_PREV_SHIFT (2)
10096#define _PyGC_PREV_MASK (((uintptr_t) -1) << _PyGC_PREV_SHIFT)
10197
10298/* set for debugging information */
@@ -122,21 +118,18 @@ typedef enum {
122118// Lowest bit of _gc_next is used for flags only in GC.
123119// But it is always 0 for normal code.
124120static inline PyGC_Head * _PyGCHead_NEXT (PyGC_Head * gc ) {
125- uintptr_t next = gc -> _gc_next & _PyGC_PREV_MASK ;
121+ uintptr_t next = gc -> _gc_next ;
126122 return (PyGC_Head * )next ;
127123}
128124static inline void _PyGCHead_SET_NEXT (PyGC_Head * gc , PyGC_Head * next ) {
129- uintptr_t unext = (uintptr_t )next ;
130- assert ((unext & ~_PyGC_PREV_MASK ) == 0 );
131- gc -> _gc_next = (gc -> _gc_next & ~_PyGC_PREV_MASK ) | unext ;
125+ gc -> _gc_next = (uintptr_t )next ;
132126}
133127
134128// Lowest two bits of _gc_prev is used for _PyGC_PREV_MASK_* flags.
135129static inline PyGC_Head * _PyGCHead_PREV (PyGC_Head * gc ) {
136130 uintptr_t prev = (gc -> _gc_prev & _PyGC_PREV_MASK );
137131 return (PyGC_Head * )prev ;
138132}
139-
140133static inline void _PyGCHead_SET_PREV (PyGC_Head * gc , PyGC_Head * prev ) {
141134 uintptr_t uprev = (uintptr_t )prev ;
142135 assert ((uprev & ~_PyGC_PREV_MASK ) == 0 );
@@ -222,13 +215,6 @@ struct gc_generation {
222215 generations */
223216};
224217
225- struct gc_collection_stats {
226- /* number of collected objects */
227- Py_ssize_t collected ;
228- /* total number of uncollectable objects (put into gc.garbage) */
229- Py_ssize_t uncollectable ;
230- };
231-
232218/* Running stats per generation */
233219struct gc_generation_stats {
234220 /* total number of collections */
@@ -250,8 +236,8 @@ struct _gc_runtime_state {
250236 int enabled ;
251237 int debug ;
252238 /* linked lists of container objects */
253- struct gc_generation young ;
254- struct gc_generation old [ 2 ] ;
239+ struct gc_generation generations [ NUM_GENERATIONS ] ;
240+ PyGC_Head * generation0 ;
255241 /* a permanent generation which won't be collected */
256242 struct gc_generation permanent_generation ;
257243 struct gc_generation_stats generation_stats [NUM_GENERATIONS ];
@@ -264,20 +250,22 @@ struct _gc_runtime_state {
264250 /* This is the number of objects that survived the last full
265251 collection. It approximates the number of long lived objects
266252 tracked by the GC.
253+
267254 (by "full collection", we mean a collection of the oldest
268255 generation). */
269256 Py_ssize_t long_lived_total ;
270-
271- Py_ssize_t work_to_do ;
272- /* Which of the old spaces is the visited space */
273- int visited_space ;
257+ /* This is the number of objects that survived all "non-full"
258+ collections, and are awaiting to undergo a full collection for
259+ the first time. */
260+ Py_ssize_t long_lived_pending ;
274261};
275262
276263
277264extern void _PyGC_InitState (struct _gc_runtime_state * );
278265
279- extern Py_ssize_t _PyGC_Collect (PyThreadState * tstate , int generation , _PyGC_Reason reason );
280- extern void _PyGC_CollectNoFail (PyThreadState * tstate );
266+ extern Py_ssize_t _PyGC_Collect (PyThreadState * tstate , int generation ,
267+ _PyGC_Reason reason );
268+ extern Py_ssize_t _PyGC_CollectNoFail (PyThreadState * tstate );
281269
282270/* Freeze objects tracked by the GC and ignore them in future collections. */
283271extern void _PyGC_Freeze (PyInterpreterState * interp );
0 commit comments