bpo-45636: Merge all numeric operators (GH-29482)

This commit is contained in:
Brandt Bucher 2021-11-10 22:56:22 -08:00 committed by GitHub
parent 1cbaa505d0
commit 9178f533ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 613 additions and 1081 deletions

345
Include/opcode.h generated
View file

@ -6,178 +6,152 @@ extern "C" {
#endif
/* Instruction opcodes for compiled code */
#define POP_TOP 1
#define ROT_TWO 2
#define ROT_THREE 3
#define DUP_TOP 4
#define DUP_TOP_TWO 5
#define ROT_FOUR 6
#define NOP 9
#define UNARY_POSITIVE 10
#define UNARY_NEGATIVE 11
#define UNARY_NOT 12
#define UNARY_INVERT 15
#define BINARY_MATRIX_MULTIPLY 16
#define INPLACE_MATRIX_MULTIPLY 17
#define BINARY_POWER 19
#define BINARY_MULTIPLY 20
#define BINARY_MODULO 22
#define BINARY_ADD 23
#define BINARY_SUBTRACT 24
#define BINARY_SUBSCR 25
#define BINARY_FLOOR_DIVIDE 26
#define BINARY_TRUE_DIVIDE 27
#define INPLACE_FLOOR_DIVIDE 28
#define INPLACE_TRUE_DIVIDE 29
#define GET_LEN 30
#define MATCH_MAPPING 31
#define MATCH_SEQUENCE 32
#define MATCH_KEYS 33
#define PUSH_EXC_INFO 35
#define POP_EXCEPT_AND_RERAISE 37
#define WITH_EXCEPT_START 49
#define GET_AITER 50
#define GET_ANEXT 51
#define BEFORE_ASYNC_WITH 52
#define BEFORE_WITH 53
#define END_ASYNC_FOR 54
#define INPLACE_ADD 55
#define INPLACE_SUBTRACT 56
#define INPLACE_MULTIPLY 57
#define INPLACE_MODULO 59
#define STORE_SUBSCR 60
#define DELETE_SUBSCR 61
#define BINARY_LSHIFT 62
#define BINARY_RSHIFT 63
#define BINARY_AND 64
#define BINARY_XOR 65
#define BINARY_OR 66
#define INPLACE_POWER 67
#define GET_ITER 68
#define GET_YIELD_FROM_ITER 69
#define PRINT_EXPR 70
#define LOAD_BUILD_CLASS 71
#define YIELD_FROM 72
#define GET_AWAITABLE 73
#define LOAD_ASSERTION_ERROR 74
#define INPLACE_LSHIFT 75
#define INPLACE_RSHIFT 76
#define INPLACE_AND 77
#define INPLACE_XOR 78
#define INPLACE_OR 79
#define LIST_TO_TUPLE 82
#define RETURN_VALUE 83
#define IMPORT_STAR 84
#define SETUP_ANNOTATIONS 85
#define YIELD_VALUE 86
#define POP_EXCEPT 89
#define HAVE_ARGUMENT 90
#define STORE_NAME 90
#define DELETE_NAME 91
#define UNPACK_SEQUENCE 92
#define FOR_ITER 93
#define UNPACK_EX 94
#define STORE_ATTR 95
#define DELETE_ATTR 96
#define STORE_GLOBAL 97
#define DELETE_GLOBAL 98
#define ROT_N 99
#define LOAD_CONST 100
#define LOAD_NAME 101
#define BUILD_TUPLE 102
#define BUILD_LIST 103
#define BUILD_SET 104
#define BUILD_MAP 105
#define LOAD_ATTR 106
#define COMPARE_OP 107
#define IMPORT_NAME 108
#define IMPORT_FROM 109
#define JUMP_FORWARD 110
#define JUMP_IF_FALSE_OR_POP 111
#define JUMP_IF_TRUE_OR_POP 112
#define JUMP_ABSOLUTE 113
#define POP_JUMP_IF_FALSE 114
#define POP_JUMP_IF_TRUE 115
#define LOAD_GLOBAL 116
#define IS_OP 117
#define CONTAINS_OP 118
#define RERAISE 119
#define COPY 120
#define JUMP_IF_NOT_EXC_MATCH 121
#define LOAD_FAST 124
#define STORE_FAST 125
#define DELETE_FAST 126
#define GEN_START 129
#define RAISE_VARARGS 130
#define CALL_FUNCTION 131
#define MAKE_FUNCTION 132
#define BUILD_SLICE 133
#define MAKE_CELL 135
#define LOAD_CLOSURE 136
#define LOAD_DEREF 137
#define STORE_DEREF 138
#define DELETE_DEREF 139
#define CALL_FUNCTION_KW 141
#define CALL_FUNCTION_EX 142
#define EXTENDED_ARG 144
#define LIST_APPEND 145
#define SET_ADD 146
#define MAP_ADD 147
#define LOAD_CLASSDEREF 148
#define MATCH_CLASS 152
#define FORMAT_VALUE 155
#define BUILD_CONST_KEY_MAP 156
#define BUILD_STRING 157
#define LOAD_METHOD 160
#define CALL_METHOD 161
#define LIST_EXTEND 162
#define SET_UPDATE 163
#define DICT_MERGE 164
#define DICT_UPDATE 165
#define CALL_METHOD_KW 166
#define BINARY_ADD_ADAPTIVE 7
#define BINARY_ADD_INT 8
#define BINARY_ADD_FLOAT 13
#define BINARY_ADD_UNICODE 14
#define BINARY_ADD_UNICODE_INPLACE_FAST 18
#define BINARY_MULTIPLY_ADAPTIVE 21
#define BINARY_MULTIPLY_INT 34
#define BINARY_MULTIPLY_FLOAT 36
#define BINARY_SUBSCR_ADAPTIVE 38
#define BINARY_SUBSCR_LIST_INT 39
#define BINARY_SUBSCR_TUPLE_INT 40
#define BINARY_SUBSCR_DICT 41
#define CALL_FUNCTION_ADAPTIVE 42
#define CALL_FUNCTION_BUILTIN_O 43
#define CALL_FUNCTION_BUILTIN_FAST 44
#define CALL_FUNCTION_LEN 45
#define CALL_FUNCTION_ISINSTANCE 46
#define CALL_FUNCTION_PY_SIMPLE 47
#define JUMP_ABSOLUTE_QUICK 48
#define LOAD_ATTR_ADAPTIVE 58
#define LOAD_ATTR_INSTANCE_VALUE 80
#define LOAD_ATTR_WITH_HINT 81
#define LOAD_ATTR_SLOT 87
#define LOAD_ATTR_MODULE 88
#define LOAD_GLOBAL_ADAPTIVE 122
#define LOAD_GLOBAL_MODULE 123
#define LOAD_GLOBAL_BUILTIN 127
#define LOAD_METHOD_ADAPTIVE 128
#define LOAD_METHOD_CACHED 134
#define LOAD_METHOD_CLASS 140
#define LOAD_METHOD_MODULE 143
#define LOAD_METHOD_NO_DICT 149
#define STORE_ATTR_ADAPTIVE 150
#define STORE_ATTR_INSTANCE_VALUE 151
#define STORE_ATTR_SLOT 153
#define STORE_ATTR_WITH_HINT 154
#define LOAD_FAST__LOAD_FAST 158
#define STORE_FAST__LOAD_FAST 159
#define LOAD_FAST__LOAD_CONST 167
#define LOAD_CONST__LOAD_FAST 168
#define STORE_FAST__STORE_FAST 169
#define DO_TRACING 255
/* Instruction opcodes for compiled code */
#define POP_TOP 1
#define ROT_TWO 2
#define ROT_THREE 3
#define DUP_TOP 4
#define DUP_TOP_TWO 5
#define ROT_FOUR 6
#define NOP 9
#define UNARY_POSITIVE 10
#define UNARY_NEGATIVE 11
#define UNARY_NOT 12
#define UNARY_INVERT 15
#define BINARY_SUBSCR 25
#define GET_LEN 30
#define MATCH_MAPPING 31
#define MATCH_SEQUENCE 32
#define MATCH_KEYS 33
#define PUSH_EXC_INFO 35
#define POP_EXCEPT_AND_RERAISE 37
#define WITH_EXCEPT_START 49
#define GET_AITER 50
#define GET_ANEXT 51
#define BEFORE_ASYNC_WITH 52
#define BEFORE_WITH 53
#define END_ASYNC_FOR 54
#define STORE_SUBSCR 60
#define DELETE_SUBSCR 61
#define GET_ITER 68
#define GET_YIELD_FROM_ITER 69
#define PRINT_EXPR 70
#define LOAD_BUILD_CLASS 71
#define YIELD_FROM 72
#define GET_AWAITABLE 73
#define LOAD_ASSERTION_ERROR 74
#define LIST_TO_TUPLE 82
#define RETURN_VALUE 83
#define IMPORT_STAR 84
#define SETUP_ANNOTATIONS 85
#define YIELD_VALUE 86
#define POP_EXCEPT 89
#define HAVE_ARGUMENT 90
#define STORE_NAME 90
#define DELETE_NAME 91
#define UNPACK_SEQUENCE 92
#define FOR_ITER 93
#define UNPACK_EX 94
#define STORE_ATTR 95
#define DELETE_ATTR 96
#define STORE_GLOBAL 97
#define DELETE_GLOBAL 98
#define ROT_N 99
#define LOAD_CONST 100
#define LOAD_NAME 101
#define BUILD_TUPLE 102
#define BUILD_LIST 103
#define BUILD_SET 104
#define BUILD_MAP 105
#define LOAD_ATTR 106
#define COMPARE_OP 107
#define IMPORT_NAME 108
#define IMPORT_FROM 109
#define JUMP_FORWARD 110
#define JUMP_IF_FALSE_OR_POP 111
#define JUMP_IF_TRUE_OR_POP 112
#define JUMP_ABSOLUTE 113
#define POP_JUMP_IF_FALSE 114
#define POP_JUMP_IF_TRUE 115
#define LOAD_GLOBAL 116
#define IS_OP 117
#define CONTAINS_OP 118
#define RERAISE 119
#define COPY 120
#define JUMP_IF_NOT_EXC_MATCH 121
#define BINARY_OP 122
#define LOAD_FAST 124
#define STORE_FAST 125
#define DELETE_FAST 126
#define GEN_START 129
#define RAISE_VARARGS 130
#define CALL_FUNCTION 131
#define MAKE_FUNCTION 132
#define BUILD_SLICE 133
#define MAKE_CELL 135
#define LOAD_CLOSURE 136
#define LOAD_DEREF 137
#define STORE_DEREF 138
#define DELETE_DEREF 139
#define CALL_FUNCTION_KW 141
#define CALL_FUNCTION_EX 142
#define EXTENDED_ARG 144
#define LIST_APPEND 145
#define SET_ADD 146
#define MAP_ADD 147
#define LOAD_CLASSDEREF 148
#define MATCH_CLASS 152
#define FORMAT_VALUE 155
#define BUILD_CONST_KEY_MAP 156
#define BUILD_STRING 157
#define LOAD_METHOD 160
#define CALL_METHOD 161
#define LIST_EXTEND 162
#define SET_UPDATE 163
#define DICT_MERGE 164
#define DICT_UPDATE 165
#define CALL_METHOD_KW 166
#define BINARY_OP_ADAPTIVE 7
#define BINARY_OP_ADD_INT 8
#define BINARY_OP_ADD_FLOAT 13
#define BINARY_OP_ADD_UNICODE 14
#define BINARY_OP_INPLACE_ADD_UNICODE 16
#define BINARY_OP_MULTIPLY_INT 17
#define BINARY_OP_MULTIPLY_FLOAT 18
#define BINARY_SUBSCR_ADAPTIVE 19
#define BINARY_SUBSCR_LIST_INT 20
#define BINARY_SUBSCR_TUPLE_INT 21
#define BINARY_SUBSCR_DICT 22
#define CALL_FUNCTION_ADAPTIVE 23
#define CALL_FUNCTION_BUILTIN_O 24
#define CALL_FUNCTION_BUILTIN_FAST 26
#define CALL_FUNCTION_LEN 27
#define CALL_FUNCTION_ISINSTANCE 28
#define CALL_FUNCTION_PY_SIMPLE 29
#define JUMP_ABSOLUTE_QUICK 34
#define LOAD_ATTR_ADAPTIVE 36
#define LOAD_ATTR_INSTANCE_VALUE 38
#define LOAD_ATTR_WITH_HINT 39
#define LOAD_ATTR_SLOT 40
#define LOAD_ATTR_MODULE 41
#define LOAD_GLOBAL_ADAPTIVE 42
#define LOAD_GLOBAL_MODULE 43
#define LOAD_GLOBAL_BUILTIN 44
#define LOAD_METHOD_ADAPTIVE 45
#define LOAD_METHOD_CACHED 46
#define LOAD_METHOD_CLASS 47
#define LOAD_METHOD_MODULE 48
#define LOAD_METHOD_NO_DICT 55
#define STORE_ATTR_ADAPTIVE 56
#define STORE_ATTR_INSTANCE_VALUE 57
#define STORE_ATTR_SLOT 58
#define STORE_ATTR_WITH_HINT 59
#define LOAD_FAST__LOAD_FAST 62
#define STORE_FAST__LOAD_FAST 63
#define LOAD_FAST__LOAD_CONST 64
#define LOAD_CONST__LOAD_FAST 65
#define STORE_FAST__STORE_FAST 66
#define DO_TRACING 255
#ifdef NEED_OPCODE_JUMP_TABLES
static uint32_t _PyOpcode_RelativeJump[8] = {
0U,
@ -205,6 +179,33 @@ static uint32_t _PyOpcode_Jump[8] = {
|| ((op) == 100) \
)
#define NB_ADD 0
#define NB_AND 1
#define NB_FLOOR_DIVIDE 2
#define NB_LSHIFT 3
#define NB_MATRIX_MULTIPLY 4
#define NB_MULTIPLY 5
#define NB_REMAINDER 6
#define NB_OR 7
#define NB_POWER 8
#define NB_RSHIFT 9
#define NB_SUBTRACT 10
#define NB_TRUE_DIVIDE 11
#define NB_XOR 12
#define NB_INPLACE_ADD 13
#define NB_INPLACE_AND 14
#define NB_INPLACE_FLOOR_DIVIDE 15
#define NB_INPLACE_LSHIFT 16
#define NB_INPLACE_MATRIX_MULTIPLY 17
#define NB_INPLACE_MULTIPLY 18
#define NB_INPLACE_REMAINDER 19
#define NB_INPLACE_OR 20
#define NB_INPLACE_POWER 21
#define NB_INPLACE_RSHIFT 22
#define NB_INPLACE_SUBTRACT 23
#define NB_INPLACE_TRUE_DIVIDE 24
#define NB_INPLACE_XOR 25
#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT)
/* Reserve some bytecodes for internal use in the compiler.