diff options
author | Sam Gross <colesbury@gmail.com> | 2024-09-12 16:37:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-12 16:37:06 (GMT) |
commit | b2afe2aae487ebf89897e22c01d9095944fd334f (patch) | |
tree | 3ffa3ebfe3c69cd21968ce76d8d7cb2f325ff6d3 /Python/gc.c | |
parent | 4ed7d1d6acc22807bfb5983c98fd59f7cb5061db (diff) | |
download | cpython-b2afe2aae487ebf89897e22c01d9095944fd334f.zip cpython-b2afe2aae487ebf89897e22c01d9095944fd334f.tar.gz cpython-b2afe2aae487ebf89897e22c01d9095944fd334f.tar.bz2 |
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.
Diffstat (limited to 'Python/gc.c')
-rw-r--r-- | Python/gc.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/gc.c b/Python/gc.c index 3d36792..024d041 100644 --- a/Python/gc.c +++ b/Python/gc.c @@ -535,6 +535,13 @@ visit_decref(PyObject *op, void *parent) } int +_PyGC_VisitStackRef(_PyStackRef *ref, visitproc visit, void *arg) +{ + Py_VISIT(PyStackRef_AsPyObjectBorrow(*ref)); + return 0; +} + +int _PyGC_VisitFrameStack(_PyInterpreterFrame *frame, visitproc visit, void *arg) { _PyStackRef *ref = _PyFrame_GetLocalsArray(frame); |