Visitar URL original
bpo-46409: Make generators in bytecode by markshannon · Pull Request #30633 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename YIELD_FROM_LOOP to JUMP_NO_INTERRUPT: describe what it does, n…
…ot where it might be used.
  • Loading branch information
markshannon committed Jan 17, 2022
commit 8b73d0d02dbfe5f5397a80cfe9b643f5e69201ac
2 changes: 1 addition & 1 deletion Include/opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def jabs_op(name, op):
def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3)
def_op('MAKE_FUNCTION', 132) # Flags
def_op('BUILD_SLICE', 133) # Number of items
jabs_op('YIELD_FROM_LOOP', 134) # Target byte offset from beginning of code
jabs_op('JUMP_NO_INTERRUPT', 134) # Target byte offset from beginning of code
def_op('MAKE_CELL', 135)
hasfree.append(135)
def_op('LOAD_CLOSURE', 136)
Expand Down
2 changes: 1 addition & 1 deletion Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ mark_stacks(PyCodeObject *code_obj, int len)
break;
}
case JUMP_ABSOLUTE:
case YIELD_FROM_LOOP:
case JUMP_NO_INTERRUPT:
j = get_arg(code, i);
assert(j < len);
if (stacks[j] == UNINITIALIZED && j < i) {
Expand Down
2 changes: 1 addition & 1 deletion Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -4111,7 +4111,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
DISPATCH();
}

TARGET(YIELD_FROM_LOOP) {
TARGET(JUMP_NO_INTERRUPT) {
frame->f_state = FRAME_EXECUTING;
JUMPTO(oparg);
DISPATCH();
Expand Down
10 changes: 5 additions & 5 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ stack_effect(int opcode, int oparg, int jump)
/* Jumps */
case JUMP_FORWARD:
case JUMP_ABSOLUTE:
case YIELD_FROM_LOOP:
case JUMP_NO_INTERRUPT:
return 0;

case JUMP_IF_TRUE_OR_POP:
Expand Down Expand Up @@ -1845,7 +1845,7 @@ compiler_add_yield_from(struct compiler *c, int await)
ADDOP_JUMP(c, SEND, exit);
compiler_use_next_block(c, resume);
ADDOP_I(c, RESUME, await ? 3 : 2);
ADDOP_JUMP(c, YIELD_FROM_LOOP, start);
ADDOP_JUMP(c, JUMP_NO_INTERRUPT, start);
compiler_use_next_block(c, exit);
return 1;
}
Expand Down Expand Up @@ -7056,7 +7056,7 @@ stackdepth(struct compiler *c)
}
depth = new_depth;
if (instr->i_opcode == JUMP_ABSOLUTE ||
instr->i_opcode == YIELD_FROM_LOOP ||
instr->i_opcode == JUMP_NO_INTERRUPT ||
instr->i_opcode == JUMP_FORWARD ||
instr->i_opcode == RETURN_VALUE ||
instr->i_opcode == RAISE_VARARGS ||
Expand Down Expand Up @@ -8812,7 +8812,7 @@ normalize_basic_block(basicblock *bb) {
break;
case JUMP_ABSOLUTE:
case JUMP_FORWARD:
case YIELD_FROM_LOOP:
case JUMP_NO_INTERRUPT:
bb->b_nofallthrough = 1;
/* fall through */
case POP_JUMP_IF_NOT_NONE:
Expand Down Expand Up @@ -8997,7 +8997,7 @@ optimize_cfg(struct compiler *c, struct assembler *a, PyObject *consts)
if (b->b_iused > 0) {
struct instr *b_last_instr = &b->b_instr[b->b_iused - 1];
if (b_last_instr->i_opcode == JUMP_ABSOLUTE ||
b_last_instr->i_opcode == YIELD_FROM_LOOP ||
b_last_instr->i_opcode == JUMP_NO_INTERRUPT ||
b_last_instr->i_opcode == JUMP_FORWARD) {
if (b_last_instr->i_target == b->b_next) {
assert(b->b_next->b_iused);
Expand Down
2 changes: 1 addition & 1 deletion Python/opcode_targets.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.