mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
gh-123923: Defer refcounting for f_executable
in _PyInterpreterFrame
(#123924)
Use a `_PyStackRef` and defer the reference to `f_executable` when possible. This avoids some reference count contention in the common case of executing the same code object from multiple threads concurrently in the free-threaded build.
This commit is contained in:
parent
4ed7d1d6ac
commit
b2afe2aae4
18 changed files with 177 additions and 99 deletions
|
@ -227,6 +227,13 @@ PyStackRef_DUP(_PyStackRef stackref)
|
|||
# define PyStackRef_DUP(stackref) PyStackRef_FromPyObjectSteal(Py_NewRef(PyStackRef_AsPyObjectBorrow(stackref)))
|
||||
#endif
|
||||
|
||||
// Convert a possibly deferred reference to a strong reference.
|
||||
static inline _PyStackRef
|
||||
PyStackRef_AsStrongReference(_PyStackRef stackref)
|
||||
{
|
||||
return PyStackRef_FromPyObjectSteal(PyStackRef_AsPyObjectSteal(stackref));
|
||||
}
|
||||
|
||||
static inline void
|
||||
_PyObjectStack_FromStackRefStack(PyObject **dst, const _PyStackRef *src, size_t length)
|
||||
{
|
||||
|
@ -261,6 +268,11 @@ PyStackRef_ExceptionInstanceCheck(_PyStackRef stackref)
|
|||
return PyExceptionInstance_Check(PyStackRef_AsPyObjectBorrow(stackref));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
PyStackRef_CodeCheck(_PyStackRef stackref)
|
||||
{
|
||||
return PyCode_Check(PyStackRef_AsPyObjectBorrow(stackref));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
PyStackRef_FunctionCheck(_PyStackRef stackref)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue