From fed90e844cbdc2939e680ac323a4d85ce819ac13 Mon Sep 17 00:00:00 2001 From: thatbirdguythatuknownot Date: Sat, 2 Sep 2023 19:46:13 +0800 Subject: [PATCH] LIST_TO_TUPLE exist??? --- Include/internal/pycore_opcode.h | 6 ++--- Include/internal/pycore_opcode_metadata.h | 6 ----- Include/opcode_ids.h | 27 +++++++++++------------ Lib/opcode.py | 2 -- Python/bytecodes.c | 6 ----- Python/compile.c | 2 +- Python/executor_cases.c.h | 11 --------- Python/generated_cases.c.h | 11 --------- Python/opcode_targets.h | 4 ++-- 9 files changed, 19 insertions(+), 56 deletions(-) diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h index dfe261e..1ff284e 100644 --- a/Include/internal/pycore_opcode.h +++ b/Include/internal/pycore_opcode.h @@ -151,7 +151,6 @@ const uint8_t _PyOpcode_Deopt[256] = { [KW_NAMES] = KW_NAMES, [LIST_APPEND] = LIST_APPEND, [LIST_EXTEND] = LIST_EXTEND, - [LIST_TO_TUPLE] = LIST_TO_TUPLE, [LOAD_ASSERTION_ERROR] = LOAD_ASSERTION_ERROR, [LOAD_ATTR] = LOAD_ATTR, [LOAD_ATTR_CLASS] = LOAD_ATTR, @@ -419,8 +418,8 @@ const char *const _PyOpcode_OpName[270] = { [SET_UPDATE] = "SET_UPDATE", [DICT_MERGE] = "DICT_MERGE", [DICT_UPDATE] = "DICT_UPDATE", - [LIST_TO_TUPLE] = "LIST_TO_TUPLE", [CALL_NO_KW_TUPLE_1] = "CALL_NO_KW_TUPLE_1", + [CALL_BUILTIN_CLASS] = "CALL_BUILTIN_CLASS", [LOAD_FAST_LOAD_FAST] = "LOAD_FAST_LOAD_FAST", [STORE_FAST_LOAD_FAST] = "STORE_FAST_LOAD_FAST", [STORE_FAST_STORE_FAST] = "STORE_FAST_STORE_FAST", @@ -431,7 +430,6 @@ const char *const _PyOpcode_OpName[270] = { [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_CLASS] = "CALL_BUILTIN_CLASS", [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", @@ -443,6 +441,7 @@ const char *const _PyOpcode_OpName[270] = { [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", + [189] = "<189>", [190] = "<190>", [191] = "<191>", [192] = "<192>", @@ -527,6 +526,7 @@ const char *const _PyOpcode_OpName[270] = { #endif // NEED_OPCODE_TABLES #define EXTRA_CASES \ + case 189: \ case 190: \ case 191: \ case 192: \ diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h index 6274a17..7bfff8f 100644 --- a/Include/internal/pycore_opcode_metadata.h +++ b/Include/internal/pycore_opcode_metadata.h @@ -158,8 +158,6 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return (oparg-1) + 2; case SET_ADD: return (oparg-1) + 2; - case LIST_TO_TUPLE: - return 1; case STORE_SUBSCR: return 3; case STORE_SUBSCR_LIST_INT: @@ -614,8 +612,6 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return (oparg-1) + 1; case SET_ADD: return (oparg-1) + 1; - case LIST_TO_TUPLE: - return 1; case STORE_SUBSCR: return 0; case STORE_SUBSCR_LIST_INT: @@ -1079,7 +1075,6 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[OPCODE_METADATA_SIZE] = { [BINARY_SUBSCR_GETITEM] = { true, INSTR_FMT_IXC, 0 }, [LIST_APPEND] = { true, INSTR_FMT_IB, HAS_ARG_FLAG }, [SET_ADD] = { true, INSTR_FMT_IB, HAS_ARG_FLAG }, - [LIST_TO_TUPLE] = { true, INSTR_FMT_IX, 0 }, [STORE_SUBSCR] = { true, INSTR_FMT_IXC, 0 }, [STORE_SUBSCR_LIST_INT] = { true, INSTR_FMT_IXC, 0 }, [STORE_SUBSCR_DICT] = { true, INSTR_FMT_IXC, 0 }, @@ -1295,7 +1290,6 @@ const struct opcode_macro_expansion _PyOpcode_macro_expansion[OPCODE_MACRO_EXPAN [BINARY_SUBSCR_DICT] = { .nuops = 1, .uops = { { BINARY_SUBSCR_DICT, 0, 0 } } }, [LIST_APPEND] = { .nuops = 1, .uops = { { LIST_APPEND, 0, 0 } } }, [SET_ADD] = { .nuops = 1, .uops = { { SET_ADD, 0, 0 } } }, - [LIST_TO_TUPLE] = { .nuops = 1, .uops = { { LIST_TO_TUPLE, 0, 0 } } }, [STORE_SUBSCR] = { .nuops = 1, .uops = { { STORE_SUBSCR, 0, 0 } } }, [STORE_SUBSCR_LIST_INT] = { .nuops = 1, .uops = { { STORE_SUBSCR_LIST_INT, 0, 0 } } }, [STORE_SUBSCR_DICT] = { .nuops = 1, .uops = { { STORE_SUBSCR_DICT, 0, 0 } } }, diff --git a/Include/opcode_ids.h b/Include/opcode_ids.h index f440a49..a3e3c43 100644 --- a/Include/opcode_ids.h +++ b/Include/opcode_ids.h @@ -118,7 +118,6 @@ extern "C" { #define SET_UPDATE 163 #define DICT_MERGE 164 #define DICT_UPDATE 165 -#define LIST_TO_TUPLE 166 #define LOAD_FAST_LOAD_FAST 168 #define STORE_FAST_LOAD_FAST 169 #define STORE_FAST_STORE_FAST 170 @@ -219,19 +218,19 @@ extern "C" { #define CALL_PY_WITH_DEFAULTS 155 #define CALL_NO_KW_TYPE_1 160 #define CALL_NO_KW_STR_1 161 -#define CALL_NO_KW_TUPLE_1 167 -#define CALL_BUILTIN_CLASS 178 -#define CALL_NO_KW_BUILTIN_O 179 -#define CALL_NO_KW_BUILTIN_FAST 180 -#define CALL_BUILTIN_FAST_WITH_KEYWORDS 181 -#define CALL_NO_KW_LEN 182 -#define CALL_NO_KW_ISINSTANCE 183 -#define CALL_NO_KW_LIST_APPEND 184 -#define CALL_NO_KW_METHOD_DESCRIPTOR_O 185 -#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 186 -#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 187 -#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 188 -#define CALL_NO_KW_ALLOC_AND_ENTER_INIT 189 +#define CALL_NO_KW_TUPLE_1 166 +#define CALL_BUILTIN_CLASS 167 +#define CALL_NO_KW_BUILTIN_O 178 +#define CALL_NO_KW_BUILTIN_FAST 179 +#define CALL_BUILTIN_FAST_WITH_KEYWORDS 180 +#define CALL_NO_KW_LEN 181 +#define CALL_NO_KW_ISINSTANCE 182 +#define CALL_NO_KW_LIST_APPEND 183 +#define CALL_NO_KW_METHOD_DESCRIPTOR_O 184 +#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 185 +#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 186 +#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 187 +#define CALL_NO_KW_ALLOC_AND_ENTER_INIT 188 #ifdef __cplusplus diff --git a/Lib/opcode.py b/Lib/opcode.py index 5989cd9..b50366f 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -166,8 +166,6 @@ def def_op(name, op): def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) -def_op('LIST_TO_TUPLE', 166) - def_op('LOAD_FAST_LOAD_FAST', 168) def_op('STORE_FAST_LOAD_FAST', 169) def_op('STORE_FAST_STORE_FAST', 170) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 96c0306..16923ba 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -656,12 +656,6 @@ dummy_func( ERROR_IF(err, error); } - inst(LIST_TO_TUPLE, (list -- res)) { - res = _PyTuple_FromArray(_PyList_ITEMS(list), PyList_GET_SIZE(list)); - DECREF_INPUTS(); - ERROR_IF(res == NULL, error); - } - family(STORE_SUBSCR, INLINE_CACHE_ENTRIES_STORE_SUBSCR) = { STORE_SUBSCR_DICT, STORE_SUBSCR_LIST_INT, diff --git a/Python/compile.c b/Python/compile.c index 2158c74..5ae58f0 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5885,7 +5885,7 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type, if (type != COMP_GENEXP) { if (type == COMP_TUPLECOMP) { - ADDOP(c, LOC(e), LIST_TO_TUPLE); + ADDOP_I(c, LOC(e), CALL_INTRINSIC_1, INTRINSIC_LIST_TO_TUPLE); } ADDOP(c, LOC(e), RETURN_VALUE); } diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index bb9cea7..7611a11 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -556,17 +556,6 @@ break; } - case LIST_TO_TUPLE: { - PyObject *list; - PyObject *res; - list = stack_pointer[-1]; - res = _PyTuple_FromArray(_PyList_ITEMS(list), PyList_GET_SIZE(list)); - Py_DECREF(list); - if (res == NULL) goto pop_1_error; - stack_pointer[-1] = res; - break; - } - case STORE_SUBSCR: { static_assert(INLINE_CACHE_ENTRIES_STORE_SUBSCR == 1, "incorrect cache size"); PyObject *sub; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 11bcb54..f6050e4 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -812,17 +812,6 @@ DISPATCH(); } - TARGET(LIST_TO_TUPLE) { - PyObject *list; - PyObject *res; - list = stack_pointer[-1]; - res = _PyTuple_FromArray(_PyList_ITEMS(list), PyList_GET_SIZE(list)); - Py_DECREF(list); - if (res == NULL) goto pop_1_error; - stack_pointer[-1] = res; - DISPATCH(); - } - TARGET(STORE_SUBSCR) { PREDICTED(STORE_SUBSCR); static_assert(INLINE_CACHE_ENTRIES_STORE_SUBSCR == 1, "incorrect cache size"); diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 07f6622..cb85e24 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -165,8 +165,8 @@ static void *opcode_targets[256] = { &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, - &&TARGET_LIST_TO_TUPLE, &&TARGET_CALL_NO_KW_TUPLE_1, + &&TARGET_CALL_BUILTIN_CLASS, &&TARGET_LOAD_FAST_LOAD_FAST, &&TARGET_STORE_FAST_LOAD_FAST, &&TARGET_STORE_FAST_STORE_FAST, @@ -177,7 +177,6 @@ static void *opcode_targets[256] = { &&TARGET_LOAD_FROM_DICT_OR_GLOBALS, &&TARGET_LOAD_FROM_DICT_OR_DEREF, &&TARGET_SET_FUNCTION_ATTRIBUTE, - &&TARGET_CALL_BUILTIN_CLASS, &&TARGET_CALL_NO_KW_BUILTIN_O, &&TARGET_CALL_NO_KW_BUILTIN_FAST, &&TARGET_CALL_BUILTIN_FAST_WITH_KEYWORDS, @@ -229,6 +228,7 @@ static void *opcode_targets[256] = { &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, + &&_unknown_opcode, &&TARGET_ENTER_EXECUTOR, &&_unknown_opcode, &&_unknown_opcode,