mirror of
https://github.com/python/cpython.git
synced 2026-05-07 02:51:00 +00:00
gh-148235: remove duplicate uops _LOAD_CONST_UNDER_INLINE(_BORROW) in JIT (GH-148236)
This commit is contained in:
parent
8923ca418c
commit
756358524e
8 changed files with 1088 additions and 1288 deletions
2150
Include/internal/pycore_uop_ids.h
generated
2150
Include/internal/pycore_uop_ids.h
generated
File diff suppressed because it is too large
Load diff
38
Include/internal/pycore_uop_metadata.h
generated
38
Include/internal/pycore_uop_metadata.h
generated
|
|
@ -394,8 +394,6 @@ const uint32_t _PyUop_Flags[MAX_UOP_ID+1] = {
|
|||
[_SHUFFLE_2_LOAD_CONST_INLINE_BORROW] = 0,
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW] = 0,
|
||||
[_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW] = HAS_ESCAPES_FLAG,
|
||||
[_LOAD_CONST_UNDER_INLINE] = 0,
|
||||
[_LOAD_CONST_UNDER_INLINE_BORROW] = 0,
|
||||
[_START_EXECUTOR] = HAS_DEOPT_FLAG,
|
||||
[_MAKE_WARM] = 0,
|
||||
[_FATAL_ERROR] = 0,
|
||||
|
|
@ -3669,24 +3667,6 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = {
|
|||
{ 1, 3, _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW_r31 },
|
||||
},
|
||||
},
|
||||
[_LOAD_CONST_UNDER_INLINE] = {
|
||||
.best = { 0, 1, 2, 2 },
|
||||
.entries = {
|
||||
{ 2, 0, _LOAD_CONST_UNDER_INLINE_r02 },
|
||||
{ 2, 1, _LOAD_CONST_UNDER_INLINE_r12 },
|
||||
{ 3, 2, _LOAD_CONST_UNDER_INLINE_r23 },
|
||||
{ -1, -1, -1 },
|
||||
},
|
||||
},
|
||||
[_LOAD_CONST_UNDER_INLINE_BORROW] = {
|
||||
.best = { 0, 1, 2, 2 },
|
||||
.entries = {
|
||||
{ 2, 0, _LOAD_CONST_UNDER_INLINE_BORROW_r02 },
|
||||
{ 2, 1, _LOAD_CONST_UNDER_INLINE_BORROW_r12 },
|
||||
{ 3, 2, _LOAD_CONST_UNDER_INLINE_BORROW_r23 },
|
||||
{ -1, -1, -1 },
|
||||
},
|
||||
},
|
||||
[_START_EXECUTOR] = {
|
||||
.best = { 0, 0, 0, 0 },
|
||||
.entries = {
|
||||
|
|
@ -4659,12 +4639,6 @@ const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1] = {
|
|||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r23] = _SHUFFLE_3_LOAD_CONST_INLINE_BORROW,
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33] = _SHUFFLE_3_LOAD_CONST_INLINE_BORROW,
|
||||
[_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW_r31] = _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW,
|
||||
[_LOAD_CONST_UNDER_INLINE_r02] = _LOAD_CONST_UNDER_INLINE,
|
||||
[_LOAD_CONST_UNDER_INLINE_r12] = _LOAD_CONST_UNDER_INLINE,
|
||||
[_LOAD_CONST_UNDER_INLINE_r23] = _LOAD_CONST_UNDER_INLINE,
|
||||
[_LOAD_CONST_UNDER_INLINE_BORROW_r02] = _LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
[_LOAD_CONST_UNDER_INLINE_BORROW_r12] = _LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
[_LOAD_CONST_UNDER_INLINE_BORROW_r23] = _LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
[_START_EXECUTOR_r00] = _START_EXECUTOR,
|
||||
[_MAKE_WARM_r00] = _MAKE_WARM,
|
||||
[_MAKE_WARM_r11] = _MAKE_WARM,
|
||||
|
|
@ -5575,14 +5549,6 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = {
|
|||
[_LOAD_CONST_INLINE_BORROW_r01] = "_LOAD_CONST_INLINE_BORROW_r01",
|
||||
[_LOAD_CONST_INLINE_BORROW_r12] = "_LOAD_CONST_INLINE_BORROW_r12",
|
||||
[_LOAD_CONST_INLINE_BORROW_r23] = "_LOAD_CONST_INLINE_BORROW_r23",
|
||||
[_LOAD_CONST_UNDER_INLINE] = "_LOAD_CONST_UNDER_INLINE",
|
||||
[_LOAD_CONST_UNDER_INLINE_r02] = "_LOAD_CONST_UNDER_INLINE_r02",
|
||||
[_LOAD_CONST_UNDER_INLINE_r12] = "_LOAD_CONST_UNDER_INLINE_r12",
|
||||
[_LOAD_CONST_UNDER_INLINE_r23] = "_LOAD_CONST_UNDER_INLINE_r23",
|
||||
[_LOAD_CONST_UNDER_INLINE_BORROW] = "_LOAD_CONST_UNDER_INLINE_BORROW",
|
||||
[_LOAD_CONST_UNDER_INLINE_BORROW_r02] = "_LOAD_CONST_UNDER_INLINE_BORROW_r02",
|
||||
[_LOAD_CONST_UNDER_INLINE_BORROW_r12] = "_LOAD_CONST_UNDER_INLINE_BORROW_r12",
|
||||
[_LOAD_CONST_UNDER_INLINE_BORROW_r23] = "_LOAD_CONST_UNDER_INLINE_BORROW_r23",
|
||||
[_LOAD_DEREF] = "_LOAD_DEREF",
|
||||
[_LOAD_DEREF_r01] = "_LOAD_DEREF_r01",
|
||||
[_LOAD_FAST] = "_LOAD_FAST",
|
||||
|
|
@ -6751,10 +6717,6 @@ int _PyUop_num_popped(int opcode, int oparg)
|
|||
return 3;
|
||||
case _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW:
|
||||
return 4;
|
||||
case _LOAD_CONST_UNDER_INLINE:
|
||||
return 1;
|
||||
case _LOAD_CONST_UNDER_INLINE_BORROW:
|
||||
return 1;
|
||||
case _START_EXECUTOR:
|
||||
return 0;
|
||||
case _MAKE_WARM:
|
||||
|
|
|
|||
|
|
@ -1846,7 +1846,7 @@ def testfunc(n):
|
|||
self.assertIsNotNone(ex)
|
||||
uops = get_opnames(ex)
|
||||
self.assertNotIn("_UNARY_INVERT", uops)
|
||||
self.assertIn("_INSERT_1_LOAD_CONST_INLINE_BORROW", uops)
|
||||
self.assertIn("_LOAD_CONST_INLINE_BORROW", uops)
|
||||
|
||||
def test_compare_op_pop_two_load_const_inline_borrow(self):
|
||||
def testfunc(n):
|
||||
|
|
@ -3192,8 +3192,8 @@ def f(n):
|
|||
self.assertEqual(res, TIER2_THRESHOLD)
|
||||
uops = get_opnames(ex)
|
||||
self.assertNotIn("_LOAD_ATTR_METHOD_NO_DICT", uops)
|
||||
self.assertNotIn("_LOAD_CONST_UNDER_INLINE", uops)
|
||||
self.assertIn("_LOAD_CONST_UNDER_INLINE_BORROW", uops)
|
||||
self.assertNotIn("_INSERT_1_LOAD_CONST_INLINE", uops)
|
||||
self.assertIn("_INSERT_1_LOAD_CONST_INLINE_BORROW", uops)
|
||||
|
||||
def test_store_fast_refcount_elimination(self):
|
||||
def foo(x):
|
||||
|
|
@ -4009,8 +4009,6 @@ class A:
|
|||
self.assertIsNotNone(ex)
|
||||
uops = get_opnames(ex)
|
||||
self.assertNotIn("_REPLACE_WITH_TRUE", uops)
|
||||
self.assertIn("_INSERT_1_LOAD_CONST_INLINE_BORROW", uops)
|
||||
self.assertEqual(count_ops(ex, "_POP_TOP_NOP"), 1)
|
||||
|
||||
def test_attr_promotion_failure(self):
|
||||
# We're not testing for any specific uops here, just
|
||||
|
|
|
|||
|
|
@ -5965,18 +5965,6 @@ dummy_func(
|
|||
value = PyStackRef_FromPyObjectBorrow(ptr);
|
||||
}
|
||||
|
||||
tier2 op(_LOAD_CONST_UNDER_INLINE, (ptr/4, old -- value, new)) {
|
||||
new = old;
|
||||
DEAD(old);
|
||||
value = PyStackRef_FromPyObjectNew(ptr);
|
||||
}
|
||||
|
||||
tier2 op(_LOAD_CONST_UNDER_INLINE_BORROW, (ptr/4, old -- value, new)) {
|
||||
new = old;
|
||||
DEAD(old);
|
||||
value = PyStackRef_FromPyObjectBorrow(ptr);
|
||||
}
|
||||
|
||||
tier2 op(_START_EXECUTOR, (executor/4 --)) {
|
||||
#ifndef _Py_JIT
|
||||
assert(current_executor == (_PyExecutorObject*)executor);
|
||||
|
|
|
|||
114
Python/executor_cases.c.h
generated
114
Python/executor_cases.c.h
generated
|
|
@ -21643,120 +21643,6 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _LOAD_CONST_UNDER_INLINE_r02: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef old;
|
||||
_PyStackRef value;
|
||||
_PyStackRef new;
|
||||
old = stack_pointer[-1];
|
||||
PyObject *ptr = (PyObject *)CURRENT_OPERAND0_64();
|
||||
new = old;
|
||||
value = PyStackRef_FromPyObjectNew(ptr);
|
||||
_tos_cache1 = new;
|
||||
_tos_cache0 = value;
|
||||
SET_CURRENT_CACHED_VALUES(2);
|
||||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_CONST_UNDER_INLINE_r12: {
|
||||
CHECK_CURRENT_CACHED_VALUES(1);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef old;
|
||||
_PyStackRef value;
|
||||
_PyStackRef new;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
old = _stack_item_0;
|
||||
PyObject *ptr = (PyObject *)CURRENT_OPERAND0_64();
|
||||
new = old;
|
||||
value = PyStackRef_FromPyObjectNew(ptr);
|
||||
_tos_cache1 = new;
|
||||
_tos_cache0 = value;
|
||||
SET_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_CONST_UNDER_INLINE_r23: {
|
||||
CHECK_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef old;
|
||||
_PyStackRef value;
|
||||
_PyStackRef new;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
old = _stack_item_1;
|
||||
PyObject *ptr = (PyObject *)CURRENT_OPERAND0_64();
|
||||
new = old;
|
||||
value = PyStackRef_FromPyObjectNew(ptr);
|
||||
_tos_cache2 = new;
|
||||
_tos_cache1 = value;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_CONST_UNDER_INLINE_BORROW_r02: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef old;
|
||||
_PyStackRef value;
|
||||
_PyStackRef new;
|
||||
old = stack_pointer[-1];
|
||||
PyObject *ptr = (PyObject *)CURRENT_OPERAND0_64();
|
||||
new = old;
|
||||
value = PyStackRef_FromPyObjectBorrow(ptr);
|
||||
_tos_cache1 = new;
|
||||
_tos_cache0 = value;
|
||||
SET_CURRENT_CACHED_VALUES(2);
|
||||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_CONST_UNDER_INLINE_BORROW_r12: {
|
||||
CHECK_CURRENT_CACHED_VALUES(1);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef old;
|
||||
_PyStackRef value;
|
||||
_PyStackRef new;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
old = _stack_item_0;
|
||||
PyObject *ptr = (PyObject *)CURRENT_OPERAND0_64();
|
||||
new = old;
|
||||
value = PyStackRef_FromPyObjectBorrow(ptr);
|
||||
_tos_cache1 = new;
|
||||
_tos_cache0 = value;
|
||||
SET_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_CONST_UNDER_INLINE_BORROW_r23: {
|
||||
CHECK_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef old;
|
||||
_PyStackRef value;
|
||||
_PyStackRef new;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
old = _stack_item_1;
|
||||
PyObject *ptr = (PyObject *)CURRENT_OPERAND0_64();
|
||||
new = old;
|
||||
value = PyStackRef_FromPyObjectBorrow(ptr);
|
||||
_tos_cache2 = new;
|
||||
_tos_cache1 = value;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _START_EXECUTOR_r00: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
|
|
|
|||
|
|
@ -611,8 +611,8 @@ const uint16_t op_without_push[MAX_UOP_ID + 1] = {
|
|||
[_COPY] = _NOP,
|
||||
[_LOAD_CONST_INLINE] = _NOP,
|
||||
[_LOAD_CONST_INLINE_BORROW] = _NOP,
|
||||
[_LOAD_CONST_UNDER_INLINE] = _POP_TOP_LOAD_CONST_INLINE,
|
||||
[_LOAD_CONST_UNDER_INLINE_BORROW] = _POP_TOP_LOAD_CONST_INLINE_BORROW,
|
||||
[_INSERT_1_LOAD_CONST_INLINE] = _POP_TOP_LOAD_CONST_INLINE,
|
||||
[_INSERT_1_LOAD_CONST_INLINE_BORROW] = _POP_TOP_LOAD_CONST_INLINE_BORROW,
|
||||
[_LOAD_FAST] = _NOP,
|
||||
[_LOAD_FAST_BORROW] = _NOP,
|
||||
[_LOAD_SMALL_INT] = _NOP,
|
||||
|
|
|
|||
|
|
@ -925,8 +925,8 @@ dummy_func(void) {
|
|||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
_LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
_LOAD_CONST_UNDER_INLINE);
|
||||
_INSERT_1_LOAD_CONST_INLINE_BORROW,
|
||||
_INSERT_1_LOAD_CONST_INLINE);
|
||||
self = owner;
|
||||
}
|
||||
|
||||
|
|
@ -935,8 +935,8 @@ dummy_func(void) {
|
|||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
_LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
_LOAD_CONST_UNDER_INLINE);
|
||||
_INSERT_1_LOAD_CONST_INLINE_BORROW,
|
||||
_INSERT_1_LOAD_CONST_INLINE);
|
||||
self = owner;
|
||||
}
|
||||
|
||||
|
|
@ -945,8 +945,8 @@ dummy_func(void) {
|
|||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
_LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
_LOAD_CONST_UNDER_INLINE);
|
||||
_INSERT_1_LOAD_CONST_INLINE_BORROW,
|
||||
_INSERT_1_LOAD_CONST_INLINE);
|
||||
self = owner;
|
||||
}
|
||||
|
||||
|
|
|
|||
38
Python/optimizer_cases.c.h
generated
38
Python/optimizer_cases.c.h
generated
|
|
@ -3413,8 +3413,8 @@
|
|||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
_LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
_LOAD_CONST_UNDER_INLINE);
|
||||
_INSERT_1_LOAD_CONST_INLINE_BORROW,
|
||||
_INSERT_1_LOAD_CONST_INLINE);
|
||||
self = owner;
|
||||
CHECK_STACK_BOUNDS(1);
|
||||
stack_pointer[-1] = attr;
|
||||
|
|
@ -3434,8 +3434,8 @@
|
|||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
_LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
_LOAD_CONST_UNDER_INLINE);
|
||||
_INSERT_1_LOAD_CONST_INLINE_BORROW,
|
||||
_INSERT_1_LOAD_CONST_INLINE);
|
||||
self = owner;
|
||||
CHECK_STACK_BOUNDS(1);
|
||||
stack_pointer[-1] = attr;
|
||||
|
|
@ -3489,8 +3489,8 @@
|
|||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 1);
|
||||
attr = lookup_attr(ctx, dependencies, this_instr, type, name,
|
||||
_LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
_LOAD_CONST_UNDER_INLINE);
|
||||
_INSERT_1_LOAD_CONST_INLINE_BORROW,
|
||||
_INSERT_1_LOAD_CONST_INLINE);
|
||||
self = owner;
|
||||
CHECK_STACK_BOUNDS(1);
|
||||
stack_pointer[-1] = attr;
|
||||
|
|
@ -5016,32 +5016,6 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _LOAD_CONST_UNDER_INLINE: {
|
||||
JitOptRef value;
|
||||
JitOptRef new;
|
||||
value = sym_new_not_null(ctx);
|
||||
new = sym_new_not_null(ctx);
|
||||
CHECK_STACK_BOUNDS(1);
|
||||
stack_pointer[-1] = value;
|
||||
stack_pointer[0] = new;
|
||||
stack_pointer += 1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_CONST_UNDER_INLINE_BORROW: {
|
||||
JitOptRef value;
|
||||
JitOptRef new;
|
||||
value = sym_new_not_null(ctx);
|
||||
new = sym_new_not_null(ctx);
|
||||
CHECK_STACK_BOUNDS(1);
|
||||
stack_pointer[-1] = value;
|
||||
stack_pointer[0] = new;
|
||||
stack_pointer += 1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
|
||||
case _START_EXECUTOR: {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue