mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
gh-117376: Make Py_DECREF
a macro in ceval.c in free-threaded build (#122975)
`Py_DECREF` and `PyStackRef_CLOSE` are now implemented as macros in the free-threaded build in ceval.c. There are two motivations; * MSVC has problems inlining functions in ceval.c in the PGO build. * We will want to mark escaping calls in order to spill the stack pointer in ceval.c and we will want to do this around `_Py_Dealloc` (or `_Py_MergeZeroLocalRefcount` or `_Py_DecRefShared`), not around the entire `Py_DECREF` or `PyStackRef_CLOSE` call.
This commit is contained in:
parent
67f2c84bff
commit
556e855684
2 changed files with 53 additions and 27 deletions
|
@ -190,18 +190,15 @@ PyStackRef_FromPyObjectImmortal(PyObject *obj)
|
|||
} while (0)
|
||||
|
||||
#ifdef Py_GIL_DISABLED
|
||||
static inline void
|
||||
PyStackRef_CLOSE(_PyStackRef stackref)
|
||||
{
|
||||
if (PyStackRef_IsDeferred(stackref)) {
|
||||
// No assert for being immortal or deferred here.
|
||||
// The GC unsets deferred objects right before clearing.
|
||||
return;
|
||||
}
|
||||
Py_DECREF(PyStackRef_AsPyObjectBorrow(stackref));
|
||||
}
|
||||
# define PyStackRef_CLOSE(REF) \
|
||||
do { \
|
||||
_PyStackRef _close_tmp = (REF); \
|
||||
if (!PyStackRef_IsDeferred(_close_tmp)) { \
|
||||
Py_DECREF(PyStackRef_AsPyObjectBorrow(_close_tmp)); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
# define PyStackRef_CLOSE(stackref) Py_DECREF(PyStackRef_AsPyObjectBorrow(stackref));
|
||||
# define PyStackRef_CLOSE(stackref) Py_DECREF(PyStackRef_AsPyObjectBorrow(stackref))
|
||||
#endif
|
||||
|
||||
#define PyStackRef_XCLOSE(stackref) \
|
||||
|
@ -227,7 +224,7 @@ PyStackRef_DUP(_PyStackRef stackref)
|
|||
return stackref;
|
||||
}
|
||||
#else
|
||||
# define PyStackRef_DUP(stackref) PyStackRef_FromPyObjectSteal(Py_NewRef(PyStackRef_AsPyObjectBorrow(stackref)));
|
||||
# define PyStackRef_DUP(stackref) PyStackRef_FromPyObjectSteal(Py_NewRef(PyStackRef_AsPyObjectBorrow(stackref)))
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue