From 5e435449bccdd61882c7ea329dade478673dc473 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 11 Aug 2023 16:53:12 -0700 Subject: [PATCH 1/8] Split things up (sorta) --- Doc/library/dis.rst | 50 ++++-- Include/internal/pycore_code.h | 4 +- Include/internal/pycore_opcode_metadata.h | 35 ++-- Include/opcode_ids.h | 111 ++++++------- Lib/_opcode_metadata.py | 119 +++++++------- Lib/importlib/_bootstrap_external.py | 3 +- Lib/opcode.py | 4 + Lib/test/test_dis.py | 6 +- Objects/frameobject.c | 10 ++ Programs/test_frozenmain.h | 6 +- Python/bytecodes.c | 164 ++++++++++++++----- Python/ceval.c | 2 - Python/ceval_macros.h | 5 - Python/compile.c | 22 +-- Python/executor_cases.c.h | 11 -- Python/flowgraph.c | 2 - Python/generated_cases.c.h | 191 ++++++++++++++++------ Python/instrumentation.c | 5 + Python/opcode_targets.h | 4 +- Python/specialize.c | 43 +++-- Tools/scripts/summarize_stats.py | 2 + 21 files changed, 511 insertions(+), 288 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 6cd5f181c8433a..70a94f40e1878d 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1390,10 +1390,38 @@ iterations of the loop. .. opcode:: CALL (argc) + Calls a callable object with the number of arguments specified by ``argc``. + On the stack are (in ascending order): + + * NULL + * The callable + * The positional arguments + * The named arguments + + or: + + * The callable + * ``self`` (or ``NULL``) + * The remaining positional arguments + + ``argc`` is the total of the positional arguments, excluding + ``self`` when a ``NULL`` is not present. + + ``CALL`` pops all arguments and the callable object off the stack, + calls the callable object with those arguments, and pushes the return value + returned by the callable object. + + .. versionadded:: 3.11 + + .. versionchanged:: 3.13 + Calls with keyword arguments are now handled by :opcode:`CALL_KW`. + + +.. opcode:: CALL_KW (argc) + Calls a callable object with the number of arguments specified by ``argc``, - including the named arguments specified by the preceding - :opcode:`KW_NAMES`, if any. - On the stack are (in ascending order), either: + including one or more named arguments. + On the stack are (in ascending order): * NULL * The callable @@ -1403,18 +1431,19 @@ iterations of the loop. or: * The callable - * ``self`` + * ``self`` (or ``NULL``) * The remaining positional arguments * The named arguments + * A :class:`tuple` of keyword argument names ``argc`` is the total of the positional and named arguments, excluding ``self`` when a ``NULL`` is not present. - ``CALL`` pops all arguments and the callable object off the stack, + ``CALL`` pops all arguments, the keyword names, and the callable object off the stack, calls the callable object with those arguments, and pushes the return value returned by the callable object. - .. versionadded:: 3.11 + .. versionadded:: 3.13 .. opcode:: CALL_FUNCTION_EX (flags) @@ -1441,15 +1470,6 @@ iterations of the loop. .. versionadded:: 3.11 -.. opcode:: KW_NAMES (consti) - - Prefixes :opcode:`CALL`. - Stores a reference to ``co_consts[consti]`` into an internal variable - for use by :opcode:`CALL`. ``co_consts[consti]`` must be a tuple of strings. - - .. versionadded:: 3.11 - - .. opcode:: MAKE_FUNCTION Pushes a new function object on the stack built from the code object at ``STACK[1]``. diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index f5127a81144353..006675416aa549 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -250,7 +250,9 @@ extern void _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, extern void _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub, _Py_CODEUNIT *instr); extern void _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, - int nargs, PyObject *kwnames); + int nargs); +extern void _Py_Specialize_CallKw(PyObject *callable, _Py_CODEUNIT *instr, + int nargs, PyObject *kwnames); extern void _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, int oparg, PyObject **locals); extern void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h index 49089721c6ac20..b3d56aaf53eb1a 100644 --- a/Include/internal/pycore_opcode_metadata.h +++ b/Include/internal/pycore_opcode_metadata.h @@ -480,8 +480,6 @@ int _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 1; case LOAD_ATTR_METHOD_LAZY_DICT: return 1; - case KW_NAMES: - return 0; case INSTRUMENTED_CALL: return 0; case CALL: @@ -517,13 +515,13 @@ int _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case EXIT_INIT_CHECK: return 1; case CALL_BUILTIN_CLASS: - return oparg + 2; + return oparg + 3; case CALL_NO_KW_BUILTIN_O: return oparg + 2; case CALL_NO_KW_BUILTIN_FAST: return oparg + 2; case CALL_BUILTIN_FAST_WITH_KEYWORDS: - return oparg + 2; + return oparg + 3; case CALL_NO_KW_LEN: return oparg + 2; case CALL_NO_KW_ISINSTANCE: @@ -533,11 +531,15 @@ int _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case CALL_NO_KW_METHOD_DESCRIPTOR_O: return oparg + 2; case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: - return oparg + 2; + return oparg + 3; case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS: return oparg + 2; case CALL_NO_KW_METHOD_DESCRIPTOR_FAST: return oparg + 2; + case INSTRUMENTED_CALL_KW: + return 0; + case CALL_KW: + return oparg + 3; case INSTRUMENTED_CALL_FUNCTION_EX: return 0; case CALL_FUNCTION_EX: @@ -1012,8 +1014,6 @@ int _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 1; case LOAD_ATTR_METHOD_LAZY_DICT: return 2; - case KW_NAMES: - return 0; case INSTRUMENTED_CALL: return 0; case CALL: @@ -1070,6 +1070,10 @@ int _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 1; case CALL_NO_KW_METHOD_DESCRIPTOR_FAST: return 1; + case INSTRUMENTED_CALL_KW: + return 0; + case CALL_KW: + return 1; case INSTRUMENTED_CALL_FUNCTION_EX: return 0; case CALL_FUNCTION_EX: @@ -1370,7 +1374,6 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[OPCODE_METADATA_SIZE] = { [LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG }, [LOAD_ATTR_NONDESCRIPTOR_NO_DICT] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG }, [LOAD_ATTR_METHOD_LAZY_DICT] = { true, INSTR_FMT_IBC00000000, HAS_ARG_FLAG }, - [KW_NAMES] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_CONST_FLAG }, [INSTRUMENTED_CALL] = { true, INSTR_FMT_IB, HAS_ARG_FLAG }, [CALL] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [CALL_BOUND_METHOD_EXACT_ARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG }, @@ -1392,6 +1395,8 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[OPCODE_METADATA_SIZE] = { [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, + [INSTRUMENTED_CALL_KW] = { true, INSTR_FMT_IB, HAS_ARG_FLAG }, + [CALL_KW] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [INSTRUMENTED_CALL_FUNCTION_EX] = { true, INSTR_FMT_IX, 0 }, [CALL_FUNCTION_EX] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [MAKE_FUNCTION] = { true, INSTR_FMT_IX, 0 }, @@ -1691,6 +1696,7 @@ const char *const _PyOpcode_OpName[268] = { [CALL_FUNCTION_EX] = "CALL_FUNCTION_EX", [CALL_INTRINSIC_1] = "CALL_INTRINSIC_1", [CALL_INTRINSIC_2] = "CALL_INTRINSIC_2", + [CALL_KW] = "CALL_KW", [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = "CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", [CALL_NO_KW_ALLOC_AND_ENTER_INIT] = "CALL_NO_KW_ALLOC_AND_ENTER_INIT", [CALL_NO_KW_BUILTIN_FAST] = "CALL_NO_KW_BUILTIN_FAST", @@ -1735,7 +1741,6 @@ const char *const _PyOpcode_OpName[268] = { [JUMP_BACKWARD] = "JUMP_BACKWARD", [JUMP_BACKWARD_NO_INTERRUPT] = "JUMP_BACKWARD_NO_INTERRUPT", [JUMP_FORWARD] = "JUMP_FORWARD", - [KW_NAMES] = "KW_NAMES", [LIST_APPEND] = "LIST_APPEND", [LIST_EXTEND] = "LIST_EXTEND", [LOAD_ATTR] = "LOAD_ATTR", @@ -1805,6 +1810,7 @@ const char *const _PyOpcode_OpName[268] = { [INSTRUMENTED_LOAD_SUPER_ATTR] = "INSTRUMENTED_LOAD_SUPER_ATTR", [INSTRUMENTED_FOR_ITER] = "INSTRUMENTED_FOR_ITER", [INSTRUMENTED_CALL] = "INSTRUMENTED_CALL", + [INSTRUMENTED_CALL_KW] = "INSTRUMENTED_CALL_KW", [INSTRUMENTED_CALL_FUNCTION_EX] = "INSTRUMENTED_CALL_FUNCTION_EX", [INSTRUMENTED_INSTRUCTION] = "INSTRUMENTED_INSTRUCTION", [INSTRUMENTED_JUMP_FORWARD] = "INSTRUMENTED_JUMP_FORWARD", @@ -1845,6 +1851,7 @@ const uint8_t _PyOpcode_Caches[256] = { [COMPARE_OP] = 1, [FOR_ITER] = 1, [CALL] = 3, + [CALL_KW] = 3, [JUMP_BACKWARD] = 1, }; #endif // NEED_OPCODE_METADATA @@ -1880,12 +1887,13 @@ const uint8_t _PyOpcode_Deopt[256] = { [CACHE] = CACHE, [CALL] = CALL, [CALL_BOUND_METHOD_EXACT_ARGS] = CALL, - [CALL_BUILTIN_CLASS] = CALL, - [CALL_BUILTIN_FAST_WITH_KEYWORDS] = CALL, + [CALL_BUILTIN_CLASS] = CALL_KW, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = CALL_KW, [CALL_FUNCTION_EX] = CALL_FUNCTION_EX, [CALL_INTRINSIC_1] = CALL_INTRINSIC_1, [CALL_INTRINSIC_2] = CALL_INTRINSIC_2, - [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = CALL, + [CALL_KW] = CALL_KW, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = CALL_KW, [CALL_NO_KW_ALLOC_AND_ENTER_INIT] = CALL, [CALL_NO_KW_BUILTIN_FAST] = CALL, [CALL_NO_KW_BUILTIN_O] = CALL, @@ -1942,6 +1950,7 @@ const uint8_t _PyOpcode_Deopt[256] = { [IMPORT_NAME] = IMPORT_NAME, [INSTRUMENTED_CALL] = INSTRUMENTED_CALL, [INSTRUMENTED_CALL_FUNCTION_EX] = INSTRUMENTED_CALL_FUNCTION_EX, + [INSTRUMENTED_CALL_KW] = INSTRUMENTED_CALL_KW, [INSTRUMENTED_END_FOR] = INSTRUMENTED_END_FOR, [INSTRUMENTED_END_SEND] = INSTRUMENTED_END_SEND, [INSTRUMENTED_FOR_ITER] = INSTRUMENTED_FOR_ITER, @@ -1963,7 +1972,6 @@ const uint8_t _PyOpcode_Deopt[256] = { [JUMP_BACKWARD] = JUMP_BACKWARD, [JUMP_BACKWARD_NO_INTERRUPT] = JUMP_BACKWARD_NO_INTERRUPT, [JUMP_FORWARD] = JUMP_FORWARD, - [KW_NAMES] = KW_NAMES, [LIST_APPEND] = LIST_APPEND, [LIST_EXTEND] = LIST_EXTEND, [LOAD_ASSERTION_ERROR] = LOAD_ASSERTION_ERROR, @@ -2110,7 +2118,6 @@ const uint8_t _PyOpcode_Deopt[256] = { case 233: \ case 234: \ case 235: \ - case 236: \ case 255: \ ; diff --git a/Include/opcode_ids.h b/Include/opcode_ids.h index cd43716415d1db..40f04886760b9c 100644 --- a/Include/opcode_ids.h +++ b/Include/opcode_ids.h @@ -93,51 +93,51 @@ extern "C" { #define CALL_FUNCTION_EX 79 #define CALL_INTRINSIC_1 80 #define CALL_INTRINSIC_2 81 -#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 82 -#define CALL_NO_KW_ALLOC_AND_ENTER_INIT 83 -#define CALL_NO_KW_BUILTIN_FAST 84 -#define CALL_NO_KW_BUILTIN_O 85 -#define CALL_NO_KW_ISINSTANCE 86 -#define CALL_NO_KW_LEN 87 -#define CALL_NO_KW_LIST_APPEND 88 -#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 89 -#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 90 -#define CALL_NO_KW_METHOD_DESCRIPTOR_O 91 -#define CALL_NO_KW_STR_1 92 -#define CALL_NO_KW_TUPLE_1 93 -#define CALL_NO_KW_TYPE_1 94 -#define CALL_PY_EXACT_ARGS 95 -#define CALL_PY_WITH_DEFAULTS 96 -#define COMPARE_OP 97 -#define COMPARE_OP_FLOAT 98 -#define COMPARE_OP_INT 99 -#define COMPARE_OP_STR 100 -#define CONTAINS_OP 101 -#define CONVERT_VALUE 102 -#define COPY 103 -#define COPY_FREE_VARS 104 -#define DELETE_ATTR 105 -#define DELETE_DEREF 106 -#define DELETE_FAST 107 -#define DELETE_GLOBAL 108 -#define DELETE_NAME 109 -#define DICT_MERGE 110 -#define DICT_UPDATE 111 -#define ENTER_EXECUTOR 112 -#define EXTENDED_ARG 113 -#define FOR_ITER 114 -#define FOR_ITER_GEN 115 -#define FOR_ITER_LIST 116 -#define FOR_ITER_RANGE 117 -#define FOR_ITER_TUPLE 118 -#define GET_AWAITABLE 119 -#define IMPORT_FROM 120 -#define IMPORT_NAME 121 -#define IS_OP 122 -#define JUMP_BACKWARD 123 -#define JUMP_BACKWARD_NO_INTERRUPT 124 -#define JUMP_FORWARD 125 -#define KW_NAMES 126 +#define CALL_KW 82 +#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 83 +#define CALL_NO_KW_ALLOC_AND_ENTER_INIT 84 +#define CALL_NO_KW_BUILTIN_FAST 85 +#define CALL_NO_KW_BUILTIN_O 86 +#define CALL_NO_KW_ISINSTANCE 87 +#define CALL_NO_KW_LEN 88 +#define CALL_NO_KW_LIST_APPEND 89 +#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 90 +#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 91 +#define CALL_NO_KW_METHOD_DESCRIPTOR_O 92 +#define CALL_NO_KW_STR_1 93 +#define CALL_NO_KW_TUPLE_1 94 +#define CALL_NO_KW_TYPE_1 95 +#define CALL_PY_EXACT_ARGS 96 +#define CALL_PY_WITH_DEFAULTS 97 +#define COMPARE_OP 98 +#define COMPARE_OP_FLOAT 99 +#define COMPARE_OP_INT 100 +#define COMPARE_OP_STR 101 +#define CONTAINS_OP 102 +#define CONVERT_VALUE 103 +#define COPY 104 +#define COPY_FREE_VARS 105 +#define DELETE_ATTR 106 +#define DELETE_DEREF 107 +#define DELETE_FAST 108 +#define DELETE_GLOBAL 109 +#define DELETE_NAME 110 +#define DICT_MERGE 111 +#define DICT_UPDATE 112 +#define ENTER_EXECUTOR 113 +#define EXTENDED_ARG 114 +#define FOR_ITER 115 +#define FOR_ITER_GEN 116 +#define FOR_ITER_LIST 117 +#define FOR_ITER_RANGE 118 +#define FOR_ITER_TUPLE 119 +#define GET_AWAITABLE 120 +#define IMPORT_FROM 121 +#define IMPORT_NAME 122 +#define IS_OP 123 +#define JUMP_BACKWARD 124 +#define JUMP_BACKWARD_NO_INTERRUPT 125 +#define JUMP_FORWARD 126 #define LIST_APPEND 127 #define LIST_EXTEND 128 #define LOAD_ATTR 129 @@ -199,16 +199,17 @@ extern "C" { #define UNPACK_SEQUENCE_TUPLE 185 #define UNPACK_SEQUENCE_TWO_TUPLE 186 #define YIELD_VALUE 187 -#define MIN_INSTRUMENTED_OPCODE 237 -#define INSTRUMENTED_RESUME 237 -#define INSTRUMENTED_END_FOR 238 -#define INSTRUMENTED_END_SEND 239 -#define INSTRUMENTED_RETURN_VALUE 240 -#define INSTRUMENTED_RETURN_CONST 241 -#define INSTRUMENTED_YIELD_VALUE 242 -#define INSTRUMENTED_LOAD_SUPER_ATTR 243 -#define INSTRUMENTED_FOR_ITER 244 -#define INSTRUMENTED_CALL 245 +#define MIN_INSTRUMENTED_OPCODE 236 +#define INSTRUMENTED_RESUME 236 +#define INSTRUMENTED_END_FOR 237 +#define INSTRUMENTED_END_SEND 238 +#define INSTRUMENTED_RETURN_VALUE 239 +#define INSTRUMENTED_RETURN_CONST 240 +#define INSTRUMENTED_YIELD_VALUE 241 +#define INSTRUMENTED_LOAD_SUPER_ATTR 242 +#define INSTRUMENTED_FOR_ITER 243 +#define INSTRUMENTED_CALL 244 +#define INSTRUMENTED_CALL_KW 245 #define INSTRUMENTED_CALL_FUNCTION_EX 246 #define INSTRUMENTED_INSTRUCTION 247 #define INSTRUMENTED_JUMP_FORWARD 248 diff --git a/Lib/_opcode_metadata.py b/Lib/_opcode_metadata.py index b02aa771c347e7..9d1ad0c49f3ad5 100644 --- a/Lib/_opcode_metadata.py +++ b/Lib/_opcode_metadata.py @@ -85,19 +85,21 @@ "CALL_NO_KW_TYPE_1", "CALL_NO_KW_STR_1", "CALL_NO_KW_TUPLE_1", - "CALL_BUILTIN_CLASS", "CALL_NO_KW_BUILTIN_O", "CALL_NO_KW_BUILTIN_FAST", - "CALL_BUILTIN_FAST_WITH_KEYWORDS", "CALL_NO_KW_LEN", "CALL_NO_KW_ISINSTANCE", "CALL_NO_KW_LIST_APPEND", "CALL_NO_KW_METHOD_DESCRIPTOR_O", - "CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", "CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS", "CALL_NO_KW_METHOD_DESCRIPTOR_FAST", "CALL_NO_KW_ALLOC_AND_ENTER_INIT", ], + "CALL_KW": [ + "CALL_BUILTIN_CLASS", + "CALL_BUILTIN_FAST_WITH_KEYWORDS", + "CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", + ], } # An irregular case: @@ -130,28 +132,28 @@ 'CALL_BOUND_METHOD_EXACT_ARGS': 76, 'CALL_BUILTIN_CLASS': 77, 'CALL_BUILTIN_FAST_WITH_KEYWORDS': 78, - 'CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS': 82, - 'CALL_NO_KW_ALLOC_AND_ENTER_INIT': 83, - 'CALL_NO_KW_BUILTIN_FAST': 84, - 'CALL_NO_KW_BUILTIN_O': 85, - 'CALL_NO_KW_ISINSTANCE': 86, - 'CALL_NO_KW_LEN': 87, - 'CALL_NO_KW_LIST_APPEND': 88, - 'CALL_NO_KW_METHOD_DESCRIPTOR_FAST': 89, - 'CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS': 90, - 'CALL_NO_KW_METHOD_DESCRIPTOR_O': 91, - 'CALL_NO_KW_STR_1': 92, - 'CALL_NO_KW_TUPLE_1': 93, - 'CALL_NO_KW_TYPE_1': 94, - 'CALL_PY_EXACT_ARGS': 95, - 'CALL_PY_WITH_DEFAULTS': 96, - 'COMPARE_OP_FLOAT': 98, - 'COMPARE_OP_INT': 99, - 'COMPARE_OP_STR': 100, - 'FOR_ITER_GEN': 115, - 'FOR_ITER_LIST': 116, - 'FOR_ITER_RANGE': 117, - 'FOR_ITER_TUPLE': 118, + 'CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS': 83, + 'CALL_NO_KW_ALLOC_AND_ENTER_INIT': 84, + 'CALL_NO_KW_BUILTIN_FAST': 85, + 'CALL_NO_KW_BUILTIN_O': 86, + 'CALL_NO_KW_ISINSTANCE': 87, + 'CALL_NO_KW_LEN': 88, + 'CALL_NO_KW_LIST_APPEND': 89, + 'CALL_NO_KW_METHOD_DESCRIPTOR_FAST': 90, + 'CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS': 91, + 'CALL_NO_KW_METHOD_DESCRIPTOR_O': 92, + 'CALL_NO_KW_STR_1': 93, + 'CALL_NO_KW_TUPLE_1': 94, + 'CALL_NO_KW_TYPE_1': 95, + 'CALL_PY_EXACT_ARGS': 96, + 'CALL_PY_WITH_DEFAULTS': 97, + 'COMPARE_OP_FLOAT': 99, + 'COMPARE_OP_INT': 100, + 'COMPARE_OP_STR': 101, + 'FOR_ITER_GEN': 116, + 'FOR_ITER_LIST': 117, + 'FOR_ITER_RANGE': 118, + 'FOR_ITER_TUPLE': 119, 'LOAD_ATTR_CLASS': 130, 'LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN': 131, 'LOAD_ATTR_INSTANCE_VALUE': 132, @@ -232,29 +234,29 @@ 'CALL_FUNCTION_EX': 79, 'CALL_INTRINSIC_1': 80, 'CALL_INTRINSIC_2': 81, - 'COMPARE_OP': 97, - 'CONTAINS_OP': 101, - 'CONVERT_VALUE': 102, - 'COPY': 103, - 'COPY_FREE_VARS': 104, - 'DELETE_ATTR': 105, - 'DELETE_DEREF': 106, - 'DELETE_FAST': 107, - 'DELETE_GLOBAL': 108, - 'DELETE_NAME': 109, - 'DICT_MERGE': 110, - 'DICT_UPDATE': 111, - 'ENTER_EXECUTOR': 112, - 'EXTENDED_ARG': 113, - 'FOR_ITER': 114, - 'GET_AWAITABLE': 119, - 'IMPORT_FROM': 120, - 'IMPORT_NAME': 121, - 'IS_OP': 122, - 'JUMP_BACKWARD': 123, - 'JUMP_BACKWARD_NO_INTERRUPT': 124, - 'JUMP_FORWARD': 125, - 'KW_NAMES': 126, + 'CALL_KW': 82, + 'COMPARE_OP': 98, + 'CONTAINS_OP': 102, + 'CONVERT_VALUE': 103, + 'COPY': 104, + 'COPY_FREE_VARS': 105, + 'DELETE_ATTR': 106, + 'DELETE_DEREF': 107, + 'DELETE_FAST': 108, + 'DELETE_GLOBAL': 109, + 'DELETE_NAME': 110, + 'DICT_MERGE': 111, + 'DICT_UPDATE': 112, + 'ENTER_EXECUTOR': 113, + 'EXTENDED_ARG': 114, + 'FOR_ITER': 115, + 'GET_AWAITABLE': 120, + 'IMPORT_FROM': 121, + 'IMPORT_NAME': 122, + 'IS_OP': 123, + 'JUMP_BACKWARD': 124, + 'JUMP_BACKWARD_NO_INTERRUPT': 125, + 'JUMP_FORWARD': 126, 'LIST_APPEND': 127, 'LIST_EXTEND': 128, 'LOAD_ATTR': 129, @@ -295,15 +297,16 @@ 'UNPACK_EX': 182, 'UNPACK_SEQUENCE': 183, 'YIELD_VALUE': 187, - 'INSTRUMENTED_RESUME': 237, - 'INSTRUMENTED_END_FOR': 238, - 'INSTRUMENTED_END_SEND': 239, - 'INSTRUMENTED_RETURN_VALUE': 240, - 'INSTRUMENTED_RETURN_CONST': 241, - 'INSTRUMENTED_YIELD_VALUE': 242, - 'INSTRUMENTED_LOAD_SUPER_ATTR': 243, - 'INSTRUMENTED_FOR_ITER': 244, - 'INSTRUMENTED_CALL': 245, + 'INSTRUMENTED_RESUME': 236, + 'INSTRUMENTED_END_FOR': 237, + 'INSTRUMENTED_END_SEND': 238, + 'INSTRUMENTED_RETURN_VALUE': 239, + 'INSTRUMENTED_RETURN_CONST': 240, + 'INSTRUMENTED_YIELD_VALUE': 241, + 'INSTRUMENTED_LOAD_SUPER_ATTR': 242, + 'INSTRUMENTED_FOR_ITER': 243, + 'INSTRUMENTED_CALL': 244, + 'INSTRUMENTED_CALL_KW': 245, 'INSTRUMENTED_CALL_FUNCTION_EX': 246, 'INSTRUMENTED_INSTRUCTION': 247, 'INSTRUMENTED_JUMP_FORWARD': 248, @@ -326,5 +329,5 @@ 'SETUP_WITH': 266, 'STORE_FAST_MAYBE_NULL': 267, } -MIN_INSTRUMENTED_OPCODE = 237 +MIN_INSTRUMENTED_OPCODE = 236 HAVE_ARGUMENT = 67 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 0717e202ecbcde..6a55bfd23273a1 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -455,6 +455,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.13a1 3557 (Make the conversion to boolean in jumps explicit) # Python 3.13a1 3558 (Reorder the stack items for CALL) # Python 3.13a1 3559 (Generate opcode IDs from bytecodes.c) +# Python 3.13a1 3560 (Add CALL_KW) # Python 3.14 will start with 3600 @@ -471,7 +472,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3559).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3560).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c diff --git a/Lib/opcode.py b/Lib/opcode.py index 386a2fba396a6a..4baf75474a490f 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -80,6 +80,10 @@ "counter": 1, "func_version": 2, }, + "CALL_KW": { + "counter": 1, + "func_version": 2, + }, "STORE_SUBSCR": { "counter": 1, }, diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index dacd6f6da2c5a9..fd588297e57b46 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -240,8 +240,8 @@ def wrap_func_w_kwargs(): LOAD_CONST 1 (1) LOAD_CONST 2 (2) LOAD_CONST 3 (5) - KW_NAMES 4 (('c',)) - CALL 3 + LOAD_CONST 4 (('c',)) + CALL_KW 3 POP_TOP RETURN_CONST 0 (None) """ % (wrap_func_w_kwargs.__code__.co_firstlineno, @@ -1003,7 +1003,7 @@ def test_bug_46724(self): self.do_disassembly_test(bug46724, dis_bug46724) def test_kw_names(self): - # Test that value is displayed for KW_NAMES + # Test that value is displayed for keyword argument names: self.do_disassembly_test(wrap_func_w_kwargs, dis_kw_names) def test_intrinsic_1(self): diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 28f5a5a1222806..75b4ffc5d3b45b 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -434,6 +434,16 @@ mark_stacks(PyCodeObject *code_obj, int len) stacks[next_i] = next_stack; break; } + case CALL_KW: + { + int args = oparg; + for (int j = 0; j < args+3; j++) { + next_stack = pop_value(next_stack); + } + next_stack = push_value(next_stack, Object); + stacks[next_i] = next_stack; + break; + } case SWAP: { int n = oparg; diff --git a/Programs/test_frozenmain.h b/Programs/test_frozenmain.h index 3fd6cdade69f9e..42b8b78dfc51f8 100644 --- a/Programs/test_frozenmain.h +++ b/Programs/test_frozenmain.h @@ -2,16 +2,16 @@ unsigned char M_test_frozenmain[] = { 227,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0, 0,0,0,0,0,243,164,0,0,0,166,0,142,0,142,1, - 121,0,180,0,142,0,142,1,121,1,180,1,153,2,46,0, + 122,0,180,0,142,0,142,1,122,1,180,1,153,2,46,0, 142,2,75,1,0,0,0,0,0,0,44,0,153,2,46,0, 142,3,153,0,129,6,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,75,2,0,0,0,0,0,0, 44,0,153,1,129,8,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,46,0,75,0,0,0,0,0, - 0,0,142,4,12,0,0,0,180,5,142,5,31,0,114,20, + 0,0,142,4,12,0,0,0,180,5,142,5,31,0,115,20, 0,0,180,6,153,2,46,0,142,6,153,6,27,0,142,7, 153,5,153,6,12,0,0,0,27,0,73,4,75,1,0,0, - 0,0,0,0,44,0,123,22,0,0,24,0,167,1,41,8, + 0,0,0,0,44,0,124,22,0,0,24,0,167,1,41,8, 233,0,0,0,0,78,122,18,70,114,111,122,101,110,32,72, 101,108,108,111,32,87,111,114,108,100,122,8,115,121,115,46, 97,114,103,118,218,6,99,111,110,102,105,103,41,5,218,12, diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 93926c03421eb7..9eabd5b6fc80e0 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2809,12 +2809,6 @@ dummy_func( self = owner; } - inst(KW_NAMES, (--)) { - ASSERT_KWNAMES_IS_NULL(); - assert(oparg < PyTuple_GET_SIZE(FRAME_CO_CONSTS)); - kwnames = GETITEM(FRAME_CO_CONSTS, oparg); - } - inst(INSTRUMENTED_CALL, ( -- )) { int is_meth = PEEK(oparg + 1) != NULL; int total_args = oparg + is_meth; @@ -2831,7 +2825,8 @@ dummy_func( } // Cache layout: counter/1, func_version/2 - // Neither CALL_INTRINSIC_1/2 nor CALL_FUNCTION_EX are members! + // Neither CALL_INTRINSIC_1/2 nor CALL_FUNCTION_EX are members! CALL_KW + // has its own family. family(CALL, INLINE_CACHE_ENTRIES_CALL) = { CALL_BOUND_METHOD_EXACT_ARGS, CALL_PY_EXACT_ARGS, @@ -2839,25 +2834,24 @@ dummy_func( CALL_NO_KW_TYPE_1, CALL_NO_KW_STR_1, CALL_NO_KW_TUPLE_1, - CALL_BUILTIN_CLASS, + // CALL_BUILTIN_CLASS, CALL_NO_KW_BUILTIN_O, CALL_NO_KW_BUILTIN_FAST, - CALL_BUILTIN_FAST_WITH_KEYWORDS, + // CALL_BUILTIN_FAST_WITH_KEYWORDS, CALL_NO_KW_LEN, CALL_NO_KW_ISINSTANCE, CALL_NO_KW_LIST_APPEND, CALL_NO_KW_METHOD_DESCRIPTOR_O, - CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, + // CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS, CALL_NO_KW_METHOD_DESCRIPTOR_FAST, CALL_NO_KW_ALLOC_AND_ENTER_INIT, }; // On entry, the stack is either - // [NULL, callable, arg1, arg2, ...] + // [callable, NULL, arg1, arg2, ...] // or - // [method, self, arg1, arg2, ...] - // (Some args may be keywords, see KW_NAMES, which sets 'kwnames'.) + // [callable, self, arg1, arg2, ...] // On exit, the stack is [result]. // When calling Python, inline the call using DISPATCH_INLINED(). inst(CALL, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { @@ -2870,7 +2864,7 @@ dummy_func( _PyCallCache *cache = (_PyCallCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { next_instr--; - _Py_Specialize_Call(callable, next_instr, total_args, kwnames); + _Py_Specialize_Call(callable, next_instr, total_args); DISPATCH_SAME_OPARG(); } STAT_INC(CALL, deferred); @@ -2886,7 +2880,6 @@ dummy_func( Py_DECREF(callable); callable = method; } - int positional_args = total_args - KWNAMES_LEN(); // Check if the call can be inlined or not if (Py_TYPE(callable) == &PyFunction_Type && tstate->interp->eval_frame == NULL && @@ -2896,9 +2889,8 @@ dummy_func( PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(callable)); _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit( tstate, (PyFunctionObject *)callable, locals, - args, positional_args, kwnames + args, total_args, NULL ); - kwnames = NULL; // Manipulate stack directly since we leave using DISPATCH_INLINED(). STACK_SHRINK(oparg + 2); // The frame has stolen all the arguments from the stack, @@ -2913,8 +2905,8 @@ dummy_func( /* Callable is not a normal Python function */ res = PyObject_Vectorcall( callable, args, - positional_args | PY_VECTORCALL_ARGUMENTS_OFFSET, - kwnames); + total_args | PY_VECTORCALL_ARGUMENTS_OFFSET, + NULL); if (opcode == INSTRUMENTED_CALL) { PyObject *arg = total_args == 0 ? &_PyInstrumentation_MISSING : args[0]; @@ -2932,7 +2924,6 @@ dummy_func( } } } - kwnames = NULL; assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); Py_DECREF(callable); for (int i = 0; i < total_args; i++) { @@ -2961,7 +2952,6 @@ dummy_func( } op(_CHECK_FUNCTION_EXACT_ARGS, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) { - ASSERT_KWNAMES_IS_NULL(); DEOPT_IF(!PyFunction_Check(callable), CALL); PyFunctionObject *func = (PyFunctionObject *)callable; DEOPT_IF(func->func_version != func_version, CALL); @@ -3034,7 +3024,6 @@ dummy_func( _PUSH_FRAME; inst(CALL_PY_WITH_DEFAULTS, (unused/1, func_version/2, callable, self_or_null, args[oparg] -- unused)) { - ASSERT_KWNAMES_IS_NULL(); DEOPT_IF(tstate->interp->eval_frame, CALL); int argcount = oparg; if (self_or_null != NULL) { @@ -3070,7 +3059,6 @@ dummy_func( } inst(CALL_NO_KW_TYPE_1, (unused/1, unused/2, callable, null, args[oparg] -- res)) { - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); PyObject *obj = args[0]; @@ -3082,7 +3070,6 @@ dummy_func( } inst(CALL_NO_KW_STR_1, (unused/1, unused/2, callable, null, args[oparg] -- res)) { - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); DEOPT_IF(callable != (PyObject *)&PyUnicode_Type, CALL); @@ -3096,7 +3083,6 @@ dummy_func( } inst(CALL_NO_KW_TUPLE_1, (unused/1, unused/2, callable, null, args[oparg] -- res)) { - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); DEOPT_IF(callable != (PyObject *)&PyTuple_Type, CALL); @@ -3115,7 +3101,6 @@ dummy_func( * 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``) * 3. Pushes the frame for ``__init__`` to the frame stack * */ - ASSERT_KWNAMES_IS_NULL(); _PyCallCache *cache = (_PyCallCache *)next_instr; DEOPT_IF(null != NULL, CALL); DEOPT_IF(!PyType_Check(callable), CALL); @@ -3172,20 +3157,19 @@ dummy_func( } } - inst(CALL_BUILTIN_CLASS, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { + inst(CALL_BUILTIN_CLASS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { int total_args = oparg; if (self_or_null != NULL) { args--; total_args++; } - int kwnames_len = KWNAMES_LEN(); + int kwnames_len = (int)PyTuple_GET_SIZE(kwnames); DEOPT_IF(!PyType_Check(callable), CALL); PyTypeObject *tp = (PyTypeObject *)callable; DEOPT_IF(tp->tp_vectorcall == NULL, CALL); STAT_INC(CALL, hit); res = tp->tp_vectorcall((PyObject *)tp, args, total_args - kwnames_len, kwnames); - kwnames = NULL; /* Free the arguments. */ for (int i = 0; i < total_args; i++) { Py_DECREF(args[i]); @@ -3197,7 +3181,6 @@ dummy_func( inst(CALL_NO_KW_BUILTIN_O, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { /* Builtin METH_O functions */ - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; @@ -3226,7 +3209,6 @@ dummy_func( inst(CALL_NO_KW_BUILTIN_FAST, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { /* Builtin METH_FASTCALL functions, without keywords */ - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; @@ -3257,7 +3239,7 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_BUILTIN_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { + inst(CALL_BUILTIN_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int total_args = oparg; if (self_or_null != NULL) { @@ -3275,11 +3257,10 @@ dummy_func( res = cfunc( PyCFunction_GET_SELF(callable), args, - total_args - KWNAMES_LEN(), + total_args - (int)PyTuple_GET_SIZE(kwnames), kwnames ); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - kwnames = NULL; /* Free the arguments. */ for (int i = 0; i < total_args; i++) { @@ -3291,7 +3272,6 @@ dummy_func( } inst(CALL_NO_KW_LEN, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { - ASSERT_KWNAMES_IS_NULL(); /* len(o) */ int total_args = oparg; if (self_or_null != NULL) { @@ -3316,7 +3296,6 @@ dummy_func( } inst(CALL_NO_KW_ISINSTANCE, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { - ASSERT_KWNAMES_IS_NULL(); /* isinstance(o, o2) */ int total_args = oparg; if (self_or_null != NULL) { @@ -3344,7 +3323,6 @@ dummy_func( // This is secretly a super-instruction inst(CALL_NO_KW_LIST_APPEND, (unused/1, unused/2, callable, self, args[oparg] -- unused)) { - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); PyInterpreterState *interp = tstate->interp; DEOPT_IF(callable != interp->callable_cache.list_append, CALL); @@ -3364,7 +3342,6 @@ dummy_func( } inst(CALL_NO_KW_METHOD_DESCRIPTOR_O, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; @@ -3395,7 +3372,7 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { + inst(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { int total_args = oparg; if (self_or_null != NULL) { args--; @@ -3412,9 +3389,8 @@ dummy_func( int nargs = total_args - 1; _PyCFunctionFastWithKeywords cfunc = (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth; - res = cfunc(self, args + 1, nargs - KWNAMES_LEN(), kwnames); + res = cfunc(self, args + 1, nargs - (int)PyTuple_GET_SIZE(kwnames), kwnames); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - kwnames = NULL; /* Free the arguments. */ for (int i = 0; i < total_args; i++) { @@ -3426,7 +3402,6 @@ dummy_func( } inst(CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 0 || oparg == 1); int total_args = oparg; if (self_or_null != NULL) { @@ -3457,7 +3432,6 @@ dummy_func( } inst(CALL_NO_KW_METHOD_DESCRIPTOR_FAST, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; @@ -3485,6 +3459,110 @@ dummy_func( CHECK_EVAL_BREAKER(); } + inst(INSTRUMENTED_CALL_KW, ( -- )) { + int is_meth = PEEK(oparg + 2) != NULL; + int total_args = oparg + is_meth; + PyObject *function = PEEK(oparg + 3); + PyObject *arg = total_args == 0 ? + &_PyInstrumentation_MISSING : PEEK(total_args + 1); + int err = _Py_call_instrumentation_2args( + tstate, PY_MONITORING_EVENT_CALL, + frame, next_instr-1, function, arg); + ERROR_IF(err, error); + _PyCallCache *cache = (_PyCallCache *)next_instr; + INCREMENT_ADAPTIVE_COUNTER(cache->counter); + GO_TO_INSTRUCTION(CALL_KW); + } + + // Cache layout: counter/1, func_version/2 + family(CALL_KW, INLINE_CACHE_ENTRIES_CALL) = { + CALL_BUILTIN_CLASS, + CALL_BUILTIN_FAST_WITH_KEYWORDS, + CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, + }; + + inst(CALL_KW, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { + int total_args = oparg; + if (self_or_null != NULL) { + args--; + total_args++; + } + #if ENABLE_SPECIALIZATION + _PyCallCache *cache = (_PyCallCache *)next_instr; + if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { + next_instr--; + _Py_Specialize_CallKw(callable, next_instr, total_args, kwnames); + DISPATCH_SAME_OPARG(); + } + STAT_INC(CALL_KW, deferred); + DECREMENT_ADAPTIVE_COUNTER(cache->counter); + #endif /* ENABLE_SPECIALIZATION */ + if (self_or_null == NULL && Py_TYPE(callable) == &PyMethod_Type) { + args--; + total_args++; + PyObject *self = ((PyMethodObject *)callable)->im_self; + args[0] = Py_NewRef(self); + PyObject *method = ((PyMethodObject *)callable)->im_func; + args[-1] = Py_NewRef(method); + Py_DECREF(callable); + callable = method; + } + int positional_args = total_args - (int)PyTuple_GET_SIZE(kwnames); + // Check if the call can be inlined or not + if (Py_TYPE(callable) == &PyFunction_Type && + tstate->interp->eval_frame == NULL && + ((PyFunctionObject *)callable)->vectorcall == _PyFunction_Vectorcall) + { + int code_flags = ((PyCodeObject*)PyFunction_GET_CODE(callable))->co_flags; + PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(callable)); + _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit( + tstate, (PyFunctionObject *)callable, locals, + args, positional_args, kwnames + ); + Py_DECREF(kwnames); + // Manipulate stack directly since we leave using DISPATCH_INLINED(). + STACK_SHRINK(oparg + 3); + // The frame has stolen all the arguments from the stack, + // so there is no need to clean them up. + if (new_frame == NULL) { + goto error; + } + SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); + frame->return_offset = 0; + DISPATCH_INLINED(new_frame); + } + /* Callable is not a normal Python function */ + res = PyObject_Vectorcall( + callable, args, + positional_args | PY_VECTORCALL_ARGUMENTS_OFFSET, + kwnames); + if (opcode == INSTRUMENTED_CALL_KW) { + PyObject *arg = total_args == 0 ? + &_PyInstrumentation_MISSING : args[0]; + if (res == NULL) { + _Py_call_instrumentation_exc2( + tstate, PY_MONITORING_EVENT_C_RAISE, + frame, next_instr-1, callable, arg); + } + else { + int err = _Py_call_instrumentation_2args( + tstate, PY_MONITORING_EVENT_C_RETURN, + frame, next_instr-1, callable, arg); + if (err < 0) { + Py_CLEAR(res); + } + } + } + Py_DECREF(kwnames); + assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); + Py_DECREF(callable); + for (int i = 0; i < total_args; i++) { + Py_DECREF(args[i]); + } + ERROR_IF(res == NULL, error); + CHECK_EVAL_BREAKER(); + } + inst(INSTRUMENTED_CALL_FUNCTION_EX, ( -- )) { GO_TO_INSTRUCTION(CALL_FUNCTION_EX); } diff --git a/Python/ceval.c b/Python/ceval.c index a56d31ea073639..4ff30fab61a9db 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -651,7 +651,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int #endif _PyInterpreterFrame entry_frame; - PyObject *kwnames = NULL; // Borrowed reference. Reset by CALL instructions. @@ -829,7 +828,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int pop_1_error: STACK_SHRINK(1); error: - kwnames = NULL; /* Double-check exception status. */ #ifdef NDEBUG if (!_PyErr_Occurred(tstate)) { diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h index 635b8e501e523e..259615aa1b5cb8 100644 --- a/Python/ceval_macros.h +++ b/Python/ceval_macros.h @@ -311,9 +311,6 @@ GETITEM(PyObject *v, Py_ssize_t i) { " in enclosing scope" #define NAME_ERROR_MSG "name '%.200s' is not defined" -#define KWNAMES_LEN() \ - (kwnames == NULL ? 0 : ((int)PyTuple_GET_SIZE(kwnames))) - #define DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dval, result) \ do { \ if (Py_REFCNT(left) == 1) { \ @@ -356,8 +353,6 @@ static const convertion_func_ptr CONVERSION_FUNCTIONS[4] = { [FVC_ASCII] = PyObject_ASCII }; -#define ASSERT_KWNAMES_IS_NULL() assert(kwnames == NULL) - // GH-89279: Force inlining by using a macro. #if defined(_MSC_VER) && SIZEOF_INT == 4 #define _Py_atomic_load_relaxed_int32(ATOMIC_VAL) (assert(sizeof((ATOMIC_VAL)->_value) == 4), *((volatile int*)&((ATOMIC_VAL)->_value))) diff --git a/Python/compile.c b/Python/compile.c index 6b816b4c6eda6c..6a65d5f6984f3a 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4981,9 +4981,13 @@ maybe_optimize_method_call(struct compiler *c, expr_ty e) VISIT_SEQ(c, keyword, kwds); RETURN_IF_ERROR( compiler_call_simple_kw_helper(c, loc, kwds, kwdsl)); + loc = update_start_location_to_match_attr(c, LOC(e), meth); + ADDOP_I(c, loc, CALL_KW, argsl + kwdsl); + } + else { + loc = update_start_location_to_match_attr(c, LOC(e), meth); + ADDOP_I(c, loc, CALL, argsl); } - loc = update_start_location_to_match_attr(c, LOC(e), meth); - ADDOP_I(c, loc, CALL, argsl + kwdsl); return 1; } @@ -5149,7 +5153,7 @@ compiler_subkwargs(struct compiler *c, location loc, } /* Used by compiler_call_helper and maybe_optimize_method_call to emit - * KW_NAMES before CALL. + * a tuple of keyword names before CALL. */ static int compiler_call_simple_kw_helper(struct compiler *c, location loc, @@ -5164,12 +5168,7 @@ compiler_call_simple_kw_helper(struct compiler *c, location loc, keyword_ty kw = asdl_seq_GET(keywords, i); PyTuple_SET_ITEM(names, i, Py_NewRef(kw->arg)); } - Py_ssize_t arg = compiler_add_const(c->c_const_cache, c->u, names); - if (arg < 0) { - return ERROR; - } - Py_DECREF(names); - ADDOP_I(c, loc, KW_NAMES, arg); + ADDOP_LOAD_CONST_NEW(c, loc, names); return SUCCESS; } @@ -5214,8 +5213,11 @@ compiler_call_helper(struct compiler *c, location loc, VISIT_SEQ(c, keyword, keywords); RETURN_IF_ERROR( compiler_call_simple_kw_helper(c, loc, keywords, nkwelts)); + ADDOP_I(c, loc, CALL_KW, n + nelts + nkwelts); + } + else { + ADDOP_I(c, loc, CALL, n + nelts); } - ADDOP_I(c, loc, CALL, n + nelts + nkwelts); return SUCCESS; ex_call: diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 1283cc7ebbf9c4..256a8af8d33039 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -2229,7 +2229,6 @@ self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; uint32_t func_version = (uint32_t)operand; - ASSERT_KWNAMES_IS_NULL(); DEOPT_IF(!PyFunction_Check(callable), CALL); PyFunctionObject *func = (PyFunctionObject *)callable; DEOPT_IF(func->func_version != func_version, CALL); @@ -2303,7 +2302,6 @@ args = stack_pointer - oparg; null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); PyObject *obj = args[0]; @@ -2326,7 +2324,6 @@ args = stack_pointer - oparg; null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); DEOPT_IF(callable != (PyObject *)&PyUnicode_Type, CALL); @@ -2351,7 +2348,6 @@ args = stack_pointer - oparg; null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); DEOPT_IF(callable != (PyObject *)&PyTuple_Type, CALL); @@ -2391,7 +2387,6 @@ self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; /* Builtin METH_O functions */ - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; @@ -2431,7 +2426,6 @@ self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; /* Builtin METH_FASTCALL functions, without keywords */ - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; @@ -2474,7 +2468,6 @@ args = stack_pointer - oparg; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); /* len(o) */ int total_args = oparg; if (self_or_null != NULL) { @@ -2510,7 +2503,6 @@ args = stack_pointer - oparg; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); /* isinstance(o, o2) */ int total_args = oparg; if (self_or_null != NULL) { @@ -2548,7 +2540,6 @@ args = stack_pointer - oparg; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; @@ -2591,7 +2582,6 @@ args = stack_pointer - oparg; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 0 || oparg == 1); int total_args = oparg; if (self_or_null != NULL) { @@ -2633,7 +2623,6 @@ args = stack_pointer - oparg; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; diff --git a/Python/flowgraph.c b/Python/flowgraph.c index 55b871dd627364..44858b9c527388 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -1624,8 +1624,6 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts) INSTR_SET_OP0(inst, NOP); } break; - case KW_NAMES: - break; case LOAD_GLOBAL: if (nextop == PUSH_NULL && (oparg & 1) == 0) { INSTR_SET_OP1(inst, LOAD_GLOBAL, oparg | 1); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 5940c185817604..0ca4ecd6eb943e 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -3676,13 +3676,6 @@ DISPATCH(); } - TARGET(KW_NAMES) { - ASSERT_KWNAMES_IS_NULL(); - assert(oparg < PyTuple_GET_SIZE(FRAME_CO_CONSTS)); - kwnames = GETITEM(FRAME_CO_CONSTS, oparg); - DISPATCH(); - } - TARGET(INSTRUMENTED_CALL) { int is_meth = PEEK(oparg + 1) != NULL; int total_args = oparg + is_meth; @@ -3717,7 +3710,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { next_instr--; - _Py_Specialize_Call(callable, next_instr, total_args, kwnames); + _Py_Specialize_Call(callable, next_instr, total_args); DISPATCH_SAME_OPARG(); } STAT_INC(CALL, deferred); @@ -3733,7 +3726,6 @@ Py_DECREF(callable); callable = method; } - int positional_args = total_args - KWNAMES_LEN(); // Check if the call can be inlined or not if (Py_TYPE(callable) == &PyFunction_Type && tstate->interp->eval_frame == NULL && @@ -3743,9 +3735,8 @@ PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(callable)); _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit( tstate, (PyFunctionObject *)callable, locals, - args, positional_args, kwnames + args, total_args, NULL ); - kwnames = NULL; // Manipulate stack directly since we leave using DISPATCH_INLINED(). STACK_SHRINK(oparg + 2); // The frame has stolen all the arguments from the stack, @@ -3760,8 +3751,8 @@ /* Callable is not a normal Python function */ res = PyObject_Vectorcall( callable, args, - positional_args | PY_VECTORCALL_ARGUMENTS_OFFSET, - kwnames); + total_args | PY_VECTORCALL_ARGUMENTS_OFFSET, + NULL); if (opcode == INSTRUMENTED_CALL) { PyObject *arg = total_args == 0 ? &_PyInstrumentation_MISSING : args[0]; @@ -3779,7 +3770,6 @@ } } } - kwnames = NULL; assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); Py_DECREF(callable); for (int i = 0; i < total_args; i++) { @@ -3827,7 +3817,6 @@ callable = func; { uint32_t func_version = read_u32(&next_instr[1].cache); - ASSERT_KWNAMES_IS_NULL(); DEOPT_IF(!PyFunction_Check(callable), CALL); PyFunctionObject *func = (PyFunctionObject *)callable; DEOPT_IF(func->func_version != func_version, CALL); @@ -3903,7 +3892,6 @@ callable = stack_pointer[-2 - oparg]; { uint32_t func_version = read_u32(&next_instr[1].cache); - ASSERT_KWNAMES_IS_NULL(); DEOPT_IF(!PyFunction_Check(callable), CALL); PyFunctionObject *func = (PyFunctionObject *)callable; DEOPT_IF(func->func_version != func_version, CALL); @@ -3973,7 +3961,6 @@ self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; uint32_t func_version = read_u32(&next_instr[1].cache); - ASSERT_KWNAMES_IS_NULL(); DEOPT_IF(tstate->interp->eval_frame, CALL); int argcount = oparg; if (self_or_null != NULL) { @@ -4018,7 +4005,6 @@ args = stack_pointer - oparg; null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); PyObject *obj = args[0]; @@ -4042,7 +4028,6 @@ args = stack_pointer - oparg; null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); DEOPT_IF(callable != (PyObject *)&PyUnicode_Type, CALL); @@ -4068,7 +4053,6 @@ args = stack_pointer - oparg; null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); DEOPT_IF(callable != (PyObject *)&PyTuple_Type, CALL); @@ -4098,7 +4082,6 @@ * 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``) * 3. Pushes the frame for ``__init__`` to the frame stack * */ - ASSERT_KWNAMES_IS_NULL(); _PyCallCache *cache = (_PyCallCache *)next_instr; DEOPT_IF(null != NULL, CALL); DEOPT_IF(!PyType_Check(callable), CALL); @@ -4162,34 +4145,35 @@ } TARGET(CALL_BUILTIN_CLASS) { + PyObject *kwnames; PyObject **args; PyObject *self_or_null; PyObject *callable; PyObject *res; - args = stack_pointer - oparg; - self_or_null = stack_pointer[-1 - oparg]; - callable = stack_pointer[-2 - oparg]; + kwnames = stack_pointer[-1]; + args = stack_pointer - 1 - oparg; + self_or_null = stack_pointer[-2 - oparg]; + callable = stack_pointer[-3 - oparg]; int total_args = oparg; if (self_or_null != NULL) { args--; total_args++; } - int kwnames_len = KWNAMES_LEN(); + int kwnames_len = (int)PyTuple_GET_SIZE(kwnames); DEOPT_IF(!PyType_Check(callable), CALL); PyTypeObject *tp = (PyTypeObject *)callable; DEOPT_IF(tp->tp_vectorcall == NULL, CALL); STAT_INC(CALL, hit); res = tp->tp_vectorcall((PyObject *)tp, args, total_args - kwnames_len, kwnames); - kwnames = NULL; /* Free the arguments. */ for (int i = 0; i < total_args; i++) { Py_DECREF(args[i]); } Py_DECREF(tp); - if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + if (res == NULL) { STACK_SHRINK(oparg); goto pop_3_error; } STACK_SHRINK(oparg); - STACK_SHRINK(1); + STACK_SHRINK(2); stack_pointer[-1] = res; next_instr += 3; CHECK_EVAL_BREAKER(); @@ -4205,7 +4189,6 @@ self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; /* Builtin METH_O functions */ - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; @@ -4246,7 +4229,6 @@ self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; /* Builtin METH_FASTCALL functions, without keywords */ - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; @@ -4283,13 +4265,15 @@ } TARGET(CALL_BUILTIN_FAST_WITH_KEYWORDS) { + PyObject *kwnames; PyObject **args; PyObject *self_or_null; PyObject *callable; PyObject *res; - args = stack_pointer - oparg; - self_or_null = stack_pointer[-1 - oparg]; - callable = stack_pointer[-2 - oparg]; + kwnames = stack_pointer[-1]; + args = stack_pointer - 1 - oparg; + self_or_null = stack_pointer[-2 - oparg]; + callable = stack_pointer[-3 - oparg]; /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int total_args = oparg; if (self_or_null != NULL) { @@ -4307,20 +4291,19 @@ res = cfunc( PyCFunction_GET_SELF(callable), args, - total_args - KWNAMES_LEN(), + total_args - (int)PyTuple_GET_SIZE(kwnames), kwnames ); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - kwnames = NULL; /* Free the arguments. */ for (int i = 0; i < total_args; i++) { Py_DECREF(args[i]); } Py_DECREF(callable); - if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + if (res == NULL) { STACK_SHRINK(oparg); goto pop_3_error; } STACK_SHRINK(oparg); - STACK_SHRINK(1); + STACK_SHRINK(2); stack_pointer[-1] = res; next_instr += 3; CHECK_EVAL_BREAKER(); @@ -4335,7 +4318,6 @@ args = stack_pointer - oparg; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); /* len(o) */ int total_args = oparg; if (self_or_null != NULL) { @@ -4372,7 +4354,6 @@ args = stack_pointer - oparg; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); /* isinstance(o, o2) */ int total_args = oparg; if (self_or_null != NULL) { @@ -4410,7 +4391,6 @@ args = stack_pointer - oparg; self = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 1); PyInterpreterState *interp = tstate->interp; DEOPT_IF(callable != interp->callable_cache.list_append, CALL); @@ -4439,7 +4419,6 @@ args = stack_pointer - oparg; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; @@ -4476,13 +4455,15 @@ } TARGET(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS) { + PyObject *kwnames; PyObject **args; PyObject *self_or_null; PyObject *callable; PyObject *res; - args = stack_pointer - oparg; - self_or_null = stack_pointer[-1 - oparg]; - callable = stack_pointer[-2 - oparg]; + kwnames = stack_pointer[-1]; + args = stack_pointer - 1 - oparg; + self_or_null = stack_pointer[-2 - oparg]; + callable = stack_pointer[-3 - oparg]; int total_args = oparg; if (self_or_null != NULL) { args--; @@ -4499,18 +4480,17 @@ int nargs = total_args - 1; _PyCFunctionFastWithKeywords cfunc = (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth; - res = cfunc(self, args + 1, nargs - KWNAMES_LEN(), kwnames); + res = cfunc(self, args + 1, nargs - (int)PyTuple_GET_SIZE(kwnames), kwnames); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - kwnames = NULL; /* Free the arguments. */ for (int i = 0; i < total_args; i++) { Py_DECREF(args[i]); } Py_DECREF(callable); - if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + if (res == NULL) { STACK_SHRINK(oparg); goto pop_3_error; } STACK_SHRINK(oparg); - STACK_SHRINK(1); + STACK_SHRINK(2); stack_pointer[-1] = res; next_instr += 3; CHECK_EVAL_BREAKER(); @@ -4525,7 +4505,6 @@ args = stack_pointer - oparg; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); assert(oparg == 0 || oparg == 1); int total_args = oparg; if (self_or_null != NULL) { @@ -4568,7 +4547,6 @@ args = stack_pointer - oparg; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - ASSERT_KWNAMES_IS_NULL(); int total_args = oparg; if (self_or_null != NULL) { args--; @@ -4601,6 +4579,119 @@ DISPATCH(); } + TARGET(INSTRUMENTED_CALL_KW) { + int is_meth = PEEK(oparg + 2) != NULL; + int total_args = oparg + is_meth; + PyObject *function = PEEK(oparg + 3); + PyObject *arg = total_args == 0 ? + &_PyInstrumentation_MISSING : PEEK(total_args + 1); + int err = _Py_call_instrumentation_2args( + tstate, PY_MONITORING_EVENT_CALL, + frame, next_instr-1, function, arg); + if (err) goto error; + _PyCallCache *cache = (_PyCallCache *)next_instr; + INCREMENT_ADAPTIVE_COUNTER(cache->counter); + GO_TO_INSTRUCTION(CALL_KW); + } + + TARGET(CALL_KW) { + PREDICTED(CALL_KW); + static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size"); + PyObject *kwnames; + PyObject **args; + PyObject *self_or_null; + PyObject *callable; + PyObject *res; + kwnames = stack_pointer[-1]; + args = stack_pointer - 1 - oparg; + self_or_null = stack_pointer[-2 - oparg]; + callable = stack_pointer[-3 - oparg]; + int total_args = oparg; + if (self_or_null != NULL) { + args--; + total_args++; + } + #if ENABLE_SPECIALIZATION + _PyCallCache *cache = (_PyCallCache *)next_instr; + if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { + next_instr--; + _Py_Specialize_CallKw(callable, next_instr, total_args, kwnames); + DISPATCH_SAME_OPARG(); + } + STAT_INC(CALL_KW, deferred); + DECREMENT_ADAPTIVE_COUNTER(cache->counter); + #endif /* ENABLE_SPECIALIZATION */ + if (self_or_null == NULL && Py_TYPE(callable) == &PyMethod_Type) { + args--; + total_args++; + PyObject *self = ((PyMethodObject *)callable)->im_self; + args[0] = Py_NewRef(self); + PyObject *method = ((PyMethodObject *)callable)->im_func; + args[-1] = Py_NewRef(method); + Py_DECREF(callable); + callable = method; + } + int positional_args = total_args - (int)PyTuple_GET_SIZE(kwnames); + // Check if the call can be inlined or not + if (Py_TYPE(callable) == &PyFunction_Type && + tstate->interp->eval_frame == NULL && + ((PyFunctionObject *)callable)->vectorcall == _PyFunction_Vectorcall) + { + int code_flags = ((PyCodeObject*)PyFunction_GET_CODE(callable))->co_flags; + PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : Py_NewRef(PyFunction_GET_GLOBALS(callable)); + _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit( + tstate, (PyFunctionObject *)callable, locals, + args, positional_args, kwnames + ); + Py_DECREF(kwnames); + // Manipulate stack directly since we leave using DISPATCH_INLINED(). + STACK_SHRINK(oparg + 3); + // The frame has stolen all the arguments from the stack, + // so there is no need to clean them up. + if (new_frame == NULL) { + goto error; + } + SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); + frame->return_offset = 0; + DISPATCH_INLINED(new_frame); + } + /* Callable is not a normal Python function */ + res = PyObject_Vectorcall( + callable, args, + positional_args | PY_VECTORCALL_ARGUMENTS_OFFSET, + kwnames); + if (opcode == INSTRUMENTED_CALL_KW) { + PyObject *arg = total_args == 0 ? + &_PyInstrumentation_MISSING : args[0]; + if (res == NULL) { + _Py_call_instrumentation_exc2( + tstate, PY_MONITORING_EVENT_C_RAISE, + frame, next_instr-1, callable, arg); + } + else { + int err = _Py_call_instrumentation_2args( + tstate, PY_MONITORING_EVENT_C_RETURN, + frame, next_instr-1, callable, arg); + if (err < 0) { + Py_CLEAR(res); + } + } + } + Py_DECREF(kwnames); + assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); + Py_DECREF(callable); + for (int i = 0; i < total_args; i++) { + Py_DECREF(args[i]); + } + if (res == NULL) { STACK_SHRINK(oparg); goto pop_3_error; } + STACK_SHRINK(oparg); + STACK_SHRINK(2); + stack_pointer[-1] = res; + next_instr += 3; + CHECK_EVAL_BREAKER(); + DISPATCH(); + } + TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { GO_TO_INSTRUCTION(CALL_FUNCTION_EX); } diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 36459687be7936..6a5603752339fa 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -35,6 +35,8 @@ static const int8_t EVENT_FOR_OPCODE[256] = { [INSTRUMENTED_RETURN_VALUE] = PY_MONITORING_EVENT_PY_RETURN, [CALL] = PY_MONITORING_EVENT_CALL, [INSTRUMENTED_CALL] = PY_MONITORING_EVENT_CALL, + [CALL_KW] = PY_MONITORING_EVENT_CALL, + [INSTRUMENTED_CALL_KW] = PY_MONITORING_EVENT_CALL, [CALL_FUNCTION_EX] = PY_MONITORING_EVENT_CALL, [INSTRUMENTED_CALL_FUNCTION_EX] = PY_MONITORING_EVENT_CALL, [LOAD_SUPER_ATTR] = PY_MONITORING_EVENT_CALL, @@ -67,6 +69,7 @@ static const uint8_t DE_INSTRUMENT[256] = { [INSTRUMENTED_RETURN_VALUE] = RETURN_VALUE, [INSTRUMENTED_RETURN_CONST] = RETURN_CONST, [INSTRUMENTED_CALL] = CALL, + [INSTRUMENTED_CALL_KW] = CALL_KW, [INSTRUMENTED_CALL_FUNCTION_EX] = CALL_FUNCTION_EX, [INSTRUMENTED_YIELD_VALUE] = YIELD_VALUE, [INSTRUMENTED_JUMP_FORWARD] = JUMP_FORWARD, @@ -88,6 +91,8 @@ static const uint8_t INSTRUMENTED_OPCODES[256] = { [INSTRUMENTED_RETURN_VALUE] = INSTRUMENTED_RETURN_VALUE, [CALL] = INSTRUMENTED_CALL, [INSTRUMENTED_CALL] = INSTRUMENTED_CALL, + [CALL_KW] = INSTRUMENTED_CALL_KW, + [INSTRUMENTED_CALL_KW] = INSTRUMENTED_CALL_KW, [CALL_FUNCTION_EX] = INSTRUMENTED_CALL_FUNCTION_EX, [INSTRUMENTED_CALL_FUNCTION_EX] = INSTRUMENTED_CALL_FUNCTION_EX, [YIELD_VALUE] = INSTRUMENTED_YIELD_VALUE, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 305eb0bfe2a7c4..bff39a7aca2bf0 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -81,6 +81,7 @@ static void *opcode_targets[256] = { &&TARGET_CALL_FUNCTION_EX, &&TARGET_CALL_INTRINSIC_1, &&TARGET_CALL_INTRINSIC_2, + &&TARGET_CALL_KW, &&TARGET_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, &&TARGET_CALL_NO_KW_ALLOC_AND_ENTER_INIT, &&TARGET_CALL_NO_KW_BUILTIN_FAST, @@ -125,7 +126,6 @@ static void *opcode_targets[256] = { &&TARGET_JUMP_BACKWARD, &&TARGET_JUMP_BACKWARD_NO_INTERRUPT, &&TARGET_JUMP_FORWARD, - &&TARGET_KW_NAMES, &&TARGET_LIST_APPEND, &&TARGET_LIST_EXTEND, &&TARGET_LOAD_ATTR, @@ -235,7 +235,6 @@ static void *opcode_targets[256] = { &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, - &&_unknown_opcode, &&TARGET_INSTRUMENTED_RESUME, &&TARGET_INSTRUMENTED_END_FOR, &&TARGET_INSTRUMENTED_END_SEND, @@ -245,6 +244,7 @@ static void *opcode_targets[256] = { &&TARGET_INSTRUMENTED_LOAD_SUPER_ATTR, &&TARGET_INSTRUMENTED_FOR_ITER, &&TARGET_INSTRUMENTED_CALL, + &&TARGET_INSTRUMENTED_CALL_KW, &&TARGET_INSTRUMENTED_CALL_FUNCTION_EX, &&TARGET_INSTRUMENTED_INSTRUCTION, &&TARGET_INSTRUMENTED_JUMP_FORWARD, diff --git a/Python/specialize.c b/Python/specialize.c index a467f163f2ca9d..951247d3710417 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -108,6 +108,7 @@ _Py_GetSpecializationStats(void) { err += add_stat_dict(stats, STORE_SUBSCR, "store_subscr"); err += add_stat_dict(stats, STORE_ATTR, "store_attr"); err += add_stat_dict(stats, CALL, "call"); + err += add_stat_dict(stats, CALL_KW, "call_kw"); err += add_stat_dict(stats, BINARY_OP, "binary_op"); err += add_stat_dict(stats, COMPARE_OP, "compare_op"); err += add_stat_dict(stats, UNPACK_SEQUENCE, "unpack_sequence"); @@ -1614,8 +1615,9 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, } } if (tp->tp_vectorcall != NULL) { - instr->op.code = CALL_BUILTIN_CLASS; - return 0; + // XXX + // instr->op.code = CALL_BUILTIN_CLASS; + // return 0; } SPECIALIZATION_FAIL(CALL, tp == &PyUnicode_Type ? SPEC_FAIL_CALL_STR : SPEC_FAIL_CALL_CLASS_NO_VECTORCALL); @@ -1732,8 +1734,9 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr, return 0; } case METH_FASTCALL | METH_KEYWORDS: { - instr->op.code = CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS; - return 0; + // XXX + // instr->op.code = CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS; + // return 0; } } SPECIALIZATION_FAIL(CALL, meth_descr_call_fail_kind(descr->d_method->ml_flags)); @@ -1835,8 +1838,9 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, return 0; } case METH_FASTCALL | METH_KEYWORDS: { - instr->op.code = CALL_BUILTIN_FAST_WITH_KEYWORDS; - return 0; + // XXX + // instr->op.code = CALL_BUILTIN_FAST_WITH_KEYWORDS; + // return 0; } default: SPECIALIZATION_FAIL(CALL, @@ -1876,8 +1880,7 @@ call_fail_kind(PyObject *callable) - Specialize calling classes. */ void -_Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, - PyObject *kwnames) +_Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) { assert(ENABLE_SPECIALIZATION); assert(_PyOpcode_Caches[CALL] == INLINE_CACHE_ENTRIES_CALL); @@ -1885,24 +1888,24 @@ _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, _PyCallCache *cache = (_PyCallCache *)(instr + 1); int fail; if (PyCFunction_CheckExact(callable)) { - fail = specialize_c_call(callable, instr, nargs, kwnames); + fail = specialize_c_call(callable, instr, nargs, NULL); } else if (PyFunction_Check(callable)) { fail = specialize_py_call((PyFunctionObject *)callable, instr, nargs, - kwnames, false); + NULL, false); } else if (PyType_Check(callable)) { - fail = specialize_class_call(callable, instr, nargs, kwnames); + fail = specialize_class_call(callable, instr, nargs, NULL); } else if (Py_IS_TYPE(callable, &PyMethodDescr_Type)) { fail = specialize_method_descriptor((PyMethodDescrObject *)callable, - instr, nargs, kwnames); + instr, nargs, NULL); } else if (PyMethod_Check(callable)) { PyObject *func = ((PyMethodObject *)callable)->im_func; if (PyFunction_Check(func)) { fail = specialize_py_call((PyFunctionObject *)func, - instr, nargs+1, kwnames, true); + instr, nargs+1, NULL, true); } else { SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_BOUND_METHOD); fail = -1; @@ -1925,6 +1928,20 @@ _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, } } +void +_Py_Specialize_CallKw(PyObject *callable, _Py_CODEUNIT *instr, int nargs, + PyObject *kwnames) +{ + assert(ENABLE_SPECIALIZATION); + assert(_PyOpcode_Caches[CALL_KW] == INLINE_CACHE_ENTRIES_CALL); + assert(_Py_OPCODE(*instr) != INSTRUMENTED_CALL_KW); + _PyCallCache *cache = (_PyCallCache *)(instr + 1); + STAT_INC(CALL_KW, failure); + assert(!PyErr_Occurred()); + instr->op.code = CALL_KW; + cache->counter = adaptive_counter_backoff(cache->counter); +} + #ifdef Py_STATS static int binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs) diff --git a/Tools/scripts/summarize_stats.py b/Tools/scripts/summarize_stats.py index 2d198506fb5c6c..3cd4f6d5ee7a7e 100644 --- a/Tools/scripts/summarize_stats.py +++ b/Tools/scripts/summarize_stats.py @@ -234,6 +234,8 @@ def kind_to_text(kind, defines, opname): opname = "ITER" elif opname.endswith("SUBSCR"): opname = "SUBSCR" + elif opname in ("CALL", "CALL_KW"): + opname = "CALL" for name in defines[kind]: if name.startswith(opname): return pretty(name[len(opname)+1:]) From b7820eef7eb683bda831ff9e999735e0c537a423 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sat, 12 Aug 2023 03:03:33 -0700 Subject: [PATCH 2/8] Fix all specialization --- Include/internal/pycore_opcode_metadata.h | 30 ++- Include/opcode_ids.h | 211 ++++++++++---------- Lib/_opcode_metadata.py | 220 +++++++++++---------- Lib/test/test_dis.py | 228 +++++++++++----------- Programs/test_frozenmain.h | 18 +- Python/bytecodes.c | 114 +++++++++-- Python/generated_cases.c.h | 149 ++++++++++++-- Python/opcode_targets.h | 8 +- Python/specialize.c | 89 +++++---- 9 files changed, 656 insertions(+), 411 deletions(-) diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h index b3d56aaf53eb1a..3ebad7d8b4bf51 100644 --- a/Include/internal/pycore_opcode_metadata.h +++ b/Include/internal/pycore_opcode_metadata.h @@ -515,12 +515,16 @@ int _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case EXIT_INIT_CHECK: return 1; case CALL_BUILTIN_CLASS: + return oparg + 2; + case CALL_KW_BUILTIN_CLASS: return oparg + 3; case CALL_NO_KW_BUILTIN_O: return oparg + 2; case CALL_NO_KW_BUILTIN_FAST: return oparg + 2; case CALL_BUILTIN_FAST_WITH_KEYWORDS: + return oparg + 2; + case CALL_KW_BUILTIN_FAST_WITH_KEYWORDS: return oparg + 3; case CALL_NO_KW_LEN: return oparg + 2; @@ -531,6 +535,8 @@ int _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case CALL_NO_KW_METHOD_DESCRIPTOR_O: return oparg + 2; case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: + return oparg + 2; + case CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: return oparg + 3; case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS: return oparg + 2; @@ -1050,12 +1056,16 @@ int _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 0; case CALL_BUILTIN_CLASS: return 1; + case CALL_KW_BUILTIN_CLASS: + return 1; case CALL_NO_KW_BUILTIN_O: return 1; case CALL_NO_KW_BUILTIN_FAST: return 1; case CALL_BUILTIN_FAST_WITH_KEYWORDS: return 1; + case CALL_KW_BUILTIN_FAST_WITH_KEYWORDS: + return 1; case CALL_NO_KW_LEN: return 1; case CALL_NO_KW_ISINSTANCE: @@ -1066,6 +1076,8 @@ int _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 1; case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: return 1; + case CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: + return 1; case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS: return 1; case CALL_NO_KW_METHOD_DESCRIPTOR_FAST: @@ -1385,14 +1397,17 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[OPCODE_METADATA_SIZE] = { [CALL_NO_KW_ALLOC_AND_ENTER_INIT] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG }, [EXIT_INIT_CHECK] = { true, INSTR_FMT_IX, 0 }, [CALL_BUILTIN_CLASS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, + [CALL_KW_BUILTIN_CLASS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [CALL_NO_KW_BUILTIN_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [CALL_NO_KW_BUILTIN_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, + [CALL_KW_BUILTIN_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [CALL_NO_KW_LEN] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG }, [CALL_NO_KW_ISINSTANCE] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG }, [CALL_NO_KW_LIST_APPEND] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG }, [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, + [CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG }, [INSTRUMENTED_CALL_KW] = { true, INSTR_FMT_IB, HAS_ARG_FLAG }, @@ -1697,6 +1712,9 @@ const char *const _PyOpcode_OpName[268] = { [CALL_INTRINSIC_1] = "CALL_INTRINSIC_1", [CALL_INTRINSIC_2] = "CALL_INTRINSIC_2", [CALL_KW] = "CALL_KW", + [CALL_KW_BUILTIN_CLASS] = "CALL_KW_BUILTIN_CLASS", + [CALL_KW_BUILTIN_FAST_WITH_KEYWORDS] = "CALL_KW_BUILTIN_FAST_WITH_KEYWORDS", + [CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = "CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = "CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", [CALL_NO_KW_ALLOC_AND_ENTER_INIT] = "CALL_NO_KW_ALLOC_AND_ENTER_INIT", [CALL_NO_KW_BUILTIN_FAST] = "CALL_NO_KW_BUILTIN_FAST", @@ -1887,13 +1905,16 @@ const uint8_t _PyOpcode_Deopt[256] = { [CACHE] = CACHE, [CALL] = CALL, [CALL_BOUND_METHOD_EXACT_ARGS] = CALL, - [CALL_BUILTIN_CLASS] = CALL_KW, - [CALL_BUILTIN_FAST_WITH_KEYWORDS] = CALL_KW, + [CALL_BUILTIN_CLASS] = CALL, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = CALL, [CALL_FUNCTION_EX] = CALL_FUNCTION_EX, [CALL_INTRINSIC_1] = CALL_INTRINSIC_1, [CALL_INTRINSIC_2] = CALL_INTRINSIC_2, [CALL_KW] = CALL_KW, - [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = CALL_KW, + [CALL_KW_BUILTIN_CLASS] = CALL_KW, + [CALL_KW_BUILTIN_FAST_WITH_KEYWORDS] = CALL_KW, + [CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = CALL_KW, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = CALL, [CALL_NO_KW_ALLOC_AND_ENTER_INIT] = CALL, [CALL_NO_KW_BUILTIN_FAST] = CALL, [CALL_NO_KW_BUILTIN_O] = CALL, @@ -2070,9 +2091,6 @@ const uint8_t _PyOpcode_Deopt[256] = { #endif // NEED_OPCODE_METADATA #define EXTRA_CASES \ - case 188: \ - case 189: \ - case 190: \ case 191: \ case 192: \ case 193: \ diff --git a/Include/opcode_ids.h b/Include/opcode_ids.h index 40f04886760b9c..1962daa793ea31 100644 --- a/Include/opcode_ids.h +++ b/Include/opcode_ids.h @@ -94,111 +94,114 @@ extern "C" { #define CALL_INTRINSIC_1 80 #define CALL_INTRINSIC_2 81 #define CALL_KW 82 -#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 83 -#define CALL_NO_KW_ALLOC_AND_ENTER_INIT 84 -#define CALL_NO_KW_BUILTIN_FAST 85 -#define CALL_NO_KW_BUILTIN_O 86 -#define CALL_NO_KW_ISINSTANCE 87 -#define CALL_NO_KW_LEN 88 -#define CALL_NO_KW_LIST_APPEND 89 -#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 90 -#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 91 -#define CALL_NO_KW_METHOD_DESCRIPTOR_O 92 -#define CALL_NO_KW_STR_1 93 -#define CALL_NO_KW_TUPLE_1 94 -#define CALL_NO_KW_TYPE_1 95 -#define CALL_PY_EXACT_ARGS 96 -#define CALL_PY_WITH_DEFAULTS 97 -#define COMPARE_OP 98 -#define COMPARE_OP_FLOAT 99 -#define COMPARE_OP_INT 100 -#define COMPARE_OP_STR 101 -#define CONTAINS_OP 102 -#define CONVERT_VALUE 103 -#define COPY 104 -#define COPY_FREE_VARS 105 -#define DELETE_ATTR 106 -#define DELETE_DEREF 107 -#define DELETE_FAST 108 -#define DELETE_GLOBAL 109 -#define DELETE_NAME 110 -#define DICT_MERGE 111 -#define DICT_UPDATE 112 -#define ENTER_EXECUTOR 113 -#define EXTENDED_ARG 114 -#define FOR_ITER 115 -#define FOR_ITER_GEN 116 -#define FOR_ITER_LIST 117 -#define FOR_ITER_RANGE 118 -#define FOR_ITER_TUPLE 119 -#define GET_AWAITABLE 120 -#define IMPORT_FROM 121 -#define IMPORT_NAME 122 -#define IS_OP 123 -#define JUMP_BACKWARD 124 -#define JUMP_BACKWARD_NO_INTERRUPT 125 -#define JUMP_FORWARD 126 -#define LIST_APPEND 127 -#define LIST_EXTEND 128 -#define LOAD_ATTR 129 -#define LOAD_ATTR_CLASS 130 -#define LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN 131 -#define LOAD_ATTR_INSTANCE_VALUE 132 -#define LOAD_ATTR_METHOD_LAZY_DICT 133 -#define LOAD_ATTR_METHOD_NO_DICT 134 -#define LOAD_ATTR_METHOD_WITH_VALUES 135 -#define LOAD_ATTR_MODULE 136 -#define LOAD_ATTR_NONDESCRIPTOR_NO_DICT 137 -#define LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES 138 -#define LOAD_ATTR_PROPERTY 139 -#define LOAD_ATTR_SLOT 140 -#define LOAD_ATTR_WITH_HINT 141 -#define LOAD_CONST 142 -#define LOAD_DEREF 143 -#define LOAD_FAST 144 -#define LOAD_FAST_AND_CLEAR 145 -#define LOAD_FAST_CHECK 146 -#define LOAD_FAST_LOAD_FAST 147 -#define LOAD_FROM_DICT_OR_DEREF 148 -#define LOAD_FROM_DICT_OR_GLOBALS 149 -#define LOAD_GLOBAL 150 -#define LOAD_GLOBAL_BUILTIN 151 -#define LOAD_GLOBAL_MODULE 152 -#define LOAD_NAME 153 -#define LOAD_SUPER_ATTR 154 -#define LOAD_SUPER_ATTR_ATTR 155 -#define LOAD_SUPER_ATTR_METHOD 156 -#define MAKE_CELL 157 -#define MAP_ADD 158 -#define MATCH_CLASS 159 -#define POP_JUMP_IF_FALSE 160 -#define POP_JUMP_IF_NONE 161 -#define POP_JUMP_IF_NOT_NONE 162 -#define POP_JUMP_IF_TRUE 163 -#define RAISE_VARARGS 164 -#define RERAISE 165 +#define CALL_KW_BUILTIN_CLASS 83 +#define CALL_KW_BUILTIN_FAST_WITH_KEYWORDS 84 +#define CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 85 +#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 86 +#define CALL_NO_KW_ALLOC_AND_ENTER_INIT 87 +#define CALL_NO_KW_BUILTIN_FAST 88 +#define CALL_NO_KW_BUILTIN_O 89 +#define CALL_NO_KW_ISINSTANCE 90 +#define CALL_NO_KW_LEN 91 +#define CALL_NO_KW_LIST_APPEND 92 +#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 93 +#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 94 +#define CALL_NO_KW_METHOD_DESCRIPTOR_O 95 +#define CALL_NO_KW_STR_1 96 +#define CALL_NO_KW_TUPLE_1 97 +#define CALL_NO_KW_TYPE_1 98 +#define CALL_PY_EXACT_ARGS 99 +#define CALL_PY_WITH_DEFAULTS 100 +#define COMPARE_OP 101 +#define COMPARE_OP_FLOAT 102 +#define COMPARE_OP_INT 103 +#define COMPARE_OP_STR 104 +#define CONTAINS_OP 105 +#define CONVERT_VALUE 106 +#define COPY 107 +#define COPY_FREE_VARS 108 +#define DELETE_ATTR 109 +#define DELETE_DEREF 110 +#define DELETE_FAST 111 +#define DELETE_GLOBAL 112 +#define DELETE_NAME 113 +#define DICT_MERGE 114 +#define DICT_UPDATE 115 +#define ENTER_EXECUTOR 116 +#define EXTENDED_ARG 117 +#define FOR_ITER 118 +#define FOR_ITER_GEN 119 +#define FOR_ITER_LIST 120 +#define FOR_ITER_RANGE 121 +#define FOR_ITER_TUPLE 122 +#define GET_AWAITABLE 123 +#define IMPORT_FROM 124 +#define IMPORT_NAME 125 +#define IS_OP 126 +#define JUMP_BACKWARD 127 +#define JUMP_BACKWARD_NO_INTERRUPT 128 +#define JUMP_FORWARD 129 +#define LIST_APPEND 130 +#define LIST_EXTEND 131 +#define LOAD_ATTR 132 +#define LOAD_ATTR_CLASS 133 +#define LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN 134 +#define LOAD_ATTR_INSTANCE_VALUE 135 +#define LOAD_ATTR_METHOD_LAZY_DICT 136 +#define LOAD_ATTR_METHOD_NO_DICT 137 +#define LOAD_ATTR_METHOD_WITH_VALUES 138 +#define LOAD_ATTR_MODULE 139 +#define LOAD_ATTR_NONDESCRIPTOR_NO_DICT 140 +#define LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES 141 +#define LOAD_ATTR_PROPERTY 142 +#define LOAD_ATTR_SLOT 143 +#define LOAD_ATTR_WITH_HINT 144 +#define LOAD_CONST 145 +#define LOAD_DEREF 146 +#define LOAD_FAST 147 +#define LOAD_FAST_AND_CLEAR 148 +#define LOAD_FAST_CHECK 149 +#define LOAD_FAST_LOAD_FAST 150 +#define LOAD_FROM_DICT_OR_DEREF 151 +#define LOAD_FROM_DICT_OR_GLOBALS 152 +#define LOAD_GLOBAL 153 +#define LOAD_GLOBAL_BUILTIN 154 +#define LOAD_GLOBAL_MODULE 155 +#define LOAD_NAME 156 +#define LOAD_SUPER_ATTR 157 +#define LOAD_SUPER_ATTR_ATTR 158 +#define LOAD_SUPER_ATTR_METHOD 159 +#define MAKE_CELL 160 +#define MAP_ADD 161 +#define MATCH_CLASS 162 +#define POP_JUMP_IF_FALSE 163 +#define POP_JUMP_IF_NONE 164 +#define POP_JUMP_IF_NOT_NONE 165 #define RESUME 166 -#define RETURN_CONST 167 -#define SEND 168 -#define SEND_GEN 169 -#define SET_ADD 170 -#define SET_FUNCTION_ATTRIBUTE 171 -#define SET_UPDATE 172 -#define STORE_ATTR 173 -#define STORE_ATTR_WITH_HINT 174 -#define STORE_DEREF 175 -#define STORE_FAST 176 -#define STORE_FAST_LOAD_FAST 177 -#define STORE_FAST_STORE_FAST 178 -#define STORE_GLOBAL 179 -#define STORE_NAME 180 -#define SWAP 181 -#define UNPACK_EX 182 -#define UNPACK_SEQUENCE 183 -#define UNPACK_SEQUENCE_LIST 184 -#define UNPACK_SEQUENCE_TUPLE 185 -#define UNPACK_SEQUENCE_TWO_TUPLE 186 -#define YIELD_VALUE 187 +#define POP_JUMP_IF_TRUE 167 +#define RAISE_VARARGS 168 +#define RERAISE 169 +#define RETURN_CONST 170 +#define SEND 171 +#define SEND_GEN 172 +#define SET_ADD 173 +#define SET_FUNCTION_ATTRIBUTE 174 +#define SET_UPDATE 175 +#define STORE_ATTR 176 +#define STORE_ATTR_WITH_HINT 177 +#define STORE_DEREF 178 +#define STORE_FAST 179 +#define STORE_FAST_LOAD_FAST 180 +#define STORE_FAST_STORE_FAST 181 +#define STORE_GLOBAL 182 +#define STORE_NAME 183 +#define SWAP 184 +#define UNPACK_EX 185 +#define UNPACK_SEQUENCE 186 +#define UNPACK_SEQUENCE_LIST 187 +#define UNPACK_SEQUENCE_TUPLE 188 +#define UNPACK_SEQUENCE_TWO_TUPLE 189 +#define YIELD_VALUE 190 #define MIN_INSTRUMENTED_OPCODE 236 #define INSTRUMENTED_RESUME 236 #define INSTRUMENTED_END_FOR 237 diff --git a/Lib/_opcode_metadata.py b/Lib/_opcode_metadata.py index 9d1ad0c49f3ad5..038d3902836ab7 100644 --- a/Lib/_opcode_metadata.py +++ b/Lib/_opcode_metadata.py @@ -85,20 +85,23 @@ "CALL_NO_KW_TYPE_1", "CALL_NO_KW_STR_1", "CALL_NO_KW_TUPLE_1", + "CALL_BUILTIN_CLASS", "CALL_NO_KW_BUILTIN_O", "CALL_NO_KW_BUILTIN_FAST", + "CALL_BUILTIN_FAST_WITH_KEYWORDS", "CALL_NO_KW_LEN", "CALL_NO_KW_ISINSTANCE", "CALL_NO_KW_LIST_APPEND", "CALL_NO_KW_METHOD_DESCRIPTOR_O", + "CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", "CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS", "CALL_NO_KW_METHOD_DESCRIPTOR_FAST", "CALL_NO_KW_ALLOC_AND_ENTER_INIT", ], "CALL_KW": [ - "CALL_BUILTIN_CLASS", - "CALL_BUILTIN_FAST_WITH_KEYWORDS", - "CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", + "CALL_KW_BUILTIN_CLASS", + "CALL_KW_BUILTIN_FAST_WITH_KEYWORDS", + "CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", ], } @@ -132,49 +135,52 @@ 'CALL_BOUND_METHOD_EXACT_ARGS': 76, 'CALL_BUILTIN_CLASS': 77, 'CALL_BUILTIN_FAST_WITH_KEYWORDS': 78, - 'CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS': 83, - 'CALL_NO_KW_ALLOC_AND_ENTER_INIT': 84, - 'CALL_NO_KW_BUILTIN_FAST': 85, - 'CALL_NO_KW_BUILTIN_O': 86, - 'CALL_NO_KW_ISINSTANCE': 87, - 'CALL_NO_KW_LEN': 88, - 'CALL_NO_KW_LIST_APPEND': 89, - 'CALL_NO_KW_METHOD_DESCRIPTOR_FAST': 90, - 'CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS': 91, - 'CALL_NO_KW_METHOD_DESCRIPTOR_O': 92, - 'CALL_NO_KW_STR_1': 93, - 'CALL_NO_KW_TUPLE_1': 94, - 'CALL_NO_KW_TYPE_1': 95, - 'CALL_PY_EXACT_ARGS': 96, - 'CALL_PY_WITH_DEFAULTS': 97, - 'COMPARE_OP_FLOAT': 99, - 'COMPARE_OP_INT': 100, - 'COMPARE_OP_STR': 101, - 'FOR_ITER_GEN': 116, - 'FOR_ITER_LIST': 117, - 'FOR_ITER_RANGE': 118, - 'FOR_ITER_TUPLE': 119, - 'LOAD_ATTR_CLASS': 130, - 'LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN': 131, - 'LOAD_ATTR_INSTANCE_VALUE': 132, - 'LOAD_ATTR_METHOD_LAZY_DICT': 133, - 'LOAD_ATTR_METHOD_NO_DICT': 134, - 'LOAD_ATTR_METHOD_WITH_VALUES': 135, - 'LOAD_ATTR_MODULE': 136, - 'LOAD_ATTR_NONDESCRIPTOR_NO_DICT': 137, - 'LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES': 138, - 'LOAD_ATTR_PROPERTY': 139, - 'LOAD_ATTR_SLOT': 140, - 'LOAD_ATTR_WITH_HINT': 141, - 'LOAD_GLOBAL_BUILTIN': 151, - 'LOAD_GLOBAL_MODULE': 152, - 'LOAD_SUPER_ATTR_ATTR': 155, - 'LOAD_SUPER_ATTR_METHOD': 156, - 'SEND_GEN': 169, - 'STORE_ATTR_WITH_HINT': 174, - 'UNPACK_SEQUENCE_LIST': 184, - 'UNPACK_SEQUENCE_TUPLE': 185, - 'UNPACK_SEQUENCE_TWO_TUPLE': 186, + 'CALL_KW_BUILTIN_CLASS': 83, + 'CALL_KW_BUILTIN_FAST_WITH_KEYWORDS': 84, + 'CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS': 85, + 'CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS': 86, + 'CALL_NO_KW_ALLOC_AND_ENTER_INIT': 87, + 'CALL_NO_KW_BUILTIN_FAST': 88, + 'CALL_NO_KW_BUILTIN_O': 89, + 'CALL_NO_KW_ISINSTANCE': 90, + 'CALL_NO_KW_LEN': 91, + 'CALL_NO_KW_LIST_APPEND': 92, + 'CALL_NO_KW_METHOD_DESCRIPTOR_FAST': 93, + 'CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS': 94, + 'CALL_NO_KW_METHOD_DESCRIPTOR_O': 95, + 'CALL_NO_KW_STR_1': 96, + 'CALL_NO_KW_TUPLE_1': 97, + 'CALL_NO_KW_TYPE_1': 98, + 'CALL_PY_EXACT_ARGS': 99, + 'CALL_PY_WITH_DEFAULTS': 100, + 'COMPARE_OP_FLOAT': 102, + 'COMPARE_OP_INT': 103, + 'COMPARE_OP_STR': 104, + 'FOR_ITER_GEN': 119, + 'FOR_ITER_LIST': 120, + 'FOR_ITER_RANGE': 121, + 'FOR_ITER_TUPLE': 122, + 'LOAD_ATTR_CLASS': 133, + 'LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN': 134, + 'LOAD_ATTR_INSTANCE_VALUE': 135, + 'LOAD_ATTR_METHOD_LAZY_DICT': 136, + 'LOAD_ATTR_METHOD_NO_DICT': 137, + 'LOAD_ATTR_METHOD_WITH_VALUES': 138, + 'LOAD_ATTR_MODULE': 139, + 'LOAD_ATTR_NONDESCRIPTOR_NO_DICT': 140, + 'LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES': 141, + 'LOAD_ATTR_PROPERTY': 142, + 'LOAD_ATTR_SLOT': 143, + 'LOAD_ATTR_WITH_HINT': 144, + 'LOAD_GLOBAL_BUILTIN': 154, + 'LOAD_GLOBAL_MODULE': 155, + 'LOAD_SUPER_ATTR_ATTR': 158, + 'LOAD_SUPER_ATTR_METHOD': 159, + 'SEND_GEN': 172, + 'STORE_ATTR_WITH_HINT': 177, + 'UNPACK_SEQUENCE_LIST': 187, + 'UNPACK_SEQUENCE_TUPLE': 188, + 'UNPACK_SEQUENCE_TWO_TUPLE': 189, } opmap = { @@ -235,68 +241,68 @@ 'CALL_INTRINSIC_1': 80, 'CALL_INTRINSIC_2': 81, 'CALL_KW': 82, - 'COMPARE_OP': 98, - 'CONTAINS_OP': 102, - 'CONVERT_VALUE': 103, - 'COPY': 104, - 'COPY_FREE_VARS': 105, - 'DELETE_ATTR': 106, - 'DELETE_DEREF': 107, - 'DELETE_FAST': 108, - 'DELETE_GLOBAL': 109, - 'DELETE_NAME': 110, - 'DICT_MERGE': 111, - 'DICT_UPDATE': 112, - 'ENTER_EXECUTOR': 113, - 'EXTENDED_ARG': 114, - 'FOR_ITER': 115, - 'GET_AWAITABLE': 120, - 'IMPORT_FROM': 121, - 'IMPORT_NAME': 122, - 'IS_OP': 123, - 'JUMP_BACKWARD': 124, - 'JUMP_BACKWARD_NO_INTERRUPT': 125, - 'JUMP_FORWARD': 126, - 'LIST_APPEND': 127, - 'LIST_EXTEND': 128, - 'LOAD_ATTR': 129, - 'LOAD_CONST': 142, - 'LOAD_DEREF': 143, - 'LOAD_FAST': 144, - 'LOAD_FAST_AND_CLEAR': 145, - 'LOAD_FAST_CHECK': 146, - 'LOAD_FAST_LOAD_FAST': 147, - 'LOAD_FROM_DICT_OR_DEREF': 148, - 'LOAD_FROM_DICT_OR_GLOBALS': 149, - 'LOAD_GLOBAL': 150, - 'LOAD_NAME': 153, - 'LOAD_SUPER_ATTR': 154, - 'MAKE_CELL': 157, - 'MAP_ADD': 158, - 'MATCH_CLASS': 159, - 'POP_JUMP_IF_FALSE': 160, - 'POP_JUMP_IF_NONE': 161, - 'POP_JUMP_IF_NOT_NONE': 162, - 'POP_JUMP_IF_TRUE': 163, - 'RAISE_VARARGS': 164, - 'RERAISE': 165, + 'COMPARE_OP': 101, + 'CONTAINS_OP': 105, + 'CONVERT_VALUE': 106, + 'COPY': 107, + 'COPY_FREE_VARS': 108, + 'DELETE_ATTR': 109, + 'DELETE_DEREF': 110, + 'DELETE_FAST': 111, + 'DELETE_GLOBAL': 112, + 'DELETE_NAME': 113, + 'DICT_MERGE': 114, + 'DICT_UPDATE': 115, + 'ENTER_EXECUTOR': 116, + 'EXTENDED_ARG': 117, + 'FOR_ITER': 118, + 'GET_AWAITABLE': 123, + 'IMPORT_FROM': 124, + 'IMPORT_NAME': 125, + 'IS_OP': 126, + 'JUMP_BACKWARD': 127, + 'JUMP_BACKWARD_NO_INTERRUPT': 128, + 'JUMP_FORWARD': 129, + 'LIST_APPEND': 130, + 'LIST_EXTEND': 131, + 'LOAD_ATTR': 132, + 'LOAD_CONST': 145, + 'LOAD_DEREF': 146, + 'LOAD_FAST': 147, + 'LOAD_FAST_AND_CLEAR': 148, + 'LOAD_FAST_CHECK': 149, + 'LOAD_FAST_LOAD_FAST': 150, + 'LOAD_FROM_DICT_OR_DEREF': 151, + 'LOAD_FROM_DICT_OR_GLOBALS': 152, + 'LOAD_GLOBAL': 153, + 'LOAD_NAME': 156, + 'LOAD_SUPER_ATTR': 157, + 'MAKE_CELL': 160, + 'MAP_ADD': 161, + 'MATCH_CLASS': 162, + 'POP_JUMP_IF_FALSE': 163, + 'POP_JUMP_IF_NONE': 164, + 'POP_JUMP_IF_NOT_NONE': 165, 'RESUME': 166, - 'RETURN_CONST': 167, - 'SEND': 168, - 'SET_ADD': 170, - 'SET_FUNCTION_ATTRIBUTE': 171, - 'SET_UPDATE': 172, - 'STORE_ATTR': 173, - 'STORE_DEREF': 175, - 'STORE_FAST': 176, - 'STORE_FAST_LOAD_FAST': 177, - 'STORE_FAST_STORE_FAST': 178, - 'STORE_GLOBAL': 179, - 'STORE_NAME': 180, - 'SWAP': 181, - 'UNPACK_EX': 182, - 'UNPACK_SEQUENCE': 183, - 'YIELD_VALUE': 187, + 'POP_JUMP_IF_TRUE': 167, + 'RAISE_VARARGS': 168, + 'RERAISE': 169, + 'RETURN_CONST': 170, + 'SEND': 171, + 'SET_ADD': 173, + 'SET_FUNCTION_ATTRIBUTE': 174, + 'SET_UPDATE': 175, + 'STORE_ATTR': 176, + 'STORE_DEREF': 178, + 'STORE_FAST': 179, + 'STORE_FAST_LOAD_FAST': 180, + 'STORE_FAST_STORE_FAST': 181, + 'STORE_GLOBAL': 182, + 'STORE_NAME': 183, + 'SWAP': 184, + 'UNPACK_EX': 185, + 'UNPACK_SEQUENCE': 186, + 'YIELD_VALUE': 190, 'INSTRUMENTED_RESUME': 236, 'INSTRUMENTED_END_FOR': 237, 'INSTRUMENTED_END_SEND': 238, diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index fd588297e57b46..ba77c5d076cce7 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1640,197 +1640,197 @@ def _prepare_test_cases(): Instruction = dis.Instruction expected_opinfo_outer = [ - Instruction(opname='MAKE_CELL', opcode=157, arg=0, argval='a', argrepr='a', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='MAKE_CELL', opcode=157, arg=1, argval='b', argrepr='b', offset=2, start_offset=2, starts_line=False, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='MAKE_CELL', opcode=160, arg=0, argval='a', argrepr='a', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='MAKE_CELL', opcode=160, arg=1, argval='b', argrepr='b', offset=2, start_offset=2, starts_line=False, line_number=None, is_jump_target=False, positions=None), Instruction(opname='RESUME', opcode=166, arg=0, argval=0, argrepr='', offset=4, start_offset=4, starts_line=True, line_number=1, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=5, argval=(3, 4), argrepr='(3, 4)', offset=6, start_offset=6, starts_line=True, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='a', argrepr='a', offset=8, start_offset=8, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=1, argval='b', argrepr='b', offset=10, start_offset=10, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=5, argval=(3, 4), argrepr='(3, 4)', offset=6, start_offset=6, starts_line=True, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='a', argrepr='a', offset=8, start_offset=8, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=1, argval='b', argrepr='b', offset=10, start_offset=10, starts_line=False, line_number=2, is_jump_target=False, positions=None), Instruction(opname='BUILD_TUPLE', opcode=74, arg=2, argval=2, argrepr='', offset=12, start_offset=12, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=1, argval=code_object_f, argrepr=repr(code_object_f), offset=14, start_offset=14, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=1, argval=code_object_f, argrepr=repr(code_object_f), offset=14, start_offset=14, starts_line=False, line_number=2, is_jump_target=False, positions=None), Instruction(opname='MAKE_FUNCTION', opcode=38, arg=None, argval=None, argrepr='', offset=16, start_offset=16, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=171, arg=8, argval=8, argrepr='closure', offset=18, start_offset=18, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=171, arg=1, argval=1, argrepr='defaults', offset=20, start_offset=20, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='STORE_FAST', opcode=176, arg=2, argval='f', argrepr='f', offset=22, start_offset=22, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=1, argval='print', argrepr='print + NULL', offset=24, start_offset=24, starts_line=True, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=143, arg=0, argval='a', argrepr='a', offset=34, start_offset=34, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=143, arg=1, argval='b', argrepr='b', offset=36, start_offset=36, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=2, argval='', argrepr="''", offset=38, start_offset=38, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=3, argval=1, argrepr='1', offset=40, start_offset=40, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=174, arg=8, argval=8, argrepr='closure', offset=18, start_offset=18, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=174, arg=1, argval=1, argrepr='defaults', offset=20, start_offset=20, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='STORE_FAST', opcode=179, arg=2, argval='f', argrepr='f', offset=22, start_offset=22, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=1, argval='print', argrepr='print + NULL', offset=24, start_offset=24, starts_line=True, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=146, arg=0, argval='a', argrepr='a', offset=34, start_offset=34, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=146, arg=1, argval='b', argrepr='b', offset=36, start_offset=36, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=2, argval='', argrepr="''", offset=38, start_offset=38, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=3, argval=1, argrepr='1', offset=40, start_offset=40, starts_line=False, line_number=7, is_jump_target=False, positions=None), Instruction(opname='BUILD_LIST', opcode=69, arg=0, argval=0, argrepr='', offset=42, start_offset=42, starts_line=False, line_number=7, is_jump_target=False, positions=None), Instruction(opname='BUILD_MAP', opcode=70, arg=0, argval=0, argrepr='', offset=44, start_offset=44, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=4, argval='Hello world!', argrepr="'Hello world!'", offset=46, start_offset=46, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=4, argval='Hello world!', argrepr="'Hello world!'", offset=46, start_offset=46, starts_line=False, line_number=7, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=7, argval=7, argrepr='', offset=48, start_offset=48, starts_line=False, line_number=7, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=56, start_offset=56, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=2, argval='f', argrepr='f', offset=58, start_offset=58, starts_line=True, line_number=8, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=2, argval='f', argrepr='f', offset=58, start_offset=58, starts_line=True, line_number=8, is_jump_target=False, positions=None), Instruction(opname='RETURN_VALUE', opcode=48, arg=None, argval=None, argrepr='', offset=60, start_offset=60, starts_line=False, line_number=8, is_jump_target=False, positions=None), ] expected_opinfo_f = [ - Instruction(opname='COPY_FREE_VARS', opcode=104, arg=2, argval=2, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='MAKE_CELL', opcode=157, arg=0, argval='c', argrepr='c', offset=2, start_offset=2, starts_line=False, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='MAKE_CELL', opcode=157, arg=1, argval='d', argrepr='d', offset=4, start_offset=4, starts_line=False, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='COPY_FREE_VARS', opcode=108, arg=2, argval=2, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='MAKE_CELL', opcode=160, arg=0, argval='c', argrepr='c', offset=2, start_offset=2, starts_line=False, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='MAKE_CELL', opcode=160, arg=1, argval='d', argrepr='d', offset=4, start_offset=4, starts_line=False, line_number=None, is_jump_target=False, positions=None), Instruction(opname='RESUME', opcode=166, arg=0, argval=0, argrepr='', offset=6, start_offset=6, starts_line=True, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=2, argval=(5, 6), argrepr='(5, 6)', offset=8, start_offset=8, starts_line=True, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=3, argval='a', argrepr='a', offset=10, start_offset=10, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=4, argval='b', argrepr='b', offset=12, start_offset=12, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='c', argrepr='c', offset=14, start_offset=14, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=1, argval='d', argrepr='d', offset=16, start_offset=16, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=2, argval=(5, 6), argrepr='(5, 6)', offset=8, start_offset=8, starts_line=True, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=3, argval='a', argrepr='a', offset=10, start_offset=10, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=4, argval='b', argrepr='b', offset=12, start_offset=12, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='c', argrepr='c', offset=14, start_offset=14, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=1, argval='d', argrepr='d', offset=16, start_offset=16, starts_line=False, line_number=3, is_jump_target=False, positions=None), Instruction(opname='BUILD_TUPLE', opcode=74, arg=4, argval=4, argrepr='', offset=18, start_offset=18, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=1, argval=code_object_inner, argrepr=repr(code_object_inner), offset=20, start_offset=20, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=1, argval=code_object_inner, argrepr=repr(code_object_inner), offset=20, start_offset=20, starts_line=False, line_number=3, is_jump_target=False, positions=None), Instruction(opname='MAKE_FUNCTION', opcode=38, arg=None, argval=None, argrepr='', offset=22, start_offset=22, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=171, arg=8, argval=8, argrepr='closure', offset=24, start_offset=24, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=171, arg=1, argval=1, argrepr='defaults', offset=26, start_offset=26, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='STORE_FAST', opcode=176, arg=2, argval='inner', argrepr='inner', offset=28, start_offset=28, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=1, argval='print', argrepr='print + NULL', offset=30, start_offset=30, starts_line=True, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=143, arg=3, argval='a', argrepr='a', offset=40, start_offset=40, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=143, arg=4, argval='b', argrepr='b', offset=42, start_offset=42, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=143, arg=0, argval='c', argrepr='c', offset=44, start_offset=44, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=143, arg=1, argval='d', argrepr='d', offset=46, start_offset=46, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=174, arg=8, argval=8, argrepr='closure', offset=24, start_offset=24, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=174, arg=1, argval=1, argrepr='defaults', offset=26, start_offset=26, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='STORE_FAST', opcode=179, arg=2, argval='inner', argrepr='inner', offset=28, start_offset=28, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=1, argval='print', argrepr='print + NULL', offset=30, start_offset=30, starts_line=True, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=146, arg=3, argval='a', argrepr='a', offset=40, start_offset=40, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=146, arg=4, argval='b', argrepr='b', offset=42, start_offset=42, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=146, arg=0, argval='c', argrepr='c', offset=44, start_offset=44, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=146, arg=1, argval='d', argrepr='d', offset=46, start_offset=46, starts_line=False, line_number=5, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=4, argval=4, argrepr='', offset=48, start_offset=48, starts_line=False, line_number=5, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=56, start_offset=56, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=2, argval='inner', argrepr='inner', offset=58, start_offset=58, starts_line=True, line_number=6, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=2, argval='inner', argrepr='inner', offset=58, start_offset=58, starts_line=True, line_number=6, is_jump_target=False, positions=None), Instruction(opname='RETURN_VALUE', opcode=48, arg=None, argval=None, argrepr='', offset=60, start_offset=60, starts_line=False, line_number=6, is_jump_target=False, positions=None), ] expected_opinfo_inner = [ - Instruction(opname='COPY_FREE_VARS', opcode=104, arg=4, argval=4, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='COPY_FREE_VARS', opcode=108, arg=4, argval=4, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), Instruction(opname='RESUME', opcode=166, arg=0, argval=0, argrepr='', offset=2, start_offset=2, starts_line=True, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=1, argval='print', argrepr='print + NULL', offset=4, start_offset=4, starts_line=True, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=143, arg=2, argval='a', argrepr='a', offset=14, start_offset=14, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=143, arg=3, argval='b', argrepr='b', offset=16, start_offset=16, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=143, arg=4, argval='c', argrepr='c', offset=18, start_offset=18, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=143, arg=5, argval='d', argrepr='d', offset=20, start_offset=20, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST_LOAD_FAST', opcode=147, arg=1, argval=('e', 'f'), argrepr='e, f', offset=22, start_offset=22, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=1, argval='print', argrepr='print + NULL', offset=4, start_offset=4, starts_line=True, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=146, arg=2, argval='a', argrepr='a', offset=14, start_offset=14, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=146, arg=3, argval='b', argrepr='b', offset=16, start_offset=16, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=146, arg=4, argval='c', argrepr='c', offset=18, start_offset=18, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=146, arg=5, argval='d', argrepr='d', offset=20, start_offset=20, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST_LOAD_FAST', opcode=150, arg=1, argval=('e', 'f'), argrepr='e, f', offset=22, start_offset=22, starts_line=False, line_number=4, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=6, argval=6, argrepr='', offset=24, start_offset=24, starts_line=False, line_number=4, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=32, start_offset=32, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='RETURN_CONST', opcode=167, arg=0, argval=None, argrepr='None', offset=34, start_offset=34, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='RETURN_CONST', opcode=170, arg=0, argval=None, argrepr='None', offset=34, start_offset=34, starts_line=False, line_number=4, is_jump_target=False, positions=None), ] expected_opinfo_jumpy = [ Instruction(opname='RESUME', opcode=166, arg=0, argval=0, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=1, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=1, argval='range', argrepr='range + NULL', offset=2, start_offset=2, starts_line=True, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=1, argval=10, argrepr='10', offset=12, start_offset=12, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=1, argval='range', argrepr='range + NULL', offset=2, start_offset=2, starts_line=True, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=1, argval=10, argrepr='10', offset=12, start_offset=12, starts_line=False, line_number=3, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=14, start_offset=14, starts_line=False, line_number=3, is_jump_target=False, positions=None), Instruction(opname='GET_ITER', opcode=31, arg=None, argval=None, argrepr='', offset=22, start_offset=22, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='FOR_ITER', opcode=114, arg=28, argval=84, argrepr='to 84', offset=24, start_offset=24, starts_line=False, line_number=3, is_jump_target=True, positions=None), - Instruction(opname='STORE_FAST', opcode=176, arg=0, argval='i', argrepr='i', offset=28, start_offset=28, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=30, start_offset=30, starts_line=True, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=40, start_offset=40, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='FOR_ITER', opcode=118, arg=28, argval=84, argrepr='to 84', offset=24, start_offset=24, starts_line=False, line_number=3, is_jump_target=True, positions=None), + Instruction(opname='STORE_FAST', opcode=179, arg=0, argval='i', argrepr='i', offset=28, start_offset=28, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=30, start_offset=30, starts_line=True, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=40, start_offset=40, starts_line=False, line_number=4, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=42, start_offset=42, starts_line=False, line_number=4, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=50, start_offset=50, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=52, start_offset=52, starts_line=True, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=2, argval=4, argrepr='4', offset=54, start_offset=54, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=97, arg=18, argval='<', argrepr='bool(<)', offset=56, start_offset=56, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=2, argval=66, argrepr='to 66', offset=60, start_offset=60, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=123, arg=21, argval=24, argrepr='to 24', offset=62, start_offset=62, starts_line=True, line_number=6, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=66, start_offset=66, starts_line=True, line_number=7, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=3, argval=6, argrepr='6', offset=68, start_offset=68, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=97, arg=148, argval='>', argrepr='bool(>)', offset=70, start_offset=70, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_TRUE', opcode=163, arg=2, argval=80, argrepr='to 80', offset=74, start_offset=74, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=123, arg=28, argval=24, argrepr='to 24', offset=76, start_offset=76, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=52, start_offset=52, starts_line=True, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=2, argval=4, argrepr='4', offset=54, start_offset=54, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=101, arg=18, argval='<', argrepr='bool(<)', offset=56, start_offset=56, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=2, argval=66, argrepr='to 66', offset=60, start_offset=60, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=127, arg=21, argval=24, argrepr='to 24', offset=62, start_offset=62, starts_line=True, line_number=6, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=66, start_offset=66, starts_line=True, line_number=7, is_jump_target=True, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=3, argval=6, argrepr='6', offset=68, start_offset=68, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=101, arg=148, argval='>', argrepr='bool(>)', offset=70, start_offset=70, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_TRUE', opcode=167, arg=2, argval=80, argrepr='to 80', offset=74, start_offset=74, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=127, arg=28, argval=24, argrepr='to 24', offset=76, start_offset=76, starts_line=False, line_number=7, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=80, start_offset=80, starts_line=True, line_number=8, is_jump_target=True, positions=None), - Instruction(opname='JUMP_FORWARD', opcode=125, arg=12, argval=108, argrepr='to 108', offset=82, start_offset=82, starts_line=False, line_number=8, is_jump_target=False, positions=None), + Instruction(opname='JUMP_FORWARD', opcode=129, arg=12, argval=108, argrepr='to 108', offset=82, start_offset=82, starts_line=False, line_number=8, is_jump_target=False, positions=None), Instruction(opname='END_FOR', opcode=24, arg=None, argval=None, argrepr='', offset=84, start_offset=84, starts_line=True, line_number=3, is_jump_target=True, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=86, start_offset=86, starts_line=True, line_number=10, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=4, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=96, start_offset=96, starts_line=False, line_number=10, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=86, start_offset=86, starts_line=True, line_number=10, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=4, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=96, start_offset=96, starts_line=False, line_number=10, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=98, start_offset=98, starts_line=False, line_number=10, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=106, start_offset=106, starts_line=False, line_number=10, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST_CHECK', opcode=146, arg=0, argval='i', argrepr='i', offset=108, start_offset=108, starts_line=True, line_number=11, is_jump_target=True, positions=None), + Instruction(opname='LOAD_FAST_CHECK', opcode=149, arg=0, argval='i', argrepr='i', offset=108, start_offset=108, starts_line=True, line_number=11, is_jump_target=True, positions=None), Instruction(opname='TO_BOOL', opcode=56, arg=None, argval=None, argrepr='', offset=110, start_offset=110, starts_line=False, line_number=11, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=37, argval=194, argrepr='to 194', offset=118, start_offset=118, starts_line=False, line_number=11, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=120, start_offset=120, starts_line=True, line_number=12, is_jump_target=True, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=130, start_offset=130, starts_line=False, line_number=12, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=37, argval=194, argrepr='to 194', offset=118, start_offset=118, starts_line=False, line_number=11, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=120, start_offset=120, starts_line=True, line_number=12, is_jump_target=True, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=130, start_offset=130, starts_line=False, line_number=12, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=132, start_offset=132, starts_line=False, line_number=12, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=140, start_offset=140, starts_line=False, line_number=12, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=142, start_offset=142, starts_line=True, line_number=13, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=5, argval=1, argrepr='1', offset=144, start_offset=144, starts_line=False, line_number=13, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=142, start_offset=142, starts_line=True, line_number=13, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=5, argval=1, argrepr='1', offset=144, start_offset=144, starts_line=False, line_number=13, is_jump_target=False, positions=None), Instruction(opname='BINARY_OP', opcode=67, arg=23, argval=23, argrepr='-=', offset=146, start_offset=146, starts_line=False, line_number=13, is_jump_target=False, positions=None), - Instruction(opname='STORE_FAST', opcode=176, arg=0, argval='i', argrepr='i', offset=150, start_offset=150, starts_line=False, line_number=13, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=152, start_offset=152, starts_line=True, line_number=14, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=3, argval=6, argrepr='6', offset=154, start_offset=154, starts_line=False, line_number=14, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=97, arg=148, argval='>', argrepr='bool(>)', offset=156, start_offset=156, starts_line=False, line_number=14, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=2, argval=166, argrepr='to 166', offset=160, start_offset=160, starts_line=False, line_number=14, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=123, arg=29, argval=108, argrepr='to 108', offset=162, start_offset=162, starts_line=True, line_number=15, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=166, start_offset=166, starts_line=True, line_number=16, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=2, argval=4, argrepr='4', offset=168, start_offset=168, starts_line=False, line_number=16, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=97, arg=18, argval='<', argrepr='bool(<)', offset=170, start_offset=170, starts_line=False, line_number=16, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=1, argval=178, argrepr='to 178', offset=174, start_offset=174, starts_line=False, line_number=16, is_jump_target=False, positions=None), - Instruction(opname='JUMP_FORWARD', opcode=125, arg=19, argval=216, argrepr='to 216', offset=176, start_offset=176, starts_line=True, line_number=17, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=178, start_offset=178, starts_line=True, line_number=11, is_jump_target=True, positions=None), + Instruction(opname='STORE_FAST', opcode=179, arg=0, argval='i', argrepr='i', offset=150, start_offset=150, starts_line=False, line_number=13, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=152, start_offset=152, starts_line=True, line_number=14, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=3, argval=6, argrepr='6', offset=154, start_offset=154, starts_line=False, line_number=14, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=101, arg=148, argval='>', argrepr='bool(>)', offset=156, start_offset=156, starts_line=False, line_number=14, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=2, argval=166, argrepr='to 166', offset=160, start_offset=160, starts_line=False, line_number=14, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=127, arg=29, argval=108, argrepr='to 108', offset=162, start_offset=162, starts_line=True, line_number=15, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=166, start_offset=166, starts_line=True, line_number=16, is_jump_target=True, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=2, argval=4, argrepr='4', offset=168, start_offset=168, starts_line=False, line_number=16, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=101, arg=18, argval='<', argrepr='bool(<)', offset=170, start_offset=170, starts_line=False, line_number=16, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=1, argval=178, argrepr='to 178', offset=174, start_offset=174, starts_line=False, line_number=16, is_jump_target=False, positions=None), + Instruction(opname='JUMP_FORWARD', opcode=129, arg=19, argval=216, argrepr='to 216', offset=176, start_offset=176, starts_line=True, line_number=17, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=178, start_offset=178, starts_line=True, line_number=11, is_jump_target=True, positions=None), Instruction(opname='TO_BOOL', opcode=56, arg=None, argval=None, argrepr='', offset=180, start_offset=180, starts_line=False, line_number=11, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=2, argval=194, argrepr='to 194', offset=188, start_offset=188, starts_line=False, line_number=11, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=123, arg=37, argval=120, argrepr='to 120', offset=190, start_offset=190, starts_line=False, line_number=11, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=194, start_offset=194, starts_line=True, line_number=19, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=6, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=204, start_offset=204, starts_line=False, line_number=19, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=2, argval=194, argrepr='to 194', offset=188, start_offset=188, starts_line=False, line_number=11, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=127, arg=37, argval=120, argrepr='to 120', offset=190, start_offset=190, starts_line=False, line_number=11, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=194, start_offset=194, starts_line=True, line_number=19, is_jump_target=True, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=6, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=204, start_offset=204, starts_line=False, line_number=19, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=206, start_offset=206, starts_line=False, line_number=19, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=214, start_offset=214, starts_line=False, line_number=19, is_jump_target=False, positions=None), Instruction(opname='NOP', opcode=42, arg=None, argval=None, argrepr='', offset=216, start_offset=216, starts_line=True, line_number=20, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=5, argval=1, argrepr='1', offset=218, start_offset=218, starts_line=True, line_number=21, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=7, argval=0, argrepr='0', offset=220, start_offset=220, starts_line=False, line_number=21, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=5, argval=1, argrepr='1', offset=218, start_offset=218, starts_line=True, line_number=21, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=7, argval=0, argrepr='0', offset=220, start_offset=220, starts_line=False, line_number=21, is_jump_target=False, positions=None), Instruction(opname='BINARY_OP', opcode=67, arg=11, argval=11, argrepr='/', offset=222, start_offset=222, starts_line=False, line_number=21, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=226, start_offset=226, starts_line=False, line_number=21, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=228, start_offset=228, starts_line=True, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=228, start_offset=228, starts_line=True, line_number=25, is_jump_target=False, positions=None), Instruction(opname='BEFORE_WITH', opcode=2, arg=None, argval=None, argrepr='', offset=230, start_offset=230, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='STORE_FAST', opcode=176, arg=1, argval='dodgy', argrepr='dodgy', offset=232, start_offset=232, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=234, start_offset=234, starts_line=True, line_number=26, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=8, argval='Never reach this', argrepr="'Never reach this'", offset=244, start_offset=244, starts_line=False, line_number=26, is_jump_target=False, positions=None), + Instruction(opname='STORE_FAST', opcode=179, arg=1, argval='dodgy', argrepr='dodgy', offset=232, start_offset=232, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=234, start_offset=234, starts_line=True, line_number=26, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=8, argval='Never reach this', argrepr="'Never reach this'", offset=244, start_offset=244, starts_line=False, line_number=26, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=246, start_offset=246, starts_line=False, line_number=26, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=254, start_offset=254, starts_line=False, line_number=26, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=0, argval=None, argrepr='None', offset=256, start_offset=256, starts_line=True, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=0, argval=None, argrepr='None', offset=258, start_offset=258, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=0, argval=None, argrepr='None', offset=260, start_offset=260, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=0, argval=None, argrepr='None', offset=256, start_offset=256, starts_line=True, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=0, argval=None, argrepr='None', offset=258, start_offset=258, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=0, argval=None, argrepr='None', offset=260, start_offset=260, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=2, argval=2, argrepr='', offset=262, start_offset=262, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=270, start_offset=270, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=272, start_offset=272, starts_line=True, line_number=28, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=282, start_offset=282, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=272, start_offset=272, starts_line=True, line_number=28, is_jump_target=True, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=282, start_offset=282, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=284, start_offset=284, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=292, start_offset=292, starts_line=False, line_number=28, is_jump_target=False, positions=None), - Instruction(opname='RETURN_CONST', opcode=167, arg=0, argval=None, argrepr='None', offset=294, start_offset=294, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='RETURN_CONST', opcode=170, arg=0, argval=None, argrepr='None', offset=294, start_offset=294, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='PUSH_EXC_INFO', opcode=45, arg=None, argval=None, argrepr='', offset=296, start_offset=296, starts_line=True, line_number=25, is_jump_target=False, positions=None), Instruction(opname='WITH_EXCEPT_START', opcode=66, arg=None, argval=None, argrepr='', offset=298, start_offset=298, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='TO_BOOL', opcode=56, arg=None, argval=None, argrepr='', offset=300, start_offset=300, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_TRUE', opcode=163, arg=1, argval=312, argrepr='to 312', offset=308, start_offset=308, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=165, arg=2, argval=2, argrepr='', offset=310, start_offset=310, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_TRUE', opcode=167, arg=1, argval=312, argrepr='to 312', offset=308, start_offset=308, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=169, arg=2, argval=2, argrepr='', offset=310, start_offset=310, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=312, start_offset=312, starts_line=False, line_number=25, is_jump_target=True, positions=None), Instruction(opname='POP_EXCEPT', opcode=43, arg=None, argval=None, argrepr='', offset=314, start_offset=314, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=316, start_offset=316, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=318, start_offset=318, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=123, arg=26, argval=272, argrepr='to 272', offset=320, start_offset=320, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='COPY', opcode=103, arg=3, argval=3, argrepr='', offset=324, start_offset=324, starts_line=True, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=127, arg=26, argval=272, argrepr='to 272', offset=320, start_offset=320, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='COPY', opcode=107, arg=3, argval=3, argrepr='', offset=324, start_offset=324, starts_line=True, line_number=None, is_jump_target=False, positions=None), Instruction(opname='POP_EXCEPT', opcode=43, arg=None, argval=None, argrepr='', offset=326, start_offset=326, starts_line=False, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=165, arg=1, argval=1, argrepr='', offset=328, start_offset=328, starts_line=False, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=169, arg=1, argval=1, argrepr='', offset=328, start_offset=328, starts_line=False, line_number=None, is_jump_target=False, positions=None), Instruction(opname='PUSH_EXC_INFO', opcode=45, arg=None, argval=None, argrepr='', offset=330, start_offset=330, starts_line=False, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=4, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=332, start_offset=332, starts_line=True, line_number=22, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=4, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=332, start_offset=332, starts_line=True, line_number=22, is_jump_target=False, positions=None), Instruction(opname='CHECK_EXC_MATCH', opcode=20, arg=None, argval=None, argrepr='', offset=342, start_offset=342, starts_line=False, line_number=22, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=15, argval=376, argrepr='to 376', offset=344, start_offset=344, starts_line=False, line_number=22, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=15, argval=376, argrepr='to 376', offset=344, start_offset=344, starts_line=False, line_number=22, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=346, start_offset=346, starts_line=False, line_number=22, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=348, start_offset=348, starts_line=True, line_number=23, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=9, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=358, start_offset=358, starts_line=False, line_number=23, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=348, start_offset=348, starts_line=True, line_number=23, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=9, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=358, start_offset=358, starts_line=False, line_number=23, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=360, start_offset=360, starts_line=False, line_number=23, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=368, start_offset=368, starts_line=False, line_number=23, is_jump_target=False, positions=None), Instruction(opname='POP_EXCEPT', opcode=43, arg=None, argval=None, argrepr='', offset=370, start_offset=370, starts_line=False, line_number=23, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=123, arg=52, argval=272, argrepr='to 272', offset=372, start_offset=372, starts_line=False, line_number=23, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=165, arg=0, argval=0, argrepr='', offset=376, start_offset=376, starts_line=True, line_number=22, is_jump_target=True, positions=None), - Instruction(opname='COPY', opcode=103, arg=3, argval=3, argrepr='', offset=378, start_offset=378, starts_line=True, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=127, arg=52, argval=272, argrepr='to 272', offset=372, start_offset=372, starts_line=False, line_number=23, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=169, arg=0, argval=0, argrepr='', offset=376, start_offset=376, starts_line=True, line_number=22, is_jump_target=True, positions=None), + Instruction(opname='COPY', opcode=107, arg=3, argval=3, argrepr='', offset=378, start_offset=378, starts_line=True, line_number=None, is_jump_target=False, positions=None), Instruction(opname='POP_EXCEPT', opcode=43, arg=None, argval=None, argrepr='', offset=380, start_offset=380, starts_line=False, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=165, arg=1, argval=1, argrepr='', offset=382, start_offset=382, starts_line=False, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=169, arg=1, argval=1, argrepr='', offset=382, start_offset=382, starts_line=False, line_number=None, is_jump_target=False, positions=None), Instruction(opname='PUSH_EXC_INFO', opcode=45, arg=None, argval=None, argrepr='', offset=384, start_offset=384, starts_line=False, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=386, start_offset=386, starts_line=True, line_number=28, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=142, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=396, start_offset=396, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=386, start_offset=386, starts_line=True, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=145, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=396, start_offset=396, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=398, start_offset=398, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=406, start_offset=406, starts_line=False, line_number=28, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=165, arg=0, argval=0, argrepr='', offset=408, start_offset=408, starts_line=False, line_number=28, is_jump_target=False, positions=None), - Instruction(opname='COPY', opcode=103, arg=3, argval=3, argrepr='', offset=410, start_offset=410, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=169, arg=0, argval=0, argrepr='', offset=408, start_offset=408, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='COPY', opcode=107, arg=3, argval=3, argrepr='', offset=410, start_offset=410, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='POP_EXCEPT', opcode=43, arg=None, argval=None, argrepr='', offset=412, start_offset=412, starts_line=False, line_number=28, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=165, arg=1, argval=1, argrepr='', offset=414, start_offset=414, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=169, arg=1, argval=1, argrepr='', offset=414, start_offset=414, starts_line=False, line_number=28, is_jump_target=False, positions=None), ] # One last piece of inspect fodder to check the default line number handling def simple(): pass expected_opinfo_simple = [ Instruction(opname='RESUME', opcode=166, arg=0, argval=0, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=simple.__code__.co_firstlineno, is_jump_target=False, positions=None), - Instruction(opname='RETURN_CONST', opcode=167, arg=0, argval=None, argrepr='None', offset=2, start_offset=2, starts_line=False, line_number=simple.__code__.co_firstlineno, is_jump_target=False), + Instruction(opname='RETURN_CONST', opcode=170, arg=0, argval=None, argrepr='None', offset=2, start_offset=2, starts_line=False, line_number=simple.__code__.co_firstlineno, is_jump_target=False), ] diff --git a/Programs/test_frozenmain.h b/Programs/test_frozenmain.h index 42b8b78dfc51f8..302379a4be12f1 100644 --- a/Programs/test_frozenmain.h +++ b/Programs/test_frozenmain.h @@ -1,17 +1,17 @@ // Auto-generated by Programs/freeze_test_frozenmain.py unsigned char M_test_frozenmain[] = { 227,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0, - 0,0,0,0,0,243,164,0,0,0,166,0,142,0,142,1, - 122,0,180,0,142,0,142,1,122,1,180,1,153,2,46,0, - 142,2,75,1,0,0,0,0,0,0,44,0,153,2,46,0, - 142,3,153,0,129,6,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,243,164,0,0,0,166,0,145,0,145,1, + 125,0,183,0,145,0,145,1,125,1,183,1,156,2,46,0, + 145,2,75,1,0,0,0,0,0,0,44,0,156,2,46,0, + 145,3,156,0,132,6,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,75,2,0,0,0,0,0,0, - 44,0,153,1,129,8,0,0,0,0,0,0,0,0,0,0, + 44,0,156,1,132,8,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,46,0,75,0,0,0,0,0, - 0,0,142,4,12,0,0,0,180,5,142,5,31,0,115,20, - 0,0,180,6,153,2,46,0,142,6,153,6,27,0,142,7, - 153,5,153,6,12,0,0,0,27,0,73,4,75,1,0,0, - 0,0,0,0,44,0,124,22,0,0,24,0,167,1,41,8, + 0,0,145,4,12,0,0,0,183,5,145,5,31,0,118,20, + 0,0,183,6,156,2,46,0,145,6,156,6,27,0,145,7, + 156,5,156,6,12,0,0,0,27,0,73,4,75,1,0,0, + 0,0,0,0,44,0,127,22,0,0,24,0,170,1,41,8, 233,0,0,0,0,78,122,18,70,114,111,122,101,110,32,72, 101,108,108,111,32,87,111,114,108,100,122,8,115,121,115,46, 97,114,103,118,218,6,99,111,110,102,105,103,41,5,218,12, diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 9eabd5b6fc80e0..4311ca12361cff 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -74,7 +74,6 @@ dummy_func( unsigned int oparg, _Py_CODEUNIT *next_instr, PyObject **stack_pointer, - PyObject *kwnames, int throwflag, PyObject *args[] ) @@ -2834,15 +2833,15 @@ dummy_func( CALL_NO_KW_TYPE_1, CALL_NO_KW_STR_1, CALL_NO_KW_TUPLE_1, - // CALL_BUILTIN_CLASS, + CALL_BUILTIN_CLASS, CALL_NO_KW_BUILTIN_O, CALL_NO_KW_BUILTIN_FAST, - // CALL_BUILTIN_FAST_WITH_KEYWORDS, + CALL_BUILTIN_FAST_WITH_KEYWORDS, CALL_NO_KW_LEN, CALL_NO_KW_ISINSTANCE, CALL_NO_KW_LIST_APPEND, CALL_NO_KW_METHOD_DESCRIPTOR_O, - // CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, + CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS, CALL_NO_KW_METHOD_DESCRIPTOR_FAST, CALL_NO_KW_ALLOC_AND_ENTER_INIT, @@ -3157,13 +3156,14 @@ dummy_func( } } - inst(CALL_BUILTIN_CLASS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { + inst(CALL_BUILTIN_CLASS, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { int total_args = oparg; if (self_or_null != NULL) { args--; total_args++; } - int kwnames_len = (int)PyTuple_GET_SIZE(kwnames); + PyObject *kwnames = NULL; + int kwnames_len = 0; DEOPT_IF(!PyType_Check(callable), CALL); PyTypeObject *tp = (PyTypeObject *)callable; DEOPT_IF(tp->tp_vectorcall == NULL, CALL); @@ -3179,6 +3179,29 @@ dummy_func( CHECK_EVAL_BREAKER(); } + inst(CALL_KW_BUILTIN_CLASS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { + int total_args = oparg; + if (self_or_null != NULL) { + args--; + total_args++; + } + int kwnames_len = (int)PyTuple_GET_SIZE(kwnames); + DEOPT_IF(!PyType_Check(callable), CALL_KW); + PyTypeObject *tp = (PyTypeObject *)callable; + DEOPT_IF(tp->tp_vectorcall == NULL, CALL_KW); + STAT_INC(CALL_KW, hit); + res = tp->tp_vectorcall((PyObject *)tp, args, + total_args - kwnames_len, kwnames); + Py_DECREF(kwnames); + /* Free the arguments. */ + for (int i = 0; i < total_args; i++) { + Py_DECREF(args[i]); + } + Py_DECREF(tp); + ERROR_IF(res == NULL, error); + CHECK_EVAL_BREAKER(); + } + inst(CALL_NO_KW_BUILTIN_O, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { /* Builtin METH_O functions */ int total_args = oparg; @@ -3239,13 +3262,15 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_BUILTIN_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { + inst(CALL_BUILTIN_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int total_args = oparg; if (self_or_null != NULL) { args--; total_args++; } + PyObject *kwnames = NULL; + int kwnames_len = 0; DEOPT_IF(!PyCFunction_CheckExact(callable), CALL); DEOPT_IF(PyCFunction_GET_FLAGS(callable) != (METH_FASTCALL | METH_KEYWORDS), CALL); @@ -3257,7 +3282,7 @@ dummy_func( res = cfunc( PyCFunction_GET_SELF(callable), args, - total_args - (int)PyTuple_GET_SIZE(kwnames), + total_args - kwnames_len, kwnames ); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); @@ -3271,6 +3296,38 @@ dummy_func( CHECK_EVAL_BREAKER(); } + inst(CALL_KW_BUILTIN_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { + /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ + int total_args = oparg; + if (self_or_null != NULL) { + args--; + total_args++; + } + DEOPT_IF(!PyCFunction_CheckExact(callable), CALL_KW); + DEOPT_IF(PyCFunction_GET_FLAGS(callable) != + (METH_FASTCALL | METH_KEYWORDS), CALL_KW); + STAT_INC(CALL_KW, hit); + /* res = func(self, args, nargs, kwnames) */ + _PyCFunctionFastWithKeywords cfunc = + (_PyCFunctionFastWithKeywords)(void(*)(void)) + PyCFunction_GET_FUNCTION(callable); + res = cfunc( + PyCFunction_GET_SELF(callable), + args, + total_args - (int)PyTuple_GET_SIZE(kwnames), + kwnames + ); + assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); + Py_DECREF(kwnames); + /* Free the arguments. */ + for (int i = 0; i < total_args; i++) { + Py_DECREF(args[i]); + } + Py_DECREF(callable); + ERROR_IF(res == NULL, error); + CHECK_EVAL_BREAKER(); + } + inst(CALL_NO_KW_LEN, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { /* len(o) */ int total_args = oparg; @@ -3372,12 +3429,14 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { + inst(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { int total_args = oparg; if (self_or_null != NULL) { args--; total_args++; } + PyObject *kwnames = NULL; + int kwnames_len = 0; PyMethodDescrObject *method = (PyMethodDescrObject *)callable; DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL); PyMethodDef *meth = method->d_method; @@ -3389,7 +3448,7 @@ dummy_func( int nargs = total_args - 1; _PyCFunctionFastWithKeywords cfunc = (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth; - res = cfunc(self, args + 1, nargs - (int)PyTuple_GET_SIZE(kwnames), kwnames); + res = cfunc(self, args + 1, nargs - kwnames_len, kwnames); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); /* Free the arguments. */ @@ -3401,6 +3460,35 @@ dummy_func( CHECK_EVAL_BREAKER(); } + inst(CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { + int total_args = oparg; + if (self_or_null != NULL) { + args--; + total_args++; + } + PyMethodDescrObject *method = (PyMethodDescrObject *)callable; + DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL_KW); + PyMethodDef *meth = method->d_method; + DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL_KW); + PyTypeObject *d_type = method->d_common.d_type; + PyObject *self = args[0]; + DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL_KW); + STAT_INC(CALL_KW, hit); + int nargs = total_args - 1; + _PyCFunctionFastWithKeywords cfunc = + (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth; + res = cfunc(self, args + 1, nargs - (int)PyTuple_GET_SIZE(kwnames), kwnames); + assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); + Py_DECREF(kwnames); + /* Free the arguments. */ + for (int i = 0; i < total_args; i++) { + Py_DECREF(args[i]); + } + Py_DECREF(callable); + ERROR_IF(res == NULL, error); + CHECK_EVAL_BREAKER(); + } + inst(CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { assert(oparg == 0 || oparg == 1); int total_args = oparg; @@ -3476,9 +3564,9 @@ dummy_func( // Cache layout: counter/1, func_version/2 family(CALL_KW, INLINE_CACHE_ENTRIES_CALL) = { - CALL_BUILTIN_CLASS, - CALL_BUILTIN_FAST_WITH_KEYWORDS, - CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, + CALL_KW_BUILTIN_CLASS, + CALL_KW_BUILTIN_FAST_WITH_KEYWORDS, + CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, }; inst(CALL_KW, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 0ca4ecd6eb943e..74d0a2ca5520a1 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -4145,6 +4145,41 @@ } TARGET(CALL_BUILTIN_CLASS) { + PyObject **args; + PyObject *self_or_null; + PyObject *callable; + PyObject *res; + args = stack_pointer - oparg; + self_or_null = stack_pointer[-1 - oparg]; + callable = stack_pointer[-2 - oparg]; + int total_args = oparg; + if (self_or_null != NULL) { + args--; + total_args++; + } + PyObject *kwnames = NULL; + int kwnames_len = 0; + DEOPT_IF(!PyType_Check(callable), CALL); + PyTypeObject *tp = (PyTypeObject *)callable; + DEOPT_IF(tp->tp_vectorcall == NULL, CALL); + STAT_INC(CALL, hit); + res = tp->tp_vectorcall((PyObject *)tp, args, + total_args - kwnames_len, kwnames); + /* Free the arguments. */ + for (int i = 0; i < total_args; i++) { + Py_DECREF(args[i]); + } + Py_DECREF(tp); + if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + STACK_SHRINK(oparg); + STACK_SHRINK(1); + stack_pointer[-1] = res; + next_instr += 3; + CHECK_EVAL_BREAKER(); + DISPATCH(); + } + + TARGET(CALL_KW_BUILTIN_CLASS) { PyObject *kwnames; PyObject **args; PyObject *self_or_null; @@ -4160,12 +4195,13 @@ total_args++; } int kwnames_len = (int)PyTuple_GET_SIZE(kwnames); - DEOPT_IF(!PyType_Check(callable), CALL); + DEOPT_IF(!PyType_Check(callable), CALL_KW); PyTypeObject *tp = (PyTypeObject *)callable; - DEOPT_IF(tp->tp_vectorcall == NULL, CALL); - STAT_INC(CALL, hit); + DEOPT_IF(tp->tp_vectorcall == NULL, CALL_KW); + STAT_INC(CALL_KW, hit); res = tp->tp_vectorcall((PyObject *)tp, args, total_args - kwnames_len, kwnames); + Py_DECREF(kwnames); /* Free the arguments. */ for (int i = 0; i < total_args; i++) { Py_DECREF(args[i]); @@ -4265,6 +4301,52 @@ } TARGET(CALL_BUILTIN_FAST_WITH_KEYWORDS) { + PyObject **args; + PyObject *self_or_null; + PyObject *callable; + PyObject *res; + args = stack_pointer - oparg; + self_or_null = stack_pointer[-1 - oparg]; + callable = stack_pointer[-2 - oparg]; + /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ + int total_args = oparg; + if (self_or_null != NULL) { + args--; + total_args++; + } + PyObject *kwnames = NULL; + int kwnames_len = 0; + DEOPT_IF(!PyCFunction_CheckExact(callable), CALL); + DEOPT_IF(PyCFunction_GET_FLAGS(callable) != + (METH_FASTCALL | METH_KEYWORDS), CALL); + STAT_INC(CALL, hit); + /* res = func(self, args, nargs, kwnames) */ + _PyCFunctionFastWithKeywords cfunc = + (_PyCFunctionFastWithKeywords)(void(*)(void)) + PyCFunction_GET_FUNCTION(callable); + res = cfunc( + PyCFunction_GET_SELF(callable), + args, + total_args - kwnames_len, + kwnames + ); + assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); + + /* Free the arguments. */ + for (int i = 0; i < total_args; i++) { + Py_DECREF(args[i]); + } + Py_DECREF(callable); + if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + STACK_SHRINK(oparg); + STACK_SHRINK(1); + stack_pointer[-1] = res; + next_instr += 3; + CHECK_EVAL_BREAKER(); + DISPATCH(); + } + + TARGET(CALL_KW_BUILTIN_FAST_WITH_KEYWORDS) { PyObject *kwnames; PyObject **args; PyObject *self_or_null; @@ -4280,10 +4362,10 @@ args--; total_args++; } - DEOPT_IF(!PyCFunction_CheckExact(callable), CALL); + DEOPT_IF(!PyCFunction_CheckExact(callable), CALL_KW); DEOPT_IF(PyCFunction_GET_FLAGS(callable) != - (METH_FASTCALL | METH_KEYWORDS), CALL); - STAT_INC(CALL, hit); + (METH_FASTCALL | METH_KEYWORDS), CALL_KW); + STAT_INC(CALL_KW, hit); /* res = func(self, args, nargs, kwnames) */ _PyCFunctionFastWithKeywords cfunc = (_PyCFunctionFastWithKeywords)(void(*)(void)) @@ -4295,7 +4377,7 @@ kwnames ); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - + Py_DECREF(kwnames); /* Free the arguments. */ for (int i = 0; i < total_args; i++) { Py_DECREF(args[i]); @@ -4455,6 +4537,49 @@ } TARGET(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS) { + PyObject **args; + PyObject *self_or_null; + PyObject *callable; + PyObject *res; + args = stack_pointer - oparg; + self_or_null = stack_pointer[-1 - oparg]; + callable = stack_pointer[-2 - oparg]; + int total_args = oparg; + if (self_or_null != NULL) { + args--; + total_args++; + } + PyObject *kwnames = NULL; + int kwnames_len = 0; + PyMethodDescrObject *method = (PyMethodDescrObject *)callable; + DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL); + PyMethodDef *meth = method->d_method; + DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL); + PyTypeObject *d_type = method->d_common.d_type; + PyObject *self = args[0]; + DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL); + STAT_INC(CALL, hit); + int nargs = total_args - 1; + _PyCFunctionFastWithKeywords cfunc = + (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth; + res = cfunc(self, args + 1, nargs - kwnames_len, kwnames); + assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); + + /* Free the arguments. */ + for (int i = 0; i < total_args; i++) { + Py_DECREF(args[i]); + } + Py_DECREF(callable); + if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + STACK_SHRINK(oparg); + STACK_SHRINK(1); + stack_pointer[-1] = res; + next_instr += 3; + CHECK_EVAL_BREAKER(); + DISPATCH(); + } + + TARGET(CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS) { PyObject *kwnames; PyObject **args; PyObject *self_or_null; @@ -4470,19 +4595,19 @@ total_args++; } PyMethodDescrObject *method = (PyMethodDescrObject *)callable; - DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL); + DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL_KW); PyMethodDef *meth = method->d_method; - DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL); + DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL_KW); PyTypeObject *d_type = method->d_common.d_type; PyObject *self = args[0]; - DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL); - STAT_INC(CALL, hit); + DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL_KW); + STAT_INC(CALL_KW, hit); int nargs = total_args - 1; _PyCFunctionFastWithKeywords cfunc = (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth; res = cfunc(self, args + 1, nargs - (int)PyTuple_GET_SIZE(kwnames), kwnames); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - + Py_DECREF(kwnames); /* Free the arguments. */ for (int i = 0; i < total_args; i++) { Py_DECREF(args[i]); diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index bff39a7aca2bf0..e3b664b19b5a48 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -82,6 +82,9 @@ static void *opcode_targets[256] = { &&TARGET_CALL_INTRINSIC_1, &&TARGET_CALL_INTRINSIC_2, &&TARGET_CALL_KW, + &&TARGET_CALL_KW_BUILTIN_CLASS, + &&TARGET_CALL_KW_BUILTIN_FAST_WITH_KEYWORDS, + &&TARGET_CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, &&TARGET_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, &&TARGET_CALL_NO_KW_ALLOC_AND_ENTER_INIT, &&TARGET_CALL_NO_KW_BUILTIN_FAST, @@ -162,10 +165,10 @@ static void *opcode_targets[256] = { &&TARGET_POP_JUMP_IF_FALSE, &&TARGET_POP_JUMP_IF_NONE, &&TARGET_POP_JUMP_IF_NOT_NONE, + &&TARGET_RESUME, &&TARGET_POP_JUMP_IF_TRUE, &&TARGET_RAISE_VARARGS, &&TARGET_RERAISE, - &&TARGET_RESUME, &&TARGET_RETURN_CONST, &&TARGET_SEND, &&TARGET_SEND_GEN, @@ -232,9 +235,6 @@ static void *opcode_targets[256] = { &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, &&TARGET_INSTRUMENTED_RESUME, &&TARGET_INSTRUMENTED_END_FOR, &&TARGET_INSTRUMENTED_END_SEND, diff --git a/Python/specialize.c b/Python/specialize.c index 951247d3710417..a82b4988ed5b6f 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1558,6 +1558,8 @@ _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub, _Py_CODEUNIT *ins cache->counter = adaptive_counter_cooldown(); } +//////////////////////////////////////////////////////////////////////////////// + /* Returns a borrowed reference. * The reference is only valid if guarded by a type version check. */ @@ -1615,9 +1617,8 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, } } if (tp->tp_vectorcall != NULL) { - // XXX - // instr->op.code = CALL_BUILTIN_CLASS; - // return 0; + instr->op.code = kwnames ? CALL_KW_BUILTIN_CLASS : CALL_BUILTIN_CLASS; + return 0; } SPECIALIZATION_FAIL(CALL, tp == &PyUnicode_Type ? SPEC_FAIL_CALL_STR : SPEC_FAIL_CALL_CLASS_NO_VECTORCALL); @@ -1734,9 +1735,9 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr, return 0; } case METH_FASTCALL | METH_KEYWORDS: { - // XXX - // instr->op.code = CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS; - // return 0; + instr->op.code = kwnames ? CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS + : CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS; + return 0; } } SPECIALIZATION_FAIL(CALL, meth_descr_call_fail_kind(descr->d_method->ml_flags)); @@ -1838,9 +1839,9 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, return 0; } case METH_FASTCALL | METH_KEYWORDS: { - // XXX - // instr->op.code = CALL_BUILTIN_FAST_WITH_KEYWORDS; - // return 0; + instr->op.code = kwnames ? CALL_KW_BUILTIN_FAST_WITH_KEYWORDS + : CALL_BUILTIN_FAST_WITH_KEYWORDS; + return 0; } default: SPECIALIZATION_FAIL(CALL, @@ -1876,46 +1877,42 @@ call_fail_kind(PyObject *callable) #endif -/* TODO: - - Specialize calling classes. -*/ -void -_Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) +int +specialize_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, PyObject *kwnames) { - assert(ENABLE_SPECIALIZATION); - assert(_PyOpcode_Caches[CALL] == INLINE_CACHE_ENTRIES_CALL); - assert(_Py_OPCODE(*instr) != INSTRUMENTED_CALL); - _PyCallCache *cache = (_PyCallCache *)(instr + 1); - int fail; if (PyCFunction_CheckExact(callable)) { - fail = specialize_c_call(callable, instr, nargs, NULL); + return specialize_c_call(callable, instr, nargs, kwnames); } - else if (PyFunction_Check(callable)) { - fail = specialize_py_call((PyFunctionObject *)callable, instr, nargs, - NULL, false); + if (PyFunction_Check(callable)) { + return specialize_py_call((PyFunctionObject *)callable, instr, nargs, kwnames, false); } - else if (PyType_Check(callable)) { - fail = specialize_class_call(callable, instr, nargs, NULL); + if (PyType_Check(callable)) { + return specialize_class_call(callable, instr, nargs, kwnames); } - else if (Py_IS_TYPE(callable, &PyMethodDescr_Type)) { - fail = specialize_method_descriptor((PyMethodDescrObject *)callable, - instr, nargs, NULL); + if (Py_IS_TYPE(callable, &PyMethodDescr_Type)) { + return specialize_method_descriptor((PyMethodDescrObject *)callable, instr, nargs, kwnames); } - else if (PyMethod_Check(callable)) { + if (PyMethod_Check(callable)) { PyObject *func = ((PyMethodObject *)callable)->im_func; if (PyFunction_Check(func)) { - fail = specialize_py_call((PyFunctionObject *)func, - instr, nargs+1, NULL, true); - } else { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_BOUND_METHOD); - fail = -1; + return specialize_py_call((PyFunctionObject *)func, instr, nargs+1, kwnames, true); } + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_BOUND_METHOD); } else { SPECIALIZATION_FAIL(CALL, call_fail_kind(callable)); - fail = -1; } - if (fail) { + return -1; +} + +void +_Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) +{ + assert(ENABLE_SPECIALIZATION); + assert(_PyOpcode_Caches[CALL] == INLINE_CACHE_ENTRIES_CALL); + assert(_Py_OPCODE(*instr) != INSTRUMENTED_CALL); + _PyCallCache *cache = (_PyCallCache *)(instr + 1); + if (specialize_call(callable, instr, nargs, NULL)) { STAT_INC(CALL, failure); assert(!PyErr_Occurred()); instr->op.code = CALL; @@ -1929,19 +1926,27 @@ _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) } void -_Py_Specialize_CallKw(PyObject *callable, _Py_CODEUNIT *instr, int nargs, - PyObject *kwnames) +_Py_Specialize_CallKw(PyObject *callable, _Py_CODEUNIT *instr, int nargs, PyObject *kwnames) { assert(ENABLE_SPECIALIZATION); assert(_PyOpcode_Caches[CALL_KW] == INLINE_CACHE_ENTRIES_CALL); assert(_Py_OPCODE(*instr) != INSTRUMENTED_CALL_KW); _PyCallCache *cache = (_PyCallCache *)(instr + 1); - STAT_INC(CALL_KW, failure); - assert(!PyErr_Occurred()); - instr->op.code = CALL_KW; - cache->counter = adaptive_counter_backoff(cache->counter); + if (specialize_call(callable, instr, nargs, kwnames)) { + STAT_INC(CALL_KW, failure); + assert(!PyErr_Occurred()); + instr->op.code = CALL_KW; + cache->counter = adaptive_counter_backoff(cache->counter); + } + else { + STAT_INC(CALL_KW, success); + assert(!PyErr_Occurred()); + cache->counter = adaptive_counter_cooldown(); + } } +//////////////////////////////////////////////////////////////////////////////// + #ifdef Py_STATS static int binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs) From 9c8ccf68f165739ae8e562bd5edff863328f5090 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 5 Sep 2023 15:10:26 -0700 Subject: [PATCH 3/8] Quick hack to fix stats --- Python/specialize.c | 57 ++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/Python/specialize.c b/Python/specialize.c index 8446a79adbf85b..a205f1dfe342ea 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1566,30 +1566,30 @@ _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub, _Py_CODEUNIT *ins * The reference is only valid if guarded by a type version check. */ static PyFunctionObject * -get_init_for_simple_managed_python_class(PyTypeObject *tp) +get_init_for_simple_managed_python_class(_Py_CODEUNIT *instr, PyTypeObject *tp) { assert(tp->tp_new == PyBaseObject_Type.tp_new); if (tp->tp_alloc != PyType_GenericAlloc) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_OVERRIDDEN); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_OVERRIDDEN); return NULL; } if ((tp->tp_flags & Py_TPFLAGS_MANAGED_DICT) == 0) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_NO_DICT); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_NO_DICT); return NULL; } if (!(tp->tp_flags & Py_TPFLAGS_HEAPTYPE)) { /* Is this possible? */ - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_EXPECTED_ERROR); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_EXPECTED_ERROR); return NULL; } PyObject *init = _PyType_Lookup(tp, &_Py_ID(__init__)); if (init == NULL || !PyFunction_Check(init)) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_INIT_NOT_PYTHON); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_INIT_NOT_PYTHON); return NULL; } int kind = function_kind((PyCodeObject *)PyFunction_GET_CODE(init)); if (kind != SIMPLE_FUNCTION) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_INIT_NOT_SIMPLE); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_INIT_NOT_SIMPLE); return NULL; } ((PyHeapTypeObject *)tp)->_spec_cache.init = init; @@ -1622,19 +1622,19 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, instr->op.code = kwnames ? CALL_KW_BUILTIN_CLASS : CALL_BUILTIN_CLASS; return 0; } - SPECIALIZATION_FAIL(CALL, tp == &PyUnicode_Type ? + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], tp == &PyUnicode_Type ? SPEC_FAIL_CALL_STR : SPEC_FAIL_CALL_CLASS_NO_VECTORCALL); return -1; } if (tp->tp_new == PyBaseObject_Type.tp_new) { - PyFunctionObject *init = get_init_for_simple_managed_python_class(tp); + PyFunctionObject *init = get_init_for_simple_managed_python_class(instr, tp); if (init != NULL) { if (((PyCodeObject *)init->func_code)->co_argcount != nargs+1) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return -1; } if (kwnames) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_KWNAMES); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_KWNAMES); return -1; } _PyCallCache *cache = (_PyCallCache *)(instr + 1); @@ -1644,7 +1644,7 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, } return -1; } - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_CLASS_MUTABLE); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_CLASS_MUTABLE); return -1; } @@ -1700,7 +1700,7 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr, int nargs, PyObject *kwnames) { if (kwnames) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_KWNAMES); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_KWNAMES); return -1; } @@ -1709,7 +1709,7 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr, METH_KEYWORDS | METH_METHOD)) { case METH_NOARGS: { if (nargs != 1) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return -1; } instr->op.code = CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS; @@ -1717,7 +1717,7 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr, } case METH_O: { if (nargs != 2) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return -1; } PyInterpreterState *interp = _PyInterpreterState_GET(); @@ -1742,7 +1742,7 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr, return 0; } } - SPECIALIZATION_FAIL(CALL, meth_descr_call_fail_kind(descr->d_method->ml_flags)); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], meth_descr_call_fail_kind(descr->d_method->ml_flags)); return -1; } @@ -1755,15 +1755,15 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs, int kind = function_kind(code); /* Don't specialize if PEP 523 is active */ if (_PyInterpreterState_GET()->eval_frame) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_PEP_523); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_PEP_523); return -1; } if (kwnames) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_KWNAMES); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_KWNAMES); return -1; } if (kind != SIMPLE_FUNCTION) { - SPECIALIZATION_FAIL(CALL, kind); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], kind); return -1; } int argcount = code->co_argcount; @@ -1771,7 +1771,7 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs, int min_args = argcount-defcount; // GH-105840: min_args is negative when somebody sets too many __defaults__! if (min_args < 0 || nargs > argcount || nargs < min_args) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return -1; } assert(nargs <= argcount && nargs >= min_args); @@ -1779,7 +1779,7 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs, assert(defcount == 0 || func->func_defaults != NULL); int version = _PyFunction_GetVersionForCurrentState(func); if (version == 0) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_OUT_OF_VERSIONS); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_OUT_OF_VERSIONS); return -1; } write_u32(cache->func_version, version); @@ -1787,7 +1787,7 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs, instr->op.code = bound_method ? CALL_BOUND_METHOD_EXACT_ARGS : CALL_PY_EXACT_ARGS; } else if (bound_method) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_BOUND_METHOD); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_BOUND_METHOD); return -1; } else { @@ -1808,11 +1808,11 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, METH_KEYWORDS | METH_METHOD)) { case METH_O: { if (kwnames) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_KWNAMES); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_KWNAMES); return -1; } if (nargs != 1) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return 1; } /* len(o) */ @@ -1826,7 +1826,7 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, } case METH_FASTCALL: { if (kwnames) { - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_KWNAMES); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_KWNAMES); return -1; } if (nargs == 2) { @@ -1846,7 +1846,7 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, return 0; } default: - SPECIALIZATION_FAIL(CALL, + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], builtin_call_fail_kind(PyCFunction_GET_FLAGS(callable))); return 1; } @@ -1882,6 +1882,7 @@ call_fail_kind(PyObject *callable) int specialize_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, PyObject *kwnames) { + assert(_PyOpcode_Deopt[instr->op.code] == (kwnames ? CALL_KW : CALL)); if (PyCFunction_CheckExact(callable)) { return specialize_c_call(callable, instr, nargs, kwnames); } @@ -1899,10 +1900,10 @@ specialize_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, PyObject *kw if (PyFunction_Check(func)) { return specialize_py_call((PyFunctionObject *)func, instr, nargs+1, kwnames, true); } - SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_BOUND_METHOD); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_BOUND_METHOD); } else { - SPECIALIZATION_FAIL(CALL, call_fail_kind(callable)); + SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], call_fail_kind(callable)); } return -1; } @@ -1923,6 +1924,7 @@ _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) else { STAT_INC(CALL, success); assert(!PyErr_Occurred()); + assert(_PyOpcode_Deopt[instr->op.code] == CALL); cache->counter = adaptive_counter_cooldown(); } } @@ -1943,6 +1945,7 @@ _Py_Specialize_CallKw(PyObject *callable, _Py_CODEUNIT *instr, int nargs, PyObje else { STAT_INC(CALL_KW, success); assert(!PyErr_Occurred()); + assert(_PyOpcode_Deopt[instr->op.code] == CALL_KW); cache->counter = adaptive_counter_cooldown(); } } From 367e7dbdd838cad0eaa59768c36e14ec3da8095f Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 6 Sep 2023 06:21:44 -0700 Subject: [PATCH 4/8] Don't specialize CALL_KW --- Doc/library/dis.rst | 28 +-- Include/internal/pycore_code.h | 2 - Include/internal/pycore_opcode_metadata.h | 30 +-- Include/opcode_ids.h | 211 ++++++++++---------- Lib/_opcode_metadata.py | 216 ++++++++++---------- Lib/importlib/_bootstrap_external.py | 2 +- Lib/opcode.py | 4 - Lib/test/test_dis.py | 230 +++++++++++----------- Objects/frameobject.c | 2 +- Programs/test_frozenmain.h | 18 +- Python/abstract_interp_cases.c.h | 21 ++ Python/bytecodes.c | 133 +------------ Python/executor_cases.c.h | 109 ++++++++++ Python/generated_cases.c.h | 165 +--------------- Python/opcode_targets.h | 8 +- Python/specialize.c | 149 +++++--------- Tools/scripts/summarize_stats.py | 2 - 17 files changed, 544 insertions(+), 786 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 70a94f40e1878d..d18708fa780926 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1122,7 +1122,7 @@ iterations of the loop. This bytecode distinguishes two cases: if ``STACK[-1]`` has a method with the correct name, the bytecode pushes the unbound method and ``STACK[-1]``. ``STACK[-1]`` will be used as the first argument (``self``) by :opcode:`CALL` - when calling the unbound method. Otherwise, ``NULL`` and the object returned by + or :opcode:`CALL_KW` when calling the unbound method. Otherwise, ``NULL`` and the object returned by the attribute lookup are pushed. .. versionchanged:: 3.12 @@ -1393,13 +1393,6 @@ iterations of the loop. Calls a callable object with the number of arguments specified by ``argc``. On the stack are (in ascending order): - * NULL - * The callable - * The positional arguments - * The named arguments - - or: - * The callable * ``self`` (or ``NULL``) * The remaining positional arguments @@ -1413,6 +1406,9 @@ iterations of the loop. .. versionadded:: 3.11 + .. versionchanged:: 3.13 + The callable now always appears at the same position on the stack. + .. versionchanged:: 3.13 Calls with keyword arguments are now handled by :opcode:`CALL_KW`. @@ -1420,15 +1416,7 @@ iterations of the loop. .. opcode:: CALL_KW (argc) Calls a callable object with the number of arguments specified by ``argc``, - including one or more named arguments. - On the stack are (in ascending order): - - * NULL - * The callable - * The positional arguments - * The named arguments - - or: + including one or more named arguments. On the stack are (in ascending order): * The callable * ``self`` (or ``NULL``) @@ -1439,9 +1427,9 @@ iterations of the loop. ``argc`` is the total of the positional and named arguments, excluding ``self`` when a ``NULL`` is not present. - ``CALL`` pops all arguments, the keyword names, and the callable object off the stack, - calls the callable object with those arguments, and pushes the return value - returned by the callable object. + ``CALL_KW`` pops all arguments, the keyword names, and the callable object + off the stack, calls the callable object with those arguments, and pushes the + return value returned by the callable object. .. versionadded:: 3.13 diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index 828af22e6c7540..1424377e82368e 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -251,8 +251,6 @@ extern void _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub, _Py_CODEUNIT *instr); extern void _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs); -extern void _Py_Specialize_CallKw(PyObject *callable, _Py_CODEUNIT *instr, - int nargs, PyObject *kwnames); extern void _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr, int oparg, PyObject **locals); extern void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h index f6b9e014195572..dd213d449b029c 100644 --- a/Include/internal/pycore_opcode_metadata.h +++ b/Include/internal/pycore_opcode_metadata.h @@ -520,16 +520,12 @@ int _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 1; case CALL_BUILTIN_CLASS: return oparg + 2; - case CALL_KW_BUILTIN_CLASS: - return oparg + 3; case CALL_NO_KW_BUILTIN_O: return oparg + 2; case CALL_NO_KW_BUILTIN_FAST: return oparg + 2; case CALL_BUILTIN_FAST_WITH_KEYWORDS: return oparg + 2; - case CALL_KW_BUILTIN_FAST_WITH_KEYWORDS: - return oparg + 3; case CALL_NO_KW_LEN: return oparg + 2; case CALL_NO_KW_ISINSTANCE: @@ -540,8 +536,6 @@ int _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return oparg + 2; case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: return oparg + 2; - case CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: - return oparg + 3; case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS: return oparg + 2; case CALL_NO_KW_METHOD_DESCRIPTOR_FAST: @@ -1060,16 +1054,12 @@ int _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 0; case CALL_BUILTIN_CLASS: return 1; - case CALL_KW_BUILTIN_CLASS: - return 1; case CALL_NO_KW_BUILTIN_O: return 1; case CALL_NO_KW_BUILTIN_FAST: return 1; case CALL_BUILTIN_FAST_WITH_KEYWORDS: return 1; - case CALL_KW_BUILTIN_FAST_WITH_KEYWORDS: - return 1; case CALL_NO_KW_LEN: return 1; case CALL_NO_KW_ISINSTANCE: @@ -1080,8 +1070,6 @@ int _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 1; case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: return 1; - case CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: - return 1; case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS: return 1; case CALL_NO_KW_METHOD_DESCRIPTOR_FAST: @@ -1446,21 +1434,18 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[OPCODE_METADATA_SIZE] = { [CALL_NO_KW_ALLOC_AND_ENTER_INIT] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [EXIT_INIT_CHECK] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG }, [CALL_BUILTIN_CLASS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_KW_BUILTIN_CLASS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_NO_KW_BUILTIN_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_NO_KW_BUILTIN_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_KW_BUILTIN_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_NO_KW_LEN] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_NO_KW_ISINSTANCE] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_NO_KW_LIST_APPEND] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [INSTRUMENTED_CALL_KW] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG }, - [CALL_KW] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG }, + [CALL_KW] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG }, [INSTRUMENTED_CALL_FUNCTION_EX] = { true, INSTR_FMT_IX, 0 }, [CALL_FUNCTION_EX] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG }, [MAKE_FUNCTION] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG }, @@ -1612,11 +1597,14 @@ const struct opcode_macro_expansion _PyOpcode_macro_expansion[OPCODE_MACRO_EXPAN [CALL_NO_KW_STR_1] = { .nuops = 1, .uops = { { CALL_NO_KW_STR_1, 0, 0 } } }, [CALL_NO_KW_TUPLE_1] = { .nuops = 1, .uops = { { CALL_NO_KW_TUPLE_1, 0, 0 } } }, [EXIT_INIT_CHECK] = { .nuops = 1, .uops = { { EXIT_INIT_CHECK, 0, 0 } } }, + [CALL_BUILTIN_CLASS] = { .nuops = 1, .uops = { { CALL_BUILTIN_CLASS, 0, 0 } } }, [CALL_NO_KW_BUILTIN_O] = { .nuops = 1, .uops = { { CALL_NO_KW_BUILTIN_O, 0, 0 } } }, [CALL_NO_KW_BUILTIN_FAST] = { .nuops = 1, .uops = { { CALL_NO_KW_BUILTIN_FAST, 0, 0 } } }, + [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { .nuops = 1, .uops = { { CALL_BUILTIN_FAST_WITH_KEYWORDS, 0, 0 } } }, [CALL_NO_KW_LEN] = { .nuops = 1, .uops = { { CALL_NO_KW_LEN, 0, 0 } } }, [CALL_NO_KW_ISINSTANCE] = { .nuops = 1, .uops = { { CALL_NO_KW_ISINSTANCE, 0, 0 } } }, [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { .nuops = 1, .uops = { { CALL_NO_KW_METHOD_DESCRIPTOR_O, 0, 0 } } }, + [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { .nuops = 1, .uops = { { CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, 0, 0 } } }, [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { .nuops = 1, .uops = { { CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS, 0, 0 } } }, [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { .nuops = 1, .uops = { { CALL_NO_KW_METHOD_DESCRIPTOR_FAST, 0, 0 } } }, [MAKE_FUNCTION] = { .nuops = 1, .uops = { { MAKE_FUNCTION, 0, 0 } } }, @@ -1772,9 +1760,6 @@ const char *const _PyOpcode_OpName[268] = { [CALL_INTRINSIC_1] = "CALL_INTRINSIC_1", [CALL_INTRINSIC_2] = "CALL_INTRINSIC_2", [CALL_KW] = "CALL_KW", - [CALL_KW_BUILTIN_CLASS] = "CALL_KW_BUILTIN_CLASS", - [CALL_KW_BUILTIN_FAST_WITH_KEYWORDS] = "CALL_KW_BUILTIN_FAST_WITH_KEYWORDS", - [CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = "CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = "CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", [CALL_NO_KW_ALLOC_AND_ENTER_INIT] = "CALL_NO_KW_ALLOC_AND_ENTER_INIT", [CALL_NO_KW_BUILTIN_FAST] = "CALL_NO_KW_BUILTIN_FAST", @@ -1929,7 +1914,6 @@ const uint8_t _PyOpcode_Caches[256] = { [COMPARE_OP] = 1, [FOR_ITER] = 1, [CALL] = 3, - [CALL_KW] = 3, [JUMP_BACKWARD] = 1, }; #endif // NEED_OPCODE_METADATA @@ -1971,9 +1955,6 @@ const uint8_t _PyOpcode_Deopt[256] = { [CALL_INTRINSIC_1] = CALL_INTRINSIC_1, [CALL_INTRINSIC_2] = CALL_INTRINSIC_2, [CALL_KW] = CALL_KW, - [CALL_KW_BUILTIN_CLASS] = CALL_KW, - [CALL_KW_BUILTIN_FAST_WITH_KEYWORDS] = CALL_KW, - [CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = CALL_KW, [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = CALL, [CALL_NO_KW_ALLOC_AND_ENTER_INIT] = CALL, [CALL_NO_KW_BUILTIN_FAST] = CALL, @@ -2151,6 +2132,9 @@ const uint8_t _PyOpcode_Deopt[256] = { #endif // NEED_OPCODE_METADATA #define EXTRA_CASES \ + case 188: \ + case 189: \ + case 190: \ case 191: \ case 192: \ case 193: \ diff --git a/Include/opcode_ids.h b/Include/opcode_ids.h index 1962daa793ea31..40f04886760b9c 100644 --- a/Include/opcode_ids.h +++ b/Include/opcode_ids.h @@ -94,114 +94,111 @@ extern "C" { #define CALL_INTRINSIC_1 80 #define CALL_INTRINSIC_2 81 #define CALL_KW 82 -#define CALL_KW_BUILTIN_CLASS 83 -#define CALL_KW_BUILTIN_FAST_WITH_KEYWORDS 84 -#define CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 85 -#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 86 -#define CALL_NO_KW_ALLOC_AND_ENTER_INIT 87 -#define CALL_NO_KW_BUILTIN_FAST 88 -#define CALL_NO_KW_BUILTIN_O 89 -#define CALL_NO_KW_ISINSTANCE 90 -#define CALL_NO_KW_LEN 91 -#define CALL_NO_KW_LIST_APPEND 92 -#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 93 -#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 94 -#define CALL_NO_KW_METHOD_DESCRIPTOR_O 95 -#define CALL_NO_KW_STR_1 96 -#define CALL_NO_KW_TUPLE_1 97 -#define CALL_NO_KW_TYPE_1 98 -#define CALL_PY_EXACT_ARGS 99 -#define CALL_PY_WITH_DEFAULTS 100 -#define COMPARE_OP 101 -#define COMPARE_OP_FLOAT 102 -#define COMPARE_OP_INT 103 -#define COMPARE_OP_STR 104 -#define CONTAINS_OP 105 -#define CONVERT_VALUE 106 -#define COPY 107 -#define COPY_FREE_VARS 108 -#define DELETE_ATTR 109 -#define DELETE_DEREF 110 -#define DELETE_FAST 111 -#define DELETE_GLOBAL 112 -#define DELETE_NAME 113 -#define DICT_MERGE 114 -#define DICT_UPDATE 115 -#define ENTER_EXECUTOR 116 -#define EXTENDED_ARG 117 -#define FOR_ITER 118 -#define FOR_ITER_GEN 119 -#define FOR_ITER_LIST 120 -#define FOR_ITER_RANGE 121 -#define FOR_ITER_TUPLE 122 -#define GET_AWAITABLE 123 -#define IMPORT_FROM 124 -#define IMPORT_NAME 125 -#define IS_OP 126 -#define JUMP_BACKWARD 127 -#define JUMP_BACKWARD_NO_INTERRUPT 128 -#define JUMP_FORWARD 129 -#define LIST_APPEND 130 -#define LIST_EXTEND 131 -#define LOAD_ATTR 132 -#define LOAD_ATTR_CLASS 133 -#define LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN 134 -#define LOAD_ATTR_INSTANCE_VALUE 135 -#define LOAD_ATTR_METHOD_LAZY_DICT 136 -#define LOAD_ATTR_METHOD_NO_DICT 137 -#define LOAD_ATTR_METHOD_WITH_VALUES 138 -#define LOAD_ATTR_MODULE 139 -#define LOAD_ATTR_NONDESCRIPTOR_NO_DICT 140 -#define LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES 141 -#define LOAD_ATTR_PROPERTY 142 -#define LOAD_ATTR_SLOT 143 -#define LOAD_ATTR_WITH_HINT 144 -#define LOAD_CONST 145 -#define LOAD_DEREF 146 -#define LOAD_FAST 147 -#define LOAD_FAST_AND_CLEAR 148 -#define LOAD_FAST_CHECK 149 -#define LOAD_FAST_LOAD_FAST 150 -#define LOAD_FROM_DICT_OR_DEREF 151 -#define LOAD_FROM_DICT_OR_GLOBALS 152 -#define LOAD_GLOBAL 153 -#define LOAD_GLOBAL_BUILTIN 154 -#define LOAD_GLOBAL_MODULE 155 -#define LOAD_NAME 156 -#define LOAD_SUPER_ATTR 157 -#define LOAD_SUPER_ATTR_ATTR 158 -#define LOAD_SUPER_ATTR_METHOD 159 -#define MAKE_CELL 160 -#define MAP_ADD 161 -#define MATCH_CLASS 162 -#define POP_JUMP_IF_FALSE 163 -#define POP_JUMP_IF_NONE 164 -#define POP_JUMP_IF_NOT_NONE 165 +#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 83 +#define CALL_NO_KW_ALLOC_AND_ENTER_INIT 84 +#define CALL_NO_KW_BUILTIN_FAST 85 +#define CALL_NO_KW_BUILTIN_O 86 +#define CALL_NO_KW_ISINSTANCE 87 +#define CALL_NO_KW_LEN 88 +#define CALL_NO_KW_LIST_APPEND 89 +#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 90 +#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 91 +#define CALL_NO_KW_METHOD_DESCRIPTOR_O 92 +#define CALL_NO_KW_STR_1 93 +#define CALL_NO_KW_TUPLE_1 94 +#define CALL_NO_KW_TYPE_1 95 +#define CALL_PY_EXACT_ARGS 96 +#define CALL_PY_WITH_DEFAULTS 97 +#define COMPARE_OP 98 +#define COMPARE_OP_FLOAT 99 +#define COMPARE_OP_INT 100 +#define COMPARE_OP_STR 101 +#define CONTAINS_OP 102 +#define CONVERT_VALUE 103 +#define COPY 104 +#define COPY_FREE_VARS 105 +#define DELETE_ATTR 106 +#define DELETE_DEREF 107 +#define DELETE_FAST 108 +#define DELETE_GLOBAL 109 +#define DELETE_NAME 110 +#define DICT_MERGE 111 +#define DICT_UPDATE 112 +#define ENTER_EXECUTOR 113 +#define EXTENDED_ARG 114 +#define FOR_ITER 115 +#define FOR_ITER_GEN 116 +#define FOR_ITER_LIST 117 +#define FOR_ITER_RANGE 118 +#define FOR_ITER_TUPLE 119 +#define GET_AWAITABLE 120 +#define IMPORT_FROM 121 +#define IMPORT_NAME 122 +#define IS_OP 123 +#define JUMP_BACKWARD 124 +#define JUMP_BACKWARD_NO_INTERRUPT 125 +#define JUMP_FORWARD 126 +#define LIST_APPEND 127 +#define LIST_EXTEND 128 +#define LOAD_ATTR 129 +#define LOAD_ATTR_CLASS 130 +#define LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN 131 +#define LOAD_ATTR_INSTANCE_VALUE 132 +#define LOAD_ATTR_METHOD_LAZY_DICT 133 +#define LOAD_ATTR_METHOD_NO_DICT 134 +#define LOAD_ATTR_METHOD_WITH_VALUES 135 +#define LOAD_ATTR_MODULE 136 +#define LOAD_ATTR_NONDESCRIPTOR_NO_DICT 137 +#define LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES 138 +#define LOAD_ATTR_PROPERTY 139 +#define LOAD_ATTR_SLOT 140 +#define LOAD_ATTR_WITH_HINT 141 +#define LOAD_CONST 142 +#define LOAD_DEREF 143 +#define LOAD_FAST 144 +#define LOAD_FAST_AND_CLEAR 145 +#define LOAD_FAST_CHECK 146 +#define LOAD_FAST_LOAD_FAST 147 +#define LOAD_FROM_DICT_OR_DEREF 148 +#define LOAD_FROM_DICT_OR_GLOBALS 149 +#define LOAD_GLOBAL 150 +#define LOAD_GLOBAL_BUILTIN 151 +#define LOAD_GLOBAL_MODULE 152 +#define LOAD_NAME 153 +#define LOAD_SUPER_ATTR 154 +#define LOAD_SUPER_ATTR_ATTR 155 +#define LOAD_SUPER_ATTR_METHOD 156 +#define MAKE_CELL 157 +#define MAP_ADD 158 +#define MATCH_CLASS 159 +#define POP_JUMP_IF_FALSE 160 +#define POP_JUMP_IF_NONE 161 +#define POP_JUMP_IF_NOT_NONE 162 +#define POP_JUMP_IF_TRUE 163 +#define RAISE_VARARGS 164 +#define RERAISE 165 #define RESUME 166 -#define POP_JUMP_IF_TRUE 167 -#define RAISE_VARARGS 168 -#define RERAISE 169 -#define RETURN_CONST 170 -#define SEND 171 -#define SEND_GEN 172 -#define SET_ADD 173 -#define SET_FUNCTION_ATTRIBUTE 174 -#define SET_UPDATE 175 -#define STORE_ATTR 176 -#define STORE_ATTR_WITH_HINT 177 -#define STORE_DEREF 178 -#define STORE_FAST 179 -#define STORE_FAST_LOAD_FAST 180 -#define STORE_FAST_STORE_FAST 181 -#define STORE_GLOBAL 182 -#define STORE_NAME 183 -#define SWAP 184 -#define UNPACK_EX 185 -#define UNPACK_SEQUENCE 186 -#define UNPACK_SEQUENCE_LIST 187 -#define UNPACK_SEQUENCE_TUPLE 188 -#define UNPACK_SEQUENCE_TWO_TUPLE 189 -#define YIELD_VALUE 190 +#define RETURN_CONST 167 +#define SEND 168 +#define SEND_GEN 169 +#define SET_ADD 170 +#define SET_FUNCTION_ATTRIBUTE 171 +#define SET_UPDATE 172 +#define STORE_ATTR 173 +#define STORE_ATTR_WITH_HINT 174 +#define STORE_DEREF 175 +#define STORE_FAST 176 +#define STORE_FAST_LOAD_FAST 177 +#define STORE_FAST_STORE_FAST 178 +#define STORE_GLOBAL 179 +#define STORE_NAME 180 +#define SWAP 181 +#define UNPACK_EX 182 +#define UNPACK_SEQUENCE 183 +#define UNPACK_SEQUENCE_LIST 184 +#define UNPACK_SEQUENCE_TUPLE 185 +#define UNPACK_SEQUENCE_TWO_TUPLE 186 +#define YIELD_VALUE 187 #define MIN_INSTRUMENTED_OPCODE 236 #define INSTRUMENTED_RESUME 236 #define INSTRUMENTED_END_FOR 237 diff --git a/Lib/_opcode_metadata.py b/Lib/_opcode_metadata.py index 038d3902836ab7..53e3c9a9134649 100644 --- a/Lib/_opcode_metadata.py +++ b/Lib/_opcode_metadata.py @@ -98,11 +98,6 @@ "CALL_NO_KW_METHOD_DESCRIPTOR_FAST", "CALL_NO_KW_ALLOC_AND_ENTER_INIT", ], - "CALL_KW": [ - "CALL_KW_BUILTIN_CLASS", - "CALL_KW_BUILTIN_FAST_WITH_KEYWORDS", - "CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", - ], } # An irregular case: @@ -135,52 +130,49 @@ 'CALL_BOUND_METHOD_EXACT_ARGS': 76, 'CALL_BUILTIN_CLASS': 77, 'CALL_BUILTIN_FAST_WITH_KEYWORDS': 78, - 'CALL_KW_BUILTIN_CLASS': 83, - 'CALL_KW_BUILTIN_FAST_WITH_KEYWORDS': 84, - 'CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS': 85, - 'CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS': 86, - 'CALL_NO_KW_ALLOC_AND_ENTER_INIT': 87, - 'CALL_NO_KW_BUILTIN_FAST': 88, - 'CALL_NO_KW_BUILTIN_O': 89, - 'CALL_NO_KW_ISINSTANCE': 90, - 'CALL_NO_KW_LEN': 91, - 'CALL_NO_KW_LIST_APPEND': 92, - 'CALL_NO_KW_METHOD_DESCRIPTOR_FAST': 93, - 'CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS': 94, - 'CALL_NO_KW_METHOD_DESCRIPTOR_O': 95, - 'CALL_NO_KW_STR_1': 96, - 'CALL_NO_KW_TUPLE_1': 97, - 'CALL_NO_KW_TYPE_1': 98, - 'CALL_PY_EXACT_ARGS': 99, - 'CALL_PY_WITH_DEFAULTS': 100, - 'COMPARE_OP_FLOAT': 102, - 'COMPARE_OP_INT': 103, - 'COMPARE_OP_STR': 104, - 'FOR_ITER_GEN': 119, - 'FOR_ITER_LIST': 120, - 'FOR_ITER_RANGE': 121, - 'FOR_ITER_TUPLE': 122, - 'LOAD_ATTR_CLASS': 133, - 'LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN': 134, - 'LOAD_ATTR_INSTANCE_VALUE': 135, - 'LOAD_ATTR_METHOD_LAZY_DICT': 136, - 'LOAD_ATTR_METHOD_NO_DICT': 137, - 'LOAD_ATTR_METHOD_WITH_VALUES': 138, - 'LOAD_ATTR_MODULE': 139, - 'LOAD_ATTR_NONDESCRIPTOR_NO_DICT': 140, - 'LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES': 141, - 'LOAD_ATTR_PROPERTY': 142, - 'LOAD_ATTR_SLOT': 143, - 'LOAD_ATTR_WITH_HINT': 144, - 'LOAD_GLOBAL_BUILTIN': 154, - 'LOAD_GLOBAL_MODULE': 155, - 'LOAD_SUPER_ATTR_ATTR': 158, - 'LOAD_SUPER_ATTR_METHOD': 159, - 'SEND_GEN': 172, - 'STORE_ATTR_WITH_HINT': 177, - 'UNPACK_SEQUENCE_LIST': 187, - 'UNPACK_SEQUENCE_TUPLE': 188, - 'UNPACK_SEQUENCE_TWO_TUPLE': 189, + 'CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS': 83, + 'CALL_NO_KW_ALLOC_AND_ENTER_INIT': 84, + 'CALL_NO_KW_BUILTIN_FAST': 85, + 'CALL_NO_KW_BUILTIN_O': 86, + 'CALL_NO_KW_ISINSTANCE': 87, + 'CALL_NO_KW_LEN': 88, + 'CALL_NO_KW_LIST_APPEND': 89, + 'CALL_NO_KW_METHOD_DESCRIPTOR_FAST': 90, + 'CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS': 91, + 'CALL_NO_KW_METHOD_DESCRIPTOR_O': 92, + 'CALL_NO_KW_STR_1': 93, + 'CALL_NO_KW_TUPLE_1': 94, + 'CALL_NO_KW_TYPE_1': 95, + 'CALL_PY_EXACT_ARGS': 96, + 'CALL_PY_WITH_DEFAULTS': 97, + 'COMPARE_OP_FLOAT': 99, + 'COMPARE_OP_INT': 100, + 'COMPARE_OP_STR': 101, + 'FOR_ITER_GEN': 116, + 'FOR_ITER_LIST': 117, + 'FOR_ITER_RANGE': 118, + 'FOR_ITER_TUPLE': 119, + 'LOAD_ATTR_CLASS': 130, + 'LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN': 131, + 'LOAD_ATTR_INSTANCE_VALUE': 132, + 'LOAD_ATTR_METHOD_LAZY_DICT': 133, + 'LOAD_ATTR_METHOD_NO_DICT': 134, + 'LOAD_ATTR_METHOD_WITH_VALUES': 135, + 'LOAD_ATTR_MODULE': 136, + 'LOAD_ATTR_NONDESCRIPTOR_NO_DICT': 137, + 'LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES': 138, + 'LOAD_ATTR_PROPERTY': 139, + 'LOAD_ATTR_SLOT': 140, + 'LOAD_ATTR_WITH_HINT': 141, + 'LOAD_GLOBAL_BUILTIN': 151, + 'LOAD_GLOBAL_MODULE': 152, + 'LOAD_SUPER_ATTR_ATTR': 155, + 'LOAD_SUPER_ATTR_METHOD': 156, + 'SEND_GEN': 169, + 'STORE_ATTR_WITH_HINT': 174, + 'UNPACK_SEQUENCE_LIST': 184, + 'UNPACK_SEQUENCE_TUPLE': 185, + 'UNPACK_SEQUENCE_TWO_TUPLE': 186, } opmap = { @@ -241,68 +233,68 @@ 'CALL_INTRINSIC_1': 80, 'CALL_INTRINSIC_2': 81, 'CALL_KW': 82, - 'COMPARE_OP': 101, - 'CONTAINS_OP': 105, - 'CONVERT_VALUE': 106, - 'COPY': 107, - 'COPY_FREE_VARS': 108, - 'DELETE_ATTR': 109, - 'DELETE_DEREF': 110, - 'DELETE_FAST': 111, - 'DELETE_GLOBAL': 112, - 'DELETE_NAME': 113, - 'DICT_MERGE': 114, - 'DICT_UPDATE': 115, - 'ENTER_EXECUTOR': 116, - 'EXTENDED_ARG': 117, - 'FOR_ITER': 118, - 'GET_AWAITABLE': 123, - 'IMPORT_FROM': 124, - 'IMPORT_NAME': 125, - 'IS_OP': 126, - 'JUMP_BACKWARD': 127, - 'JUMP_BACKWARD_NO_INTERRUPT': 128, - 'JUMP_FORWARD': 129, - 'LIST_APPEND': 130, - 'LIST_EXTEND': 131, - 'LOAD_ATTR': 132, - 'LOAD_CONST': 145, - 'LOAD_DEREF': 146, - 'LOAD_FAST': 147, - 'LOAD_FAST_AND_CLEAR': 148, - 'LOAD_FAST_CHECK': 149, - 'LOAD_FAST_LOAD_FAST': 150, - 'LOAD_FROM_DICT_OR_DEREF': 151, - 'LOAD_FROM_DICT_OR_GLOBALS': 152, - 'LOAD_GLOBAL': 153, - 'LOAD_NAME': 156, - 'LOAD_SUPER_ATTR': 157, - 'MAKE_CELL': 160, - 'MAP_ADD': 161, - 'MATCH_CLASS': 162, - 'POP_JUMP_IF_FALSE': 163, - 'POP_JUMP_IF_NONE': 164, - 'POP_JUMP_IF_NOT_NONE': 165, + 'COMPARE_OP': 98, + 'CONTAINS_OP': 102, + 'CONVERT_VALUE': 103, + 'COPY': 104, + 'COPY_FREE_VARS': 105, + 'DELETE_ATTR': 106, + 'DELETE_DEREF': 107, + 'DELETE_FAST': 108, + 'DELETE_GLOBAL': 109, + 'DELETE_NAME': 110, + 'DICT_MERGE': 111, + 'DICT_UPDATE': 112, + 'ENTER_EXECUTOR': 113, + 'EXTENDED_ARG': 114, + 'FOR_ITER': 115, + 'GET_AWAITABLE': 120, + 'IMPORT_FROM': 121, + 'IMPORT_NAME': 122, + 'IS_OP': 123, + 'JUMP_BACKWARD': 124, + 'JUMP_BACKWARD_NO_INTERRUPT': 125, + 'JUMP_FORWARD': 126, + 'LIST_APPEND': 127, + 'LIST_EXTEND': 128, + 'LOAD_ATTR': 129, + 'LOAD_CONST': 142, + 'LOAD_DEREF': 143, + 'LOAD_FAST': 144, + 'LOAD_FAST_AND_CLEAR': 145, + 'LOAD_FAST_CHECK': 146, + 'LOAD_FAST_LOAD_FAST': 147, + 'LOAD_FROM_DICT_OR_DEREF': 148, + 'LOAD_FROM_DICT_OR_GLOBALS': 149, + 'LOAD_GLOBAL': 150, + 'LOAD_NAME': 153, + 'LOAD_SUPER_ATTR': 154, + 'MAKE_CELL': 157, + 'MAP_ADD': 158, + 'MATCH_CLASS': 159, + 'POP_JUMP_IF_FALSE': 160, + 'POP_JUMP_IF_NONE': 161, + 'POP_JUMP_IF_NOT_NONE': 162, + 'POP_JUMP_IF_TRUE': 163, + 'RAISE_VARARGS': 164, + 'RERAISE': 165, 'RESUME': 166, - 'POP_JUMP_IF_TRUE': 167, - 'RAISE_VARARGS': 168, - 'RERAISE': 169, - 'RETURN_CONST': 170, - 'SEND': 171, - 'SET_ADD': 173, - 'SET_FUNCTION_ATTRIBUTE': 174, - 'SET_UPDATE': 175, - 'STORE_ATTR': 176, - 'STORE_DEREF': 178, - 'STORE_FAST': 179, - 'STORE_FAST_LOAD_FAST': 180, - 'STORE_FAST_STORE_FAST': 181, - 'STORE_GLOBAL': 182, - 'STORE_NAME': 183, - 'SWAP': 184, - 'UNPACK_EX': 185, - 'UNPACK_SEQUENCE': 186, - 'YIELD_VALUE': 190, + 'RETURN_CONST': 167, + 'SEND': 168, + 'SET_ADD': 170, + 'SET_FUNCTION_ATTRIBUTE': 171, + 'SET_UPDATE': 172, + 'STORE_ATTR': 173, + 'STORE_DEREF': 175, + 'STORE_FAST': 176, + 'STORE_FAST_LOAD_FAST': 177, + 'STORE_FAST_STORE_FAST': 178, + 'STORE_GLOBAL': 179, + 'STORE_NAME': 180, + 'SWAP': 181, + 'UNPACK_EX': 182, + 'UNPACK_SEQUENCE': 183, + 'YIELD_VALUE': 187, 'INSTRUMENTED_RESUME': 236, 'INSTRUMENTED_END_FOR': 237, 'INSTRUMENTED_END_SEND': 238, diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 6a55bfd23273a1..5d9b2ef0f1c521 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -455,7 +455,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.13a1 3557 (Make the conversion to boolean in jumps explicit) # Python 3.13a1 3558 (Reorder the stack items for CALL) # Python 3.13a1 3559 (Generate opcode IDs from bytecodes.c) -# Python 3.13a1 3560 (Add CALL_KW) +# Python 3.13a1 3560 (Add CALL_KW and remove KW_NAMES) # Python 3.14 will start with 3600 diff --git a/Lib/opcode.py b/Lib/opcode.py index 4baf75474a490f..386a2fba396a6a 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -80,10 +80,6 @@ "counter": 1, "func_version": 2, }, - "CALL_KW": { - "counter": 1, - "func_version": 2, - }, "STORE_SUBSCR": { "counter": 1, }, diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index ba77c5d076cce7..0594af54cb0f4a 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1635,202 +1635,202 @@ def _prepare_test_cases(): result = result.replace(repr(code_object_inner), "code_object_inner") print(result) -# _prepare_test_cases() +# from test.test_dis import _prepare_test_cases; _prepare_test_cases() Instruction = dis.Instruction expected_opinfo_outer = [ - Instruction(opname='MAKE_CELL', opcode=160, arg=0, argval='a', argrepr='a', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='MAKE_CELL', opcode=160, arg=1, argval='b', argrepr='b', offset=2, start_offset=2, starts_line=False, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='MAKE_CELL', opcode=157, arg=0, argval='a', argrepr='a', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='MAKE_CELL', opcode=157, arg=1, argval='b', argrepr='b', offset=2, start_offset=2, starts_line=False, line_number=None, is_jump_target=False, positions=None), Instruction(opname='RESUME', opcode=166, arg=0, argval=0, argrepr='', offset=4, start_offset=4, starts_line=True, line_number=1, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=5, argval=(3, 4), argrepr='(3, 4)', offset=6, start_offset=6, starts_line=True, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='a', argrepr='a', offset=8, start_offset=8, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=1, argval='b', argrepr='b', offset=10, start_offset=10, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=5, argval=(3, 4), argrepr='(3, 4)', offset=6, start_offset=6, starts_line=True, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='a', argrepr='a', offset=8, start_offset=8, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=1, argval='b', argrepr='b', offset=10, start_offset=10, starts_line=False, line_number=2, is_jump_target=False, positions=None), Instruction(opname='BUILD_TUPLE', opcode=74, arg=2, argval=2, argrepr='', offset=12, start_offset=12, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=1, argval=code_object_f, argrepr=repr(code_object_f), offset=14, start_offset=14, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=1, argval=code_object_f, argrepr=repr(code_object_f), offset=14, start_offset=14, starts_line=False, line_number=2, is_jump_target=False, positions=None), Instruction(opname='MAKE_FUNCTION', opcode=38, arg=None, argval=None, argrepr='', offset=16, start_offset=16, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=174, arg=8, argval=8, argrepr='closure', offset=18, start_offset=18, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=174, arg=1, argval=1, argrepr='defaults', offset=20, start_offset=20, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='STORE_FAST', opcode=179, arg=2, argval='f', argrepr='f', offset=22, start_offset=22, starts_line=False, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=1, argval='print', argrepr='print + NULL', offset=24, start_offset=24, starts_line=True, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=146, arg=0, argval='a', argrepr='a', offset=34, start_offset=34, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=146, arg=1, argval='b', argrepr='b', offset=36, start_offset=36, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=2, argval='', argrepr="''", offset=38, start_offset=38, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=3, argval=1, argrepr='1', offset=40, start_offset=40, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=171, arg=8, argval=8, argrepr='closure', offset=18, start_offset=18, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=171, arg=1, argval=1, argrepr='defaults', offset=20, start_offset=20, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='STORE_FAST', opcode=176, arg=2, argval='f', argrepr='f', offset=22, start_offset=22, starts_line=False, line_number=2, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=1, argval='print', argrepr='print + NULL', offset=24, start_offset=24, starts_line=True, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=143, arg=0, argval='a', argrepr='a', offset=34, start_offset=34, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=143, arg=1, argval='b', argrepr='b', offset=36, start_offset=36, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=2, argval='', argrepr="''", offset=38, start_offset=38, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=3, argval=1, argrepr='1', offset=40, start_offset=40, starts_line=False, line_number=7, is_jump_target=False, positions=None), Instruction(opname='BUILD_LIST', opcode=69, arg=0, argval=0, argrepr='', offset=42, start_offset=42, starts_line=False, line_number=7, is_jump_target=False, positions=None), Instruction(opname='BUILD_MAP', opcode=70, arg=0, argval=0, argrepr='', offset=44, start_offset=44, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=4, argval='Hello world!', argrepr="'Hello world!'", offset=46, start_offset=46, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=4, argval='Hello world!', argrepr="'Hello world!'", offset=46, start_offset=46, starts_line=False, line_number=7, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=7, argval=7, argrepr='', offset=48, start_offset=48, starts_line=False, line_number=7, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=56, start_offset=56, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=2, argval='f', argrepr='f', offset=58, start_offset=58, starts_line=True, line_number=8, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=2, argval='f', argrepr='f', offset=58, start_offset=58, starts_line=True, line_number=8, is_jump_target=False, positions=None), Instruction(opname='RETURN_VALUE', opcode=48, arg=None, argval=None, argrepr='', offset=60, start_offset=60, starts_line=False, line_number=8, is_jump_target=False, positions=None), ] expected_opinfo_f = [ - Instruction(opname='COPY_FREE_VARS', opcode=108, arg=2, argval=2, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='MAKE_CELL', opcode=160, arg=0, argval='c', argrepr='c', offset=2, start_offset=2, starts_line=False, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='MAKE_CELL', opcode=160, arg=1, argval='d', argrepr='d', offset=4, start_offset=4, starts_line=False, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='COPY_FREE_VARS', opcode=105, arg=2, argval=2, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='MAKE_CELL', opcode=157, arg=0, argval='c', argrepr='c', offset=2, start_offset=2, starts_line=False, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='MAKE_CELL', opcode=157, arg=1, argval='d', argrepr='d', offset=4, start_offset=4, starts_line=False, line_number=None, is_jump_target=False, positions=None), Instruction(opname='RESUME', opcode=166, arg=0, argval=0, argrepr='', offset=6, start_offset=6, starts_line=True, line_number=2, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=2, argval=(5, 6), argrepr='(5, 6)', offset=8, start_offset=8, starts_line=True, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=3, argval='a', argrepr='a', offset=10, start_offset=10, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=4, argval='b', argrepr='b', offset=12, start_offset=12, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='c', argrepr='c', offset=14, start_offset=14, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=1, argval='d', argrepr='d', offset=16, start_offset=16, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=2, argval=(5, 6), argrepr='(5, 6)', offset=8, start_offset=8, starts_line=True, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=3, argval='a', argrepr='a', offset=10, start_offset=10, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=4, argval='b', argrepr='b', offset=12, start_offset=12, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='c', argrepr='c', offset=14, start_offset=14, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=1, argval='d', argrepr='d', offset=16, start_offset=16, starts_line=False, line_number=3, is_jump_target=False, positions=None), Instruction(opname='BUILD_TUPLE', opcode=74, arg=4, argval=4, argrepr='', offset=18, start_offset=18, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=1, argval=code_object_inner, argrepr=repr(code_object_inner), offset=20, start_offset=20, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=1, argval=code_object_inner, argrepr=repr(code_object_inner), offset=20, start_offset=20, starts_line=False, line_number=3, is_jump_target=False, positions=None), Instruction(opname='MAKE_FUNCTION', opcode=38, arg=None, argval=None, argrepr='', offset=22, start_offset=22, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=174, arg=8, argval=8, argrepr='closure', offset=24, start_offset=24, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=174, arg=1, argval=1, argrepr='defaults', offset=26, start_offset=26, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='STORE_FAST', opcode=179, arg=2, argval='inner', argrepr='inner', offset=28, start_offset=28, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=1, argval='print', argrepr='print + NULL', offset=30, start_offset=30, starts_line=True, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=146, arg=3, argval='a', argrepr='a', offset=40, start_offset=40, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=146, arg=4, argval='b', argrepr='b', offset=42, start_offset=42, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=146, arg=0, argval='c', argrepr='c', offset=44, start_offset=44, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=146, arg=1, argval='d', argrepr='d', offset=46, start_offset=46, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=171, arg=8, argval=8, argrepr='closure', offset=24, start_offset=24, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='SET_FUNCTION_ATTRIBUTE', opcode=171, arg=1, argval=1, argrepr='defaults', offset=26, start_offset=26, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='STORE_FAST', opcode=176, arg=2, argval='inner', argrepr='inner', offset=28, start_offset=28, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=1, argval='print', argrepr='print + NULL', offset=30, start_offset=30, starts_line=True, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=143, arg=3, argval='a', argrepr='a', offset=40, start_offset=40, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=143, arg=4, argval='b', argrepr='b', offset=42, start_offset=42, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=143, arg=0, argval='c', argrepr='c', offset=44, start_offset=44, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=143, arg=1, argval='d', argrepr='d', offset=46, start_offset=46, starts_line=False, line_number=5, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=4, argval=4, argrepr='', offset=48, start_offset=48, starts_line=False, line_number=5, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=56, start_offset=56, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=2, argval='inner', argrepr='inner', offset=58, start_offset=58, starts_line=True, line_number=6, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=2, argval='inner', argrepr='inner', offset=58, start_offset=58, starts_line=True, line_number=6, is_jump_target=False, positions=None), Instruction(opname='RETURN_VALUE', opcode=48, arg=None, argval=None, argrepr='', offset=60, start_offset=60, starts_line=False, line_number=6, is_jump_target=False, positions=None), ] expected_opinfo_inner = [ - Instruction(opname='COPY_FREE_VARS', opcode=108, arg=4, argval=4, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='COPY_FREE_VARS', opcode=105, arg=4, argval=4, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=None, is_jump_target=False, positions=None), Instruction(opname='RESUME', opcode=166, arg=0, argval=0, argrepr='', offset=2, start_offset=2, starts_line=True, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=1, argval='print', argrepr='print + NULL', offset=4, start_offset=4, starts_line=True, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=146, arg=2, argval='a', argrepr='a', offset=14, start_offset=14, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=146, arg=3, argval='b', argrepr='b', offset=16, start_offset=16, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=146, arg=4, argval='c', argrepr='c', offset=18, start_offset=18, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_DEREF', opcode=146, arg=5, argval='d', argrepr='d', offset=20, start_offset=20, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST_LOAD_FAST', opcode=150, arg=1, argval=('e', 'f'), argrepr='e, f', offset=22, start_offset=22, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=1, argval='print', argrepr='print + NULL', offset=4, start_offset=4, starts_line=True, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=143, arg=2, argval='a', argrepr='a', offset=14, start_offset=14, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=143, arg=3, argval='b', argrepr='b', offset=16, start_offset=16, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=143, arg=4, argval='c', argrepr='c', offset=18, start_offset=18, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_DEREF', opcode=143, arg=5, argval='d', argrepr='d', offset=20, start_offset=20, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST_LOAD_FAST', opcode=147, arg=1, argval=('e', 'f'), argrepr='e, f', offset=22, start_offset=22, starts_line=False, line_number=4, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=6, argval=6, argrepr='', offset=24, start_offset=24, starts_line=False, line_number=4, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=32, start_offset=32, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='RETURN_CONST', opcode=170, arg=0, argval=None, argrepr='None', offset=34, start_offset=34, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='RETURN_CONST', opcode=167, arg=0, argval=None, argrepr='None', offset=34, start_offset=34, starts_line=False, line_number=4, is_jump_target=False, positions=None), ] expected_opinfo_jumpy = [ Instruction(opname='RESUME', opcode=166, arg=0, argval=0, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=1, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=1, argval='range', argrepr='range + NULL', offset=2, start_offset=2, starts_line=True, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=1, argval=10, argrepr='10', offset=12, start_offset=12, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=1, argval='range', argrepr='range + NULL', offset=2, start_offset=2, starts_line=True, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=1, argval=10, argrepr='10', offset=12, start_offset=12, starts_line=False, line_number=3, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=14, start_offset=14, starts_line=False, line_number=3, is_jump_target=False, positions=None), Instruction(opname='GET_ITER', opcode=31, arg=None, argval=None, argrepr='', offset=22, start_offset=22, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='FOR_ITER', opcode=118, arg=28, argval=84, argrepr='to 84', offset=24, start_offset=24, starts_line=False, line_number=3, is_jump_target=True, positions=None), - Instruction(opname='STORE_FAST', opcode=179, arg=0, argval='i', argrepr='i', offset=28, start_offset=28, starts_line=False, line_number=3, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=30, start_offset=30, starts_line=True, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=40, start_offset=40, starts_line=False, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='FOR_ITER', opcode=115, arg=28, argval=84, argrepr='to 84', offset=24, start_offset=24, starts_line=False, line_number=3, is_jump_target=True, positions=None), + Instruction(opname='STORE_FAST', opcode=176, arg=0, argval='i', argrepr='i', offset=28, start_offset=28, starts_line=False, line_number=3, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=30, start_offset=30, starts_line=True, line_number=4, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=40, start_offset=40, starts_line=False, line_number=4, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=42, start_offset=42, starts_line=False, line_number=4, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=50, start_offset=50, starts_line=False, line_number=4, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=52, start_offset=52, starts_line=True, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=2, argval=4, argrepr='4', offset=54, start_offset=54, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=101, arg=18, argval='<', argrepr='bool(<)', offset=56, start_offset=56, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=2, argval=66, argrepr='to 66', offset=60, start_offset=60, starts_line=False, line_number=5, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=127, arg=21, argval=24, argrepr='to 24', offset=62, start_offset=62, starts_line=True, line_number=6, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=66, start_offset=66, starts_line=True, line_number=7, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=3, argval=6, argrepr='6', offset=68, start_offset=68, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=101, arg=148, argval='>', argrepr='bool(>)', offset=70, start_offset=70, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_TRUE', opcode=167, arg=2, argval=80, argrepr='to 80', offset=74, start_offset=74, starts_line=False, line_number=7, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=127, arg=28, argval=24, argrepr='to 24', offset=76, start_offset=76, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=52, start_offset=52, starts_line=True, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=2, argval=4, argrepr='4', offset=54, start_offset=54, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=98, arg=18, argval='<', argrepr='bool(<)', offset=56, start_offset=56, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=2, argval=66, argrepr='to 66', offset=60, start_offset=60, starts_line=False, line_number=5, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=124, arg=21, argval=24, argrepr='to 24', offset=62, start_offset=62, starts_line=True, line_number=6, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=66, start_offset=66, starts_line=True, line_number=7, is_jump_target=True, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=3, argval=6, argrepr='6', offset=68, start_offset=68, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=98, arg=148, argval='>', argrepr='bool(>)', offset=70, start_offset=70, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_TRUE', opcode=163, arg=2, argval=80, argrepr='to 80', offset=74, start_offset=74, starts_line=False, line_number=7, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=124, arg=28, argval=24, argrepr='to 24', offset=76, start_offset=76, starts_line=False, line_number=7, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=80, start_offset=80, starts_line=True, line_number=8, is_jump_target=True, positions=None), - Instruction(opname='JUMP_FORWARD', opcode=129, arg=12, argval=108, argrepr='to 108', offset=82, start_offset=82, starts_line=False, line_number=8, is_jump_target=False, positions=None), + Instruction(opname='JUMP_FORWARD', opcode=126, arg=12, argval=108, argrepr='to 108', offset=82, start_offset=82, starts_line=False, line_number=8, is_jump_target=False, positions=None), Instruction(opname='END_FOR', opcode=24, arg=None, argval=None, argrepr='', offset=84, start_offset=84, starts_line=True, line_number=3, is_jump_target=True, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=86, start_offset=86, starts_line=True, line_number=10, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=4, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=96, start_offset=96, starts_line=False, line_number=10, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=86, start_offset=86, starts_line=True, line_number=10, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=4, argval='I can haz else clause?', argrepr="'I can haz else clause?'", offset=96, start_offset=96, starts_line=False, line_number=10, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=98, start_offset=98, starts_line=False, line_number=10, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=106, start_offset=106, starts_line=False, line_number=10, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST_CHECK', opcode=149, arg=0, argval='i', argrepr='i', offset=108, start_offset=108, starts_line=True, line_number=11, is_jump_target=True, positions=None), + Instruction(opname='LOAD_FAST_CHECK', opcode=146, arg=0, argval='i', argrepr='i', offset=108, start_offset=108, starts_line=True, line_number=11, is_jump_target=True, positions=None), Instruction(opname='TO_BOOL', opcode=56, arg=None, argval=None, argrepr='', offset=110, start_offset=110, starts_line=False, line_number=11, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=37, argval=194, argrepr='to 194', offset=118, start_offset=118, starts_line=False, line_number=11, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=120, start_offset=120, starts_line=True, line_number=12, is_jump_target=True, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=130, start_offset=130, starts_line=False, line_number=12, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=37, argval=194, argrepr='to 194', offset=118, start_offset=118, starts_line=False, line_number=11, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=120, start_offset=120, starts_line=True, line_number=12, is_jump_target=True, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=130, start_offset=130, starts_line=False, line_number=12, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=132, start_offset=132, starts_line=False, line_number=12, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=140, start_offset=140, starts_line=False, line_number=12, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=142, start_offset=142, starts_line=True, line_number=13, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=5, argval=1, argrepr='1', offset=144, start_offset=144, starts_line=False, line_number=13, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=142, start_offset=142, starts_line=True, line_number=13, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=5, argval=1, argrepr='1', offset=144, start_offset=144, starts_line=False, line_number=13, is_jump_target=False, positions=None), Instruction(opname='BINARY_OP', opcode=67, arg=23, argval=23, argrepr='-=', offset=146, start_offset=146, starts_line=False, line_number=13, is_jump_target=False, positions=None), - Instruction(opname='STORE_FAST', opcode=179, arg=0, argval='i', argrepr='i', offset=150, start_offset=150, starts_line=False, line_number=13, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=152, start_offset=152, starts_line=True, line_number=14, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=3, argval=6, argrepr='6', offset=154, start_offset=154, starts_line=False, line_number=14, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=101, arg=148, argval='>', argrepr='bool(>)', offset=156, start_offset=156, starts_line=False, line_number=14, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=2, argval=166, argrepr='to 166', offset=160, start_offset=160, starts_line=False, line_number=14, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=127, arg=29, argval=108, argrepr='to 108', offset=162, start_offset=162, starts_line=True, line_number=15, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=166, start_offset=166, starts_line=True, line_number=16, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=2, argval=4, argrepr='4', offset=168, start_offset=168, starts_line=False, line_number=16, is_jump_target=False, positions=None), - Instruction(opname='COMPARE_OP', opcode=101, arg=18, argval='<', argrepr='bool(<)', offset=170, start_offset=170, starts_line=False, line_number=16, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=1, argval=178, argrepr='to 178', offset=174, start_offset=174, starts_line=False, line_number=16, is_jump_target=False, positions=None), - Instruction(opname='JUMP_FORWARD', opcode=129, arg=19, argval=216, argrepr='to 216', offset=176, start_offset=176, starts_line=True, line_number=17, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=178, start_offset=178, starts_line=True, line_number=11, is_jump_target=True, positions=None), + Instruction(opname='STORE_FAST', opcode=176, arg=0, argval='i', argrepr='i', offset=150, start_offset=150, starts_line=False, line_number=13, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=152, start_offset=152, starts_line=True, line_number=14, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=3, argval=6, argrepr='6', offset=154, start_offset=154, starts_line=False, line_number=14, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=98, arg=148, argval='>', argrepr='bool(>)', offset=156, start_offset=156, starts_line=False, line_number=14, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=2, argval=166, argrepr='to 166', offset=160, start_offset=160, starts_line=False, line_number=14, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=124, arg=29, argval=108, argrepr='to 108', offset=162, start_offset=162, starts_line=True, line_number=15, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=166, start_offset=166, starts_line=True, line_number=16, is_jump_target=True, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=2, argval=4, argrepr='4', offset=168, start_offset=168, starts_line=False, line_number=16, is_jump_target=False, positions=None), + Instruction(opname='COMPARE_OP', opcode=98, arg=18, argval='<', argrepr='bool(<)', offset=170, start_offset=170, starts_line=False, line_number=16, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=1, argval=178, argrepr='to 178', offset=174, start_offset=174, starts_line=False, line_number=16, is_jump_target=False, positions=None), + Instruction(opname='JUMP_FORWARD', opcode=126, arg=19, argval=216, argrepr='to 216', offset=176, start_offset=176, starts_line=True, line_number=17, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=178, start_offset=178, starts_line=True, line_number=11, is_jump_target=True, positions=None), Instruction(opname='TO_BOOL', opcode=56, arg=None, argval=None, argrepr='', offset=180, start_offset=180, starts_line=False, line_number=11, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=2, argval=194, argrepr='to 194', offset=188, start_offset=188, starts_line=False, line_number=11, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=127, arg=37, argval=120, argrepr='to 120', offset=190, start_offset=190, starts_line=False, line_number=11, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=194, start_offset=194, starts_line=True, line_number=19, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=6, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=204, start_offset=204, starts_line=False, line_number=19, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=2, argval=194, argrepr='to 194', offset=188, start_offset=188, starts_line=False, line_number=11, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=124, arg=37, argval=120, argrepr='to 120', offset=190, start_offset=190, starts_line=False, line_number=11, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=194, start_offset=194, starts_line=True, line_number=19, is_jump_target=True, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=6, argval='Who let lolcatz into this test suite?', argrepr="'Who let lolcatz into this test suite?'", offset=204, start_offset=204, starts_line=False, line_number=19, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=206, start_offset=206, starts_line=False, line_number=19, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=214, start_offset=214, starts_line=False, line_number=19, is_jump_target=False, positions=None), Instruction(opname='NOP', opcode=42, arg=None, argval=None, argrepr='', offset=216, start_offset=216, starts_line=True, line_number=20, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=5, argval=1, argrepr='1', offset=218, start_offset=218, starts_line=True, line_number=21, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=7, argval=0, argrepr='0', offset=220, start_offset=220, starts_line=False, line_number=21, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=5, argval=1, argrepr='1', offset=218, start_offset=218, starts_line=True, line_number=21, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=7, argval=0, argrepr='0', offset=220, start_offset=220, starts_line=False, line_number=21, is_jump_target=False, positions=None), Instruction(opname='BINARY_OP', opcode=67, arg=11, argval=11, argrepr='/', offset=222, start_offset=222, starts_line=False, line_number=21, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=226, start_offset=226, starts_line=False, line_number=21, is_jump_target=False, positions=None), - Instruction(opname='LOAD_FAST', opcode=147, arg=0, argval='i', argrepr='i', offset=228, start_offset=228, starts_line=True, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='LOAD_FAST', opcode=144, arg=0, argval='i', argrepr='i', offset=228, start_offset=228, starts_line=True, line_number=25, is_jump_target=False, positions=None), Instruction(opname='BEFORE_WITH', opcode=2, arg=None, argval=None, argrepr='', offset=230, start_offset=230, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='STORE_FAST', opcode=179, arg=1, argval='dodgy', argrepr='dodgy', offset=232, start_offset=232, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=234, start_offset=234, starts_line=True, line_number=26, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=8, argval='Never reach this', argrepr="'Never reach this'", offset=244, start_offset=244, starts_line=False, line_number=26, is_jump_target=False, positions=None), + Instruction(opname='STORE_FAST', opcode=176, arg=1, argval='dodgy', argrepr='dodgy', offset=232, start_offset=232, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=234, start_offset=234, starts_line=True, line_number=26, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=8, argval='Never reach this', argrepr="'Never reach this'", offset=244, start_offset=244, starts_line=False, line_number=26, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=246, start_offset=246, starts_line=False, line_number=26, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=254, start_offset=254, starts_line=False, line_number=26, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=0, argval=None, argrepr='None', offset=256, start_offset=256, starts_line=True, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=0, argval=None, argrepr='None', offset=258, start_offset=258, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=0, argval=None, argrepr='None', offset=260, start_offset=260, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=0, argval=None, argrepr='None', offset=256, start_offset=256, starts_line=True, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=0, argval=None, argrepr='None', offset=258, start_offset=258, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=0, argval=None, argrepr='None', offset=260, start_offset=260, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=2, argval=2, argrepr='', offset=262, start_offset=262, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=270, start_offset=270, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=272, start_offset=272, starts_line=True, line_number=28, is_jump_target=True, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=282, start_offset=282, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=272, start_offset=272, starts_line=True, line_number=28, is_jump_target=True, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=282, start_offset=282, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=284, start_offset=284, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=292, start_offset=292, starts_line=False, line_number=28, is_jump_target=False, positions=None), - Instruction(opname='RETURN_CONST', opcode=170, arg=0, argval=None, argrepr='None', offset=294, start_offset=294, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='RETURN_CONST', opcode=167, arg=0, argval=None, argrepr='None', offset=294, start_offset=294, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='PUSH_EXC_INFO', opcode=45, arg=None, argval=None, argrepr='', offset=296, start_offset=296, starts_line=True, line_number=25, is_jump_target=False, positions=None), Instruction(opname='WITH_EXCEPT_START', opcode=66, arg=None, argval=None, argrepr='', offset=298, start_offset=298, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='TO_BOOL', opcode=56, arg=None, argval=None, argrepr='', offset=300, start_offset=300, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_TRUE', opcode=167, arg=1, argval=312, argrepr='to 312', offset=308, start_offset=308, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=169, arg=2, argval=2, argrepr='', offset=310, start_offset=310, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_TRUE', opcode=163, arg=1, argval=312, argrepr='to 312', offset=308, start_offset=308, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=165, arg=2, argval=2, argrepr='', offset=310, start_offset=310, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=312, start_offset=312, starts_line=False, line_number=25, is_jump_target=True, positions=None), Instruction(opname='POP_EXCEPT', opcode=43, arg=None, argval=None, argrepr='', offset=314, start_offset=314, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=316, start_offset=316, starts_line=False, line_number=25, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=318, start_offset=318, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=127, arg=26, argval=272, argrepr='to 272', offset=320, start_offset=320, starts_line=False, line_number=25, is_jump_target=False, positions=None), - Instruction(opname='COPY', opcode=107, arg=3, argval=3, argrepr='', offset=324, start_offset=324, starts_line=True, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=124, arg=26, argval=272, argrepr='to 272', offset=320, start_offset=320, starts_line=False, line_number=25, is_jump_target=False, positions=None), + Instruction(opname='COPY', opcode=104, arg=3, argval=3, argrepr='', offset=324, start_offset=324, starts_line=True, line_number=None, is_jump_target=False, positions=None), Instruction(opname='POP_EXCEPT', opcode=43, arg=None, argval=None, argrepr='', offset=326, start_offset=326, starts_line=False, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=169, arg=1, argval=1, argrepr='', offset=328, start_offset=328, starts_line=False, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=165, arg=1, argval=1, argrepr='', offset=328, start_offset=328, starts_line=False, line_number=None, is_jump_target=False, positions=None), Instruction(opname='PUSH_EXC_INFO', opcode=45, arg=None, argval=None, argrepr='', offset=330, start_offset=330, starts_line=False, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=4, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=332, start_offset=332, starts_line=True, line_number=22, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=4, argval='ZeroDivisionError', argrepr='ZeroDivisionError', offset=332, start_offset=332, starts_line=True, line_number=22, is_jump_target=False, positions=None), Instruction(opname='CHECK_EXC_MATCH', opcode=20, arg=None, argval=None, argrepr='', offset=342, start_offset=342, starts_line=False, line_number=22, is_jump_target=False, positions=None), - Instruction(opname='POP_JUMP_IF_FALSE', opcode=163, arg=15, argval=376, argrepr='to 376', offset=344, start_offset=344, starts_line=False, line_number=22, is_jump_target=False, positions=None), + Instruction(opname='POP_JUMP_IF_FALSE', opcode=160, arg=15, argval=376, argrepr='to 376', offset=344, start_offset=344, starts_line=False, line_number=22, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=346, start_offset=346, starts_line=False, line_number=22, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=348, start_offset=348, starts_line=True, line_number=23, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=9, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=358, start_offset=358, starts_line=False, line_number=23, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=348, start_offset=348, starts_line=True, line_number=23, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=9, argval='Here we go, here we go, here we go...', argrepr="'Here we go, here we go, here we go...'", offset=358, start_offset=358, starts_line=False, line_number=23, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=360, start_offset=360, starts_line=False, line_number=23, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=368, start_offset=368, starts_line=False, line_number=23, is_jump_target=False, positions=None), Instruction(opname='POP_EXCEPT', opcode=43, arg=None, argval=None, argrepr='', offset=370, start_offset=370, starts_line=False, line_number=23, is_jump_target=False, positions=None), - Instruction(opname='JUMP_BACKWARD', opcode=127, arg=52, argval=272, argrepr='to 272', offset=372, start_offset=372, starts_line=False, line_number=23, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=169, arg=0, argval=0, argrepr='', offset=376, start_offset=376, starts_line=True, line_number=22, is_jump_target=True, positions=None), - Instruction(opname='COPY', opcode=107, arg=3, argval=3, argrepr='', offset=378, start_offset=378, starts_line=True, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='JUMP_BACKWARD', opcode=124, arg=52, argval=272, argrepr='to 272', offset=372, start_offset=372, starts_line=False, line_number=23, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=165, arg=0, argval=0, argrepr='', offset=376, start_offset=376, starts_line=True, line_number=22, is_jump_target=True, positions=None), + Instruction(opname='COPY', opcode=104, arg=3, argval=3, argrepr='', offset=378, start_offset=378, starts_line=True, line_number=None, is_jump_target=False, positions=None), Instruction(opname='POP_EXCEPT', opcode=43, arg=None, argval=None, argrepr='', offset=380, start_offset=380, starts_line=False, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=169, arg=1, argval=1, argrepr='', offset=382, start_offset=382, starts_line=False, line_number=None, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=165, arg=1, argval=1, argrepr='', offset=382, start_offset=382, starts_line=False, line_number=None, is_jump_target=False, positions=None), Instruction(opname='PUSH_EXC_INFO', opcode=45, arg=None, argval=None, argrepr='', offset=384, start_offset=384, starts_line=False, line_number=None, is_jump_target=False, positions=None), - Instruction(opname='LOAD_GLOBAL', opcode=153, arg=3, argval='print', argrepr='print + NULL', offset=386, start_offset=386, starts_line=True, line_number=28, is_jump_target=False, positions=None), - Instruction(opname='LOAD_CONST', opcode=145, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=396, start_offset=396, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='LOAD_GLOBAL', opcode=150, arg=3, argval='print', argrepr='print + NULL', offset=386, start_offset=386, starts_line=True, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='LOAD_CONST', opcode=142, arg=10, argval="OK, now we're done", argrepr='"OK, now we\'re done"', offset=396, start_offset=396, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='CALL', opcode=75, arg=1, argval=1, argrepr='', offset=398, start_offset=398, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='POP_TOP', opcode=44, arg=None, argval=None, argrepr='', offset=406, start_offset=406, starts_line=False, line_number=28, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=169, arg=0, argval=0, argrepr='', offset=408, start_offset=408, starts_line=False, line_number=28, is_jump_target=False, positions=None), - Instruction(opname='COPY', opcode=107, arg=3, argval=3, argrepr='', offset=410, start_offset=410, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=165, arg=0, argval=0, argrepr='', offset=408, start_offset=408, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='COPY', opcode=104, arg=3, argval=3, argrepr='', offset=410, start_offset=410, starts_line=False, line_number=28, is_jump_target=False, positions=None), Instruction(opname='POP_EXCEPT', opcode=43, arg=None, argval=None, argrepr='', offset=412, start_offset=412, starts_line=False, line_number=28, is_jump_target=False, positions=None), - Instruction(opname='RERAISE', opcode=169, arg=1, argval=1, argrepr='', offset=414, start_offset=414, starts_line=False, line_number=28, is_jump_target=False, positions=None), + Instruction(opname='RERAISE', opcode=165, arg=1, argval=1, argrepr='', offset=414, start_offset=414, starts_line=False, line_number=28, is_jump_target=False, positions=None), ] # One last piece of inspect fodder to check the default line number handling def simple(): pass expected_opinfo_simple = [ Instruction(opname='RESUME', opcode=166, arg=0, argval=0, argrepr='', offset=0, start_offset=0, starts_line=True, line_number=simple.__code__.co_firstlineno, is_jump_target=False, positions=None), - Instruction(opname='RETURN_CONST', opcode=170, arg=0, argval=None, argrepr='None', offset=2, start_offset=2, starts_line=False, line_number=simple.__code__.co_firstlineno, is_jump_target=False), + Instruction(opname='RETURN_CONST', opcode=167, arg=0, argval=None, argrepr='None', offset=2, start_offset=2, starts_line=False, line_number=simple.__code__.co_firstlineno, is_jump_target=False), ] diff --git a/Objects/frameobject.c b/Objects/frameobject.c index ccde85f18c039a..d9c676a0c6c094 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -437,7 +437,7 @@ mark_stacks(PyCodeObject *code_obj, int len) case CALL_KW: { int args = oparg; - for (int j = 0; j < args+3; j++) { + for (int j = 0; j < args + 3; j++) { next_stack = pop_value(next_stack); } next_stack = push_value(next_stack, Object); diff --git a/Programs/test_frozenmain.h b/Programs/test_frozenmain.h index 302379a4be12f1..42b8b78dfc51f8 100644 --- a/Programs/test_frozenmain.h +++ b/Programs/test_frozenmain.h @@ -1,17 +1,17 @@ // Auto-generated by Programs/freeze_test_frozenmain.py unsigned char M_test_frozenmain[] = { 227,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0, - 0,0,0,0,0,243,164,0,0,0,166,0,145,0,145,1, - 125,0,183,0,145,0,145,1,125,1,183,1,156,2,46,0, - 145,2,75,1,0,0,0,0,0,0,44,0,156,2,46,0, - 145,3,156,0,132,6,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,243,164,0,0,0,166,0,142,0,142,1, + 122,0,180,0,142,0,142,1,122,1,180,1,153,2,46,0, + 142,2,75,1,0,0,0,0,0,0,44,0,153,2,46,0, + 142,3,153,0,129,6,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,75,2,0,0,0,0,0,0, - 44,0,156,1,132,8,0,0,0,0,0,0,0,0,0,0, + 44,0,153,1,129,8,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,46,0,75,0,0,0,0,0, - 0,0,145,4,12,0,0,0,183,5,145,5,31,0,118,20, - 0,0,183,6,156,2,46,0,145,6,156,6,27,0,145,7, - 156,5,156,6,12,0,0,0,27,0,73,4,75,1,0,0, - 0,0,0,0,44,0,127,22,0,0,24,0,170,1,41,8, + 0,0,142,4,12,0,0,0,180,5,142,5,31,0,115,20, + 0,0,180,6,153,2,46,0,142,6,153,6,27,0,142,7, + 153,5,153,6,12,0,0,0,27,0,73,4,75,1,0,0, + 0,0,0,0,44,0,124,22,0,0,24,0,167,1,41,8, 233,0,0,0,0,78,122,18,70,114,111,122,101,110,32,72, 101,108,108,111,32,87,111,114,108,100,122,8,115,121,115,46, 97,114,103,118,218,6,99,111,110,102,105,103,41,5,218,12, diff --git a/Python/abstract_interp_cases.c.h b/Python/abstract_interp_cases.c.h index 07e8a711575c5b..a6025810b10878 100644 --- a/Python/abstract_interp_cases.c.h +++ b/Python/abstract_interp_cases.c.h @@ -681,6 +681,13 @@ break; } + case CALL_BUILTIN_CLASS: { + STACK_SHRINK(oparg); + STACK_SHRINK(1); + PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); + break; + } + case CALL_NO_KW_BUILTIN_O: { STACK_SHRINK(oparg); STACK_SHRINK(1); @@ -695,6 +702,13 @@ break; } + case CALL_BUILTIN_FAST_WITH_KEYWORDS: { + STACK_SHRINK(oparg); + STACK_SHRINK(1); + PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); + break; + } + case CALL_NO_KW_LEN: { STACK_SHRINK(oparg); STACK_SHRINK(1); @@ -716,6 +730,13 @@ break; } + case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: { + STACK_SHRINK(oparg); + STACK_SHRINK(1); + PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); + break; + } + case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS: { STACK_SHRINK(oparg); STACK_SHRINK(1); diff --git a/Python/bytecodes.c b/Python/bytecodes.c index cb7ad3a852c2e7..d1666dd64a0b91 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2825,8 +2825,7 @@ dummy_func( } // Cache layout: counter/1, func_version/2 - // Neither CALL_INTRINSIC_1/2 nor CALL_FUNCTION_EX are members! CALL_KW - // has its own family. + // CALL_INTRINSIC_1/2, CALL_KW, and CALL_FUNCTION_EX aren't members! family(CALL, INLINE_CACHE_ENTRIES_CALL) = { CALL_BOUND_METHOD_EXACT_ARGS, CALL_PY_EXACT_ARGS, @@ -3165,37 +3164,11 @@ dummy_func( args--; total_args++; } - PyObject *kwnames = NULL; - int kwnames_len = 0; DEOPT_IF(!PyType_Check(callable), CALL); PyTypeObject *tp = (PyTypeObject *)callable; DEOPT_IF(tp->tp_vectorcall == NULL, CALL); STAT_INC(CALL, hit); - res = tp->tp_vectorcall((PyObject *)tp, args, - total_args - kwnames_len, kwnames); - /* Free the arguments. */ - for (int i = 0; i < total_args; i++) { - Py_DECREF(args[i]); - } - Py_DECREF(tp); - ERROR_IF(res == NULL, error); - CHECK_EVAL_BREAKER(); - } - - inst(CALL_KW_BUILTIN_CLASS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { - int total_args = oparg; - if (self_or_null != NULL) { - args--; - total_args++; - } - int kwnames_len = (int)PyTuple_GET_SIZE(kwnames); - DEOPT_IF(!PyType_Check(callable), CALL_KW); - PyTypeObject *tp = (PyTypeObject *)callable; - DEOPT_IF(tp->tp_vectorcall == NULL, CALL_KW); - STAT_INC(CALL_KW, hit); - res = tp->tp_vectorcall((PyObject *)tp, args, - total_args - kwnames_len, kwnames); - Py_DECREF(kwnames); + res = tp->tp_vectorcall((PyObject *)tp, args, total_args, NULL); /* Free the arguments. */ for (int i = 0; i < total_args; i++) { Py_DECREF(args[i]); @@ -3272,8 +3245,6 @@ dummy_func( args--; total_args++; } - PyObject *kwnames = NULL; - int kwnames_len = 0; DEOPT_IF(!PyCFunction_CheckExact(callable), CALL); DEOPT_IF(PyCFunction_GET_FLAGS(callable) != (METH_FASTCALL | METH_KEYWORDS), CALL); @@ -3282,12 +3253,7 @@ dummy_func( _PyCFunctionFastWithKeywords cfunc = (_PyCFunctionFastWithKeywords)(void(*)(void)) PyCFunction_GET_FUNCTION(callable); - res = cfunc( - PyCFunction_GET_SELF(callable), - args, - total_args - kwnames_len, - kwnames - ); + res = cfunc(PyCFunction_GET_SELF(callable), args, total_args, NULL); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); /* Free the arguments. */ @@ -3299,38 +3265,6 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_KW_BUILTIN_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { - /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ - int total_args = oparg; - if (self_or_null != NULL) { - args--; - total_args++; - } - DEOPT_IF(!PyCFunction_CheckExact(callable), CALL_KW); - DEOPT_IF(PyCFunction_GET_FLAGS(callable) != - (METH_FASTCALL | METH_KEYWORDS), CALL_KW); - STAT_INC(CALL_KW, hit); - /* res = func(self, args, nargs, kwnames) */ - _PyCFunctionFastWithKeywords cfunc = - (_PyCFunctionFastWithKeywords)(void(*)(void)) - PyCFunction_GET_FUNCTION(callable); - res = cfunc( - PyCFunction_GET_SELF(callable), - args, - total_args - (int)PyTuple_GET_SIZE(kwnames), - kwnames - ); - assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - Py_DECREF(kwnames); - /* Free the arguments. */ - for (int i = 0; i < total_args; i++) { - Py_DECREF(args[i]); - } - Py_DECREF(callable); - ERROR_IF(res == NULL, error); - CHECK_EVAL_BREAKER(); - } - inst(CALL_NO_KW_LEN, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { /* len(o) */ int total_args = oparg; @@ -3438,8 +3372,6 @@ dummy_func( args--; total_args++; } - PyObject *kwnames = NULL; - int kwnames_len = 0; PyMethodDescrObject *method = (PyMethodDescrObject *)callable; DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL); PyMethodDef *meth = method->d_method; @@ -3451,7 +3383,7 @@ dummy_func( int nargs = total_args - 1; _PyCFunctionFastWithKeywords cfunc = (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth; - res = cfunc(self, args + 1, nargs - kwnames_len, kwnames); + res = cfunc(self, args + 1, nargs, NULL); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); /* Free the arguments. */ @@ -3463,35 +3395,6 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { - int total_args = oparg; - if (self_or_null != NULL) { - args--; - total_args++; - } - PyMethodDescrObject *method = (PyMethodDescrObject *)callable; - DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL_KW); - PyMethodDef *meth = method->d_method; - DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL_KW); - PyTypeObject *d_type = method->d_common.d_type; - PyObject *self = args[0]; - DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL_KW); - STAT_INC(CALL_KW, hit); - int nargs = total_args - 1; - _PyCFunctionFastWithKeywords cfunc = - (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth; - res = cfunc(self, args + 1, nargs - (int)PyTuple_GET_SIZE(kwnames), kwnames); - assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - Py_DECREF(kwnames); - /* Free the arguments. */ - for (int i = 0; i < total_args; i++) { - Py_DECREF(args[i]); - } - Py_DECREF(callable); - ERROR_IF(res == NULL, error); - CHECK_EVAL_BREAKER(); - } - inst(CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { assert(oparg == 0 || oparg == 1); int total_args = oparg; @@ -3554,40 +3457,21 @@ dummy_func( int is_meth = PEEK(oparg + 2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(oparg + 3); - PyObject *arg = total_args == 0 ? - &_PyInstrumentation_MISSING : PEEK(total_args + 1); + PyObject *arg = total_args == 0 ? &_PyInstrumentation_MISSING + : PEEK(total_args + 1); int err = _Py_call_instrumentation_2args( tstate, PY_MONITORING_EVENT_CALL, - frame, next_instr-1, function, arg); + frame, next_instr - 1, function, arg); ERROR_IF(err, error); - _PyCallCache *cache = (_PyCallCache *)next_instr; - INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL_KW); } - // Cache layout: counter/1, func_version/2 - family(CALL_KW, INLINE_CACHE_ENTRIES_CALL) = { - CALL_KW_BUILTIN_CLASS, - CALL_KW_BUILTIN_FAST_WITH_KEYWORDS, - CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, - }; - - inst(CALL_KW, (unused/1, unused/2, callable, self_or_null, args[oparg], kwnames -- res)) { + inst(CALL_KW, (callable, self_or_null, args[oparg], kwnames -- res)) { int total_args = oparg; if (self_or_null != NULL) { args--; total_args++; } - #if ENABLE_SPECIALIZATION - _PyCallCache *cache = (_PyCallCache *)next_instr; - if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { - next_instr--; - _Py_Specialize_CallKw(callable, next_instr, total_args, kwnames); - DISPATCH_SAME_OPARG(); - } - STAT_INC(CALL_KW, deferred); - DECREMENT_ADAPTIVE_COUNTER(cache->counter); - #endif /* ENABLE_SPECIALIZATION */ if (self_or_null == NULL && Py_TYPE(callable) == &PyMethod_Type) { args--; total_args++; @@ -3618,7 +3502,6 @@ dummy_func( if (new_frame == NULL) { goto error; } - SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); } diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index a232c69f9fd1f1..f45a18e89935ef 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -2381,6 +2381,37 @@ break; } + case CALL_BUILTIN_CLASS: { + PyObject **args; + PyObject *self_or_null; + PyObject *callable; + PyObject *res; + args = stack_pointer - oparg; + self_or_null = stack_pointer[-1 - oparg]; + callable = stack_pointer[-2 - oparg]; + int total_args = oparg; + if (self_or_null != NULL) { + args--; + total_args++; + } + DEOPT_IF(!PyType_Check(callable), CALL); + PyTypeObject *tp = (PyTypeObject *)callable; + DEOPT_IF(tp->tp_vectorcall == NULL, CALL); + STAT_INC(CALL, hit); + res = tp->tp_vectorcall((PyObject *)tp, args, total_args, NULL); + /* Free the arguments. */ + for (int i = 0; i < total_args; i++) { + Py_DECREF(args[i]); + } + Py_DECREF(tp); + if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + STACK_SHRINK(oparg); + STACK_SHRINK(1); + stack_pointer[-1] = res; + CHECK_EVAL_BREAKER(); + break; + } + case CALL_NO_KW_BUILTIN_O: { PyObject **args; PyObject *self_or_null; @@ -2463,6 +2494,44 @@ break; } + case CALL_BUILTIN_FAST_WITH_KEYWORDS: { + PyObject **args; + PyObject *self_or_null; + PyObject *callable; + PyObject *res; + args = stack_pointer - oparg; + self_or_null = stack_pointer[-1 - oparg]; + callable = stack_pointer[-2 - oparg]; + /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ + int total_args = oparg; + if (self_or_null != NULL) { + args--; + total_args++; + } + DEOPT_IF(!PyCFunction_CheckExact(callable), CALL); + DEOPT_IF(PyCFunction_GET_FLAGS(callable) != + (METH_FASTCALL | METH_KEYWORDS), CALL); + STAT_INC(CALL, hit); + /* res = func(self, args, nargs, kwnames) */ + _PyCFunctionFastWithKeywords cfunc = + (_PyCFunctionFastWithKeywords)(void(*)(void)) + PyCFunction_GET_FUNCTION(callable); + res = cfunc(PyCFunction_GET_SELF(callable), args, total_args, NULL); + assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); + + /* Free the arguments. */ + for (int i = 0; i < total_args; i++) { + Py_DECREF(args[i]); + } + Py_DECREF(callable); + if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + STACK_SHRINK(oparg); + STACK_SHRINK(1); + stack_pointer[-1] = res; + CHECK_EVAL_BREAKER(); + break; + } + case CALL_NO_KW_LEN: { PyObject **args; PyObject *self_or_null; @@ -2577,6 +2646,46 @@ break; } + case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: { + PyObject **args; + PyObject *self_or_null; + PyObject *callable; + PyObject *res; + args = stack_pointer - oparg; + self_or_null = stack_pointer[-1 - oparg]; + callable = stack_pointer[-2 - oparg]; + int total_args = oparg; + if (self_or_null != NULL) { + args--; + total_args++; + } + PyMethodDescrObject *method = (PyMethodDescrObject *)callable; + DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL); + PyMethodDef *meth = method->d_method; + DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL); + PyTypeObject *d_type = method->d_common.d_type; + PyObject *self = args[0]; + DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL); + STAT_INC(CALL, hit); + int nargs = total_args - 1; + _PyCFunctionFastWithKeywords cfunc = + (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth; + res = cfunc(self, args + 1, nargs, NULL); + assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); + + /* Free the arguments. */ + for (int i = 0; i < total_args; i++) { + Py_DECREF(args[i]); + } + Py_DECREF(callable); + if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + STACK_SHRINK(oparg); + STACK_SHRINK(1); + stack_pointer[-1] = res; + CHECK_EVAL_BREAKER(); + break; + } + case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS: { PyObject **args; PyObject *self_or_null; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 3377e33cbf0ee9..eb324d0ae2767e 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -4167,14 +4167,11 @@ args--; total_args++; } - PyObject *kwnames = NULL; - int kwnames_len = 0; DEOPT_IF(!PyType_Check(callable), CALL); PyTypeObject *tp = (PyTypeObject *)callable; DEOPT_IF(tp->tp_vectorcall == NULL, CALL); STAT_INC(CALL, hit); - res = tp->tp_vectorcall((PyObject *)tp, args, - total_args - kwnames_len, kwnames); + res = tp->tp_vectorcall((PyObject *)tp, args, total_args, NULL); /* Free the arguments. */ for (int i = 0; i < total_args; i++) { Py_DECREF(args[i]); @@ -4189,43 +4186,6 @@ DISPATCH(); } - TARGET(CALL_KW_BUILTIN_CLASS) { - PyObject *kwnames; - PyObject **args; - PyObject *self_or_null; - PyObject *callable; - PyObject *res; - kwnames = stack_pointer[-1]; - args = stack_pointer - 1 - oparg; - self_or_null = stack_pointer[-2 - oparg]; - callable = stack_pointer[-3 - oparg]; - int total_args = oparg; - if (self_or_null != NULL) { - args--; - total_args++; - } - int kwnames_len = (int)PyTuple_GET_SIZE(kwnames); - DEOPT_IF(!PyType_Check(callable), CALL_KW); - PyTypeObject *tp = (PyTypeObject *)callable; - DEOPT_IF(tp->tp_vectorcall == NULL, CALL_KW); - STAT_INC(CALL_KW, hit); - res = tp->tp_vectorcall((PyObject *)tp, args, - total_args - kwnames_len, kwnames); - Py_DECREF(kwnames); - /* Free the arguments. */ - for (int i = 0; i < total_args; i++) { - Py_DECREF(args[i]); - } - Py_DECREF(tp); - if (res == NULL) { STACK_SHRINK(oparg); goto pop_3_error; } - STACK_SHRINK(oparg); - STACK_SHRINK(2); - stack_pointer[-1] = res; - next_instr += 3; - CHECK_EVAL_BREAKER(); - DISPATCH(); - } - TARGET(CALL_NO_KW_BUILTIN_O) { PyObject **args; PyObject *self_or_null; @@ -4324,8 +4284,6 @@ args--; total_args++; } - PyObject *kwnames = NULL; - int kwnames_len = 0; DEOPT_IF(!PyCFunction_CheckExact(callable), CALL); DEOPT_IF(PyCFunction_GET_FLAGS(callable) != (METH_FASTCALL | METH_KEYWORDS), CALL); @@ -4334,12 +4292,7 @@ _PyCFunctionFastWithKeywords cfunc = (_PyCFunctionFastWithKeywords)(void(*)(void)) PyCFunction_GET_FUNCTION(callable); - res = cfunc( - PyCFunction_GET_SELF(callable), - args, - total_args - kwnames_len, - kwnames - ); + res = cfunc(PyCFunction_GET_SELF(callable), args, total_args, NULL); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); /* Free the arguments. */ @@ -4356,52 +4309,6 @@ DISPATCH(); } - TARGET(CALL_KW_BUILTIN_FAST_WITH_KEYWORDS) { - PyObject *kwnames; - PyObject **args; - PyObject *self_or_null; - PyObject *callable; - PyObject *res; - kwnames = stack_pointer[-1]; - args = stack_pointer - 1 - oparg; - self_or_null = stack_pointer[-2 - oparg]; - callable = stack_pointer[-3 - oparg]; - /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ - int total_args = oparg; - if (self_or_null != NULL) { - args--; - total_args++; - } - DEOPT_IF(!PyCFunction_CheckExact(callable), CALL_KW); - DEOPT_IF(PyCFunction_GET_FLAGS(callable) != - (METH_FASTCALL | METH_KEYWORDS), CALL_KW); - STAT_INC(CALL_KW, hit); - /* res = func(self, args, nargs, kwnames) */ - _PyCFunctionFastWithKeywords cfunc = - (_PyCFunctionFastWithKeywords)(void(*)(void)) - PyCFunction_GET_FUNCTION(callable); - res = cfunc( - PyCFunction_GET_SELF(callable), - args, - total_args - (int)PyTuple_GET_SIZE(kwnames), - kwnames - ); - assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - Py_DECREF(kwnames); - /* Free the arguments. */ - for (int i = 0; i < total_args; i++) { - Py_DECREF(args[i]); - } - Py_DECREF(callable); - if (res == NULL) { STACK_SHRINK(oparg); goto pop_3_error; } - STACK_SHRINK(oparg); - STACK_SHRINK(2); - stack_pointer[-1] = res; - next_instr += 3; - CHECK_EVAL_BREAKER(); - DISPATCH(); - } - TARGET(CALL_NO_KW_LEN) { PyObject **args; PyObject *self_or_null; @@ -4559,8 +4466,6 @@ args--; total_args++; } - PyObject *kwnames = NULL; - int kwnames_len = 0; PyMethodDescrObject *method = (PyMethodDescrObject *)callable; DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL); PyMethodDef *meth = method->d_method; @@ -4572,7 +4477,7 @@ int nargs = total_args - 1; _PyCFunctionFastWithKeywords cfunc = (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth; - res = cfunc(self, args + 1, nargs - kwnames_len, kwnames); + res = cfunc(self, args + 1, nargs, NULL); assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); /* Free the arguments. */ @@ -4589,49 +4494,6 @@ DISPATCH(); } - TARGET(CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS) { - PyObject *kwnames; - PyObject **args; - PyObject *self_or_null; - PyObject *callable; - PyObject *res; - kwnames = stack_pointer[-1]; - args = stack_pointer - 1 - oparg; - self_or_null = stack_pointer[-2 - oparg]; - callable = stack_pointer[-3 - oparg]; - int total_args = oparg; - if (self_or_null != NULL) { - args--; - total_args++; - } - PyMethodDescrObject *method = (PyMethodDescrObject *)callable; - DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type), CALL_KW); - PyMethodDef *meth = method->d_method; - DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS), CALL_KW); - PyTypeObject *d_type = method->d_common.d_type; - PyObject *self = args[0]; - DEOPT_IF(!Py_IS_TYPE(self, d_type), CALL_KW); - STAT_INC(CALL_KW, hit); - int nargs = total_args - 1; - _PyCFunctionFastWithKeywords cfunc = - (_PyCFunctionFastWithKeywords)(void(*)(void))meth->ml_meth; - res = cfunc(self, args + 1, nargs - (int)PyTuple_GET_SIZE(kwnames), kwnames); - assert((res != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - Py_DECREF(kwnames); - /* Free the arguments. */ - for (int i = 0; i < total_args; i++) { - Py_DECREF(args[i]); - } - Py_DECREF(callable); - if (res == NULL) { STACK_SHRINK(oparg); goto pop_3_error; } - STACK_SHRINK(oparg); - STACK_SHRINK(2); - stack_pointer[-1] = res; - next_instr += 3; - CHECK_EVAL_BREAKER(); - DISPATCH(); - } - TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS) { PyObject **args; PyObject *self_or_null; @@ -4718,20 +4580,17 @@ int is_meth = PEEK(oparg + 2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(oparg + 3); - PyObject *arg = total_args == 0 ? - &_PyInstrumentation_MISSING : PEEK(total_args + 1); + PyObject *arg = total_args == 0 ? &_PyInstrumentation_MISSING + : PEEK(total_args + 1); int err = _Py_call_instrumentation_2args( tstate, PY_MONITORING_EVENT_CALL, - frame, next_instr-1, function, arg); + frame, next_instr - 1, function, arg); if (err) goto error; - _PyCallCache *cache = (_PyCallCache *)next_instr; - INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL_KW); } TARGET(CALL_KW) { PREDICTED(CALL_KW); - static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size"); PyObject *kwnames; PyObject **args; PyObject *self_or_null; @@ -4746,16 +4605,6 @@ args--; total_args++; } - #if ENABLE_SPECIALIZATION - _PyCallCache *cache = (_PyCallCache *)next_instr; - if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { - next_instr--; - _Py_Specialize_CallKw(callable, next_instr, total_args, kwnames); - DISPATCH_SAME_OPARG(); - } - STAT_INC(CALL_KW, deferred); - DECREMENT_ADAPTIVE_COUNTER(cache->counter); - #endif /* ENABLE_SPECIALIZATION */ if (self_or_null == NULL && Py_TYPE(callable) == &PyMethod_Type) { args--; total_args++; @@ -4786,7 +4635,6 @@ if (new_frame == NULL) { goto error; } - SKIP_OVER(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); } @@ -4822,7 +4670,6 @@ STACK_SHRINK(oparg); STACK_SHRINK(2); stack_pointer[-1] = res; - next_instr += 3; CHECK_EVAL_BREAKER(); DISPATCH(); } diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index e3b664b19b5a48..bff39a7aca2bf0 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -82,9 +82,6 @@ static void *opcode_targets[256] = { &&TARGET_CALL_INTRINSIC_1, &&TARGET_CALL_INTRINSIC_2, &&TARGET_CALL_KW, - &&TARGET_CALL_KW_BUILTIN_CLASS, - &&TARGET_CALL_KW_BUILTIN_FAST_WITH_KEYWORDS, - &&TARGET_CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, &&TARGET_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, &&TARGET_CALL_NO_KW_ALLOC_AND_ENTER_INIT, &&TARGET_CALL_NO_KW_BUILTIN_FAST, @@ -165,10 +162,10 @@ static void *opcode_targets[256] = { &&TARGET_POP_JUMP_IF_FALSE, &&TARGET_POP_JUMP_IF_NONE, &&TARGET_POP_JUMP_IF_NOT_NONE, - &&TARGET_RESUME, &&TARGET_POP_JUMP_IF_TRUE, &&TARGET_RAISE_VARARGS, &&TARGET_RERAISE, + &&TARGET_RESUME, &&TARGET_RETURN_CONST, &&TARGET_SEND, &&TARGET_SEND_GEN, @@ -235,6 +232,9 @@ static void *opcode_targets[256] = { &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, &&TARGET_INSTRUMENTED_RESUME, &&TARGET_INSTRUMENTED_END_FOR, &&TARGET_INSTRUMENTED_END_SEND, diff --git a/Python/specialize.c b/Python/specialize.c index 4c2ef292d3704d..96034d4f95c43d 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -107,7 +107,6 @@ _Py_GetSpecializationStats(void) { err += add_stat_dict(stats, STORE_SUBSCR, "store_subscr"); err += add_stat_dict(stats, STORE_ATTR, "store_attr"); err += add_stat_dict(stats, CALL, "call"); - err += add_stat_dict(stats, CALL_KW, "call_kw"); err += add_stat_dict(stats, BINARY_OP, "binary_op"); err += add_stat_dict(stats, COMPARE_OP, "compare_op"); err += add_stat_dict(stats, UNPACK_SEQUENCE, "unpack_sequence"); @@ -460,7 +459,6 @@ _PyCode_Quicken(PyCodeObject *code) #define SPEC_FAIL_CALL_STR 24 #define SPEC_FAIL_CALL_CLASS_NO_VECTORCALL 25 #define SPEC_FAIL_CALL_CLASS_MUTABLE 26 -#define SPEC_FAIL_CALL_KWNAMES 27 #define SPEC_FAIL_CALL_METHOD_WRAPPER 28 #define SPEC_FAIL_CALL_OPERATOR_WRAPPER 29 #define SPEC_FAIL_CALL_INIT_NOT_SIMPLE 30 @@ -1606,26 +1604,26 @@ get_init_for_simple_managed_python_class(_Py_CODEUNIT *instr, PyTypeObject *tp) { assert(tp->tp_new == PyBaseObject_Type.tp_new); if (tp->tp_alloc != PyType_GenericAlloc) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_OVERRIDDEN); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_OVERRIDDEN); return NULL; } if ((tp->tp_flags & Py_TPFLAGS_MANAGED_DICT) == 0) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_NO_DICT); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_NO_DICT); return NULL; } if (!(tp->tp_flags & Py_TPFLAGS_HEAPTYPE)) { /* Is this possible? */ - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_EXPECTED_ERROR); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_EXPECTED_ERROR); return NULL; } PyObject *init = _PyType_Lookup(tp, &_Py_ID(__init__)); if (init == NULL || !PyFunction_Check(init)) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_INIT_NOT_PYTHON); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_INIT_NOT_PYTHON); return NULL; } int kind = function_kind((PyCodeObject *)PyFunction_GET_CODE(init)); if (kind != SIMPLE_FUNCTION) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_INIT_NOT_SIMPLE); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_INIT_NOT_SIMPLE); return NULL; } ((PyHeapTypeObject *)tp)->_spec_cache.init = init; @@ -1633,14 +1631,13 @@ get_init_for_simple_managed_python_class(_Py_CODEUNIT *instr, PyTypeObject *tp) } static int -specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, - PyObject *kwnames) +specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) { assert(PyType_Check(callable)); PyTypeObject *tp = _PyType_CAST(callable); if (tp->tp_flags & Py_TPFLAGS_IMMUTABLETYPE) { int oparg = instr->op.arg; - if (nargs == 1 && kwnames == NULL && oparg == 1) { + if (nargs == 1 && oparg == 1) { if (tp == &PyUnicode_Type) { instr->op.code = CALL_NO_KW_STR_1; return 0; @@ -1655,10 +1652,10 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, } } if (tp->tp_vectorcall != NULL) { - instr->op.code = kwnames ? CALL_KW_BUILTIN_CLASS : CALL_BUILTIN_CLASS; + instr->op.code = CALL_BUILTIN_CLASS; return 0; } - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], tp == &PyUnicode_Type ? + SPECIALIZATION_FAIL(CALL, tp == &PyUnicode_Type ? SPEC_FAIL_CALL_STR : SPEC_FAIL_CALL_CLASS_NO_VECTORCALL); return -1; } @@ -1666,11 +1663,7 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, PyFunctionObject *init = get_init_for_simple_managed_python_class(instr, tp); if (init != NULL) { if (((PyCodeObject *)init->func_code)->co_argcount != nargs+1) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); - return -1; - } - if (kwnames) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_KWNAMES); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return -1; } _PyCallCache *cache = (_PyCallCache *)(instr + 1); @@ -1680,7 +1673,7 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, } return -1; } - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_CLASS_MUTABLE); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_CLASS_MUTABLE); return -1; } @@ -1733,19 +1726,14 @@ meth_descr_call_fail_kind(int ml_flags) static int specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr, - int nargs, PyObject *kwnames) + int nargs) { - if (kwnames) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_KWNAMES); - return -1; - } - switch (descr->d_method->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) { case METH_NOARGS: { if (nargs != 1) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return -1; } instr->op.code = CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS; @@ -1753,7 +1741,7 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr, } case METH_O: { if (nargs != 2) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return -1; } PyInterpreterState *interp = _PyInterpreterState_GET(); @@ -1773,33 +1761,28 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr, return 0; } case METH_FASTCALL | METH_KEYWORDS: { - instr->op.code = kwnames ? CALL_KW_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS - : CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS; + instr->op.code = CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS; return 0; } } - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], meth_descr_call_fail_kind(descr->d_method->ml_flags)); + SPECIALIZATION_FAIL(CALL, meth_descr_call_fail_kind(descr->d_method->ml_flags)); return -1; } static int specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs, - PyObject *kwnames, bool bound_method) + bool bound_method) { _PyCallCache *cache = (_PyCallCache *)(instr + 1); PyCodeObject *code = (PyCodeObject *)func->func_code; int kind = function_kind(code); /* Don't specialize if PEP 523 is active */ if (_PyInterpreterState_GET()->eval_frame) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_PEP_523); - return -1; - } - if (kwnames) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_KWNAMES); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_PEP_523); return -1; } if (kind != SIMPLE_FUNCTION) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], kind); + SPECIALIZATION_FAIL(CALL, kind); return -1; } int argcount = code->co_argcount; @@ -1807,7 +1790,7 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs, int min_args = argcount-defcount; // GH-105840: min_args is negative when somebody sets too many __defaults__! if (min_args < 0 || nargs > argcount || nargs < min_args) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return -1; } assert(nargs <= argcount && nargs >= min_args); @@ -1815,7 +1798,7 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs, assert(defcount == 0 || func->func_defaults != NULL); int version = _PyFunction_GetVersionForCurrentState(func); if (version == 0) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_OUT_OF_VERSIONS); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_OUT_OF_VERSIONS); return -1; } write_u32(cache->func_version, version); @@ -1823,7 +1806,7 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs, instr->op.code = bound_method ? CALL_BOUND_METHOD_EXACT_ARGS : CALL_PY_EXACT_ARGS; } else if (bound_method) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_BOUND_METHOD); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_BOUND_METHOD); return -1; } else { @@ -1833,8 +1816,7 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs, } static int -specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, - PyObject *kwnames) +specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) { if (PyCFunction_GET_FUNCTION(callable) == NULL) { return 1; @@ -1843,12 +1825,8 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) { case METH_O: { - if (kwnames) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_KWNAMES); - return -1; - } if (nargs != 1) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return 1; } /* len(o) */ @@ -1861,10 +1839,6 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, return 0; } case METH_FASTCALL: { - if (kwnames) { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_KWNAMES); - return -1; - } if (nargs == 2) { /* isinstance(o1, o2) */ PyInterpreterState *interp = _PyInterpreterState_GET(); @@ -1877,12 +1851,11 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, return 0; } case METH_FASTCALL | METH_KEYWORDS: { - instr->op.code = kwnames ? CALL_KW_BUILTIN_FAST_WITH_KEYWORDS - : CALL_BUILTIN_FAST_WITH_KEYWORDS; + instr->op.code = CALL_BUILTIN_FAST_WITH_KEYWORDS; return 0; } default: - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], + SPECIALIZATION_FAIL(CALL, builtin_call_fail_kind(PyCFunction_GET_FLAGS(callable))); return 1; } @@ -1915,43 +1888,39 @@ call_fail_kind(PyObject *callable) #endif // Py_STATS -int -specialize_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs, PyObject *kwnames) +void +_Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) { - assert(_PyOpcode_Deopt[instr->op.code] == (kwnames ? CALL_KW : CALL)); + assert(ENABLE_SPECIALIZATION); + assert(_PyOpcode_Caches[CALL] == INLINE_CACHE_ENTRIES_CALL); + assert(_Py_OPCODE(*instr) != INSTRUMENTED_CALL); + _PyCallCache *cache = (_PyCallCache *)(instr + 1); + int fail = 0; if (PyCFunction_CheckExact(callable)) { - return specialize_c_call(callable, instr, nargs, kwnames); + fail = specialize_c_call(callable, instr, nargs); } - if (PyFunction_Check(callable)) { - return specialize_py_call((PyFunctionObject *)callable, instr, nargs, kwnames, false); + else if (PyFunction_Check(callable)) { + fail = specialize_py_call((PyFunctionObject *)callable, instr, nargs, false); } - if (PyType_Check(callable)) { - return specialize_class_call(callable, instr, nargs, kwnames); + else if (PyType_Check(callable)) { + fail = specialize_class_call(callable, instr, nargs); } - if (Py_IS_TYPE(callable, &PyMethodDescr_Type)) { - return specialize_method_descriptor((PyMethodDescrObject *)callable, instr, nargs, kwnames); + else if (Py_IS_TYPE(callable, &PyMethodDescr_Type)) { + fail = specialize_method_descriptor((PyMethodDescrObject *)callable, instr, nargs); } - if (PyMethod_Check(callable)) { + else if (PyMethod_Check(callable)) { PyObject *func = ((PyMethodObject *)callable)->im_func; if (PyFunction_Check(func)) { - return specialize_py_call((PyFunctionObject *)func, instr, nargs+1, kwnames, true); + fail = specialize_py_call((PyFunctionObject *)func, instr, nargs+1, true); + } + else { + SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_BOUND_METHOD); } - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], SPEC_FAIL_CALL_BOUND_METHOD); } else { - SPECIALIZATION_FAIL(_PyOpcode_Deopt[instr->op.code], call_fail_kind(callable)); + SPECIALIZATION_FAIL(CALL, call_fail_kind(callable)); } - return -1; -} - -void -_Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) -{ - assert(ENABLE_SPECIALIZATION); - assert(_PyOpcode_Caches[CALL] == INLINE_CACHE_ENTRIES_CALL); - assert(_Py_OPCODE(*instr) != INSTRUMENTED_CALL); - _PyCallCache *cache = (_PyCallCache *)(instr + 1); - if (specialize_call(callable, instr, nargs, NULL)) { + if (fail) { STAT_INC(CALL, failure); assert(!PyErr_Occurred()); instr->op.code = CALL; @@ -1960,34 +1929,10 @@ _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) else { STAT_INC(CALL, success); assert(!PyErr_Occurred()); - assert(_PyOpcode_Deopt[instr->op.code] == CALL); - cache->counter = adaptive_counter_cooldown(); - } -} - -void -_Py_Specialize_CallKw(PyObject *callable, _Py_CODEUNIT *instr, int nargs, PyObject *kwnames) -{ - assert(ENABLE_SPECIALIZATION); - assert(_PyOpcode_Caches[CALL_KW] == INLINE_CACHE_ENTRIES_CALL); - assert(_Py_OPCODE(*instr) != INSTRUMENTED_CALL_KW); - _PyCallCache *cache = (_PyCallCache *)(instr + 1); - if (specialize_call(callable, instr, nargs, kwnames)) { - STAT_INC(CALL_KW, failure); - assert(!PyErr_Occurred()); - instr->op.code = CALL_KW; - cache->counter = adaptive_counter_backoff(cache->counter); - } - else { - STAT_INC(CALL_KW, success); - assert(!PyErr_Occurred()); - assert(_PyOpcode_Deopt[instr->op.code] == CALL_KW); cache->counter = adaptive_counter_cooldown(); } } -//////////////////////////////////////////////////////////////////////////////// - #ifdef Py_STATS static int binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs) diff --git a/Tools/scripts/summarize_stats.py b/Tools/scripts/summarize_stats.py index 3cd4f6d5ee7a7e..2d198506fb5c6c 100644 --- a/Tools/scripts/summarize_stats.py +++ b/Tools/scripts/summarize_stats.py @@ -234,8 +234,6 @@ def kind_to_text(kind, defines, opname): opname = "ITER" elif opname.endswith("SUBSCR"): opname = "SUBSCR" - elif opname in ("CALL", "CALL_KW"): - opname = "CALL" for name in defines[kind]: if name.startswith(opname): return pretty(name[len(opname)+1:]) From b0e33b681993eaf286ac5a2367d555eccf715e9c Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 6 Sep 2023 06:32:52 -0700 Subject: [PATCH 5/8] More cleanup --- Objects/frameobject.c | 24 ++---------------------- Python/specialize.c | 10 +++++----- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/Objects/frameobject.c b/Objects/frameobject.c index d9c676a0c6c094..2664c86af67613 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -405,10 +405,10 @@ mark_stacks(PyCodeObject *code_obj, int len) case LOAD_GLOBAL: { int j = oparg; + next_stack = push_value(next_stack, Object); if (j & 1) { next_stack = push_value(next_stack, Null); } - next_stack = push_value(next_stack, Object); stacks[next_i] = next_stack; break; } @@ -418,32 +418,12 @@ mark_stacks(PyCodeObject *code_obj, int len) int j = oparg; if (j & 1) { next_stack = pop_value(next_stack); - next_stack = push_value(next_stack, Null); next_stack = push_value(next_stack, Object); + next_stack = push_value(next_stack, Null); } stacks[next_i] = next_stack; break; } - case CALL: - { - int args = oparg; - for (int j = 0; j < args+2; j++) { - next_stack = pop_value(next_stack); - } - next_stack = push_value(next_stack, Object); - stacks[next_i] = next_stack; - break; - } - case CALL_KW: - { - int args = oparg; - for (int j = 0; j < args + 3; j++) { - next_stack = pop_value(next_stack); - } - next_stack = push_value(next_stack, Object); - stacks[next_i] = next_stack; - break; - } case SWAP: { int n = oparg; diff --git a/Python/specialize.c b/Python/specialize.c index 96034d4f95c43d..931a820856ef24 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1594,13 +1594,11 @@ _Py_Specialize_StoreSubscr(PyObject *container, PyObject *sub, _Py_CODEUNIT *ins cache->counter = adaptive_counter_cooldown(); } -//////////////////////////////////////////////////////////////////////////////// - /* Returns a borrowed reference. * The reference is only valid if guarded by a type version check. */ static PyFunctionObject * -get_init_for_simple_managed_python_class(_Py_CODEUNIT *instr, PyTypeObject *tp) +get_init_for_simple_managed_python_class(PyTypeObject *tp) { assert(tp->tp_new == PyBaseObject_Type.tp_new); if (tp->tp_alloc != PyType_GenericAlloc) { @@ -1660,7 +1658,7 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) return -1; } if (tp->tp_new == PyBaseObject_Type.tp_new) { - PyFunctionObject *init = get_init_for_simple_managed_python_class(instr, tp); + PyFunctionObject *init = get_init_for_simple_managed_python_class(tp); if (init != NULL) { if (((PyCodeObject *)init->func_code)->co_argcount != nargs+1) { SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); @@ -1895,7 +1893,7 @@ _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) assert(_PyOpcode_Caches[CALL] == INLINE_CACHE_ENTRIES_CALL); assert(_Py_OPCODE(*instr) != INSTRUMENTED_CALL); _PyCallCache *cache = (_PyCallCache *)(instr + 1); - int fail = 0; + int fail; if (PyCFunction_CheckExact(callable)) { fail = specialize_c_call(callable, instr, nargs); } @@ -1915,10 +1913,12 @@ _Py_Specialize_Call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) } else { SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_BOUND_METHOD); + fail = -1; } } else { SPECIALIZATION_FAIL(CALL, call_fail_kind(callable)); + fail = -1; } if (fail) { STAT_INC(CALL, failure); From 6cd03180304c9faae73913ab99486eafe9f8464e Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 7 Sep 2023 20:26:43 -0700 Subject: [PATCH 6/8] CALL_NO_KW -> CALL --- Include/internal/pycore_opcode_metadata.h | 140 +++++++++++----------- Include/opcode_ids.h | 44 +++---- Lib/_opcode_metadata.py | 68 +++++------ Lib/test/test_descr.py | 10 +- Lib/test/test_dis.py | 2 +- Python/abstract_interp_cases.c.h | 20 ++-- Python/bytecodes.c | 48 ++++---- Python/executor_cases.c.h | 20 ++-- Python/generated_cases.c.h | 24 ++-- Python/opcode_targets.h | 24 ++-- Python/specialize.c | 26 ++-- 11 files changed, 213 insertions(+), 213 deletions(-) diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h index 2adbcd23956a00..e0bf7e1b2ed565 100644 --- a/Include/internal/pycore_opcode_metadata.h +++ b/Include/internal/pycore_opcode_metadata.h @@ -504,37 +504,37 @@ int _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return oparg + 2; case CALL_PY_WITH_DEFAULTS: return oparg + 2; - case CALL_NO_KW_TYPE_1: + case CALL_TYPE_1: return oparg + 2; - case CALL_NO_KW_STR_1: + case CALL_STR_1: return oparg + 2; - case CALL_NO_KW_TUPLE_1: + case CALL_TUPLE_1: return oparg + 2; - case CALL_NO_KW_ALLOC_AND_ENTER_INIT: + case CALL_ALLOC_AND_ENTER_INIT: return oparg + 2; case EXIT_INIT_CHECK: return 1; case CALL_BUILTIN_CLASS: return oparg + 2; - case CALL_NO_KW_BUILTIN_O: + case CALL_BUILTIN_O: return oparg + 2; - case CALL_NO_KW_BUILTIN_FAST: + case CALL_BUILTIN_FAST: return oparg + 2; case CALL_BUILTIN_FAST_WITH_KEYWORDS: return oparg + 2; - case CALL_NO_KW_LEN: + case CALL_LEN: return oparg + 2; - case CALL_NO_KW_ISINSTANCE: + case CALL_ISINSTANCE: return oparg + 2; - case CALL_NO_KW_LIST_APPEND: + case CALL_LIST_APPEND: return oparg + 2; - case CALL_NO_KW_METHOD_DESCRIPTOR_O: + case CALL_METHOD_DESCRIPTOR_O: return oparg + 2; case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: return oparg + 2; - case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS: + case CALL_METHOD_DESCRIPTOR_NOARGS: return oparg + 2; - case CALL_NO_KW_METHOD_DESCRIPTOR_FAST: + case CALL_METHOD_DESCRIPTOR_FAST: return oparg + 2; case INSTRUMENTED_CALL_KW: return 0; @@ -1036,37 +1036,37 @@ int _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 1; case CALL_PY_WITH_DEFAULTS: return 1; - case CALL_NO_KW_TYPE_1: + case CALL_TYPE_1: return 1; - case CALL_NO_KW_STR_1: + case CALL_STR_1: return 1; - case CALL_NO_KW_TUPLE_1: + case CALL_TUPLE_1: return 1; - case CALL_NO_KW_ALLOC_AND_ENTER_INIT: + case CALL_ALLOC_AND_ENTER_INIT: return 1; case EXIT_INIT_CHECK: return 0; case CALL_BUILTIN_CLASS: return 1; - case CALL_NO_KW_BUILTIN_O: + case CALL_BUILTIN_O: return 1; - case CALL_NO_KW_BUILTIN_FAST: + case CALL_BUILTIN_FAST: return 1; case CALL_BUILTIN_FAST_WITH_KEYWORDS: return 1; - case CALL_NO_KW_LEN: + case CALL_LEN: return 1; - case CALL_NO_KW_ISINSTANCE: + case CALL_ISINSTANCE: return 1; - case CALL_NO_KW_LIST_APPEND: + case CALL_LIST_APPEND: return 1; - case CALL_NO_KW_METHOD_DESCRIPTOR_O: + case CALL_METHOD_DESCRIPTOR_O: return 1; case CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS: return 1; - case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS: + case CALL_METHOD_DESCRIPTOR_NOARGS: return 1; - case CALL_NO_KW_METHOD_DESCRIPTOR_FAST: + case CALL_METHOD_DESCRIPTOR_FAST: return 1; case INSTRUMENTED_CALL_KW: return 0; @@ -1421,22 +1421,22 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[OPCODE_METADATA_SIZE] = { [CALL_BOUND_METHOD_EXACT_ARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, [CALL_PY_EXACT_ARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, [CALL_PY_WITH_DEFAULTS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, - [CALL_NO_KW_TYPE_1] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, - [CALL_NO_KW_STR_1] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_NO_KW_TUPLE_1] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_NO_KW_ALLOC_AND_ENTER_INIT] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, + [CALL_TYPE_1] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG }, + [CALL_STR_1] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, + [CALL_TUPLE_1] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, + [CALL_ALLOC_AND_ENTER_INIT] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [EXIT_INIT_CHECK] = { true, INSTR_FMT_IX, HAS_ERROR_FLAG }, [CALL_BUILTIN_CLASS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_NO_KW_BUILTIN_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_NO_KW_BUILTIN_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, + [CALL_BUILTIN_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, + [CALL_BUILTIN_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_NO_KW_LEN] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_NO_KW_ISINSTANCE] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_NO_KW_LIST_APPEND] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, + [CALL_LEN] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, + [CALL_ISINSTANCE] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, + [CALL_LIST_APPEND] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, + [CALL_METHOD_DESCRIPTOR_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, - [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, + [CALL_METHOD_DESCRIPTOR_NOARGS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, + [CALL_METHOD_DESCRIPTOR_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG }, [INSTRUMENTED_CALL_KW] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG }, [CALL_KW] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG }, [INSTRUMENTED_CALL_FUNCTION_EX] = { true, INSTR_FMT_IX, 0 }, @@ -1586,20 +1586,20 @@ const struct opcode_macro_expansion _PyOpcode_macro_expansion[OPCODE_MACRO_EXPAN [PUSH_EXC_INFO] = { .nuops = 1, .uops = { { PUSH_EXC_INFO, 0, 0 } } }, [CALL_BOUND_METHOD_EXACT_ARGS] = { .nuops = 9, .uops = { { _CHECK_PEP_523, 0, 0 }, { _CHECK_CALL_BOUND_METHOD_EXACT_ARGS, 0, 0 }, { _INIT_CALL_BOUND_METHOD_EXACT_ARGS, 0, 0 }, { _CHECK_FUNCTION_EXACT_ARGS, 2, 1 }, { _CHECK_STACK_SPACE, 0, 0 }, { _INIT_CALL_PY_EXACT_ARGS, 0, 0 }, { _SET_IP, 7, 3 }, { _SAVE_CURRENT_IP, 0, 0 }, { _PUSH_FRAME, 0, 0 } } }, [CALL_PY_EXACT_ARGS] = { .nuops = 7, .uops = { { _CHECK_PEP_523, 0, 0 }, { _CHECK_FUNCTION_EXACT_ARGS, 2, 1 }, { _CHECK_STACK_SPACE, 0, 0 }, { _INIT_CALL_PY_EXACT_ARGS, 0, 0 }, { _SET_IP, 7, 3 }, { _SAVE_CURRENT_IP, 0, 0 }, { _PUSH_FRAME, 0, 0 } } }, - [CALL_NO_KW_TYPE_1] = { .nuops = 1, .uops = { { CALL_NO_KW_TYPE_1, 0, 0 } } }, - [CALL_NO_KW_STR_1] = { .nuops = 1, .uops = { { CALL_NO_KW_STR_1, 0, 0 } } }, - [CALL_NO_KW_TUPLE_1] = { .nuops = 1, .uops = { { CALL_NO_KW_TUPLE_1, 0, 0 } } }, + [CALL_TYPE_1] = { .nuops = 1, .uops = { { CALL_TYPE_1, 0, 0 } } }, + [CALL_STR_1] = { .nuops = 1, .uops = { { CALL_STR_1, 0, 0 } } }, + [CALL_TUPLE_1] = { .nuops = 1, .uops = { { CALL_TUPLE_1, 0, 0 } } }, [EXIT_INIT_CHECK] = { .nuops = 1, .uops = { { EXIT_INIT_CHECK, 0, 0 } } }, [CALL_BUILTIN_CLASS] = { .nuops = 1, .uops = { { CALL_BUILTIN_CLASS, 0, 0 } } }, - [CALL_NO_KW_BUILTIN_O] = { .nuops = 1, .uops = { { CALL_NO_KW_BUILTIN_O, 0, 0 } } }, - [CALL_NO_KW_BUILTIN_FAST] = { .nuops = 1, .uops = { { CALL_NO_KW_BUILTIN_FAST, 0, 0 } } }, + [CALL_BUILTIN_O] = { .nuops = 1, .uops = { { CALL_BUILTIN_O, 0, 0 } } }, + [CALL_BUILTIN_FAST] = { .nuops = 1, .uops = { { CALL_BUILTIN_FAST, 0, 0 } } }, [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { .nuops = 1, .uops = { { CALL_BUILTIN_FAST_WITH_KEYWORDS, 0, 0 } } }, - [CALL_NO_KW_LEN] = { .nuops = 1, .uops = { { CALL_NO_KW_LEN, 0, 0 } } }, - [CALL_NO_KW_ISINSTANCE] = { .nuops = 1, .uops = { { CALL_NO_KW_ISINSTANCE, 0, 0 } } }, - [CALL_NO_KW_METHOD_DESCRIPTOR_O] = { .nuops = 1, .uops = { { CALL_NO_KW_METHOD_DESCRIPTOR_O, 0, 0 } } }, + [CALL_LEN] = { .nuops = 1, .uops = { { CALL_LEN, 0, 0 } } }, + [CALL_ISINSTANCE] = { .nuops = 1, .uops = { { CALL_ISINSTANCE, 0, 0 } } }, + [CALL_METHOD_DESCRIPTOR_O] = { .nuops = 1, .uops = { { CALL_METHOD_DESCRIPTOR_O, 0, 0 } } }, [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = { .nuops = 1, .uops = { { CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, 0, 0 } } }, - [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = { .nuops = 1, .uops = { { CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS, 0, 0 } } }, - [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = { .nuops = 1, .uops = { { CALL_NO_KW_METHOD_DESCRIPTOR_FAST, 0, 0 } } }, + [CALL_METHOD_DESCRIPTOR_NOARGS] = { .nuops = 1, .uops = { { CALL_METHOD_DESCRIPTOR_NOARGS, 0, 0 } } }, + [CALL_METHOD_DESCRIPTOR_FAST] = { .nuops = 1, .uops = { { CALL_METHOD_DESCRIPTOR_FAST, 0, 0 } } }, [MAKE_FUNCTION] = { .nuops = 1, .uops = { { MAKE_FUNCTION, 0, 0 } } }, [SET_FUNCTION_ATTRIBUTE] = { .nuops = 1, .uops = { { SET_FUNCTION_ATTRIBUTE, 0, 0 } } }, [BUILD_SLICE] = { .nuops = 1, .uops = { { BUILD_SLICE, 0, 0 } } }, @@ -1745,28 +1745,28 @@ const char *const _PyOpcode_OpName[268] = { [BUILD_STRING] = "BUILD_STRING", [BUILD_TUPLE] = "BUILD_TUPLE", [CALL] = "CALL", + [CALL_ALLOC_AND_ENTER_INIT] = "CALL_ALLOC_AND_ENTER_INIT", [CALL_BOUND_METHOD_EXACT_ARGS] = "CALL_BOUND_METHOD_EXACT_ARGS", [CALL_BUILTIN_CLASS] = "CALL_BUILTIN_CLASS", + [CALL_BUILTIN_FAST] = "CALL_BUILTIN_FAST", [CALL_BUILTIN_FAST_WITH_KEYWORDS] = "CALL_BUILTIN_FAST_WITH_KEYWORDS", + [CALL_BUILTIN_O] = "CALL_BUILTIN_O", [CALL_FUNCTION_EX] = "CALL_FUNCTION_EX", [CALL_INTRINSIC_1] = "CALL_INTRINSIC_1", [CALL_INTRINSIC_2] = "CALL_INTRINSIC_2", + [CALL_ISINSTANCE] = "CALL_ISINSTANCE", [CALL_KW] = "CALL_KW", + [CALL_LEN] = "CALL_LEN", + [CALL_LIST_APPEND] = "CALL_LIST_APPEND", + [CALL_METHOD_DESCRIPTOR_FAST] = "CALL_METHOD_DESCRIPTOR_FAST", [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = "CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", - [CALL_NO_KW_ALLOC_AND_ENTER_INIT] = "CALL_NO_KW_ALLOC_AND_ENTER_INIT", - [CALL_NO_KW_BUILTIN_FAST] = "CALL_NO_KW_BUILTIN_FAST", - [CALL_NO_KW_BUILTIN_O] = "CALL_NO_KW_BUILTIN_O", - [CALL_NO_KW_ISINSTANCE] = "CALL_NO_KW_ISINSTANCE", - [CALL_NO_KW_LEN] = "CALL_NO_KW_LEN", - [CALL_NO_KW_LIST_APPEND] = "CALL_NO_KW_LIST_APPEND", - [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = "CALL_NO_KW_METHOD_DESCRIPTOR_FAST", - [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = "CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS", - [CALL_NO_KW_METHOD_DESCRIPTOR_O] = "CALL_NO_KW_METHOD_DESCRIPTOR_O", - [CALL_NO_KW_STR_1] = "CALL_NO_KW_STR_1", - [CALL_NO_KW_TUPLE_1] = "CALL_NO_KW_TUPLE_1", - [CALL_NO_KW_TYPE_1] = "CALL_NO_KW_TYPE_1", + [CALL_METHOD_DESCRIPTOR_NOARGS] = "CALL_METHOD_DESCRIPTOR_NOARGS", + [CALL_METHOD_DESCRIPTOR_O] = "CALL_METHOD_DESCRIPTOR_O", [CALL_PY_EXACT_ARGS] = "CALL_PY_EXACT_ARGS", [CALL_PY_WITH_DEFAULTS] = "CALL_PY_WITH_DEFAULTS", + [CALL_STR_1] = "CALL_STR_1", + [CALL_TUPLE_1] = "CALL_TUPLE_1", + [CALL_TYPE_1] = "CALL_TYPE_1", [COMPARE_OP] = "COMPARE_OP", [COMPARE_OP_FLOAT] = "COMPARE_OP_FLOAT", [COMPARE_OP_INT] = "COMPARE_OP_INT", @@ -1944,28 +1944,28 @@ const uint8_t _PyOpcode_Deopt[256] = { [BUILD_TUPLE] = BUILD_TUPLE, [CACHE] = CACHE, [CALL] = CALL, + [CALL_ALLOC_AND_ENTER_INIT] = CALL, [CALL_BOUND_METHOD_EXACT_ARGS] = CALL, [CALL_BUILTIN_CLASS] = CALL, + [CALL_BUILTIN_FAST] = CALL, [CALL_BUILTIN_FAST_WITH_KEYWORDS] = CALL, + [CALL_BUILTIN_O] = CALL, [CALL_FUNCTION_EX] = CALL_FUNCTION_EX, [CALL_INTRINSIC_1] = CALL_INTRINSIC_1, [CALL_INTRINSIC_2] = CALL_INTRINSIC_2, + [CALL_ISINSTANCE] = CALL, [CALL_KW] = CALL_KW, + [CALL_LEN] = CALL, + [CALL_LIST_APPEND] = CALL, + [CALL_METHOD_DESCRIPTOR_FAST] = CALL, [CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = CALL, - [CALL_NO_KW_ALLOC_AND_ENTER_INIT] = CALL, - [CALL_NO_KW_BUILTIN_FAST] = CALL, - [CALL_NO_KW_BUILTIN_O] = CALL, - [CALL_NO_KW_ISINSTANCE] = CALL, - [CALL_NO_KW_LEN] = CALL, - [CALL_NO_KW_LIST_APPEND] = CALL, - [CALL_NO_KW_METHOD_DESCRIPTOR_FAST] = CALL, - [CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = CALL, - [CALL_NO_KW_METHOD_DESCRIPTOR_O] = CALL, - [CALL_NO_KW_STR_1] = CALL, - [CALL_NO_KW_TUPLE_1] = CALL, - [CALL_NO_KW_TYPE_1] = CALL, + [CALL_METHOD_DESCRIPTOR_NOARGS] = CALL, + [CALL_METHOD_DESCRIPTOR_O] = CALL, [CALL_PY_EXACT_ARGS] = CALL, [CALL_PY_WITH_DEFAULTS] = CALL, + [CALL_STR_1] = CALL, + [CALL_TUPLE_1] = CALL, + [CALL_TYPE_1] = CALL, [CHECK_EG_MATCH] = CHECK_EG_MATCH, [CHECK_EXC_MATCH] = CHECK_EXC_MATCH, [CLEANUP_THROW] = CLEANUP_THROW, diff --git a/Include/opcode_ids.h b/Include/opcode_ids.h index c7360a2aacac41..6db32a33020c8a 100644 --- a/Include/opcode_ids.h +++ b/Include/opcode_ids.h @@ -88,28 +88,28 @@ extern "C" { #define BUILD_STRING 74 #define BUILD_TUPLE 75 #define CALL 76 -#define CALL_BOUND_METHOD_EXACT_ARGS 77 -#define CALL_BUILTIN_CLASS 78 -#define CALL_BUILTIN_FAST_WITH_KEYWORDS 79 -#define CALL_FUNCTION_EX 80 -#define CALL_INTRINSIC_1 81 -#define CALL_INTRINSIC_2 82 -#define CALL_KW 83 -#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 84 -#define CALL_NO_KW_ALLOC_AND_ENTER_INIT 85 -#define CALL_NO_KW_BUILTIN_FAST 86 -#define CALL_NO_KW_BUILTIN_O 87 -#define CALL_NO_KW_ISINSTANCE 88 -#define CALL_NO_KW_LEN 89 -#define CALL_NO_KW_LIST_APPEND 90 -#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 91 -#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 92 -#define CALL_NO_KW_METHOD_DESCRIPTOR_O 93 -#define CALL_NO_KW_STR_1 94 -#define CALL_NO_KW_TUPLE_1 95 -#define CALL_NO_KW_TYPE_1 96 -#define CALL_PY_EXACT_ARGS 97 -#define CALL_PY_WITH_DEFAULTS 98 +#define CALL_ALLOC_AND_ENTER_INIT 77 +#define CALL_BOUND_METHOD_EXACT_ARGS 78 +#define CALL_BUILTIN_CLASS 79 +#define CALL_BUILTIN_FAST 80 +#define CALL_BUILTIN_FAST_WITH_KEYWORDS 81 +#define CALL_BUILTIN_O 82 +#define CALL_FUNCTION_EX 83 +#define CALL_INTRINSIC_1 84 +#define CALL_INTRINSIC_2 85 +#define CALL_ISINSTANCE 86 +#define CALL_KW 87 +#define CALL_LEN 88 +#define CALL_LIST_APPEND 89 +#define CALL_METHOD_DESCRIPTOR_FAST 90 +#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 91 +#define CALL_METHOD_DESCRIPTOR_NOARGS 92 +#define CALL_METHOD_DESCRIPTOR_O 93 +#define CALL_PY_EXACT_ARGS 94 +#define CALL_PY_WITH_DEFAULTS 95 +#define CALL_STR_1 96 +#define CALL_TUPLE_1 97 +#define CALL_TYPE_1 98 #define COMPARE_OP 99 #define COMPARE_OP_FLOAT 100 #define COMPARE_OP_INT 101 diff --git a/Lib/_opcode_metadata.py b/Lib/_opcode_metadata.py index f03f05f53587b2..39f0f7b0e6daf2 100644 --- a/Lib/_opcode_metadata.py +++ b/Lib/_opcode_metadata.py @@ -85,21 +85,21 @@ "CALL_BOUND_METHOD_EXACT_ARGS", "CALL_PY_EXACT_ARGS", "CALL_PY_WITH_DEFAULTS", - "CALL_NO_KW_TYPE_1", - "CALL_NO_KW_STR_1", - "CALL_NO_KW_TUPLE_1", + "CALL_TYPE_1", + "CALL_STR_1", + "CALL_TUPLE_1", "CALL_BUILTIN_CLASS", - "CALL_NO_KW_BUILTIN_O", - "CALL_NO_KW_BUILTIN_FAST", + "CALL_BUILTIN_O", + "CALL_BUILTIN_FAST", "CALL_BUILTIN_FAST_WITH_KEYWORDS", - "CALL_NO_KW_LEN", - "CALL_NO_KW_ISINSTANCE", - "CALL_NO_KW_LIST_APPEND", - "CALL_NO_KW_METHOD_DESCRIPTOR_O", + "CALL_LEN", + "CALL_ISINSTANCE", + "CALL_LIST_APPEND", + "CALL_METHOD_DESCRIPTOR_O", "CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS", - "CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS", - "CALL_NO_KW_METHOD_DESCRIPTOR_FAST", - "CALL_NO_KW_ALLOC_AND_ENTER_INIT", + "CALL_METHOD_DESCRIPTOR_NOARGS", + "CALL_METHOD_DESCRIPTOR_FAST", + "CALL_ALLOC_AND_ENTER_INIT", ], } @@ -131,24 +131,24 @@ 'TO_BOOL_LIST': 61, 'TO_BOOL_NONE': 62, 'TO_BOOL_STR': 63, - 'CALL_BOUND_METHOD_EXACT_ARGS': 77, - 'CALL_BUILTIN_CLASS': 78, - 'CALL_BUILTIN_FAST_WITH_KEYWORDS': 79, - 'CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS': 84, - 'CALL_NO_KW_ALLOC_AND_ENTER_INIT': 85, - 'CALL_NO_KW_BUILTIN_FAST': 86, - 'CALL_NO_KW_BUILTIN_O': 87, - 'CALL_NO_KW_ISINSTANCE': 88, - 'CALL_NO_KW_LEN': 89, - 'CALL_NO_KW_LIST_APPEND': 90, - 'CALL_NO_KW_METHOD_DESCRIPTOR_FAST': 91, - 'CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS': 92, - 'CALL_NO_KW_METHOD_DESCRIPTOR_O': 93, - 'CALL_NO_KW_STR_1': 94, - 'CALL_NO_KW_TUPLE_1': 95, - 'CALL_NO_KW_TYPE_1': 96, - 'CALL_PY_EXACT_ARGS': 97, - 'CALL_PY_WITH_DEFAULTS': 98, + 'CALL_ALLOC_AND_ENTER_INIT': 77, + 'CALL_BOUND_METHOD_EXACT_ARGS': 78, + 'CALL_BUILTIN_CLASS': 79, + 'CALL_BUILTIN_FAST': 80, + 'CALL_BUILTIN_FAST_WITH_KEYWORDS': 81, + 'CALL_BUILTIN_O': 82, + 'CALL_ISINSTANCE': 86, + 'CALL_LEN': 88, + 'CALL_LIST_APPEND': 89, + 'CALL_METHOD_DESCRIPTOR_FAST': 90, + 'CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS': 91, + 'CALL_METHOD_DESCRIPTOR_NOARGS': 92, + 'CALL_METHOD_DESCRIPTOR_O': 93, + 'CALL_PY_EXACT_ARGS': 94, + 'CALL_PY_WITH_DEFAULTS': 95, + 'CALL_STR_1': 96, + 'CALL_TUPLE_1': 97, + 'CALL_TYPE_1': 98, 'COMPARE_OP_FLOAT': 100, 'COMPARE_OP_INT': 101, 'COMPARE_OP_STR': 102, @@ -233,10 +233,10 @@ 'BUILD_STRING': 74, 'BUILD_TUPLE': 75, 'CALL': 76, - 'CALL_FUNCTION_EX': 80, - 'CALL_INTRINSIC_1': 81, - 'CALL_INTRINSIC_2': 82, - 'CALL_KW': 83, + 'CALL_FUNCTION_EX': 83, + 'CALL_INTRINSIC_1': 84, + 'CALL_INTRINSIC_2': 85, + 'CALL_KW': 87, 'COMPARE_OP': 99, 'CONTAINS_OP': 103, 'CONVERT_VALUE': 104, diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index f6bd9094e8fece..35ddb7915eb5c7 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4757,24 +4757,24 @@ class Thing: thing = Thing() for i in range(20): with self.assertRaises(TypeError): - # PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS + # CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS list.sort(thing) for i in range(20): with self.assertRaises(TypeError): - # PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS + # CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS str.split(thing) for i in range(20): with self.assertRaises(TypeError): - # PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS + # CALL_METHOD_DESCRIPTOR_NOARGS str.upper(thing) for i in range(20): with self.assertRaises(TypeError): - # PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST + # CALL_METHOD_DESCRIPTOR_FAST str.strip(thing) from collections import deque for i in range(20): with self.assertRaises(TypeError): - # PRECALL_NO_KW_METHOD_DESCRIPTOR_O + # CALL_METHOD_DESCRIPTOR_O deque.append(thing, thing) def test_repr_as_str(self): diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index f052a08059e69c..54328c5a89b4c1 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1256,7 +1256,7 @@ def test_call_specialize(self): 1 LOAD_NAME 0 (str) PUSH_NULL LOAD_CONST 0 (1) - CALL_NO_KW_STR_1 1 + CALL_STR_1 1 RETURN_VALUE """ co = compile("str(1)", "", "eval") diff --git a/Python/abstract_interp_cases.c.h b/Python/abstract_interp_cases.c.h index f0e339c36024ac..5a3848cd726245 100644 --- a/Python/abstract_interp_cases.c.h +++ b/Python/abstract_interp_cases.c.h @@ -661,21 +661,21 @@ break; } - case CALL_NO_KW_TYPE_1: { + case CALL_TYPE_1: { STACK_SHRINK(oparg); STACK_SHRINK(1); PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); break; } - case CALL_NO_KW_STR_1: { + case CALL_STR_1: { STACK_SHRINK(oparg); STACK_SHRINK(1); PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); break; } - case CALL_NO_KW_TUPLE_1: { + case CALL_TUPLE_1: { STACK_SHRINK(oparg); STACK_SHRINK(1); PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); @@ -694,14 +694,14 @@ break; } - case CALL_NO_KW_BUILTIN_O: { + case CALL_BUILTIN_O: { STACK_SHRINK(oparg); STACK_SHRINK(1); PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); break; } - case CALL_NO_KW_BUILTIN_FAST: { + case CALL_BUILTIN_FAST: { STACK_SHRINK(oparg); STACK_SHRINK(1); PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); @@ -715,21 +715,21 @@ break; } - case CALL_NO_KW_LEN: { + case CALL_LEN: { STACK_SHRINK(oparg); STACK_SHRINK(1); PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); break; } - case CALL_NO_KW_ISINSTANCE: { + case CALL_ISINSTANCE: { STACK_SHRINK(oparg); STACK_SHRINK(1); PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); break; } - case CALL_NO_KW_METHOD_DESCRIPTOR_O: { + case CALL_METHOD_DESCRIPTOR_O: { STACK_SHRINK(oparg); STACK_SHRINK(1); PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); @@ -743,14 +743,14 @@ break; } - case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS: { + case CALL_METHOD_DESCRIPTOR_NOARGS: { STACK_SHRINK(oparg); STACK_SHRINK(1); PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); break; } - case CALL_NO_KW_METHOD_DESCRIPTOR_FAST: { + case CALL_METHOD_DESCRIPTOR_FAST: { STACK_SHRINK(oparg); STACK_SHRINK(1); PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)PARTITIONNODE_NULLROOT, PEEK(-(-1)), true); diff --git a/Python/bytecodes.c b/Python/bytecodes.c index c447d3edabdbbf..e1e9040ac00994 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2877,21 +2877,21 @@ dummy_func( CALL_BOUND_METHOD_EXACT_ARGS, CALL_PY_EXACT_ARGS, CALL_PY_WITH_DEFAULTS, - CALL_NO_KW_TYPE_1, - CALL_NO_KW_STR_1, - CALL_NO_KW_TUPLE_1, + CALL_TYPE_1, + CALL_STR_1, + CALL_TUPLE_1, CALL_BUILTIN_CLASS, - CALL_NO_KW_BUILTIN_O, - CALL_NO_KW_BUILTIN_FAST, + CALL_BUILTIN_O, + CALL_BUILTIN_FAST, CALL_BUILTIN_FAST_WITH_KEYWORDS, - CALL_NO_KW_LEN, - CALL_NO_KW_ISINSTANCE, - CALL_NO_KW_LIST_APPEND, - CALL_NO_KW_METHOD_DESCRIPTOR_O, + CALL_LEN, + CALL_ISINSTANCE, + CALL_LIST_APPEND, + CALL_METHOD_DESCRIPTOR_O, CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, - CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS, - CALL_NO_KW_METHOD_DESCRIPTOR_FAST, - CALL_NO_KW_ALLOC_AND_ENTER_INIT, + CALL_METHOD_DESCRIPTOR_NOARGS, + CALL_METHOD_DESCRIPTOR_FAST, + CALL_ALLOC_AND_ENTER_INIT, }; // On entry, the stack is either @@ -3106,7 +3106,7 @@ dummy_func( DISPATCH_INLINED(new_frame); } - inst(CALL_NO_KW_TYPE_1, (unused/1, unused/2, callable, null, args[oparg] -- res)) { + inst(CALL_TYPE_1, (unused/1, unused/2, callable, null, args[oparg] -- res)) { assert(oparg == 1); DEOPT_IF(null != NULL, CALL); PyObject *obj = args[0]; @@ -3117,7 +3117,7 @@ dummy_func( Py_DECREF(&PyType_Type); // I.e., callable } - inst(CALL_NO_KW_STR_1, (unused/1, unused/2, callable, null, args[oparg] -- res)) { + inst(CALL_STR_1, (unused/1, unused/2, callable, null, args[oparg] -- res)) { assert(oparg == 1); DEOPT_IF(null != NULL, CALL); DEOPT_IF(callable != (PyObject *)&PyUnicode_Type, CALL); @@ -3130,7 +3130,7 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_NO_KW_TUPLE_1, (unused/1, unused/2, callable, null, args[oparg] -- res)) { + inst(CALL_TUPLE_1, (unused/1, unused/2, callable, null, args[oparg] -- res)) { assert(oparg == 1); DEOPT_IF(null != NULL, CALL); DEOPT_IF(callable != (PyObject *)&PyTuple_Type, CALL); @@ -3143,7 +3143,7 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_NO_KW_ALLOC_AND_ENTER_INIT, (unused/1, unused/2, callable, null, args[oparg] -- unused)) { + inst(CALL_ALLOC_AND_ENTER_INIT, (unused/1, unused/2, callable, null, args[oparg] -- unused)) { /* This instruction does the following: * 1. Creates the object (by calling ``object.__new__``) * 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``) @@ -3225,7 +3225,7 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_NO_KW_BUILTIN_O, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { + inst(CALL_BUILTIN_O, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { /* Builtin METH_O functions */ int total_args = oparg; if (self_or_null != NULL) { @@ -3253,7 +3253,7 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_NO_KW_BUILTIN_FAST, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { + inst(CALL_BUILTIN_FAST, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { /* Builtin METH_FASTCALL functions, without keywords */ int total_args = oparg; if (self_or_null != NULL) { @@ -3312,7 +3312,7 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_NO_KW_LEN, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { + inst(CALL_LEN, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { /* len(o) */ int total_args = oparg; if (self_or_null != NULL) { @@ -3336,7 +3336,7 @@ dummy_func( ERROR_IF(res == NULL, error); } - inst(CALL_NO_KW_ISINSTANCE, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { + inst(CALL_ISINSTANCE, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { /* isinstance(o, o2) */ int total_args = oparg; if (self_or_null != NULL) { @@ -3363,7 +3363,7 @@ dummy_func( } // This is secretly a super-instruction - inst(CALL_NO_KW_LIST_APPEND, (unused/1, unused/2, callable, self, args[oparg] -- unused)) { + inst(CALL_LIST_APPEND, (unused/1, unused/2, callable, self, args[oparg] -- unused)) { assert(oparg == 1); PyInterpreterState *interp = tstate->interp; DEOPT_IF(callable != interp->callable_cache.list_append, CALL); @@ -3382,7 +3382,7 @@ dummy_func( DISPATCH(); } - inst(CALL_NO_KW_METHOD_DESCRIPTOR_O, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { + inst(CALL_METHOD_DESCRIPTOR_O, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { int total_args = oparg; if (self_or_null != NULL) { args--; @@ -3442,7 +3442,7 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { + inst(CALL_METHOD_DESCRIPTOR_NOARGS, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { assert(oparg == 0 || oparg == 1); int total_args = oparg; if (self_or_null != NULL) { @@ -3472,7 +3472,7 @@ dummy_func( CHECK_EVAL_BREAKER(); } - inst(CALL_NO_KW_METHOD_DESCRIPTOR_FAST, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { + inst(CALL_METHOD_DESCRIPTOR_FAST, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { int total_args = oparg; if (self_or_null != NULL) { args--; diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 31a6b702cadef4..e8087d46666a65 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -2326,7 +2326,7 @@ break; } - case CALL_NO_KW_TYPE_1: { + case CALL_TYPE_1: { PyObject **args; PyObject *null; PyObject *callable; @@ -2348,7 +2348,7 @@ break; } - case CALL_NO_KW_STR_1: { + case CALL_STR_1: { PyObject **args; PyObject *null; PyObject *callable; @@ -2372,7 +2372,7 @@ break; } - case CALL_NO_KW_TUPLE_1: { + case CALL_TUPLE_1: { PyObject **args; PyObject *null; PyObject *callable; @@ -2441,7 +2441,7 @@ break; } - case CALL_NO_KW_BUILTIN_O: { + case CALL_BUILTIN_O: { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -2480,7 +2480,7 @@ break; } - case CALL_NO_KW_BUILTIN_FAST: { + case CALL_BUILTIN_FAST: { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -2561,7 +2561,7 @@ break; } - case CALL_NO_KW_LEN: { + case CALL_LEN: { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -2596,7 +2596,7 @@ break; } - case CALL_NO_KW_ISINSTANCE: { + case CALL_ISINSTANCE: { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -2633,7 +2633,7 @@ break; } - case CALL_NO_KW_METHOD_DESCRIPTOR_O: { + case CALL_METHOD_DESCRIPTOR_O: { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -2715,7 +2715,7 @@ break; } - case CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS: { + case CALL_METHOD_DESCRIPTOR_NOARGS: { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -2756,7 +2756,7 @@ break; } - case CALL_NO_KW_METHOD_DESCRIPTOR_FAST: { + case CALL_METHOD_DESCRIPTOR_FAST: { PyObject **args; PyObject *self_or_null; PyObject *callable; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 58ebcbe376692f..c41c13917cc888 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -4026,7 +4026,7 @@ STACK_SHRINK(1); } - TARGET(CALL_NO_KW_TYPE_1) { + TARGET(CALL_TYPE_1) { PyObject **args; PyObject *null; PyObject *callable; @@ -4049,7 +4049,7 @@ DISPATCH(); } - TARGET(CALL_NO_KW_STR_1) { + TARGET(CALL_STR_1) { PyObject **args; PyObject *null; PyObject *callable; @@ -4074,7 +4074,7 @@ DISPATCH(); } - TARGET(CALL_NO_KW_TUPLE_1) { + TARGET(CALL_TUPLE_1) { PyObject **args; PyObject *null; PyObject *callable; @@ -4099,7 +4099,7 @@ DISPATCH(); } - TARGET(CALL_NO_KW_ALLOC_AND_ENTER_INIT) { + TARGET(CALL_ALLOC_AND_ENTER_INIT) { PyObject **args; PyObject *null; PyObject *callable; @@ -4205,7 +4205,7 @@ DISPATCH(); } - TARGET(CALL_NO_KW_BUILTIN_O) { + TARGET(CALL_BUILTIN_O) { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -4245,7 +4245,7 @@ DISPATCH(); } - TARGET(CALL_NO_KW_BUILTIN_FAST) { + TARGET(CALL_BUILTIN_FAST) { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -4328,7 +4328,7 @@ DISPATCH(); } - TARGET(CALL_NO_KW_LEN) { + TARGET(CALL_LEN) { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -4364,7 +4364,7 @@ DISPATCH(); } - TARGET(CALL_NO_KW_ISINSTANCE) { + TARGET(CALL_ISINSTANCE) { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -4402,7 +4402,7 @@ DISPATCH(); } - TARGET(CALL_NO_KW_LIST_APPEND) { + TARGET(CALL_LIST_APPEND) { PyObject **args; PyObject *self; PyObject *callable; @@ -4429,7 +4429,7 @@ STACK_SHRINK(1); } - TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { + TARGET(CALL_METHOD_DESCRIPTOR_O) { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -4513,7 +4513,7 @@ DISPATCH(); } - TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS) { + TARGET(CALL_METHOD_DESCRIPTOR_NOARGS) { PyObject **args; PyObject *self_or_null; PyObject *callable; @@ -4555,7 +4555,7 @@ DISPATCH(); } - TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_FAST) { + TARGET(CALL_METHOD_DESCRIPTOR_FAST) { PyObject **args; PyObject *self_or_null; PyObject *callable; diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 3732d8a619cbbb..5abda053215639 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -76,28 +76,28 @@ static void *opcode_targets[256] = { &&TARGET_BUILD_STRING, &&TARGET_BUILD_TUPLE, &&TARGET_CALL, + &&TARGET_CALL_ALLOC_AND_ENTER_INIT, &&TARGET_CALL_BOUND_METHOD_EXACT_ARGS, &&TARGET_CALL_BUILTIN_CLASS, + &&TARGET_CALL_BUILTIN_FAST, &&TARGET_CALL_BUILTIN_FAST_WITH_KEYWORDS, + &&TARGET_CALL_BUILTIN_O, &&TARGET_CALL_FUNCTION_EX, &&TARGET_CALL_INTRINSIC_1, &&TARGET_CALL_INTRINSIC_2, + &&TARGET_CALL_ISINSTANCE, &&TARGET_CALL_KW, + &&TARGET_CALL_LEN, + &&TARGET_CALL_LIST_APPEND, + &&TARGET_CALL_METHOD_DESCRIPTOR_FAST, &&TARGET_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, - &&TARGET_CALL_NO_KW_ALLOC_AND_ENTER_INIT, - &&TARGET_CALL_NO_KW_BUILTIN_FAST, - &&TARGET_CALL_NO_KW_BUILTIN_O, - &&TARGET_CALL_NO_KW_ISINSTANCE, - &&TARGET_CALL_NO_KW_LEN, - &&TARGET_CALL_NO_KW_LIST_APPEND, - &&TARGET_CALL_NO_KW_METHOD_DESCRIPTOR_FAST, - &&TARGET_CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS, - &&TARGET_CALL_NO_KW_METHOD_DESCRIPTOR_O, - &&TARGET_CALL_NO_KW_STR_1, - &&TARGET_CALL_NO_KW_TUPLE_1, - &&TARGET_CALL_NO_KW_TYPE_1, + &&TARGET_CALL_METHOD_DESCRIPTOR_NOARGS, + &&TARGET_CALL_METHOD_DESCRIPTOR_O, &&TARGET_CALL_PY_EXACT_ARGS, &&TARGET_CALL_PY_WITH_DEFAULTS, + &&TARGET_CALL_STR_1, + &&TARGET_CALL_TUPLE_1, + &&TARGET_CALL_TYPE_1, &&TARGET_COMPARE_OP, &&TARGET_COMPARE_OP_FLOAT, &&TARGET_COMPARE_OP_INT, diff --git a/Python/specialize.c b/Python/specialize.c index 134f8f6a9487b0..aaf245ec17dd57 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1651,15 +1651,15 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) int oparg = instr->op.arg; if (nargs == 1 && oparg == 1) { if (tp == &PyUnicode_Type) { - instr->op.code = CALL_NO_KW_STR_1; + instr->op.code = CALL_STR_1; return 0; } else if (tp == &PyType_Type) { - instr->op.code = CALL_NO_KW_TYPE_1; + instr->op.code = CALL_TYPE_1; return 0; } else if (tp == &PyTuple_Type) { - instr->op.code = CALL_NO_KW_TUPLE_1; + instr->op.code = CALL_TUPLE_1; return 0; } } @@ -1680,7 +1680,7 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) } _PyCallCache *cache = (_PyCallCache *)(instr + 1); write_u32(cache->func_version, tp->tp_version_tag); - _Py_SET_OPCODE(*instr, CALL_NO_KW_ALLOC_AND_ENTER_INIT); + _Py_SET_OPCODE(*instr, CALL_ALLOC_AND_ENTER_INIT); return 0; } return -1; @@ -1748,7 +1748,7 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr, SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return -1; } - instr->op.code = CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS; + instr->op.code = CALL_METHOD_DESCRIPTOR_NOARGS; return 0; } case METH_O: { @@ -1762,14 +1762,14 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr, bool pop = (next.op.code == POP_TOP); int oparg = instr->op.arg; if ((PyObject *)descr == list_append && oparg == 1 && pop) { - instr->op.code = CALL_NO_KW_LIST_APPEND; + instr->op.code = CALL_LIST_APPEND; return 0; } - instr->op.code = CALL_NO_KW_METHOD_DESCRIPTOR_O; + instr->op.code = CALL_METHOD_DESCRIPTOR_O; return 0; } case METH_FASTCALL: { - instr->op.code = CALL_NO_KW_METHOD_DESCRIPTOR_FAST; + instr->op.code = CALL_METHOD_DESCRIPTOR_FAST; return 0; } case METH_FASTCALL | METH_KEYWORDS: { @@ -1844,10 +1844,10 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) /* len(o) */ PyInterpreterState *interp = _PyInterpreterState_GET(); if (callable == interp->callable_cache.len) { - instr->op.code = CALL_NO_KW_LEN; + instr->op.code = CALL_LEN; return 0; } - instr->op.code = CALL_NO_KW_BUILTIN_O; + instr->op.code = CALL_BUILTIN_O; return 0; } case METH_FASTCALL: { @@ -1855,11 +1855,11 @@ specialize_c_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs) /* isinstance(o1, o2) */ PyInterpreterState *interp = _PyInterpreterState_GET(); if (callable == interp->callable_cache.isinstance) { - instr->op.code = CALL_NO_KW_ISINSTANCE; + instr->op.code = CALL_ISINSTANCE; return 0; } } - instr->op.code = CALL_NO_KW_BUILTIN_FAST; + instr->op.code = CALL_BUILTIN_FAST; return 0; } case METH_FASTCALL | METH_KEYWORDS: { @@ -2461,7 +2461,7 @@ _Py_Specialize_ToBool(PyObject *value, _Py_CODEUNIT *instr) } /* Code init cleanup. - * CALL_NO_KW_ALLOC_AND_ENTER_INIT will set up + * CALL_ALLOC_AND_ENTER_INIT will set up * the frame to execute the EXIT_INIT_CHECK * instruction. * Ends with a RESUME so that it is not traced. From 53917a55d08c47082cf094b739af5bfe1f1a8f41 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 7 Sep 2023 20:52:55 -0700 Subject: [PATCH 7/8] blurb add --- .../2023-09-07-20-52-27.gh-issue-105848.p799D1.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-09-07-20-52-27.gh-issue-105848.p799D1.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-09-07-20-52-27.gh-issue-105848.p799D1.rst b/Misc/NEWS.d/next/Core and Builtins/2023-09-07-20-52-27.gh-issue-105848.p799D1.rst new file mode 100644 index 00000000000000..14661d14e190ce --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-09-07-20-52-27.gh-issue-105848.p799D1.rst @@ -0,0 +1,3 @@ +Add a new :opcode:`CALL_KW` opcode, used for calls containing keyword +arguments. Also, fix a possible crash when jumping over method calls in a +debugger. From 21b7fef77782efad37b5febc661b121d788ee520 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 8 Sep 2023 10:20:11 -0700 Subject: [PATCH 8/8] Feedback from code review --- Doc/library/dis.rst | 14 +++++++------- Python/bytecodes.c | 7 ++----- Python/generated_cases.c.h | 2 ++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index d18708fa780926..62101a2f9a4d41 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1122,7 +1122,8 @@ iterations of the loop. This bytecode distinguishes two cases: if ``STACK[-1]`` has a method with the correct name, the bytecode pushes the unbound method and ``STACK[-1]``. ``STACK[-1]`` will be used as the first argument (``self``) by :opcode:`CALL` - or :opcode:`CALL_KW` when calling the unbound method. Otherwise, ``NULL`` and the object returned by + or :opcode:`CALL_KW` when calling the unbound method. + Otherwise, ``NULL`` and the object returned by the attribute lookup are pushed. .. versionchanged:: 3.12 @@ -1394,11 +1395,10 @@ iterations of the loop. On the stack are (in ascending order): * The callable - * ``self`` (or ``NULL``) + * ``self`` or ``NULL`` * The remaining positional arguments - ``argc`` is the total of the positional arguments, excluding - ``self`` when a ``NULL`` is not present. + ``argc`` is the total of the positional arguments, excluding ``self``. ``CALL`` pops all arguments and the callable object off the stack, calls the callable object with those arguments, and pushes the return value @@ -1419,13 +1419,13 @@ iterations of the loop. including one or more named arguments. On the stack are (in ascending order): * The callable - * ``self`` (or ``NULL``) + * ``self`` or ``NULL`` * The remaining positional arguments * The named arguments * A :class:`tuple` of keyword argument names - ``argc`` is the total of the positional and named arguments, excluding - ``self`` when a ``NULL`` is not present. + ``argc`` is the total of the positional and named arguments, excluding ``self``. + The length of the tuple of keyword argument names is the number of named arguments. ``CALL_KW`` pops all arguments, the keyword names, and the callable object off the stack, calls the callable object with those arguments, and pushes the diff --git a/Python/bytecodes.c b/Python/bytecodes.c index e1e9040ac00994..3faecd9654ea69 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2894,13 +2894,9 @@ dummy_func( CALL_ALLOC_AND_ENTER_INIT, }; - // On entry, the stack is either - // [callable, NULL, arg1, arg2, ...] - // or - // [callable, self, arg1, arg2, ...] - // On exit, the stack is [result]. // When calling Python, inline the call using DISPATCH_INLINED(). inst(CALL, (unused/1, unused/2, callable, self_or_null, args[oparg] -- res)) { + // oparg counts all of the args, but *not* self: int total_args = oparg; if (self_or_null != NULL) { args--; @@ -3514,6 +3510,7 @@ dummy_func( } inst(CALL_KW, (callable, self_or_null, args[oparg], kwnames -- res)) { + // oparg counts all of the args, but *not* self: int total_args = oparg; if (self_or_null != NULL) { args--; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index c41c13917cc888..024722dcbbf3da 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -3724,6 +3724,7 @@ args = stack_pointer - oparg; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; + // oparg counts all of the args, but *not* self: int total_args = oparg; if (self_or_null != NULL) { args--; @@ -4619,6 +4620,7 @@ args = stack_pointer - 1 - oparg; self_or_null = stack_pointer[-2 - oparg]; callable = stack_pointer[-3 - oparg]; + // oparg counts all of the args, but *not* self: int total_args = oparg; if (self_or_null != NULL) { args--;