Previously, `_Py_RefcntAdd` hasn't called
`_Py_INCREF_STAT_INC/_Py_INCREF_IMMORTAL_STAT_INC` which is incorrect.
Now it has been fixed.
(cherry picked from commit
ab05beb8cea62636bd86f6f7cf1a82d7efca7162)
_Py_AddRefTotal(_PyInterpreterState_GET(), n);
#endif
op->ob_refcnt += n;
+
+ // Although the ref count was increased by `n` (which may be greater than 1)
+ // it is only a single increment (i.e. addition) operation, so only 1 refcnt
+ // increment operation is counted.
+ _Py_INCREF_STAT_INC();
}
#define _Py_RefcntAdd(op, n) _Py_RefcntAdd(_PyObject_CAST(op), n)
--- /dev/null
+Fix statistics for increments of object reference counts (in particular, when
+a reference count was increased by more than 1 in a single operation).