mirror of
https://github.com/python/cpython.git
synced 2025-08-23 18:24:46 +00:00
gh-100239: specialize long tail of binary operations (#128722)
This commit is contained in:
parent
e81fe940c9
commit
3893a92d95
21 changed files with 796 additions and 492 deletions
45
Python/executor_cases.c.h
generated
45
Python/executor_cases.c.h
generated
|
@ -899,6 +899,51 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _GUARD_BINARY_OP_EXTEND: {
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
right = stack_pointer[-1];
|
||||
left = stack_pointer[-2];
|
||||
PyObject *descr = (PyObject *)CURRENT_OPERAND0();
|
||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
_PyBinaryOpSpecializationDescr *d = (_PyBinaryOpSpecializationDescr*)descr;
|
||||
assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5);
|
||||
assert(d && d->guard);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
int res = d->guard(left_o, right_o);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
if (!res) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_EXTEND: {
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
right = stack_pointer[-1];
|
||||
left = stack_pointer[-2];
|
||||
PyObject *descr = (PyObject *)CURRENT_OPERAND0();
|
||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5);
|
||||
_PyBinaryOpSpecializationDescr *d = (_PyBinaryOpSpecializationDescr*)descr;
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyObject *res_o = d->action(left_o, right_o);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
PyStackRef_CLOSE(left);
|
||||
PyStackRef_CLOSE(right);
|
||||
res = PyStackRef_FromPyObjectSteal(res_o);
|
||||
stack_pointer[-2] = res;
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_SUBSCR: {
|
||||
_PyStackRef sub;
|
||||
_PyStackRef container;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue