@@ -88,15 +88,11 @@ static inline void _PyObject_GC_SET_SHARED(PyObject *op) {
88
88
89
89
/* Bit flags for _gc_prev */
90
90
/* Bit 0 is set when tp_finalize is called */
91
- #define _PyGC_PREV_MASK_FINALIZED 1
91
+ #define _PyGC_PREV_MASK_FINALIZED (1)
92
92
/* 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)
98
94
/* The (N-2) most significant bits contain the real address. */
99
- #define _PyGC_PREV_SHIFT 2
95
+ #define _PyGC_PREV_SHIFT (2)
100
96
#define _PyGC_PREV_MASK (((uintptr_t) -1) << _PyGC_PREV_SHIFT)
101
97
102
98
/* set for debugging information */
@@ -122,21 +118,18 @@ typedef enum {
122
118
// Lowest bit of _gc_next is used for flags only in GC.
123
119
// But it is always 0 for normal code.
124
120
static 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 ;
126
122
return (PyGC_Head * )next ;
127
123
}
128
124
static 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 ;
132
126
}
133
127
134
128
// Lowest two bits of _gc_prev is used for _PyGC_PREV_MASK_* flags.
135
129
static inline PyGC_Head * _PyGCHead_PREV (PyGC_Head * gc ) {
136
130
uintptr_t prev = (gc -> _gc_prev & _PyGC_PREV_MASK );
137
131
return (PyGC_Head * )prev ;
138
132
}
139
-
140
133
static inline void _PyGCHead_SET_PREV (PyGC_Head * gc , PyGC_Head * prev ) {
141
134
uintptr_t uprev = (uintptr_t )prev ;
142
135
assert ((uprev & ~_PyGC_PREV_MASK ) == 0 );
@@ -222,13 +215,6 @@ struct gc_generation {
222
215
generations */
223
216
};
224
217
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
-
232
218
/* Running stats per generation */
233
219
struct gc_generation_stats {
234
220
/* total number of collections */
@@ -250,8 +236,8 @@ struct _gc_runtime_state {
250
236
int enabled ;
251
237
int debug ;
252
238
/* 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 ;
255
241
/* a permanent generation which won't be collected */
256
242
struct gc_generation permanent_generation ;
257
243
struct gc_generation_stats generation_stats [NUM_GENERATIONS ];
@@ -264,20 +250,22 @@ struct _gc_runtime_state {
264
250
/* This is the number of objects that survived the last full
265
251
collection. It approximates the number of long lived objects
266
252
tracked by the GC.
253
+
267
254
(by "full collection", we mean a collection of the oldest
268
255
generation). */
269
256
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 ;
274
261
};
275
262
276
263
277
264
extern void _PyGC_InitState (struct _gc_runtime_state * );
278
265
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 );
281
269
282
270
/* Freeze objects tracked by the GC and ignore them in future collections. */
283
271
extern void _PyGC_Freeze (PyInterpreterState * interp );
0 commit comments