@@ -131,7 +131,6 @@ static inline void _PyObject_GC_SET_SHARED(PyObject *op) {
131131 * When object are moved from the pending space, old[gcstate->visited_space^1]
132132 * into the increment, the old space bit is flipped.
133133*/
134- #define _PyGC_NEXT_MASK_OLD_SPACE_1 1
135134
136135#define _PyGC_PREV_SHIFT 2
137136#define _PyGC_PREV_MASK (((uintptr_t) -1) << _PyGC_PREV_SHIFT)
@@ -159,13 +158,11 @@ typedef enum {
159158// Lowest bit of _gc_next is used for flags only in GC.
160159// But it is always 0 for normal code.
161160static inline PyGC_Head * _PyGCHead_NEXT (PyGC_Head * gc ) {
162- uintptr_t next = gc -> _gc_next & _PyGC_PREV_MASK ;
161+ uintptr_t next = gc -> _gc_next ;
163162 return (PyGC_Head * )next ;
164163}
165164static inline void _PyGCHead_SET_NEXT (PyGC_Head * gc , PyGC_Head * next ) {
166- uintptr_t unext = (uintptr_t )next ;
167- assert ((unext & ~_PyGC_PREV_MASK ) == 0 );
168- gc -> _gc_next = (gc -> _gc_next & ~_PyGC_PREV_MASK ) | unext ;
165+ gc -> _gc_next = (uintptr_t )next ;
169166}
170167
171168// Lowest two bits of _gc_prev is used for _PyGC_PREV_MASK_* flags.
@@ -207,10 +204,6 @@ static inline void _PyGC_CLEAR_FINALIZED(PyObject *op) {
207204
208205extern void _Py_ScheduleGC (PyThreadState * tstate );
209206
210- #ifndef Py_GIL_DISABLED
211- extern void _Py_TriggerGC (struct _gc_runtime_state * gcstate );
212- #endif
213-
214207
215208/* Tell the GC to track this object.
216209 *
@@ -244,19 +237,12 @@ static inline void _PyObject_GC_TRACK(
244237 "object is in generation which is garbage collected" ,
245238 filename , lineno , __func__ );
246239
247- struct _gc_runtime_state * gcstate = & _PyInterpreterState_GET ()-> gc ;
248- PyGC_Head * generation0 = & gcstate -> young .head ;
240+ PyGC_Head * generation0 = _PyInterpreterState_GET ()-> gc .generation0 ;
249241 PyGC_Head * last = (PyGC_Head * )(generation0 -> _gc_prev );
250242 _PyGCHead_SET_NEXT (last , gc );
251243 _PyGCHead_SET_PREV (gc , last );
252- uintptr_t not_visited = 1 ^ gcstate -> visited_space ;
253- gc -> _gc_next = ((uintptr_t )generation0 ) | not_visited ;
244+ _PyGCHead_SET_NEXT (gc , generation0 );
254245 generation0 -> _gc_prev = (uintptr_t )gc ;
255- gcstate -> young .count ++ ; /* number of tracked GC objects */
256- gcstate -> heap_size ++ ;
257- if (gcstate -> young .count > gcstate -> young .threshold ) {
258- _Py_TriggerGC (gcstate );
259- }
260246#endif
261247}
262248
@@ -291,11 +277,6 @@ static inline void _PyObject_GC_UNTRACK(
291277 _PyGCHead_SET_PREV (next , prev );
292278 gc -> _gc_next = 0 ;
293279 gc -> _gc_prev &= _PyGC_PREV_MASK_FINALIZED ;
294- struct _gc_runtime_state * gcstate = & _PyInterpreterState_GET ()-> gc ;
295- if (gcstate -> young .count > 0 ) {
296- gcstate -> young .count -- ;
297- }
298- gcstate -> heap_size -- ;
299280#endif
300281}
301282
0 commit comments