summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authoradphrost <104581013+adphrost@users.noreply.github.com>2022-09-15 15:42:37 (GMT)
committerGitHub <noreply@github.com>2022-09-15 15:42:37 (GMT)
commita41ed975e863ae0ca435783596f14f8492d62f8d (patch)
treeb87ceae5a7c55e1131a7cdf02b0cda2b6ca41eaf /Python/ceval.c
parente37ac5fbb6de593521cf218aa05bc58a45c5a7c9 (diff)
downloadcpython-a41ed975e863ae0ca435783596f14f8492d62f8d.zip
cpython-a41ed975e863ae0ca435783596f14f8492d62f8d.tar.gz
cpython-a41ed975e863ae0ca435783596f14f8492d62f8d.tar.bz2
GH-91049: Introduce set vectorcall field API for PyFunctionObject (GH-92257)
Co-authored-by: Andrew Frost <adfrost@fb.com> Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index b61cc08..8891d6c 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3126,8 +3126,11 @@ handle_eval_breaker:
PyObject *getattribute = read_obj(cache->descr);
assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
PyFunctionObject *f = (PyFunctionObject *)getattribute;
+ uint32_t func_version = read_u32(cache->keys_version);
+ assert(func_version != 0);
+ DEOPT_IF(f->func_version != func_version, LOAD_ATTR);
PyCodeObject *code = (PyCodeObject *)f->func_code;
- DEOPT_IF(((PyCodeObject *)f->func_code)->co_argcount != 2, LOAD_ATTR);
+ assert(code->co_argcount == 2);
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
STAT_INC(LOAD_ATTR, hit);
@@ -4133,7 +4136,10 @@ handle_eval_breaker:
function = PEEK(total_args + 1);
int positional_args = total_args - KWNAMES_LEN();
// Check if the call can be inlined or not
- if (Py_TYPE(function) == &PyFunction_Type && tstate->interp->eval_frame == NULL) {
+ if (Py_TYPE(function) == &PyFunction_Type &&
+ tstate->interp->eval_frame == NULL &&
+ ((PyFunctionObject *)function)->vectorcall == _PyFunction_Vectorcall)
+ {
int code_flags = ((PyCodeObject*)PyFunction_GET_CODE(function))->co_flags;
PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(function));
STACK_SHRINK(total_args);