diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2024-07-25 10:45:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-25 10:45:28 -0700 |
commit | 5f6001130f8ada871193377954cfcfee01ef93b6 (patch) | |
tree | 982d1ac9e0f248c6bbacb2f35fd4d791c952acb2 /Python/executor_cases.c.h | |
parent | 5e686ff57d6bc2fd8c675bd2c59a064be6da2839 (diff) | |
download | cpython-5f6001130f8ada871193377954cfcfee01ef93b6.tar.gz cpython-5f6001130f8ada871193377954cfcfee01ef93b6.zip |
GH-118093: Add tier two support for LOAD_ATTR_PROPERTY (GH-122283)
Diffstat (limited to 'Python/executor_cases.c.h')
-rw-r--r-- | Python/executor_cases.c.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 87c9255ef79..b8343f9ffd5 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -2507,7 +2507,39 @@ /* _LOAD_ATTR_CLASS is split on (oparg & 1) */ - /* _LOAD_ATTR_PROPERTY is not a viable micro-op for tier 2 because it uses the 'this_instr' variable */ + case _LOAD_ATTR_PROPERTY_FRAME: { + _PyStackRef owner; + _PyInterpreterFrame *new_frame; + oparg = CURRENT_OPARG(); + owner = stack_pointer[-1]; + PyObject *fget = (PyObject *)CURRENT_OPERAND(); + assert((oparg & 1) == 0); + assert(Py_IS_TYPE(fget, &PyFunction_Type)); + PyFunctionObject *f = (PyFunctionObject *)fget; + PyCodeObject *code = (PyCodeObject *)f->func_code; + if ((code->co_flags & (CO_VARKEYWORDS | CO_VARARGS | CO_OPTIMIZED)) != CO_OPTIMIZED) { + UOP_STAT_INC(uopcode, miss); + JUMP_TO_JUMP_TARGET(); + } + if (code->co_kwonlyargcount) { + UOP_STAT_INC(uopcode, miss); + JUMP_TO_JUMP_TARGET(); + } + if (code->co_argcount != 1) { + UOP_STAT_INC(uopcode, miss); + JUMP_TO_JUMP_TARGET(); + } + if (!_PyThreadState_HasStackSpace(tstate, code->co_framesize)) { + UOP_STAT_INC(uopcode, miss); + JUMP_TO_JUMP_TARGET(); + } + STAT_INC(LOAD_ATTR, hit); + Py_INCREF(fget); + new_frame = _PyFrame_PushUnchecked(tstate, f, 1); + new_frame->localsplus[0] = owner; + stack_pointer[-1].bits = (uintptr_t)new_frame; + break; + } /* _LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN is not a viable micro-op for tier 2 because it uses the 'this_instr' variable */ |