mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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
4
Python/executor_cases.c.h
generated
4
Python/executor_cases.c.h
generated
|
@ -4143,7 +4143,7 @@
|
|||
self = stack_pointer[-2 - oparg];
|
||||
_PyInterpreterFrame *shim = _PyFrame_PushTrampolineUnchecked(
|
||||
tstate, (PyCodeObject *)&_Py_InitCleanup, 1, frame);
|
||||
assert(_PyCode_CODE((PyCodeObject *)shim->f_executable)[0].op.code == EXIT_INIT_CHECK);
|
||||
assert(_PyCode_CODE(_PyFrame_GetCode(shim))[0].op.code == EXIT_INIT_CHECK);
|
||||
/* Push self onto stack of shim */
|
||||
shim->localsplus[0] = PyStackRef_DUP(self);
|
||||
PyFunctionObject *init_func = (PyFunctionObject *)PyStackRef_AsPyObjectSteal(init);
|
||||
|
@ -5413,7 +5413,7 @@
|
|||
#endif
|
||||
_PyExecutorObject *executor;
|
||||
if (target->op.code == ENTER_EXECUTOR) {
|
||||
PyCodeObject *code = (PyCodeObject *)frame->f_executable;
|
||||
PyCodeObject *code = _PyFrame_GetCode(frame);
|
||||
executor = code->co_executors->executors[target->op.arg];
|
||||
Py_INCREF(executor);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue