Skip to content

Commit a42b434

Browse files
Remove list optimizations to minimize PR
1 parent 7f90d0c commit a42b434

File tree

8 files changed

+222
-417
lines changed

8 files changed

+222
-417
lines changed

Include/internal/pycore_uop_ids.h

Lines changed: 220 additions & 222 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_capi/test_opt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,10 +1707,10 @@ def f(n):
17071707
self.assertIsNotNone(ex)
17081708
uops = get_opnames(ex)
17091709
self.assertEqual(uops.count("_GUARD_NOS_LIST"), 0)
1710-
self.assertEqual(uops.count("_STORE_SUBSCR_LIST_INT__NO_DECREF_INPUTS"), 1)
1710+
self.assertEqual(uops.count("_STORE_SUBSCR_LIST_INT"), 1)
17111711
self.assertEqual(uops.count("_GUARD_TOS_LIST"), 0)
17121712
self.assertEqual(uops.count("_UNPACK_SEQUENCE_LIST"), 1)
1713-
self.assertEqual(uops.count("_BINARY_OP_SUBSCR_LIST_INT__NO_DECREF_INPUTS"), 1)
1713+
self.assertEqual(uops.count("_BINARY_OP_SUBSCR_LIST_INT"), 1)
17141714
self.assertEqual(uops.count("_TO_BOOL_LIST"), 1)
17151715

17161716
def test_remove_guard_for_known_type_set(self):

Python/bytecodes.c

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -907,32 +907,6 @@ dummy_func(
907907
DECREF_INPUTS();
908908
}
909909

910-
op(_BINARY_OP_SUBSCR_LIST_INT__NO_DECREF_INPUTS, (list_st, sub_st -- res)) {
911-
PyObject *sub = PyStackRef_AsPyObjectBorrow(sub_st);
912-
PyObject *list = PyStackRef_AsPyObjectBorrow(list_st);
913-
914-
assert(PyLong_CheckExact(sub));
915-
assert(PyList_CheckExact(list));
916-
917-
// Deopt unless 0 <= sub < PyList_Size(list)
918-
DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub));
919-
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
920-
#ifdef Py_GIL_DISABLED
921-
PyObject *res_o = _PyList_GetItemRef((PyListObject*)list, index);
922-
DEOPT_IF(res_o == NULL);
923-
STAT_INC(BINARY_OP, hit);
924-
res = PyStackRef_FromPyObjectSteal(res_o);
925-
#else
926-
DEOPT_IF(index >= PyList_GET_SIZE(list));
927-
STAT_INC(BINARY_OP, hit);
928-
PyObject *res_o = PyList_GET_ITEM(list, index);
929-
assert(res_o != NULL);
930-
res = PyStackRef_FromPyObjectNew(res_o);
931-
#endif
932-
STAT_INC(BINARY_OP, hit);
933-
INPUTS_DEAD();
934-
}
935-
936910
macro(BINARY_OP_SUBSCR_LIST_SLICE) =
937911
_GUARD_TOS_SLICE + _GUARD_NOS_LIST + unused/5 + _BINARY_OP_SUBSCR_LIST_SLICE;
938912

@@ -1135,34 +1109,6 @@ dummy_func(
11351109
Py_DECREF(old_value);
11361110
}
11371111

1138-
op(_STORE_SUBSCR_LIST_INT__NO_DECREF_INPUTS, (value, list_st, sub_st -- )) {
1139-
PyObject *sub = PyStackRef_AsPyObjectBorrow(sub_st);
1140-
PyObject *list = PyStackRef_AsPyObjectBorrow(list_st);
1141-
1142-
assert(PyLong_CheckExact(sub));
1143-
assert(PyList_CheckExact(list));
1144-
1145-
// Ensure nonnegative, zero-or-one-digit ints.
1146-
DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub));
1147-
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
1148-
DEOPT_IF(!LOCK_OBJECT(list));
1149-
// Ensure index < len(list)
1150-
if (index >= PyList_GET_SIZE(list)) {
1151-
UNLOCK_OBJECT(list);
1152-
DEOPT_IF(true);
1153-
}
1154-
STAT_INC(STORE_SUBSCR, hit);
1155-
1156-
PyObject *old_value = PyList_GET_ITEM(list, index);
1157-
FT_ATOMIC_STORE_PTR_RELEASE(_PyList_ITEMS(list)[index],
1158-
PyStackRef_AsPyObjectSteal(value));
1159-
assert(old_value != NULL);
1160-
UNLOCK_OBJECT(list); // unlock before decrefs!
1161-
DEAD(sub_st);
1162-
DEAD(list_st);
1163-
Py_DECREF(old_value);
1164-
}
1165-
11661112
macro(STORE_SUBSCR_DICT) =
11671113
_GUARD_NOS_DICT + unused/1 + _STORE_SUBSCR_DICT;
11681114

Python/executor_cases.c.h

Lines changed: 0 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_analysis.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,6 @@ const uint16_t op_without_decref_inputs[MAX_UOP_ID + 1] = {
448448
[_BINARY_OP_MULTIPLY_FLOAT] = _BINARY_OP_MULTIPLY_FLOAT__NO_DECREF_INPUTS,
449449
[_BINARY_OP_ADD_FLOAT] = _BINARY_OP_ADD_FLOAT__NO_DECREF_INPUTS,
450450
[_BINARY_OP_SUBTRACT_FLOAT] = _BINARY_OP_SUBTRACT_FLOAT__NO_DECREF_INPUTS,
451-
[_STORE_SUBSCR_LIST_INT] = _STORE_SUBSCR_LIST_INT__NO_DECREF_INPUTS,
452-
[_BINARY_OP_SUBSCR_LIST_INT] = _BINARY_OP_SUBSCR_LIST_INT__NO_DECREF_INPUTS,
453451
};
454452

455453
/* 1 for success, 0 for not ready, cannot error at the moment. */

Python/optimizer_bytecodes.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,6 @@ dummy_func(void) {
104104
GETLOCAL(oparg) = value;
105105
}
106106

107-
op(_STORE_SUBSCR_LIST_INT, (value, list_st, sub_st -- )) {
108-
// Can't move this to the optimizer generator for now, as it requires list_st and sub_st
109-
// to be borrowed, but not value.
110-
// Alternatively, we could just stricten it and require all to be borrowed.
111-
if (sym_is_skip_refcount(ctx, list_st) && sym_is_skip_refcount(ctx, sub_st)) {
112-
REPLACE_OP(this_instr, op_without_decref_inputs[opcode], oparg, 0);
113-
}
114-
}
115-
116107
op(_PUSH_NULL, (-- res)) {
117108
res = sym_new_null(ctx);
118109
}
@@ -403,14 +394,6 @@ dummy_func(void) {
403394
ctx->done = true;
404395
}
405396

406-
op(_BINARY_OP_SUBSCR_LIST_INT, (list_st, sub_st -- res)) {
407-
// TODO (gh-134584): Move this to the optimizer generator.
408-
if (sym_is_skip_refcount(ctx, list_st) && sym_is_skip_refcount(ctx, sub_st)) {
409-
REPLACE_OP(this_instr, op_without_decref_inputs[opcode], oparg, 0);
410-
}
411-
res = sym_new_not_null(ctx);
412-
}
413-
414397
op(_BINARY_OP_SUBSCR_STR_INT, (str_st, sub_st -- res)) {
415398
res = sym_new_type(ctx, &PyUnicode_Type);
416399
}

Python/optimizer_cases.c.h

Lines changed: 0 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)