Skip to content

Commit 6ad8076

Browse files
committed
move _PyLong_IsNonNegativeCompact into specialize
and just assert in the bytecodes
1 parent f7c0739 commit 6ad8076

File tree

4 files changed

+7
-27
lines changed

4 files changed

+7
-27
lines changed

Python/bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ dummy_func(
951951

952952
assert(PyLong_CheckExact(sub));
953953
assert(PyUnicode_CheckExact(str));
954-
DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub));
954+
assert(_PyLong_IsNonNegativeCompact((PyLongObject *)sub));
955955
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
956956
DEOPT_IF(PyUnicode_GET_LENGTH(str) <= index);
957957
uint8_t c = PyUnicode_1BYTE_DATA(str)[index];
@@ -973,7 +973,7 @@ dummy_func(
973973

974974
assert(PyLong_CheckExact(sub));
975975
assert(PyUnicode_CheckExact(str));
976-
DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub));
976+
assert(_PyLong_IsNonNegativeCompact((PyLongObject *)sub));
977977
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
978978
DEOPT_IF(PyUnicode_GET_LENGTH(str) <= index);
979979
// Specialize for reading an ASCII character from any string:

Python/executor_cases.c.h

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

Python/generated_cases.c.h

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

Python/specialize.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
22422242
specialize(instr, BINARY_OP_SUBSCR_TUPLE_INT);
22432243
return;
22442244
}
2245-
if (PyUnicode_CheckExact(lhs)) {
2245+
if (PyUnicode_CheckExact(lhs) && _PyLong_IsNonNegativeCompact((PyLongObject*)rhs)) {
22462246
if (PyUnicode_IS_COMPACT_ASCII(lhs)) {
22472247
specialize(instr, BINARY_OP_SUBSCR_STR_INT);
22482248
return;

0 commit comments

Comments
 (0)