Skip to content

Commit a662119

Browse files
committed
Split LOAD_ATTR_PROPERTY into uops (but final uop is not yet viable)
1 parent 9601b08 commit a662119

File tree

5 files changed

+145
-73
lines changed

5 files changed

+145
-73
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 57 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/abstract_interp_cases.c.h

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,23 +1992,23 @@ dummy_func(
19921992
unused/2 +
19931993
_LOAD_ATTR_CLASS;
19941994

1995-
inst(LOAD_ATTR_PROPERTY, (unused/1, type_version/2, fget/4, func_version/2, owner -- unused, unused if (0))) {
1996-
assert((oparg & 1) == 0);
1997-
DEOPT_IF(tstate->interp->eval_frame);
1998-
1999-
PyTypeObject *cls = Py_TYPE(owner);
2000-
assert(type_version != 0);
2001-
DEOPT_IF(cls->tp_version_tag != type_version);
1995+
op(_HELPER_LOAD_FUNC_FROM_CACHE, (fget/4 -- func: PyFunctionObject *)) {
20021996
assert(Py_IS_TYPE(fget, &PyFunction_Type));
2003-
PyFunctionObject *f = (PyFunctionObject *)fget;
1997+
func = (PyFunctionObject *)fget;
1998+
}
1999+
2000+
op(_CHECK_FUNC_VERSION, (func_version/2, func: PyFunctionObject * -- func: PyFunctionObject *)) {
20042001
assert(func_version != 0);
2005-
DEOPT_IF(f->func_version != func_version);
2006-
PyCodeObject *code = (PyCodeObject *)f->func_code;
2002+
DEOPT_IF(func->func_version != func_version);
2003+
}
2004+
2005+
op(_LOAD_ATTR_PROPERTY, (owner, func: PyFunctionObject * -- unused, unused if (0))) {
2006+
assert((oparg & 1) == 0);
2007+
PyCodeObject *code = (PyCodeObject *)func->func_code;
20072008
assert(code->co_argcount == 1);
20082009
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize));
20092010
STAT_INC(LOAD_ATTR, hit);
2010-
Py_INCREF(fget);
2011-
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, f, 1);
2011+
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, Py_NewRef(func), 1);
20122012
// Manipulate stack directly because we exit with DISPATCH_INLINED().
20132013
STACK_SHRINK(1);
20142014
new_frame->localsplus[0] = owner;
@@ -2017,6 +2017,14 @@ dummy_func(
20172017
DISPATCH_INLINED(new_frame);
20182018
}
20192019

2020+
macro(LOAD_ATTR_PROPERTY) =
2021+
unused/1 +
2022+
_CHECK_PEP_523 +
2023+
_GUARD_TYPE_VERSION +
2024+
_HELPER_LOAD_FUNC_FROM_CACHE +
2025+
_CHECK_FUNC_VERSION +
2026+
_LOAD_ATTR_PROPERTY;
2027+
20202028
inst(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN, (unused/1, type_version/2, func_version/2, getattribute/4, owner -- unused, unused if (0))) {
20212029
assert((oparg & 1) == 0);
20222030
DEOPT_IF(tstate->interp->eval_frame);

Python/executor_cases.c.h

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 39 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)