mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-115999: Specialize CALL_KW
in free-threaded builds (#127713)
* Enable specialization of CALL_KW * Fix bug pushing frame in _PY_FRAME_KW `_PY_FRAME_KW` pushes a pointer to the new frame onto the stack for consumption by the next uop. When pushing the frame fails, we do not want to push the result, `NULL`, to the stack because it is not a valid stackref. This works in the default build because `PyStackRef_NULL` and `NULL` are the same value, so the `PyStackRef_XCLOSE()` in the error handler ignores it. In the free-threaded build the values are not the same; `PyStackRef_XCLOSE()` will attempt to decref a null pointer.
This commit is contained in:
parent
e8f4e272cc
commit
c84928ed6d
4 changed files with 26 additions and 35 deletions
11
Python/executor_cases.c.h
generated
11
Python/executor_cases.c.h
generated
|
@ -5235,7 +5235,7 @@
|
|||
int code_flags = ((PyCodeObject*)PyFunction_GET_CODE(callable_o))->co_flags;
|
||||
PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(callable_o));
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
new_frame = _PyEvalFramePushAndInit(
|
||||
_PyInterpreterFrame *temp = _PyEvalFramePushAndInit(
|
||||
tstate, callable[0], locals,
|
||||
args, positional_args, kwnames_o, frame
|
||||
);
|
||||
|
@ -5243,12 +5243,15 @@
|
|||
PyStackRef_CLOSE(kwnames);
|
||||
// The frame has stolen all the arguments from the stack,
|
||||
// so there is no need to clean them up.
|
||||
stack_pointer[-3 - oparg].bits = (uintptr_t)new_frame;
|
||||
stack_pointer += -2 - oparg;
|
||||
stack_pointer += -3 - oparg;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
if (new_frame == NULL) {
|
||||
if (temp == NULL) {
|
||||
JUMP_TO_ERROR();
|
||||
}
|
||||
new_frame = temp;
|
||||
stack_pointer[0].bits = (uintptr_t)new_frame;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue