summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/dis.rst8
-rw-r--r--Doc/whatsnew/3.11.rst2
-rw-r--r--Include/opcode.h7
-rw-r--r--Lib/importlib/_bootstrap_external.py3
-rw-r--r--Lib/opcode.py1
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2022-01-03-11-36-34.bpo-46009.QZGrov.rst1
-rw-r--r--Objects/frameobject.c8
-rw-r--r--Python/ceval.c8
-rw-r--r--Python/compile.c21
-rw-r--r--Python/opcode_targets.h8
10 files changed, 20 insertions, 47 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index 87ec584..8490a09 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -1175,14 +1175,6 @@ All of the following opcodes use their arguments.
Previously, this instruction also pushed a boolean value indicating
success (``True``) or failure (``False``).
-.. opcode:: GEN_START (kind)
-
- Pops TOS. The ``kind`` operand corresponds to the type of generator or
- coroutine. The legal kinds are 0 for generator, 1 for coroutine,
- and 2 for async generator.
-
- .. versionadded:: 3.10
-
.. opcode:: ROT_N (count)
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index be6cb15..6794e82 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -388,7 +388,7 @@ CPython bytecode changes
This decouples the argument shifting for methods from the handling of
keyword arguments and allows better specialization of calls.
-* Removed ``COPY_DICT_WITHOUT_KEYS``.
+* Removed ``COPY_DICT_WITHOUT_KEYS`` and ``GEN_START``.
* :opcode:`MATCH_CLASS` and :opcode:`MATCH_KEYS` no longer push an additional
boolean value indicating whether the match succeeded or failed. Instead, they
diff --git a/Include/opcode.h b/Include/opcode.h
index ef334de..1af5494 100644
--- a/Include/opcode.h
+++ b/Include/opcode.h
@@ -84,7 +84,6 @@ extern "C" {
#define STORE_FAST 125
#define DELETE_FAST 126
#define JUMP_IF_NOT_EG_MATCH 127
-#define GEN_START 129
#define RAISE_VARARGS 130
#define MAKE_FUNCTION 132
#define BUILD_SLICE 133
@@ -164,9 +163,9 @@ extern "C" {
#define STORE_ATTR_WITH_HINT 81
#define LOAD_FAST__LOAD_FAST 87
#define STORE_FAST__LOAD_FAST 128
-#define LOAD_FAST__LOAD_CONST 131
-#define LOAD_CONST__LOAD_FAST 134
-#define STORE_FAST__STORE_FAST 140
+#define LOAD_FAST__LOAD_CONST 129
+#define LOAD_CONST__LOAD_FAST 131
+#define STORE_FAST__STORE_FAST 134
#define DO_TRACING 255
#ifdef NEED_OPCODE_JUMP_TABLES
static uint32_t _PyOpcode_RelativeJump[8] = {
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index 2932466..872d6d9 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -377,6 +377,7 @@ _code_type = type(_write_atomic.__code__)
# Python 3.11a4 3469 (bpo-45711: remove type, traceback from exc_info)
# Python 3.11a4 3470 (bpo-46221: PREP_RERAISE_STAR no longer pushes lasti)
# Python 3.11a4 3471 (bpo-46202: remove pop POP_EXCEPT_AND_RERAISE)
+# Python 3.11a4 3472 (bpo-46009: replace GEN_START with POP_TOP)
#
# MAGIC must change whenever the bytecode emitted by the compiler may no
@@ -386,7 +387,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 = (3471).to_bytes(2, 'little') + b'\r\n'
+MAGIC_NUMBER = (3472).to_bytes(2, 'little') + b'\r\n'
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c
_PYCACHE = '__pycache__'
diff --git a/Lib/opcode.py b/Lib/opcode.py
index 9bbff18..f99e20a 100644
--- a/Lib/opcode.py
+++ b/Lib/opcode.py
@@ -151,7 +151,6 @@ haslocal.append(126)
jabs_op('JUMP_IF_NOT_EG_MATCH', 127)
-def_op('GEN_START', 129) # Kind of generator/coroutine
def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3)
def_op('MAKE_FUNCTION', 132) # Flags
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-01-03-11-36-34.bpo-46009.QZGrov.rst b/Misc/NEWS.d/next/Core and Builtins/2022-01-03-11-36-34.bpo-46009.QZGrov.rst
new file mode 100644
index 0000000..1ffcc76
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-01-03-11-36-34.bpo-46009.QZGrov.rst
@@ -0,0 +1 @@
+Remove the ``GEN_START`` opcode.
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 078fcfc..4dd2183 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -192,6 +192,11 @@ mark_stacks(PyCodeObject *code_obj, int len)
stacks[i] = UNINITIALIZED;
}
stacks[0] = 0;
+ if (code_obj->co_flags & (CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR))
+ {
+ // Generators get sent None while starting:
+ stacks[0] = push_value(stacks[0], Object);
+ }
int todo = 1;
while (todo) {
todo = 0;
@@ -291,9 +296,6 @@ mark_stacks(PyCodeObject *code_obj, int len)
case RERAISE:
/* End of block */
break;
- case GEN_START:
- stacks[i+1] = next_stack;
- break;
default:
{
int delta = PyCompile_OpcodeStackEffect(opcode, _Py_OPARG(code[i]));
diff --git a/Python/ceval.c b/Python/ceval.c
index 81bea44..953876f 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2709,14 +2709,6 @@ check_eval_breaker:
return retval;
}
- TARGET(GEN_START) {
- PyObject *none = POP();
- assert(none == Py_None);
- assert(oparg < 3);
- Py_DECREF(none);
- DISPATCH();
- }
-
TARGET(POP_EXCEPT) {
_PyErr_StackItem *exc_info = tstate->exc_info;
PyObject *value = exc_info->exc_value;
diff --git a/Python/compile.c b/Python/compile.c
index 9d37529..3a39075 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1208,8 +1208,6 @@ stack_effect(int opcode, int oparg, int jump)
return 1;
case LIST_TO_TUPLE:
return 0;
- case GEN_START:
- return -1;
case LIST_EXTEND:
case SET_UPDATE:
case DICT_MERGE:
@@ -8028,27 +8026,16 @@ insert_prefix_instructions(struct compiler *c, basicblock *entryblock,
/* Add the generator prefix instructions. */
if (flags & (CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR)) {
- int kind;
- if (flags & CO_COROUTINE) {
- kind = 1;
- }
- else if (flags & CO_ASYNC_GENERATOR) {
- kind = 2;
- }
- else {
- kind = 0;
- }
-
- struct instr gen_start = {
- .i_opcode = GEN_START,
- .i_oparg = kind,
+ struct instr pop_top = {
+ .i_opcode = POP_TOP,
+ .i_oparg = 0,
.i_lineno = -1,
.i_col_offset = -1,
.i_end_lineno = -1,
.i_end_col_offset = -1,
.i_target = NULL,
};
- if (insert_instruction(entryblock, 0, &gen_start) < 0) {
+ if (insert_instruction(entryblock, 0, &pop_top) < 0) {
return -1;
}
}
diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h
index a8f1398..e9f1a48 100644
--- a/Python/opcode_targets.h
+++ b/Python/opcode_targets.h
@@ -128,18 +128,18 @@ static void *opcode_targets[256] = {
&&TARGET_DELETE_FAST,
&&TARGET_JUMP_IF_NOT_EG_MATCH,
&&TARGET_STORE_FAST__LOAD_FAST,
- &&TARGET_GEN_START,
- &&TARGET_RAISE_VARARGS,
&&TARGET_LOAD_FAST__LOAD_CONST,
+ &&TARGET_RAISE_VARARGS,
+ &&TARGET_LOAD_CONST__LOAD_FAST,
&&TARGET_MAKE_FUNCTION,
&&TARGET_BUILD_SLICE,
- &&TARGET_LOAD_CONST__LOAD_FAST,
+ &&TARGET_STORE_FAST__STORE_FAST,
&&TARGET_MAKE_CELL,
&&TARGET_LOAD_CLOSURE,
&&TARGET_LOAD_DEREF,
&&TARGET_STORE_DEREF,
&&TARGET_DELETE_DEREF,
- &&TARGET_STORE_FAST__STORE_FAST,
+ &&_unknown_opcode,
&&_unknown_opcode,
&&TARGET_CALL_FUNCTION_EX,
&&_unknown_opcode,