Skip to content

Commit e69b52b

Browse files
committed
Split LOAD_ATTR_PROPERTY into uops (but final uop is not yet viable)
1 parent 58fda36 commit e69b52b

File tree

5 files changed

+152
-80
lines changed

5 files changed

+152
-80
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 65 additions & 44 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
@@ -2043,30 +2043,38 @@ dummy_func(
20432043
unused/2 +
20442044
_LOAD_ATTR_CLASS;
20452045

2046-
inst(LOAD_ATTR_PROPERTY, (unused/1, type_version/2, fget/4, func_version/2, owner -- unused, unused if (0))) {
2047-
assert((oparg & 1) == 0);
2048-
DEOPT_IF(tstate->interp->eval_frame);
2049-
2050-
PyTypeObject *cls = Py_TYPE(owner);
2051-
assert(type_version != 0);
2052-
DEOPT_IF(cls->tp_version_tag != type_version);
2046+
op(_HELPER_LOAD_FUNC_FROM_CACHE, (fget/4 -- func: PyFunctionObject *)) {
20532047
assert(Py_IS_TYPE(fget, &PyFunction_Type));
2054-
PyFunctionObject *f = (PyFunctionObject *)fget;
2048+
func = (PyFunctionObject *)fget;
2049+
}
2050+
2051+
op(_CHECK_FUNC_VERSION, (func_version/2, func: PyFunctionObject * -- func: PyFunctionObject *)) {
20552052
assert(func_version != 0);
2056-
DEOPT_IF(f->func_version != func_version);
2057-
PyCodeObject *code = (PyCodeObject *)f->func_code;
2053+
DEOPT_IF(func->func_version != func_version);
2054+
}
2055+
2056+
op(_LOAD_ATTR_PROPERTY, (owner, func: PyFunctionObject * -- unused, unused if (0))) {
2057+
assert((oparg & 1) == 0);
2058+
PyCodeObject *code = (PyCodeObject *)func->func_code;
20582059
assert(code->co_argcount == 1);
20592060
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize));
20602061
STAT_INC(LOAD_ATTR, hit);
2061-
Py_INCREF(fget);
2062-
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, f, 1);
2062+
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, Py_NewRef(func), 1);
20632063
// Manipulate stack directly because we exit with DISPATCH_INLINED().
20642064
STACK_SHRINK(1);
20652065
new_frame->localsplus[0] = owner;
20662066
frame->return_offset = (uint16_t)(next_instr - this_instr);
20672067
DISPATCH_INLINED(new_frame);
20682068
}
20692069

2070+
macro(LOAD_ATTR_PROPERTY) =
2071+
unused/1 +
2072+
_CHECK_PEP_523 +
2073+
_GUARD_TYPE_VERSION +
2074+
_HELPER_LOAD_FUNC_FROM_CACHE +
2075+
_CHECK_FUNC_VERSION +
2076+
_LOAD_ATTR_PROPERTY;
2077+
20702078
inst(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN, (unused/1, type_version/2, func_version/2, getattribute/4, owner -- unused, unused if (0))) {
20712079
assert((oparg & 1) == 0);
20722080
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: 38 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)