mirror of
https://github.com/python/cpython.git
synced 2025-07-18 16:55:20 +00:00
gh-111354: define names for RESUME oparg values (#111365)
This commit is contained in:
parent
309efb39dc
commit
a0c414c35d
7 changed files with 16 additions and 8 deletions
|
@ -147,7 +147,7 @@ dummy_func(
|
|||
next_instr--;
|
||||
}
|
||||
else {
|
||||
if (oparg < 2) {
|
||||
if (oparg < RESUME_AFTER_YIELD_FROM) {
|
||||
CHECK_EVAL_BREAKER();
|
||||
}
|
||||
next_instr[-1].op.code = RESUME_CHECK;
|
||||
|
|
|
@ -643,7 +643,7 @@ static const _Py_CODEUNIT _Py_INTERPRETER_TRAMPOLINE_INSTRUCTIONS[] = {
|
|||
{ .op.code = INTERPRETER_EXIT, .op.arg = 0 }, /* reached on return */
|
||||
{ .op.code = NOP, .op.arg = 0 },
|
||||
{ .op.code = INTERPRETER_EXIT, .op.arg = 0 }, /* reached on yield */
|
||||
{ .op.code = RESUME, .op.arg = 0 }
|
||||
{ .op.code = RESUME, .op.arg = RESUME_AT_FUNC_START }
|
||||
};
|
||||
|
||||
extern const struct _PyCode_DEF(8) _Py_InitCleanup;
|
||||
|
|
|
@ -1383,7 +1383,7 @@ compiler_enter_scope(struct compiler *c, identifier name,
|
|||
else {
|
||||
RETURN_IF_ERROR(compiler_set_qualname(c));
|
||||
}
|
||||
ADDOP_I(c, loc, RESUME, 0);
|
||||
ADDOP_I(c, loc, RESUME, RESUME_AT_FUNC_START);
|
||||
|
||||
if (u->u_scope_type == COMPILER_SCOPE_MODULE) {
|
||||
loc.lineno = -1;
|
||||
|
@ -1552,7 +1552,7 @@ compiler_add_yield_from(struct compiler *c, location loc, int await)
|
|||
ADDOP_JUMP(c, loc, SETUP_FINALLY, fail);
|
||||
ADDOP_I(c, loc, YIELD_VALUE, 0);
|
||||
ADDOP(c, NO_LOCATION, POP_BLOCK);
|
||||
ADDOP_I(c, loc, RESUME, await ? 3 : 2);
|
||||
ADDOP_I(c, loc, RESUME, await ? RESUME_AFTER_AWAIT : RESUME_AFTER_YIELD_FROM);
|
||||
ADDOP_JUMP(c, loc, JUMP_NO_INTERRUPT, send);
|
||||
|
||||
USE_LABEL(c, fail);
|
||||
|
@ -4161,7 +4161,7 @@ addop_yield(struct compiler *c, location loc) {
|
|||
ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_ASYNC_GEN_WRAP);
|
||||
}
|
||||
ADDOP_I(c, loc, YIELD_VALUE, 0);
|
||||
ADDOP_I(c, loc, RESUME, 1);
|
||||
ADDOP_I(c, loc, RESUME, RESUME_AFTER_YIELD);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
|
2
Python/generated_cases.c.h
generated
2
Python/generated_cases.c.h
generated
|
@ -23,7 +23,7 @@
|
|||
next_instr--;
|
||||
}
|
||||
else {
|
||||
if (oparg < 2) {
|
||||
if (oparg < RESUME_AFTER_YIELD_FROM) {
|
||||
CHECK_EVAL_BREAKER();
|
||||
}
|
||||
next_instr[-1].op.code = RESUME_CHECK;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "pycore_moduleobject.h"
|
||||
#include "pycore_object.h"
|
||||
#include "pycore_opcode_metadata.h" // _PyOpcode_Caches
|
||||
#include "pycore_opcode_utils.h" // RESUME_AT_FUNC_START
|
||||
#include "pycore_pylifecycle.h" // _PyOS_URandomNonblock()
|
||||
#include "pycore_runtime.h" // _Py_ID()
|
||||
|
||||
|
@ -2541,6 +2542,6 @@ const struct _PyCode_DEF(8) _Py_InitCleanup = {
|
|||
.co_code_adaptive = {
|
||||
EXIT_INIT_CHECK, 0,
|
||||
RETURN_VALUE, 0,
|
||||
RESUME, 0,
|
||||
RESUME, RESUME_AT_FUNC_START,
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue