diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2024-05-28 19:45:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-28 19:45:11 (GMT) |
commit | cfcc054dee87a5a3f18c99d83a2957bf3487de1d (patch) | |
tree | da9460af9efade22f122b64a20233392302c1b4a /Python | |
parent | d87b0151062e36e67f9e42e1595fba5bf23a485c (diff) | |
download | cpython-cfcc054dee87a5a3f18c99d83a2957bf3487de1d.zip cpython-cfcc054dee87a5a3f18c99d83a2957bf3487de1d.tar.gz cpython-cfcc054dee87a5a3f18c99d83a2957bf3487de1d.tar.bz2 |
GH-119476: Split _CHECK_FUNCTION_VERSION out of _CHECK_FUNCTION_EXACT_ARGS (GH-119510)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bytecodes.c | 7 | ||||
-rw-r--r-- | Python/executor_cases.c.h | 10 | ||||
-rw-r--r-- | Python/generated_cases.c.h | 20 | ||||
-rw-r--r-- | Python/optimizer_bytecodes.c | 3 | ||||
-rw-r--r-- | Python/optimizer_cases.c.h | 2 |
5 files changed, 21 insertions, 21 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 025fed3..8b12da0 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -3261,10 +3261,9 @@ dummy_func( DEOPT_IF(tstate->interp->eval_frame); } - op(_CHECK_FUNCTION_EXACT_ARGS, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) { - EXIT_IF(!PyFunction_Check(callable)); + op(_CHECK_FUNCTION_EXACT_ARGS, (callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) { + assert(PyFunction_Check(callable)); PyFunctionObject *func = (PyFunctionObject *)callable; - EXIT_IF(func->func_version != func_version); PyCodeObject *code = (PyCodeObject *)func->func_code; EXIT_IF(code->co_argcount != oparg + (self_or_null != NULL)); } @@ -3308,6 +3307,7 @@ dummy_func( _CHECK_PEP_523 + _CHECK_CALL_BOUND_METHOD_EXACT_ARGS + _INIT_CALL_BOUND_METHOD_EXACT_ARGS + + _CHECK_FUNCTION_VERSION + _CHECK_FUNCTION_EXACT_ARGS + _CHECK_STACK_SPACE + _INIT_CALL_PY_EXACT_ARGS + @@ -3317,6 +3317,7 @@ dummy_func( macro(CALL_PY_EXACT_ARGS) = unused/1 + // Skip over the counter _CHECK_PEP_523 + + _CHECK_FUNCTION_VERSION + _CHECK_FUNCTION_EXACT_ARGS + _CHECK_STACK_SPACE + _INIT_CALL_PY_EXACT_ARGS + diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index a3d7af2..a00b382 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -3240,16 +3240,8 @@ oparg = CURRENT_OPARG(); self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - uint32_t func_version = (uint32_t)CURRENT_OPERAND(); - if (!PyFunction_Check(callable)) { - UOP_STAT_INC(uopcode, miss); - JUMP_TO_JUMP_TARGET(); - } + assert(PyFunction_Check(callable)); PyFunctionObject *func = (PyFunctionObject *)callable; - if (func->func_version != func_version) { - UOP_STAT_INC(uopcode, miss); - JUMP_TO_JUMP_TARGET(); - } PyCodeObject *code = (PyCodeObject *)func->func_code; if (code->co_argcount != oparg + (self_or_null != NULL)) { UOP_STAT_INC(uopcode, miss); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 07d9965..b897c38 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -943,14 +943,19 @@ stack_pointer[-2 - oparg] = func; // This is used by CALL, upon deoptimization Py_DECREF(callable); } - // _CHECK_FUNCTION_EXACT_ARGS - self_or_null = self; + // _CHECK_FUNCTION_VERSION callable = func; { uint32_t func_version = read_u32(&this_instr[2].cache); DEOPT_IF(!PyFunction_Check(callable), CALL); PyFunctionObject *func = (PyFunctionObject *)callable; DEOPT_IF(func->func_version != func_version, CALL); + } + // _CHECK_FUNCTION_EXACT_ARGS + self_or_null = stack_pointer[-1 - oparg]; + { + assert(PyFunction_Check(callable)); + PyFunctionObject *func = (PyFunctionObject *)callable; PyCodeObject *code = (PyCodeObject *)func->func_code; DEOPT_IF(code->co_argcount != oparg + (self_or_null != NULL), CALL); } @@ -1859,8 +1864,8 @@ next_instr += 4; INSTRUCTION_STATS(CALL_PY_EXACT_ARGS); static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size"); - PyObject *self_or_null; PyObject *callable; + PyObject *self_or_null; PyObject **args; _PyInterpreterFrame *new_frame; /* Skip 1 cache entry */ @@ -1868,14 +1873,19 @@ { DEOPT_IF(tstate->interp->eval_frame, CALL); } - // _CHECK_FUNCTION_EXACT_ARGS - self_or_null = stack_pointer[-1 - oparg]; + // _CHECK_FUNCTION_VERSION callable = stack_pointer[-2 - oparg]; { uint32_t func_version = read_u32(&this_instr[2].cache); DEOPT_IF(!PyFunction_Check(callable), CALL); PyFunctionObject *func = (PyFunctionObject *)callable; DEOPT_IF(func->func_version != func_version, CALL); + } + // _CHECK_FUNCTION_EXACT_ARGS + self_or_null = stack_pointer[-1 - oparg]; + { + assert(PyFunction_Check(callable)); + PyFunctionObject *func = (PyFunctionObject *)callable; PyCodeObject *code = (PyCodeObject *)func->func_code; DEOPT_IF(code->co_argcount != oparg + (self_or_null != NULL), CALL); } diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c index e5c982b..a2cb4c0 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -519,10 +519,9 @@ dummy_func(void) { self = sym_new_not_null(ctx); } - op(_CHECK_FUNCTION_EXACT_ARGS, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) { + op(_CHECK_FUNCTION_EXACT_ARGS, (callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) { sym_set_type(callable, &PyFunction_Type); (void)self_or_null; - (void)func_version; } op(_CHECK_CALL_BOUND_METHOD_EXACT_ARGS, (callable, null, unused[oparg] -- callable, null, unused[oparg])) { diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h index 30ed011..4d5c803 100644 --- a/Python/optimizer_cases.c.h +++ b/Python/optimizer_cases.c.h @@ -1537,10 +1537,8 @@ _Py_UopsSymbol *callable; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - uint32_t func_version = (uint32_t)this_instr->operand; sym_set_type(callable, &PyFunction_Type); (void)self_or_null; - (void)func_version; break; } |