summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Sweeney <36520290+sweeneyde@users.noreply.github.com>2022-04-28 04:36:34 (GMT)
committerGitHub <noreply@github.com>2022-04-28 04:36:34 (GMT)
commit37c6db60f9ac62b8a80bf04a8146274756ee0da0 (patch)
tree29cc3ac65b9ee6d2246f4efbdf23767749fbd9bd
parent407c3afe1986f4c43cb0e68e28b90da30eebd738 (diff)
downloadcpython-37c6db60f9ac62b8a80bf04a8146274756ee0da0.zip
cpython-37c6db60f9ac62b8a80bf04a8146274756ee0da0.tar.gz
cpython-37c6db60f9ac62b8a80bf04a8146274756ee0da0.tar.bz2
gh-91869: Fix tracing of specialized instructions with extended args (GH-91945)
-rw-r--r--Include/internal/pycore_opcode.h36
-rw-r--r--Include/opcode.h99
-rw-r--r--Lib/importlib/_bootstrap_external.py2
-rw-r--r--Lib/opcode.py3
-rw-r--r--Lib/test/test_sys_settrace.py42
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2022-04-26-05-05-32.gh-issue-91869.ELbTXl.rst1
-rw-r--r--Python/ceval.c9
-rw-r--r--Python/compile.c7
-rw-r--r--Python/opcode_targets.h34
9 files changed, 145 insertions, 88 deletions
diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h
index 46c9986..eadcba1 100644
--- a/Include/internal/pycore_opcode.h
+++ b/Include/internal/pycore_opcode.h
@@ -105,6 +105,7 @@ const uint8_t _PyOpcode_Deopt[256] = {
[DICT_UPDATE] = DICT_UPDATE,
[END_ASYNC_FOR] = END_ASYNC_FOR,
[EXTENDED_ARG] = EXTENDED_ARG,
+ [EXTENDED_ARG_QUICK] = EXTENDED_ARG,
[FORMAT_VALUE] = FORMAT_VALUE,
[FOR_ITER] = FOR_ITER,
[GET_AITER] = GET_AITER,
@@ -272,10 +273,11 @@ static const char *const _PyOpcode_OpName[256] = {
[MATCH_MAPPING] = "MATCH_MAPPING",
[MATCH_SEQUENCE] = "MATCH_SEQUENCE",
[MATCH_KEYS] = "MATCH_KEYS",
- [JUMP_BACKWARD_QUICK] = "JUMP_BACKWARD_QUICK",
+ [EXTENDED_ARG_QUICK] = "EXTENDED_ARG_QUICK",
[PUSH_EXC_INFO] = "PUSH_EXC_INFO",
[CHECK_EXC_MATCH] = "CHECK_EXC_MATCH",
[CHECK_EG_MATCH] = "CHECK_EG_MATCH",
+ [JUMP_BACKWARD_QUICK] = "JUMP_BACKWARD_QUICK",
[LOAD_ATTR_ADAPTIVE] = "LOAD_ATTR_ADAPTIVE",
[LOAD_ATTR_INSTANCE_VALUE] = "LOAD_ATTR_INSTANCE_VALUE",
[LOAD_ATTR_MODULE] = "LOAD_ATTR_MODULE",
@@ -286,40 +288,39 @@ static const char *const _PyOpcode_OpName[256] = {
[LOAD_FAST__LOAD_FAST] = "LOAD_FAST__LOAD_FAST",
[LOAD_GLOBAL_ADAPTIVE] = "LOAD_GLOBAL_ADAPTIVE",
[LOAD_GLOBAL_BUILTIN] = "LOAD_GLOBAL_BUILTIN",
- [LOAD_GLOBAL_MODULE] = "LOAD_GLOBAL_MODULE",
[WITH_EXCEPT_START] = "WITH_EXCEPT_START",
[GET_AITER] = "GET_AITER",
[GET_ANEXT] = "GET_ANEXT",
[BEFORE_ASYNC_WITH] = "BEFORE_ASYNC_WITH",
[BEFORE_WITH] = "BEFORE_WITH",
[END_ASYNC_FOR] = "END_ASYNC_FOR",
+ [LOAD_GLOBAL_MODULE] = "LOAD_GLOBAL_MODULE",
[LOAD_METHOD_ADAPTIVE] = "LOAD_METHOD_ADAPTIVE",
[LOAD_METHOD_CLASS] = "LOAD_METHOD_CLASS",
[LOAD_METHOD_MODULE] = "LOAD_METHOD_MODULE",
[LOAD_METHOD_NO_DICT] = "LOAD_METHOD_NO_DICT",
- [LOAD_METHOD_WITH_DICT] = "LOAD_METHOD_WITH_DICT",
[STORE_SUBSCR] = "STORE_SUBSCR",
[DELETE_SUBSCR] = "DELETE_SUBSCR",
+ [LOAD_METHOD_WITH_DICT] = "LOAD_METHOD_WITH_DICT",
[LOAD_METHOD_WITH_VALUES] = "LOAD_METHOD_WITH_VALUES",
[PRECALL_ADAPTIVE] = "PRECALL_ADAPTIVE",
[PRECALL_BOUND_METHOD] = "PRECALL_BOUND_METHOD",
[PRECALL_BUILTIN_CLASS] = "PRECALL_BUILTIN_CLASS",
[PRECALL_BUILTIN_FAST_WITH_KEYWORDS] = "PRECALL_BUILTIN_FAST_WITH_KEYWORDS",
- [PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = "PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS",
[GET_ITER] = "GET_ITER",
[GET_YIELD_FROM_ITER] = "GET_YIELD_FROM_ITER",
[PRINT_EXPR] = "PRINT_EXPR",
[LOAD_BUILD_CLASS] = "LOAD_BUILD_CLASS",
+ [PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS] = "PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS",
[PRECALL_NO_KW_BUILTIN_FAST] = "PRECALL_NO_KW_BUILTIN_FAST",
- [PRECALL_NO_KW_BUILTIN_O] = "PRECALL_NO_KW_BUILTIN_O",
[LOAD_ASSERTION_ERROR] = "LOAD_ASSERTION_ERROR",
[RETURN_GENERATOR] = "RETURN_GENERATOR",
+ [PRECALL_NO_KW_BUILTIN_O] = "PRECALL_NO_KW_BUILTIN_O",
[PRECALL_NO_KW_ISINSTANCE] = "PRECALL_NO_KW_ISINSTANCE",
[PRECALL_NO_KW_LEN] = "PRECALL_NO_KW_LEN",
[PRECALL_NO_KW_LIST_APPEND] = "PRECALL_NO_KW_LIST_APPEND",
[PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST] = "PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST",
[PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS] = "PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS",
- [PRECALL_NO_KW_METHOD_DESCRIPTOR_O] = "PRECALL_NO_KW_METHOD_DESCRIPTOR_O",
[LIST_TO_TUPLE] = "LIST_TO_TUPLE",
[RETURN_VALUE] = "RETURN_VALUE",
[IMPORT_STAR] = "IMPORT_STAR",
@@ -351,7 +352,7 @@ static const char *const _PyOpcode_OpName[256] = {
[JUMP_FORWARD] = "JUMP_FORWARD",
[JUMP_IF_FALSE_OR_POP] = "JUMP_IF_FALSE_OR_POP",
[JUMP_IF_TRUE_OR_POP] = "JUMP_IF_TRUE_OR_POP",
- [PRECALL_NO_KW_STR_1] = "PRECALL_NO_KW_STR_1",
+ [PRECALL_NO_KW_METHOD_DESCRIPTOR_O] = "PRECALL_NO_KW_METHOD_DESCRIPTOR_O",
[POP_JUMP_FORWARD_IF_FALSE] = "POP_JUMP_FORWARD_IF_FALSE",
[POP_JUMP_FORWARD_IF_TRUE] = "POP_JUMP_FORWARD_IF_TRUE",
[LOAD_GLOBAL] = "LOAD_GLOBAL",
@@ -359,13 +360,13 @@ static const char *const _PyOpcode_OpName[256] = {
[CONTAINS_OP] = "CONTAINS_OP",
[RERAISE] = "RERAISE",
[COPY] = "COPY",
- [PRECALL_NO_KW_TUPLE_1] = "PRECALL_NO_KW_TUPLE_1",
+ [PRECALL_NO_KW_STR_1] = "PRECALL_NO_KW_STR_1",
[BINARY_OP] = "BINARY_OP",
[SEND] = "SEND",
[LOAD_FAST] = "LOAD_FAST",
[STORE_FAST] = "STORE_FAST",
[DELETE_FAST] = "DELETE_FAST",
- [PRECALL_NO_KW_TYPE_1] = "PRECALL_NO_KW_TYPE_1",
+ [PRECALL_NO_KW_TUPLE_1] = "PRECALL_NO_KW_TUPLE_1",
[POP_JUMP_FORWARD_IF_NOT_NONE] = "POP_JUMP_FORWARD_IF_NOT_NONE",
[POP_JUMP_FORWARD_IF_NONE] = "POP_JUMP_FORWARD_IF_NONE",
[RAISE_VARARGS] = "RAISE_VARARGS",
@@ -379,46 +380,46 @@ static const char *const _PyOpcode_OpName[256] = {
[STORE_DEREF] = "STORE_DEREF",
[DELETE_DEREF] = "DELETE_DEREF",
[JUMP_BACKWARD] = "JUMP_BACKWARD",
- [PRECALL_PYFUNC] = "PRECALL_PYFUNC",
+ [PRECALL_NO_KW_TYPE_1] = "PRECALL_NO_KW_TYPE_1",
[CALL_FUNCTION_EX] = "CALL_FUNCTION_EX",
- [RESUME_QUICK] = "RESUME_QUICK",
+ [PRECALL_PYFUNC] = "PRECALL_PYFUNC",
[EXTENDED_ARG] = "EXTENDED_ARG",
[LIST_APPEND] = "LIST_APPEND",
[SET_ADD] = "SET_ADD",
[MAP_ADD] = "MAP_ADD",
[LOAD_CLASSDEREF] = "LOAD_CLASSDEREF",
[COPY_FREE_VARS] = "COPY_FREE_VARS",
- [STORE_ATTR_ADAPTIVE] = "STORE_ATTR_ADAPTIVE",
+ [RESUME_QUICK] = "RESUME_QUICK",
[RESUME] = "RESUME",
[MATCH_CLASS] = "MATCH_CLASS",
+ [STORE_ATTR_ADAPTIVE] = "STORE_ATTR_ADAPTIVE",
[STORE_ATTR_INSTANCE_VALUE] = "STORE_ATTR_INSTANCE_VALUE",
- [STORE_ATTR_SLOT] = "STORE_ATTR_SLOT",
[FORMAT_VALUE] = "FORMAT_VALUE",
[BUILD_CONST_KEY_MAP] = "BUILD_CONST_KEY_MAP",
[BUILD_STRING] = "BUILD_STRING",
+ [STORE_ATTR_SLOT] = "STORE_ATTR_SLOT",
[STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT",
- [STORE_FAST__LOAD_FAST] = "STORE_FAST__LOAD_FAST",
[LOAD_METHOD] = "LOAD_METHOD",
- [STORE_FAST__STORE_FAST] = "STORE_FAST__STORE_FAST",
+ [STORE_FAST__LOAD_FAST] = "STORE_FAST__LOAD_FAST",
[LIST_EXTEND] = "LIST_EXTEND",
[SET_UPDATE] = "SET_UPDATE",
[DICT_MERGE] = "DICT_MERGE",
[DICT_UPDATE] = "DICT_UPDATE",
[PRECALL] = "PRECALL",
+ [STORE_FAST__STORE_FAST] = "STORE_FAST__STORE_FAST",
[STORE_SUBSCR_ADAPTIVE] = "STORE_SUBSCR_ADAPTIVE",
[STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT",
[STORE_SUBSCR_LIST_INT] = "STORE_SUBSCR_LIST_INT",
- [UNPACK_SEQUENCE_ADAPTIVE] = "UNPACK_SEQUENCE_ADAPTIVE",
[CALL] = "CALL",
[KW_NAMES] = "KW_NAMES",
[POP_JUMP_BACKWARD_IF_NOT_NONE] = "POP_JUMP_BACKWARD_IF_NOT_NONE",
[POP_JUMP_BACKWARD_IF_NONE] = "POP_JUMP_BACKWARD_IF_NONE",
[POP_JUMP_BACKWARD_IF_FALSE] = "POP_JUMP_BACKWARD_IF_FALSE",
[POP_JUMP_BACKWARD_IF_TRUE] = "POP_JUMP_BACKWARD_IF_TRUE",
+ [UNPACK_SEQUENCE_ADAPTIVE] = "UNPACK_SEQUENCE_ADAPTIVE",
[UNPACK_SEQUENCE_LIST] = "UNPACK_SEQUENCE_LIST",
[UNPACK_SEQUENCE_TUPLE] = "UNPACK_SEQUENCE_TUPLE",
[UNPACK_SEQUENCE_TWO_TUPLE] = "UNPACK_SEQUENCE_TWO_TUPLE",
- [180] = "<180>",
[181] = "<181>",
[182] = "<182>",
[183] = "<183>",
@@ -498,7 +499,6 @@ static const char *const _PyOpcode_OpName[256] = {
#endif
#define EXTRA_CASES \
- case 180: \
case 181: \
case 182: \
case 183: \
diff --git a/Include/opcode.h b/Include/opcode.h
index 399847d..084d34b 100644
--- a/Include/opcode.h
+++ b/Include/opcode.h
@@ -140,55 +140,56 @@ extern "C" {
#define COMPARE_OP_FLOAT_JUMP 27
#define COMPARE_OP_INT_JUMP 28
#define COMPARE_OP_STR_JUMP 29
-#define JUMP_BACKWARD_QUICK 34
-#define LOAD_ATTR_ADAPTIVE 38
-#define LOAD_ATTR_INSTANCE_VALUE 39
-#define LOAD_ATTR_MODULE 40
-#define LOAD_ATTR_SLOT 41
-#define LOAD_ATTR_WITH_HINT 42
-#define LOAD_CONST__LOAD_FAST 43
-#define LOAD_FAST__LOAD_CONST 44
-#define LOAD_FAST__LOAD_FAST 45
-#define LOAD_GLOBAL_ADAPTIVE 46
-#define LOAD_GLOBAL_BUILTIN 47
-#define LOAD_GLOBAL_MODULE 48
-#define LOAD_METHOD_ADAPTIVE 55
-#define LOAD_METHOD_CLASS 56
-#define LOAD_METHOD_MODULE 57
-#define LOAD_METHOD_NO_DICT 58
-#define LOAD_METHOD_WITH_DICT 59
-#define LOAD_METHOD_WITH_VALUES 62
-#define PRECALL_ADAPTIVE 63
-#define PRECALL_BOUND_METHOD 64
-#define PRECALL_BUILTIN_CLASS 65
-#define PRECALL_BUILTIN_FAST_WITH_KEYWORDS 66
-#define PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 67
-#define PRECALL_NO_KW_BUILTIN_FAST 72
-#define PRECALL_NO_KW_BUILTIN_O 73
-#define PRECALL_NO_KW_ISINSTANCE 76
-#define PRECALL_NO_KW_LEN 77
-#define PRECALL_NO_KW_LIST_APPEND 78
-#define PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST 79
-#define PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 80
-#define PRECALL_NO_KW_METHOD_DESCRIPTOR_O 81
-#define PRECALL_NO_KW_STR_1 113
-#define PRECALL_NO_KW_TUPLE_1 121
-#define PRECALL_NO_KW_TYPE_1 127
-#define PRECALL_PYFUNC 141
-#define RESUME_QUICK 143
-#define STORE_ATTR_ADAPTIVE 150
-#define STORE_ATTR_INSTANCE_VALUE 153
-#define STORE_ATTR_SLOT 154
-#define STORE_ATTR_WITH_HINT 158
-#define STORE_FAST__LOAD_FAST 159
-#define STORE_FAST__STORE_FAST 161
-#define STORE_SUBSCR_ADAPTIVE 167
-#define STORE_SUBSCR_DICT 168
-#define STORE_SUBSCR_LIST_INT 169
-#define UNPACK_SEQUENCE_ADAPTIVE 170
-#define UNPACK_SEQUENCE_LIST 177
-#define UNPACK_SEQUENCE_TUPLE 178
-#define UNPACK_SEQUENCE_TWO_TUPLE 179
+#define EXTENDED_ARG_QUICK 34
+#define JUMP_BACKWARD_QUICK 38
+#define LOAD_ATTR_ADAPTIVE 39
+#define LOAD_ATTR_INSTANCE_VALUE 40
+#define LOAD_ATTR_MODULE 41
+#define LOAD_ATTR_SLOT 42
+#define LOAD_ATTR_WITH_HINT 43
+#define LOAD_CONST__LOAD_FAST 44
+#define LOAD_FAST__LOAD_CONST 45
+#define LOAD_FAST__LOAD_FAST 46
+#define LOAD_GLOBAL_ADAPTIVE 47
+#define LOAD_GLOBAL_BUILTIN 48
+#define LOAD_GLOBAL_MODULE 55
+#define LOAD_METHOD_ADAPTIVE 56
+#define LOAD_METHOD_CLASS 57
+#define LOAD_METHOD_MODULE 58
+#define LOAD_METHOD_NO_DICT 59
+#define LOAD_METHOD_WITH_DICT 62
+#define LOAD_METHOD_WITH_VALUES 63
+#define PRECALL_ADAPTIVE 64
+#define PRECALL_BOUND_METHOD 65
+#define PRECALL_BUILTIN_CLASS 66
+#define PRECALL_BUILTIN_FAST_WITH_KEYWORDS 67
+#define PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 72
+#define PRECALL_NO_KW_BUILTIN_FAST 73
+#define PRECALL_NO_KW_BUILTIN_O 76
+#define PRECALL_NO_KW_ISINSTANCE 77
+#define PRECALL_NO_KW_LEN 78
+#define PRECALL_NO_KW_LIST_APPEND 79
+#define PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST 80
+#define PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 81
+#define PRECALL_NO_KW_METHOD_DESCRIPTOR_O 113
+#define PRECALL_NO_KW_STR_1 121
+#define PRECALL_NO_KW_TUPLE_1 127
+#define PRECALL_NO_KW_TYPE_1 141
+#define PRECALL_PYFUNC 143
+#define RESUME_QUICK 150
+#define STORE_ATTR_ADAPTIVE 153
+#define STORE_ATTR_INSTANCE_VALUE 154
+#define STORE_ATTR_SLOT 158
+#define STORE_ATTR_WITH_HINT 159
+#define STORE_FAST__LOAD_FAST 161
+#define STORE_FAST__STORE_FAST 167
+#define STORE_SUBSCR_ADAPTIVE 168
+#define STORE_SUBSCR_DICT 169
+#define STORE_SUBSCR_LIST_INT 170
+#define UNPACK_SEQUENCE_ADAPTIVE 177
+#define UNPACK_SEQUENCE_LIST 178
+#define UNPACK_SEQUENCE_TUPLE 179
+#define UNPACK_SEQUENCE_TWO_TUPLE 180
#define DO_TRACING 255
#define HAS_CONST(op) (false\
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index 71e1e24..5f67226 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -416,7 +416,7 @@ _code_type = type(_write_atomic.__code__)
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.
-MAGIC_NUMBER = (3493).to_bytes(2, 'little') + b'\r\n'
+MAGIC_NUMBER = (3494).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 9ee0683..6c38627 100644
--- a/Lib/opcode.py
+++ b/Lib/opcode.py
@@ -264,6 +264,9 @@ _specializations = {
"COMPARE_OP_INT_JUMP",
"COMPARE_OP_STR_JUMP",
],
+ "EXTENDED_ARG": [
+ "EXTENDED_ARG_QUICK",
+ ],
"JUMP_BACKWARD": [
"JUMP_BACKWARD_QUICK",
],
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index 85d6bdf..b1c8f6f 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -2432,5 +2432,47 @@ output.append(4)
output.append(5)
+class TestExtendedArgs(unittest.TestCase):
+
+ def setUp(self):
+ self.addCleanup(sys.settrace, sys.gettrace())
+ sys.settrace(None)
+
+ def count_traces(self, func):
+ # warmup
+ for _ in range(20):
+ func()
+
+ counts = {"call": 0, "line": 0, "return": 0}
+ def trace(frame, event, arg):
+ counts[event] += 1
+ return trace
+
+ sys.settrace(trace)
+ func()
+ sys.settrace(None)
+
+ return counts
+
+ def test_trace_unpack_long_sequence(self):
+ ns = {}
+ code = "def f():\n (" + "y,\n "*300 + ") = range(300)"
+ exec(code, ns)
+ counts = self.count_traces(ns["f"])
+ self.assertEqual(counts, {'call': 1, 'line': 301, 'return': 1})
+
+ def test_trace_lots_of_globals(self):
+ code = """if 1:
+ def f():
+ return (
+ {}
+ )
+ """.format("\n+\n".join(f"var{i}\n" for i in range(1000)))
+ ns = {f"var{i}": i for i in range(1000)}
+ exec(code, ns)
+ counts = self.count_traces(ns["f"])
+ self.assertEqual(counts, {'call': 1, 'line': 2000, 'return': 1})
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-04-26-05-05-32.gh-issue-91869.ELbTXl.rst b/Misc/NEWS.d/next/Core and Builtins/2022-04-26-05-05-32.gh-issue-91869.ELbTXl.rst
new file mode 100644
index 0000000..05b84be
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-04-26-05-05-32.gh-issue-91869.ELbTXl.rst
@@ -0,0 +1 @@
+Fix an issue where specialized opcodes with extended arguments could produce incorrect tracing output or lead to assertion failures.
diff --git a/Python/ceval.c b/Python/ceval.c
index 6e7a248..1d2c643 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -5627,6 +5627,15 @@ handle_eval_breaker:
assert(oparg);
oparg <<= 8;
oparg |= _Py_OPARG(*next_instr);
+ opcode = _PyOpcode_Deopt[_Py_OPCODE(*next_instr)];
+ PRE_DISPATCH_GOTO();
+ DISPATCH_GOTO();
+ }
+
+ TARGET(EXTENDED_ARG_QUICK) {
+ assert(oparg);
+ oparg <<= 8;
+ oparg |= _Py_OPARG(*next_instr);
NOTRACE_DISPATCH_SAME_OPARG();
}
diff --git a/Python/compile.c b/Python/compile.c
index 42b011c..10d6307 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -211,13 +211,13 @@ write_instr(_Py_CODEUNIT *codestr, struct instr *instruction, int ilen)
int caches = _PyOpcode_Caches[opcode];
switch (ilen - caches) {
case 4:
- *codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 24) & 0xFF);
+ *codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG_QUICK, (oparg >> 24) & 0xFF);
/* fall through */
case 3:
- *codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 16) & 0xFF);
+ *codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG_QUICK, (oparg >> 16) & 0xFF);
/* fall through */
case 2:
- *codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 8) & 0xFF);
+ *codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG_QUICK, (oparg >> 8) & 0xFF);
/* fall through */
case 1:
*codestr++ = _Py_MAKECODEUNIT(opcode, oparg & 0xFF);
@@ -8254,6 +8254,7 @@ fix_cell_offsets(struct compiler *c, basicblock *entryblock, int *fixedmap)
struct instr *inst = &b->b_instr[i];
// This is called before extended args are generated.
assert(inst->i_opcode != EXTENDED_ARG);
+ assert(inst->i_opcode != EXTENDED_ARG_QUICK);
int oldoffset = inst->i_oparg;
switch(inst->i_opcode) {
case MAKE_CELL:
diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h
index 5268c4f..d37c132 100644
--- a/Python/opcode_targets.h
+++ b/Python/opcode_targets.h
@@ -33,10 +33,11 @@ static void *opcode_targets[256] = {
&&TARGET_MATCH_MAPPING,
&&TARGET_MATCH_SEQUENCE,
&&TARGET_MATCH_KEYS,
- &&TARGET_JUMP_BACKWARD_QUICK,
+ &&TARGET_EXTENDED_ARG_QUICK,
&&TARGET_PUSH_EXC_INFO,
&&TARGET_CHECK_EXC_MATCH,
&&TARGET_CHECK_EG_MATCH,
+ &&TARGET_JUMP_BACKWARD_QUICK,
&&TARGET_LOAD_ATTR_ADAPTIVE,
&&TARGET_LOAD_ATTR_INSTANCE_VALUE,
&&TARGET_LOAD_ATTR_MODULE,
@@ -47,40 +48,39 @@ static void *opcode_targets[256] = {
&&TARGET_LOAD_FAST__LOAD_FAST,
&&TARGET_LOAD_GLOBAL_ADAPTIVE,
&&TARGET_LOAD_GLOBAL_BUILTIN,
- &&TARGET_LOAD_GLOBAL_MODULE,
&&TARGET_WITH_EXCEPT_START,
&&TARGET_GET_AITER,
&&TARGET_GET_ANEXT,
&&TARGET_BEFORE_ASYNC_WITH,
&&TARGET_BEFORE_WITH,
&&TARGET_END_ASYNC_FOR,
+ &&TARGET_LOAD_GLOBAL_MODULE,
&&TARGET_LOAD_METHOD_ADAPTIVE,
&&TARGET_LOAD_METHOD_CLASS,
&&TARGET_LOAD_METHOD_MODULE,
&&TARGET_LOAD_METHOD_NO_DICT,
- &&TARGET_LOAD_METHOD_WITH_DICT,
&&TARGET_STORE_SUBSCR,
&&TARGET_DELETE_SUBSCR,
+ &&TARGET_LOAD_METHOD_WITH_DICT,
&&TARGET_LOAD_METHOD_WITH_VALUES,
&&TARGET_PRECALL_ADAPTIVE,
&&TARGET_PRECALL_BOUND_METHOD,
&&TARGET_PRECALL_BUILTIN_CLASS,
&&TARGET_PRECALL_BUILTIN_FAST_WITH_KEYWORDS,
- &&TARGET_PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS,
&&TARGET_GET_ITER,
&&TARGET_GET_YIELD_FROM_ITER,
&&TARGET_PRINT_EXPR,
&&TARGET_LOAD_BUILD_CLASS,
+ &&TARGET_PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS,
&&TARGET_PRECALL_NO_KW_BUILTIN_FAST,
- &&TARGET_PRECALL_NO_KW_BUILTIN_O,
&&TARGET_LOAD_ASSERTION_ERROR,
&&TARGET_RETURN_GENERATOR,
+ &&TARGET_PRECALL_NO_KW_BUILTIN_O,
&&TARGET_PRECALL_NO_KW_ISINSTANCE,
&&TARGET_PRECALL_NO_KW_LEN,
&&TARGET_PRECALL_NO_KW_LIST_APPEND,
&&TARGET_PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST,
&&TARGET_PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS,
- &&TARGET_PRECALL_NO_KW_METHOD_DESCRIPTOR_O,
&&TARGET_LIST_TO_TUPLE,
&&TARGET_RETURN_VALUE,
&&TARGET_IMPORT_STAR,
@@ -112,7 +112,7 @@ static void *opcode_targets[256] = {
&&TARGET_JUMP_FORWARD,
&&TARGET_JUMP_IF_FALSE_OR_POP,
&&TARGET_JUMP_IF_TRUE_OR_POP,
- &&TARGET_PRECALL_NO_KW_STR_1,
+ &&TARGET_PRECALL_NO_KW_METHOD_DESCRIPTOR_O,
&&TARGET_POP_JUMP_FORWARD_IF_FALSE,
&&TARGET_POP_JUMP_FORWARD_IF_TRUE,
&&TARGET_LOAD_GLOBAL,
@@ -120,13 +120,13 @@ static void *opcode_targets[256] = {
&&TARGET_CONTAINS_OP,
&&TARGET_RERAISE,
&&TARGET_COPY,
- &&TARGET_PRECALL_NO_KW_TUPLE_1,
+ &&TARGET_PRECALL_NO_KW_STR_1,
&&TARGET_BINARY_OP,
&&TARGET_SEND,
&&TARGET_LOAD_FAST,
&&TARGET_STORE_FAST,
&&TARGET_DELETE_FAST,
- &&TARGET_PRECALL_NO_KW_TYPE_1,
+ &&TARGET_PRECALL_NO_KW_TUPLE_1,
&&TARGET_POP_JUMP_FORWARD_IF_NOT_NONE,
&&TARGET_POP_JUMP_FORWARD_IF_NONE,
&&TARGET_RAISE_VARARGS,
@@ -140,42 +140,43 @@ static void *opcode_targets[256] = {
&&TARGET_STORE_DEREF,
&&TARGET_DELETE_DEREF,
&&TARGET_JUMP_BACKWARD,
- &&TARGET_PRECALL_PYFUNC,
+ &&TARGET_PRECALL_NO_KW_TYPE_1,
&&TARGET_CALL_FUNCTION_EX,
- &&TARGET_RESUME_QUICK,
+ &&TARGET_PRECALL_PYFUNC,
&&TARGET_EXTENDED_ARG,
&&TARGET_LIST_APPEND,
&&TARGET_SET_ADD,
&&TARGET_MAP_ADD,
&&TARGET_LOAD_CLASSDEREF,
&&TARGET_COPY_FREE_VARS,
- &&TARGET_STORE_ATTR_ADAPTIVE,
+ &&TARGET_RESUME_QUICK,
&&TARGET_RESUME,
&&TARGET_MATCH_CLASS,
+ &&TARGET_STORE_ATTR_ADAPTIVE,
&&TARGET_STORE_ATTR_INSTANCE_VALUE,
- &&TARGET_STORE_ATTR_SLOT,
&&TARGET_FORMAT_VALUE,
&&TARGET_BUILD_CONST_KEY_MAP,
&&TARGET_BUILD_STRING,
+ &&TARGET_STORE_ATTR_SLOT,
&&TARGET_STORE_ATTR_WITH_HINT,
- &&TARGET_STORE_FAST__LOAD_FAST,
&&TARGET_LOAD_METHOD,
- &&TARGET_STORE_FAST__STORE_FAST,
+ &&TARGET_STORE_FAST__LOAD_FAST,
&&TARGET_LIST_EXTEND,
&&TARGET_SET_UPDATE,
&&TARGET_DICT_MERGE,
&&TARGET_DICT_UPDATE,
&&TARGET_PRECALL,
+ &&TARGET_STORE_FAST__STORE_FAST,
&&TARGET_STORE_SUBSCR_ADAPTIVE,
&&TARGET_STORE_SUBSCR_DICT,
&&TARGET_STORE_SUBSCR_LIST_INT,
- &&TARGET_UNPACK_SEQUENCE_ADAPTIVE,
&&TARGET_CALL,
&&TARGET_KW_NAMES,
&&TARGET_POP_JUMP_BACKWARD_IF_NOT_NONE,
&&TARGET_POP_JUMP_BACKWARD_IF_NONE,
&&TARGET_POP_JUMP_BACKWARD_IF_FALSE,
&&TARGET_POP_JUMP_BACKWARD_IF_TRUE,
+ &&TARGET_UNPACK_SEQUENCE_ADAPTIVE,
&&TARGET_UNPACK_SEQUENCE_LIST,
&&TARGET_UNPACK_SEQUENCE_TUPLE,
&&TARGET_UNPACK_SEQUENCE_TWO_TUPLE,
@@ -253,6 +254,5 @@ static void *opcode_targets[256] = {
&&_unknown_opcode,
&&_unknown_opcode,
&&_unknown_opcode,
- &&_unknown_opcode,
&&TARGET_DO_TRACING
};