mirror of
https://github.com/python/cpython.git
synced 2025-12-31 12:33:28 +00:00
gh-134584: JIT: Eliminate redundant refcount ops for X_INT (GH-142765)
This commit is contained in:
parent
0978b9a7d5
commit
790a46a449
9 changed files with 1050 additions and 1246 deletions
227
Python/executor_cases.c.h
generated
227
Python/executor_cases.c.h
generated
|
|
@ -3353,12 +3353,14 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_MULTIPLY_INT_r01: {
|
||||
case _BINARY_OP_MULTIPLY_INT_r03: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef l;
|
||||
_PyStackRef r;
|
||||
right = stack_pointer[-1];
|
||||
left = stack_pointer[-2];
|
||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||
|
|
@ -3373,22 +3375,26 @@
|
|||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
l = left;
|
||||
r = right;
|
||||
_tos_cache2 = r;
|
||||
_tos_cache1 = l;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
stack_pointer += -2;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_MULTIPLY_INT_r11: {
|
||||
case _BINARY_OP_MULTIPLY_INT_r13: {
|
||||
CHECK_CURRENT_CACHED_VALUES(1);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef l;
|
||||
_PyStackRef r;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
right = _stack_item_0;
|
||||
left = stack_pointer[-1];
|
||||
|
|
@ -3405,22 +3411,26 @@
|
|||
SET_CURRENT_CACHED_VALUES(1);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
l = left;
|
||||
r = right;
|
||||
_tos_cache2 = r;
|
||||
_tos_cache1 = l;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_MULTIPLY_INT_r21: {
|
||||
case _BINARY_OP_MULTIPLY_INT_r23: {
|
||||
CHECK_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef l;
|
||||
_PyStackRef r;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
right = _stack_item_1;
|
||||
|
|
@ -3439,55 +3449,24 @@
|
|||
SET_CURRENT_CACHED_VALUES(2);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
l = left;
|
||||
r = right;
|
||||
_tos_cache2 = r;
|
||||
_tos_cache1 = l;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_MULTIPLY_INT_r32: {
|
||||
CHECK_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
_PyStackRef _stack_item_2 = _tos_cache2;
|
||||
right = _stack_item_2;
|
||||
left = _stack_item_1;
|
||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
assert(PyLong_CheckExact(left_o));
|
||||
assert(PyLong_CheckExact(right_o));
|
||||
assert(_PyLong_BothAreCompact((PyLongObject *)left_o, (PyLongObject *)right_o));
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
res = _PyCompactLong_Multiply((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||
if (PyStackRef_IsNull(res)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache2 = right;
|
||||
_tos_cache1 = left;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
_tos_cache1 = res;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_ADD_INT_r01: {
|
||||
case _BINARY_OP_ADD_INT_r03: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef l;
|
||||
_PyStackRef r;
|
||||
right = stack_pointer[-1];
|
||||
left = stack_pointer[-2];
|
||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||
|
|
@ -3502,22 +3481,26 @@
|
|||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
l = left;
|
||||
r = right;
|
||||
_tos_cache2 = r;
|
||||
_tos_cache1 = l;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
stack_pointer += -2;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_ADD_INT_r11: {
|
||||
case _BINARY_OP_ADD_INT_r13: {
|
||||
CHECK_CURRENT_CACHED_VALUES(1);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef l;
|
||||
_PyStackRef r;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
right = _stack_item_0;
|
||||
left = stack_pointer[-1];
|
||||
|
|
@ -3534,22 +3517,26 @@
|
|||
SET_CURRENT_CACHED_VALUES(1);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
l = left;
|
||||
r = right;
|
||||
_tos_cache2 = r;
|
||||
_tos_cache1 = l;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_ADD_INT_r21: {
|
||||
case _BINARY_OP_ADD_INT_r23: {
|
||||
CHECK_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef l;
|
||||
_PyStackRef r;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
right = _stack_item_1;
|
||||
|
|
@ -3568,55 +3555,24 @@
|
|||
SET_CURRENT_CACHED_VALUES(2);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
l = left;
|
||||
r = right;
|
||||
_tos_cache2 = r;
|
||||
_tos_cache1 = l;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_ADD_INT_r32: {
|
||||
CHECK_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
_PyStackRef _stack_item_2 = _tos_cache2;
|
||||
right = _stack_item_2;
|
||||
left = _stack_item_1;
|
||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
assert(PyLong_CheckExact(left_o));
|
||||
assert(PyLong_CheckExact(right_o));
|
||||
assert(_PyLong_BothAreCompact((PyLongObject *)left_o, (PyLongObject *)right_o));
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
res = _PyCompactLong_Add((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||
if (PyStackRef_IsNull(res)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache2 = right;
|
||||
_tos_cache1 = left;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
_tos_cache1 = res;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_SUBTRACT_INT_r01: {
|
||||
case _BINARY_OP_SUBTRACT_INT_r03: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef l;
|
||||
_PyStackRef r;
|
||||
right = stack_pointer[-1];
|
||||
left = stack_pointer[-2];
|
||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||
|
|
@ -3631,22 +3587,26 @@
|
|||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
l = left;
|
||||
r = right;
|
||||
_tos_cache2 = r;
|
||||
_tos_cache1 = l;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
stack_pointer += -2;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_SUBTRACT_INT_r11: {
|
||||
case _BINARY_OP_SUBTRACT_INT_r13: {
|
||||
CHECK_CURRENT_CACHED_VALUES(1);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef l;
|
||||
_PyStackRef r;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
right = _stack_item_0;
|
||||
left = stack_pointer[-1];
|
||||
|
|
@ -3663,22 +3623,26 @@
|
|||
SET_CURRENT_CACHED_VALUES(1);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
l = left;
|
||||
r = right;
|
||||
_tos_cache2 = r;
|
||||
_tos_cache1 = l;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_SUBTRACT_INT_r21: {
|
||||
case _BINARY_OP_SUBTRACT_INT_r23: {
|
||||
CHECK_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef l;
|
||||
_PyStackRef r;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
right = _stack_item_1;
|
||||
|
|
@ -3697,45 +3661,12 @@
|
|||
SET_CURRENT_CACHED_VALUES(2);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
l = left;
|
||||
r = right;
|
||||
_tos_cache2 = r;
|
||||
_tos_cache1 = l;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_OP_SUBTRACT_INT_r32: {
|
||||
CHECK_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
_PyStackRef _stack_item_2 = _tos_cache2;
|
||||
right = _stack_item_2;
|
||||
left = _stack_item_1;
|
||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
assert(PyLong_CheckExact(left_o));
|
||||
assert(PyLong_CheckExact(right_o));
|
||||
assert(_PyLong_BothAreCompact((PyLongObject *)left_o, (PyLongObject *)right_o));
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
res = _PyCompactLong_Subtract((PyLongObject *)left_o, (PyLongObject *)right_o);
|
||||
if (PyStackRef_IsNull(res)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache2 = right;
|
||||
_tos_cache1 = left;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
_tos_cache1 = res;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(2);
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
|
@ -9054,12 +8985,14 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _COMPARE_OP_INT_r21: {
|
||||
case _COMPARE_OP_INT_r23: {
|
||||
CHECK_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef right;
|
||||
_PyStackRef left;
|
||||
_PyStackRef res;
|
||||
_PyStackRef l;
|
||||
_PyStackRef r;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
oparg = CURRENT_OPARG();
|
||||
|
|
@ -9075,13 +9008,13 @@
|
|||
Py_ssize_t ileft = _PyLong_CompactValue((PyLongObject *)left_o);
|
||||
Py_ssize_t iright = _PyLong_CompactValue((PyLongObject *)right_o);
|
||||
int sign_ish = COMPARISON_BIT(ileft, iright);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyLong_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyLong_ExactDealloc);
|
||||
l = left;
|
||||
r = right;
|
||||
res = (sign_ish & oparg) ? PyStackRef_True : PyStackRef_False;
|
||||
_tos_cache2 = r;
|
||||
_tos_cache1 = l;
|
||||
_tos_cache0 = res;
|
||||
_tos_cache1 = PyStackRef_ZERO_BITS;
|
||||
_tos_cache2 = PyStackRef_ZERO_BITS;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue