mirror of
https://github.com/python/cpython.git
synced 2026-02-06 01:45:25 +00:00
GH-144179: Use recorded values to make optimizer more robust (GH-144437)
* Add three new symbol kinds * Do not smuggle code object in _PUSH_FRAME operand * Fix small bug in predicate analysis
This commit is contained in:
parent
b6d8aa436b
commit
b53fc7caa6
16 changed files with 2062 additions and 1507 deletions
109
Python/executor_cases.c.h
generated
109
Python/executor_cases.c.h
generated
|
|
@ -6184,7 +6184,6 @@
|
|||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
getitem = PyStackRef_FromPyObjectNew(getitem_o);
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
_tos_cache2 = getitem;
|
||||
_tos_cache1 = _stack_item_1;
|
||||
_tos_cache0 = container;
|
||||
|
|
@ -6203,6 +6202,7 @@
|
|||
getitem = stack_pointer[-1];
|
||||
sub = stack_pointer[-2];
|
||||
container = stack_pointer[-3];
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
_PyInterpreterFrame* pushed_frame = _PyFrame_PushUnchecked(tstate, getitem, 2, frame);
|
||||
pushed_frame->localsplus[0] = container;
|
||||
pushed_frame->localsplus[1] = sub;
|
||||
|
|
@ -6227,6 +6227,7 @@
|
|||
getitem = _stack_item_0;
|
||||
sub = stack_pointer[-1];
|
||||
container = stack_pointer[-2];
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
_PyInterpreterFrame* pushed_frame = _PyFrame_PushUnchecked(tstate, getitem, 2, frame);
|
||||
pushed_frame->localsplus[0] = container;
|
||||
pushed_frame->localsplus[1] = sub;
|
||||
|
|
@ -6252,6 +6253,7 @@
|
|||
getitem = _stack_item_1;
|
||||
sub = _stack_item_0;
|
||||
container = stack_pointer[-1];
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
_PyInterpreterFrame* pushed_frame = _PyFrame_PushUnchecked(tstate, getitem, 2, frame);
|
||||
pushed_frame->localsplus[0] = container;
|
||||
pushed_frame->localsplus[1] = sub;
|
||||
|
|
@ -6278,6 +6280,7 @@
|
|||
getitem = _stack_item_2;
|
||||
sub = _stack_item_1;
|
||||
container = _stack_item_0;
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
_PyInterpreterFrame* pushed_frame = _PyFrame_PushUnchecked(tstate, getitem, 2, frame);
|
||||
pushed_frame->localsplus[0] = container;
|
||||
pushed_frame->localsplus[1] = sub;
|
||||
|
|
@ -20142,6 +20145,110 @@
|
|||
GOTO_TIER_ONE(target);
|
||||
}
|
||||
|
||||
case _GUARD_CODE_r00: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
uint32_t version = (uint32_t)CURRENT_OPERAND0_32();
|
||||
PyObject *code = PyStackRef_AsPyObjectBorrow(frame->f_executable);
|
||||
if (code == Py_None) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
if (((PyCodeObject *)code)->co_version != version) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _GUARD_CODE_r11: {
|
||||
CHECK_CURRENT_CACHED_VALUES(1);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
uint32_t version = (uint32_t)CURRENT_OPERAND0_32();
|
||||
PyObject *code = PyStackRef_AsPyObjectBorrow(frame->f_executable);
|
||||
if (code == Py_None) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
if (((PyCodeObject *)code)->co_version != version) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _GUARD_CODE_r22: {
|
||||
CHECK_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
uint32_t version = (uint32_t)CURRENT_OPERAND0_32();
|
||||
PyObject *code = PyStackRef_AsPyObjectBorrow(frame->f_executable);
|
||||
if (code == Py_None) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache1 = _stack_item_1;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(2);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
if (((PyCodeObject *)code)->co_version != version) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache1 = _stack_item_1;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(2);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
_tos_cache1 = _stack_item_1;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _GUARD_CODE_r33: {
|
||||
CHECK_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
_PyStackRef _stack_item_2 = _tos_cache2;
|
||||
uint32_t version = (uint32_t)CURRENT_OPERAND0_32();
|
||||
PyObject *code = PyStackRef_AsPyObjectBorrow(frame->f_executable);
|
||||
if (code == Py_None) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache2 = _stack_item_2;
|
||||
_tos_cache1 = _stack_item_1;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
if (((PyCodeObject *)code)->co_version != version) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache2 = _stack_item_2;
|
||||
_tos_cache1 = _stack_item_1;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
_tos_cache2 = _stack_item_2;
|
||||
_tos_cache1 = _stack_item_1;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _GUARD_IP__PUSH_FRAME_r00: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue