@@ -227,6 +227,7 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
227
227
uint32_t local = _Py_atomic_load_uint32_relaxed (& op -> ob_ref_local );
228
228
uint32_t new_local = local + 1 ;
229
229
if (new_local == 0 ) {
230
+ _Py_INCREF_IMMORTAL_STAT_INC ();
230
231
// local is equal to _Py_IMMORTAL_REFCNT: do nothing
231
232
return ;
232
233
}
@@ -241,6 +242,7 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
241
242
PY_UINT32_T cur_refcnt = op -> ob_refcnt_split [PY_BIG_ENDIAN ];
242
243
PY_UINT32_T new_refcnt = cur_refcnt + 1 ;
243
244
if (new_refcnt == 0 ) {
245
+ _Py_INCREF_IMMORTAL_STAT_INC ();
244
246
// cur_refcnt is equal to _Py_IMMORTAL_REFCNT: the object is immortal,
245
247
// do nothing
246
248
return ;
@@ -249,6 +251,7 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
249
251
#else
250
252
// Explicitly check immortality against the immortal value
251
253
if (_Py_IsImmortal (op )) {
254
+ _Py_INCREF_IMMORTAL_STAT_INC ();
252
255
return ;
253
256
}
254
257
op -> ob_refcnt ++ ;
@@ -295,6 +298,7 @@ static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
295
298
{
296
299
uint32_t local = _Py_atomic_load_uint32_relaxed (& op -> ob_ref_local );
297
300
if (local == _Py_IMMORTAL_REFCNT_LOCAL ) {
301
+ _Py_DECREF_IMMORTAL_STAT_INC ();
298
302
return ;
299
303
}
300
304
_Py_DECREF_STAT_INC ();
@@ -320,6 +324,7 @@ static inline void Py_DECREF(PyObject *op)
320
324
{
321
325
uint32_t local = _Py_atomic_load_uint32_relaxed (& op -> ob_ref_local );
322
326
if (local == _Py_IMMORTAL_REFCNT_LOCAL ) {
327
+ _Py_DECREF_IMMORTAL_STAT_INC ();
323
328
return ;
324
329
}
325
330
_Py_DECREF_STAT_INC ();
@@ -343,6 +348,7 @@ static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
343
348
_Py_NegativeRefcount (filename , lineno , op );
344
349
}
345
350
if (_Py_IsImmortal (op )) {
351
+ _Py_DECREF_IMMORTAL_STAT_INC ();
346
352
return ;
347
353
}
348
354
_Py_DECREF_STAT_INC ();
@@ -359,6 +365,7 @@ static inline Py_ALWAYS_INLINE void Py_DECREF(PyObject *op)
359
365
// Non-limited C API and limited C API for Python 3.9 and older access
360
366
// directly PyObject.ob_refcnt.
361
367
if (_Py_IsImmortal (op )) {
368
+ _Py_DECREF_IMMORTAL_STAT_INC ();
362
369
return ;
363
370
}
364
371
_Py_DECREF_STAT_INC ();
0 commit comments