Skip to content

Commit

Permalink
fix: insert cache entries for SUBSCR tier 2 instructions (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner authored Jun 3, 2023
1 parent f9c4484 commit cd81ce6
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 130 deletions.
44 changes: 23 additions & 21 deletions Include/internal/pycore_opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 75 additions & 75 deletions Include/opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ def pseudo_op(name, op, real_ops):
"BINARY_SUBSCR_GETITEM",
"BINARY_SUBSCR_LIST_INT",
"BINARY_SUBSCR_TUPLE_INT",

# Tier 2
"BINARY_SUBSCR_LIST_INT_REST",
],
"CALL": [
"CALL_PY_EXACT_ARGS",
Expand Down Expand Up @@ -371,6 +374,9 @@ def pseudo_op(name, op, real_ops):
"STORE_SUBSCR": [
"STORE_SUBSCR_DICT",
"STORE_SUBSCR_LIST_INT",

# Tier 2
"STORE_SUBSCR_LIST_INT_REST",
],
"UNPACK_SEQUENCE": [
"UNPACK_SEQUENCE_LIST",
Expand Down Expand Up @@ -495,9 +501,6 @@ def pseudo_op(name, op, real_ops):
'BINARY_OP_MULTIPLY_INT_REST',
'BINARY_OP_MULTIPLY_FLOAT_UNBOXED',

# Containers
'BINARY_SUBSCR_LIST_INT_REST',
'STORE_SUBSCR_LIST_INT_REST',

# Boxing / unboxing ops
'POP_TOP_NO_DECREF',
Expand Down
4 changes: 2 additions & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ dummy_func(
U_INST(BINARY_SUBSCR_LIST_INT_REST);
}

u_inst(BINARY_SUBSCR_LIST_INT_REST, (list, sub -- res)) {
u_inst(BINARY_SUBSCR_LIST_INT_REST, (unused/4, list, sub -- res)) {
Py_ssize_t index = ((PyLongObject *)sub)->long_value.ob_digit[0];
DEOPT_IF(index >= PyList_GET_SIZE(list), BINARY_SUBSCR);
STAT_INC(BINARY_SUBSCR, hit);
Expand Down Expand Up @@ -556,7 +556,7 @@ dummy_func(
U_INST(STORE_SUBSCR_LIST_INT_REST);
}

u_inst(STORE_SUBSCR_LIST_INT_REST, (value, list, sub -- )) {
u_inst(STORE_SUBSCR_LIST_INT_REST, (unused/1, value, list, sub -- )) {
Py_ssize_t index = ((PyLongObject *)sub)->long_value.ob_digit[0];
/* Ensure index < len(list) */
DEOPT_IF(index >= PyList_GET_SIZE(list), STORE_SUBSCR);
Expand Down
2 changes: 2 additions & 0 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cd81ce6

Please sign in to comment.