summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2023-08-08 20:42:43 (GMT)
committerGitHub <noreply@github.com>2023-08-08 20:42:43 (GMT)
commitea72c6fe3b6db5f4e8ce3d3405c0ea65dc002faf (patch)
tree97e185191d3f852d6533f5db5af5f32d7cc3d5f6 /Include
parentaab6f7173a3b825599629dd6fa5cb7e477421595 (diff)
downloadcpython-ea72c6fe3b6db5f4e8ce3d3405c0ea65dc002faf.zip
cpython-ea72c6fe3b6db5f4e8ce3d3405c0ea65dc002faf.tar.gz
cpython-ea72c6fe3b6db5f4e8ce3d3405c0ea65dc002faf.tar.bz2
GH-107596: Specialize str[int] (GH-107597)
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_opcode.h36
-rw-r--r--Include/internal/pycore_opcode_metadata.h6
-rw-r--r--Include/opcode.h103
3 files changed, 76 insertions, 69 deletions
diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h
index aff09a2..a187da6 100644
--- a/Include/internal/pycore_opcode.h
+++ b/Include/internal/pycore_opcode.h
@@ -52,6 +52,7 @@ const uint8_t _PyOpcode_Deopt[256] = {
[BINARY_SUBSCR_DICT] = BINARY_SUBSCR,
[BINARY_SUBSCR_GETITEM] = BINARY_SUBSCR,
[BINARY_SUBSCR_LIST_INT] = BINARY_SUBSCR,
+ [BINARY_SUBSCR_STR_INT] = BINARY_SUBSCR,
[BINARY_SUBSCR_TUPLE_INT] = BINARY_SUBSCR,
[BUILD_CONST_KEY_MAP] = BUILD_CONST_KEY_MAP,
[BUILD_LIST] = BUILD_LIST,
@@ -292,12 +293,12 @@ const char *const _PyOpcode_OpName[268] = {
[FORMAT_SIMPLE] = "FORMAT_SIMPLE",
[FORMAT_WITH_SPEC] = "FORMAT_WITH_SPEC",
[BINARY_SUBSCR_LIST_INT] = "BINARY_SUBSCR_LIST_INT",
+ [BINARY_SUBSCR_STR_INT] = "BINARY_SUBSCR_STR_INT",
[BINARY_SUBSCR_TUPLE_INT] = "BINARY_SUBSCR_TUPLE_INT",
[STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT",
[STORE_SUBSCR_LIST_INT] = "STORE_SUBSCR_LIST_INT",
[SEND_GEN] = "SEND_GEN",
[UNPACK_SEQUENCE_TWO_TUPLE] = "UNPACK_SEQUENCE_TWO_TUPLE",
- [UNPACK_SEQUENCE_TUPLE] = "UNPACK_SEQUENCE_TUPLE",
[WITH_EXCEPT_START] = "WITH_EXCEPT_START",
[GET_AITER] = "GET_AITER",
[GET_ANEXT] = "GET_ANEXT",
@@ -305,39 +306,39 @@ const char *const _PyOpcode_OpName[268] = {
[BEFORE_WITH] = "BEFORE_WITH",
[END_ASYNC_FOR] = "END_ASYNC_FOR",
[CLEANUP_THROW] = "CLEANUP_THROW",
+ [UNPACK_SEQUENCE_TUPLE] = "UNPACK_SEQUENCE_TUPLE",
[UNPACK_SEQUENCE_LIST] = "UNPACK_SEQUENCE_LIST",
[STORE_ATTR_INSTANCE_VALUE] = "STORE_ATTR_INSTANCE_VALUE",
[STORE_ATTR_SLOT] = "STORE_ATTR_SLOT",
- [STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT",
[STORE_SUBSCR] = "STORE_SUBSCR",
[DELETE_SUBSCR] = "DELETE_SUBSCR",
+ [STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT",
[LOAD_GLOBAL_MODULE] = "LOAD_GLOBAL_MODULE",
[LOAD_GLOBAL_BUILTIN] = "LOAD_GLOBAL_BUILTIN",
[LOAD_SUPER_ATTR_ATTR] = "LOAD_SUPER_ATTR_ATTR",
[LOAD_SUPER_ATTR_METHOD] = "LOAD_SUPER_ATTR_METHOD",
[LOAD_ATTR_INSTANCE_VALUE] = "LOAD_ATTR_INSTANCE_VALUE",
- [LOAD_ATTR_MODULE] = "LOAD_ATTR_MODULE",
[GET_ITER] = "GET_ITER",
[GET_YIELD_FROM_ITER] = "GET_YIELD_FROM_ITER",
- [LOAD_ATTR_WITH_HINT] = "LOAD_ATTR_WITH_HINT",
+ [LOAD_ATTR_MODULE] = "LOAD_ATTR_MODULE",
[LOAD_BUILD_CLASS] = "LOAD_BUILD_CLASS",
+ [LOAD_ATTR_WITH_HINT] = "LOAD_ATTR_WITH_HINT",
[LOAD_ATTR_SLOT] = "LOAD_ATTR_SLOT",
- [LOAD_ATTR_CLASS] = "LOAD_ATTR_CLASS",
[LOAD_ASSERTION_ERROR] = "LOAD_ASSERTION_ERROR",
[RETURN_GENERATOR] = "RETURN_GENERATOR",
+ [LOAD_ATTR_CLASS] = "LOAD_ATTR_CLASS",
[LOAD_ATTR_PROPERTY] = "LOAD_ATTR_PROPERTY",
[LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN] = "LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN",
[LOAD_ATTR_METHOD_WITH_VALUES] = "LOAD_ATTR_METHOD_WITH_VALUES",
[LOAD_ATTR_METHOD_NO_DICT] = "LOAD_ATTR_METHOD_NO_DICT",
[LOAD_ATTR_METHOD_LAZY_DICT] = "LOAD_ATTR_METHOD_LAZY_DICT",
[LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES] = "LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES",
- [LOAD_ATTR_NONDESCRIPTOR_NO_DICT] = "LOAD_ATTR_NONDESCRIPTOR_NO_DICT",
[RETURN_VALUE] = "RETURN_VALUE",
- [COMPARE_OP_FLOAT] = "COMPARE_OP_FLOAT",
+ [LOAD_ATTR_NONDESCRIPTOR_NO_DICT] = "LOAD_ATTR_NONDESCRIPTOR_NO_DICT",
[SETUP_ANNOTATIONS] = "SETUP_ANNOTATIONS",
- [COMPARE_OP_INT] = "COMPARE_OP_INT",
+ [COMPARE_OP_FLOAT] = "COMPARE_OP_FLOAT",
[LOAD_LOCALS] = "LOAD_LOCALS",
- [COMPARE_OP_STR] = "COMPARE_OP_STR",
+ [COMPARE_OP_INT] = "COMPARE_OP_INT",
[POP_EXCEPT] = "POP_EXCEPT",
[STORE_NAME] = "STORE_NAME",
[DELETE_NAME] = "DELETE_NAME",
@@ -360,9 +361,9 @@ const char *const _PyOpcode_OpName[268] = {
[IMPORT_NAME] = "IMPORT_NAME",
[IMPORT_FROM] = "IMPORT_FROM",
[JUMP_FORWARD] = "JUMP_FORWARD",
+ [COMPARE_OP_STR] = "COMPARE_OP_STR",
[FOR_ITER_LIST] = "FOR_ITER_LIST",
[FOR_ITER_TUPLE] = "FOR_ITER_TUPLE",
- [FOR_ITER_RANGE] = "FOR_ITER_RANGE",
[POP_JUMP_IF_FALSE] = "POP_JUMP_IF_FALSE",
[POP_JUMP_IF_TRUE] = "POP_JUMP_IF_TRUE",
[LOAD_GLOBAL] = "LOAD_GLOBAL",
@@ -381,11 +382,11 @@ const char *const _PyOpcode_OpName[268] = {
[POP_JUMP_IF_NONE] = "POP_JUMP_IF_NONE",
[RAISE_VARARGS] = "RAISE_VARARGS",
[GET_AWAITABLE] = "GET_AWAITABLE",
- [FOR_ITER_GEN] = "FOR_ITER_GEN",
+ [FOR_ITER_RANGE] = "FOR_ITER_RANGE",
[BUILD_SLICE] = "BUILD_SLICE",
[JUMP_BACKWARD_NO_INTERRUPT] = "JUMP_BACKWARD_NO_INTERRUPT",
[MAKE_CELL] = "MAKE_CELL",
- [CALL_BOUND_METHOD_EXACT_ARGS] = "CALL_BOUND_METHOD_EXACT_ARGS",
+ [FOR_ITER_GEN] = "FOR_ITER_GEN",
[LOAD_DEREF] = "LOAD_DEREF",
[STORE_DEREF] = "STORE_DEREF",
[DELETE_DEREF] = "DELETE_DEREF",
@@ -397,26 +398,26 @@ const char *const _PyOpcode_OpName[268] = {
[LIST_APPEND] = "LIST_APPEND",
[SET_ADD] = "SET_ADD",
[MAP_ADD] = "MAP_ADD",
- [CALL_PY_EXACT_ARGS] = "CALL_PY_EXACT_ARGS",
+ [CALL_BOUND_METHOD_EXACT_ARGS] = "CALL_BOUND_METHOD_EXACT_ARGS",
[COPY_FREE_VARS] = "COPY_FREE_VARS",
[YIELD_VALUE] = "YIELD_VALUE",
[RESUME] = "RESUME",
[MATCH_CLASS] = "MATCH_CLASS",
+ [CALL_PY_EXACT_ARGS] = "CALL_PY_EXACT_ARGS",
[CALL_PY_WITH_DEFAULTS] = "CALL_PY_WITH_DEFAULTS",
[CALL_NO_KW_TYPE_1] = "CALL_NO_KW_TYPE_1",
- [CALL_NO_KW_STR_1] = "CALL_NO_KW_STR_1",
[BUILD_CONST_KEY_MAP] = "BUILD_CONST_KEY_MAP",
[BUILD_STRING] = "BUILD_STRING",
[CONVERT_VALUE] = "CONVERT_VALUE",
+ [CALL_NO_KW_STR_1] = "CALL_NO_KW_STR_1",
[CALL_NO_KW_TUPLE_1] = "CALL_NO_KW_TUPLE_1",
[CALL_BUILTIN_CLASS] = "CALL_BUILTIN_CLASS",
- [CALL_NO_KW_BUILTIN_O] = "CALL_NO_KW_BUILTIN_O",
[LIST_EXTEND] = "LIST_EXTEND",
[SET_UPDATE] = "SET_UPDATE",
[DICT_MERGE] = "DICT_MERGE",
[DICT_UPDATE] = "DICT_UPDATE",
+ [CALL_NO_KW_BUILTIN_O] = "CALL_NO_KW_BUILTIN_O",
[CALL_NO_KW_BUILTIN_FAST] = "CALL_NO_KW_BUILTIN_FAST",
- [CALL_BUILTIN_FAST_WITH_KEYWORDS] = "CALL_BUILTIN_FAST_WITH_KEYWORDS",
[LOAD_FAST_LOAD_FAST] = "LOAD_FAST_LOAD_FAST",
[STORE_FAST_LOAD_FAST] = "STORE_FAST_LOAD_FAST",
[STORE_FAST_STORE_FAST] = "STORE_FAST_STORE_FAST",
@@ -427,6 +428,7 @@ const char *const _PyOpcode_OpName[268] = {
[LOAD_FROM_DICT_OR_GLOBALS] = "LOAD_FROM_DICT_OR_GLOBALS",
[LOAD_FROM_DICT_OR_DEREF] = "LOAD_FROM_DICT_OR_DEREF",
[SET_FUNCTION_ATTRIBUTE] = "SET_FUNCTION_ATTRIBUTE",
+ [CALL_BUILTIN_FAST_WITH_KEYWORDS] = "CALL_BUILTIN_FAST_WITH_KEYWORDS",
[CALL_NO_KW_LEN] = "CALL_NO_KW_LEN",
[CALL_NO_KW_ISINSTANCE] = "CALL_NO_KW_ISINSTANCE",
[CALL_NO_KW_LIST_APPEND] = "CALL_NO_KW_LIST_APPEND",
@@ -435,7 +437,6 @@ const char *const _PyOpcode_OpName[268] = {
[CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = "CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS",
[CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = "CALL_NO_KW_METHOD_DESCRIPTOR_FAST",
[CALL_NO_KW_ALLOC_AND_ENTER_INIT] = "CALL_NO_KW_ALLOC_AND_ENTER_INIT",
- [186] = "<186>",
[187] = "<187>",
[188] = "<188>",
[189] = "<189>",
@@ -521,7 +522,6 @@ const char *const _PyOpcode_OpName[268] = {
#endif // NEED_OPCODE_TABLES
#define EXTRA_CASES \
- case 186: \
case 187: \
case 188: \
case 189: \
diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h
index 1cab6c9..02303c4 100644
--- a/Include/internal/pycore_opcode_metadata.h
+++ b/Include/internal/pycore_opcode_metadata.h
@@ -144,6 +144,8 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
return 4;
case BINARY_SUBSCR_LIST_INT:
return 2;
+ case BINARY_SUBSCR_STR_INT:
+ return 2;
case BINARY_SUBSCR_TUPLE_INT:
return 2;
case BINARY_SUBSCR_DICT:
@@ -588,6 +590,8 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
return 0;
case BINARY_SUBSCR_LIST_INT:
return 1;
+ case BINARY_SUBSCR_STR_INT:
+ return 1;
case BINARY_SUBSCR_TUPLE_INT:
return 1;
case BINARY_SUBSCR_DICT:
@@ -1047,6 +1051,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[OPCODE_METADATA_SIZE] = {
[BINARY_SLICE] = { true, INSTR_FMT_IX, 0 },
[STORE_SLICE] = { true, INSTR_FMT_IX, 0 },
[BINARY_SUBSCR_LIST_INT] = { true, INSTR_FMT_IXC, 0 },
+ [BINARY_SUBSCR_STR_INT] = { true, INSTR_FMT_IXC, 0 },
[BINARY_SUBSCR_TUPLE_INT] = { true, INSTR_FMT_IXC, 0 },
[BINARY_SUBSCR_DICT] = { true, INSTR_FMT_IXC, 0 },
[BINARY_SUBSCR_GETITEM] = { true, INSTR_FMT_IXC, 0 },
@@ -1258,6 +1263,7 @@ const struct opcode_macro_expansion _PyOpcode_macro_expansion[OPCODE_MACRO_EXPAN
[BINARY_SLICE] = { .nuops = 1, .uops = { { BINARY_SLICE, 0, 0 } } },
[STORE_SLICE] = { .nuops = 1, .uops = { { STORE_SLICE, 0, 0 } } },
[BINARY_SUBSCR_LIST_INT] = { .nuops = 1, .uops = { { BINARY_SUBSCR_LIST_INT, 0, 0 } } },
+ [BINARY_SUBSCR_STR_INT] = { .nuops = 1, .uops = { { BINARY_SUBSCR_STR_INT, 0, 0 } } },
[BINARY_SUBSCR_TUPLE_INT] = { .nuops = 1, .uops = { { BINARY_SUBSCR_TUPLE_INT, 0, 0 } } },
[BINARY_SUBSCR_DICT] = { .nuops = 1, .uops = { { BINARY_SUBSCR_DICT, 0, 0 } } },
[LIST_APPEND] = { .nuops = 1, .uops = { { LIST_APPEND, 0, 0 } } },
diff --git a/Include/opcode.h b/Include/opcode.h
index ede1518..b3d6cba 100644
--- a/Include/opcode.h
+++ b/Include/opcode.h
@@ -175,57 +175,58 @@ extern "C" {
#define BINARY_SUBSCR_DICT 38
#define BINARY_SUBSCR_GETITEM 39
#define BINARY_SUBSCR_LIST_INT 42
-#define BINARY_SUBSCR_TUPLE_INT 43
-#define STORE_SUBSCR_DICT 44
-#define STORE_SUBSCR_LIST_INT 45
-#define SEND_GEN 46
-#define UNPACK_SEQUENCE_TWO_TUPLE 47
-#define UNPACK_SEQUENCE_TUPLE 48
-#define UNPACK_SEQUENCE_LIST 56
-#define STORE_ATTR_INSTANCE_VALUE 57
-#define STORE_ATTR_SLOT 58
-#define STORE_ATTR_WITH_HINT 59
-#define LOAD_GLOBAL_MODULE 62
-#define LOAD_GLOBAL_BUILTIN 63
-#define LOAD_SUPER_ATTR_ATTR 64
-#define LOAD_SUPER_ATTR_METHOD 65
-#define LOAD_ATTR_INSTANCE_VALUE 66
-#define LOAD_ATTR_MODULE 67
-#define LOAD_ATTR_WITH_HINT 70
-#define LOAD_ATTR_SLOT 72
-#define LOAD_ATTR_CLASS 73
-#define LOAD_ATTR_PROPERTY 76
-#define LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN 77
-#define LOAD_ATTR_METHOD_WITH_VALUES 78
-#define LOAD_ATTR_METHOD_NO_DICT 79
-#define LOAD_ATTR_METHOD_LAZY_DICT 80
-#define LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES 81
-#define LOAD_ATTR_NONDESCRIPTOR_NO_DICT 82
-#define COMPARE_OP_FLOAT 84
-#define COMPARE_OP_INT 86
-#define COMPARE_OP_STR 88
-#define FOR_ITER_LIST 111
-#define FOR_ITER_TUPLE 112
-#define FOR_ITER_RANGE 113
-#define FOR_ITER_GEN 132
-#define CALL_BOUND_METHOD_EXACT_ARGS 136
-#define CALL_PY_EXACT_ARGS 148
-#define CALL_PY_WITH_DEFAULTS 153
-#define CALL_NO_KW_TYPE_1 154
-#define CALL_NO_KW_STR_1 155
-#define CALL_NO_KW_TUPLE_1 159
-#define CALL_BUILTIN_CLASS 160
-#define CALL_NO_KW_BUILTIN_O 161
-#define CALL_NO_KW_BUILTIN_FAST 166
-#define CALL_BUILTIN_FAST_WITH_KEYWORDS 167
-#define CALL_NO_KW_LEN 178
-#define CALL_NO_KW_ISINSTANCE 179
-#define CALL_NO_KW_LIST_APPEND 180
-#define CALL_NO_KW_METHOD_DESCRIPTOR_O 181
-#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 182
-#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 183
-#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 184
-#define CALL_NO_KW_ALLOC_AND_ENTER_INIT 185
+#define BINARY_SUBSCR_STR_INT 43
+#define BINARY_SUBSCR_TUPLE_INT 44
+#define STORE_SUBSCR_DICT 45
+#define STORE_SUBSCR_LIST_INT 46
+#define SEND_GEN 47
+#define UNPACK_SEQUENCE_TWO_TUPLE 48
+#define UNPACK_SEQUENCE_TUPLE 56
+#define UNPACK_SEQUENCE_LIST 57
+#define STORE_ATTR_INSTANCE_VALUE 58
+#define STORE_ATTR_SLOT 59
+#define STORE_ATTR_WITH_HINT 62
+#define LOAD_GLOBAL_MODULE 63
+#define LOAD_GLOBAL_BUILTIN 64
+#define LOAD_SUPER_ATTR_ATTR 65
+#define LOAD_SUPER_ATTR_METHOD 66
+#define LOAD_ATTR_INSTANCE_VALUE 67
+#define LOAD_ATTR_MODULE 70
+#define LOAD_ATTR_WITH_HINT 72
+#define LOAD_ATTR_SLOT 73
+#define LOAD_ATTR_CLASS 76
+#define LOAD_ATTR_PROPERTY 77
+#define LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN 78
+#define LOAD_ATTR_METHOD_WITH_VALUES 79
+#define LOAD_ATTR_METHOD_NO_DICT 80
+#define LOAD_ATTR_METHOD_LAZY_DICT 81
+#define LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES 82
+#define LOAD_ATTR_NONDESCRIPTOR_NO_DICT 84
+#define COMPARE_OP_FLOAT 86
+#define COMPARE_OP_INT 88
+#define COMPARE_OP_STR 111
+#define FOR_ITER_LIST 112
+#define FOR_ITER_TUPLE 113
+#define FOR_ITER_RANGE 132
+#define FOR_ITER_GEN 136
+#define CALL_BOUND_METHOD_EXACT_ARGS 148
+#define CALL_PY_EXACT_ARGS 153
+#define CALL_PY_WITH_DEFAULTS 154
+#define CALL_NO_KW_TYPE_1 155
+#define CALL_NO_KW_STR_1 159
+#define CALL_NO_KW_TUPLE_1 160
+#define CALL_BUILTIN_CLASS 161
+#define CALL_NO_KW_BUILTIN_O 166
+#define CALL_NO_KW_BUILTIN_FAST 167
+#define CALL_BUILTIN_FAST_WITH_KEYWORDS 178
+#define CALL_NO_KW_LEN 179
+#define CALL_NO_KW_ISINSTANCE 180
+#define CALL_NO_KW_LIST_APPEND 181
+#define CALL_NO_KW_METHOD_DESCRIPTOR_O 182
+#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 183
+#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 184
+#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 185
+#define CALL_NO_KW_ALLOC_AND_ENTER_INIT 186
#define NB_ADD 0
#define NB_AND 1