mirror of
https://github.com/python/cpython.git
synced 2026-01-04 14:32:21 +00:00
gh-123923: Defer refcounting for f_funcobj in _PyInterpreterFrame (#124026)
Use a `_PyStackRef` and defer the reference to `f_funcobj` 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
d3c76dff44
commit
f4997bb3ac
17 changed files with 143 additions and 137 deletions
|
|
@ -13,11 +13,8 @@ _PyFrame_Traverse(_PyInterpreterFrame *frame, visitproc visit, void *arg)
|
|||
{
|
||||
Py_VISIT(frame->frame_obj);
|
||||
Py_VISIT(frame->f_locals);
|
||||
Py_VISIT(frame->f_funcobj);
|
||||
int err = _PyGC_VisitStackRef(&frame->f_executable, visit, arg);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
_Py_VISIT_STACKREF(frame->f_funcobj);
|
||||
_Py_VISIT_STACKREF(frame->f_executable);
|
||||
return _PyGC_VisitFrameStack(frame, visit, arg);
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +123,7 @@ _PyFrame_ClearExceptCode(_PyInterpreterFrame *frame)
|
|||
Py_DECREF(f);
|
||||
}
|
||||
_PyFrame_ClearLocals(frame);
|
||||
Py_DECREF(frame->f_funcobj);
|
||||
PyStackRef_CLEAR(frame->f_funcobj);
|
||||
}
|
||||
|
||||
/* Unstable API functions */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue