mirror of
https://github.com/python/cpython.git
synced 2026-04-20 02:40:59 +00:00
gh-gh-131798: optimize LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN in the JIT (#148555)
This commit is contained in:
parent
c88c27b0c1
commit
1aa7e7ee6d
11 changed files with 1353 additions and 1168 deletions
|
|
@ -2942,35 +2942,34 @@ dummy_func(
|
|||
_SAVE_RETURN_OFFSET +
|
||||
_PUSH_FRAME;
|
||||
|
||||
inst(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN, (unused/1, type_version/2, func_version/2, getattribute/4, owner -- unused)) {
|
||||
PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner);
|
||||
|
||||
op(_LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN_FRAME, (func_version/2, getattribute/4, owner -- new_frame)) {
|
||||
assert((oparg & 1) == 0);
|
||||
DEOPT_IF(IS_PEP523_HOOKED(tstate));
|
||||
PyTypeObject *cls = Py_TYPE(owner_o);
|
||||
assert(type_version != 0);
|
||||
DEOPT_IF(FT_ATOMIC_LOAD_UINT_RELAXED(cls->tp_version_tag) != type_version);
|
||||
assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
|
||||
PyFunctionObject *f = (PyFunctionObject *)getattribute;
|
||||
assert(func_version != 0);
|
||||
DEOPT_IF(f->func_version != func_version);
|
||||
EXIT_IF(f->func_version != func_version);
|
||||
PyCodeObject *code = (PyCodeObject *)f->func_code;
|
||||
assert(code->co_argcount == 2);
|
||||
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize));
|
||||
EXIT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize));
|
||||
STAT_INC(LOAD_ATTR, hit);
|
||||
|
||||
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1);
|
||||
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(
|
||||
_PyInterpreterFrame *pushed_frame = _PyFrame_PushUnchecked(
|
||||
tstate, PyStackRef_FromPyObjectNew(f), 2, frame);
|
||||
new_frame->localsplus[0] = owner;
|
||||
pushed_frame->localsplus[0] = owner;
|
||||
DEAD(owner);
|
||||
// Manipulate stack directly because we exit with DISPATCH_INLINED().
|
||||
SYNC_SP();
|
||||
new_frame->localsplus[1] = PyStackRef_FromPyObjectNew(name);
|
||||
frame->return_offset = INSTRUCTION_SIZE;
|
||||
DISPATCH_INLINED(new_frame);
|
||||
pushed_frame->localsplus[1] = PyStackRef_FromPyObjectNew(name);
|
||||
new_frame = PyStackRef_Wrap(pushed_frame);
|
||||
}
|
||||
|
||||
macro(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) =
|
||||
unused/1 +
|
||||
_RECORD_TOS_TYPE +
|
||||
_GUARD_TYPE_VERSION +
|
||||
_CHECK_PEP_523 +
|
||||
_LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN_FRAME +
|
||||
_SAVE_RETURN_OFFSET +
|
||||
_PUSH_FRAME;
|
||||
|
||||
op(_GUARD_DORV_NO_DICT, (owner -- owner)) {
|
||||
PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue