diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 10 | ||||
-rw-r--r-- | Python/specialize.c | 5 |
2 files changed, 13 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); diff --git a/Python/specialize.c b/Python/specialize.c index 93f1d28..b7c321e 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -837,6 +837,11 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name) if (!function_check_args(descr, 2, LOAD_ATTR)) { goto fail; } + uint32_t version = function_get_version(descr, LOAD_ATTR); + if (version == 0) { + goto fail; + } + write_u32(lm_cache->keys_version, version); /* borrowed */ write_obj(lm_cache->descr, descr); write_u32(lm_cache->type_version, type->tp_version_tag); |