mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
GH-89914: Make the oparg of the YIELD_VALUE instruction equal the stack depth. (GH-92960)
This commit is contained in:
parent
70aa1b9b91
commit
3fd8610002
9 changed files with 35 additions and 26 deletions
|
@ -2698,6 +2698,7 @@ handle_eval_breaker:
|
|||
}
|
||||
|
||||
TARGET(YIELD_VALUE) {
|
||||
assert(oparg == STACK_LEVEL());
|
||||
assert(frame->is_entry);
|
||||
PyObject *retval = POP();
|
||||
_PyFrame_GetGenerator(frame)->gi_frame_state = FRAME_SUSPENDED;
|
||||
|
|
|
@ -1962,7 +1962,7 @@ compiler_add_yield_from(struct compiler *c, int await)
|
|||
compiler_use_next_block(c, start);
|
||||
ADDOP_JUMP(c, SEND, exit);
|
||||
compiler_use_next_block(c, resume);
|
||||
ADDOP(c, YIELD_VALUE);
|
||||
ADDOP_I(c, YIELD_VALUE, 0);
|
||||
ADDOP_I(c, RESUME, await ? 3 : 2);
|
||||
ADDOP_JUMP(c, JUMP_NO_INTERRUPT, start);
|
||||
compiler_use_next_block(c, exit);
|
||||
|
@ -4193,7 +4193,7 @@ addop_yield(struct compiler *c) {
|
|||
if (c->u->u_ste->ste_generator && c->u->u_ste->ste_coroutine) {
|
||||
ADDOP(c, ASYNC_GEN_WRAP);
|
||||
}
|
||||
ADDOP(c, YIELD_VALUE);
|
||||
ADDOP_I(c, YIELD_VALUE, 0);
|
||||
ADDOP_I(c, RESUME, 1);
|
||||
return 1;
|
||||
}
|
||||
|
@ -7152,6 +7152,9 @@ stackdepth(struct compiler *c, basicblock *entry)
|
|||
next = NULL;
|
||||
break;
|
||||
}
|
||||
if (instr->i_opcode == YIELD_VALUE) {
|
||||
instr->i_oparg = depth;
|
||||
}
|
||||
}
|
||||
if (next != NULL) {
|
||||
assert(b->b_nofallthrough == 0);
|
||||
|
|
14
Python/opcode_targets.h
generated
14
Python/opcode_targets.h
generated
|
@ -85,7 +85,7 @@ static void *opcode_targets[256] = {
|
|||
&&TARGET_RETURN_VALUE,
|
||||
&&TARGET_IMPORT_STAR,
|
||||
&&TARGET_SETUP_ANNOTATIONS,
|
||||
&&TARGET_YIELD_VALUE,
|
||||
&&TARGET_LOAD_METHOD_NO_DICT,
|
||||
&&TARGET_ASYNC_GEN_WRAP,
|
||||
&&TARGET_PREP_RERAISE_STAR,
|
||||
&&TARGET_POP_EXCEPT,
|
||||
|
@ -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_LOAD_METHOD_NO_DICT,
|
||||
&&TARGET_LOAD_METHOD_WITH_DICT,
|
||||
&&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_LOAD_METHOD_WITH_DICT,
|
||||
&&TARGET_LOAD_METHOD_WITH_VALUES,
|
||||
&&TARGET_BINARY_OP,
|
||||
&&TARGET_SEND,
|
||||
&&TARGET_LOAD_FAST,
|
||||
&&TARGET_STORE_FAST,
|
||||
&&TARGET_DELETE_FAST,
|
||||
&&TARGET_LOAD_METHOD_WITH_VALUES,
|
||||
&&TARGET_RESUME_QUICK,
|
||||
&&TARGET_POP_JUMP_FORWARD_IF_NOT_NONE,
|
||||
&&TARGET_POP_JUMP_FORWARD_IF_NONE,
|
||||
&&TARGET_RAISE_VARARGS,
|
||||
|
@ -140,16 +140,16 @@ static void *opcode_targets[256] = {
|
|||
&&TARGET_STORE_DEREF,
|
||||
&&TARGET_DELETE_DEREF,
|
||||
&&TARGET_JUMP_BACKWARD,
|
||||
&&TARGET_RESUME_QUICK,
|
||||
&&TARGET_CALL_FUNCTION_EX,
|
||||
&&TARGET_STORE_ATTR_ADAPTIVE,
|
||||
&&TARGET_CALL_FUNCTION_EX,
|
||||
&&TARGET_STORE_ATTR_INSTANCE_VALUE,
|
||||
&&TARGET_EXTENDED_ARG,
|
||||
&&TARGET_LIST_APPEND,
|
||||
&&TARGET_SET_ADD,
|
||||
&&TARGET_MAP_ADD,
|
||||
&&TARGET_LOAD_CLASSDEREF,
|
||||
&&TARGET_COPY_FREE_VARS,
|
||||
&&TARGET_STORE_ATTR_INSTANCE_VALUE,
|
||||
&&TARGET_YIELD_VALUE,
|
||||
&&TARGET_RESUME,
|
||||
&&TARGET_MATCH_CLASS,
|
||||
&&TARGET_STORE_ATTR_SLOT,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue