summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-04-30 10:33:13 (GMT)
committerGitHub <noreply@github.com>2024-04-30 10:33:13 (GMT)
commit5b05d452cd20d9f0cfecdeec90adad3af5e4dfff (patch)
tree98991696903decd44fc348f6ac10f09b4c4785a5 /Python/bytecodes.c
parent0f797402bc77192c76a952410ca8e17359feab3c (diff)
downloadcpython-5b05d452cd20d9f0cfecdeec90adad3af5e4dfff.zip
cpython-5b05d452cd20d9f0cfecdeec90adad3af5e4dfff.tar.gz
cpython-5b05d452cd20d9f0cfecdeec90adad3af5e4dfff.tar.bz2
GH-118095: Add tier 2 support for YIELD_VALUE (GH-118380)
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index f688856..eee8b32 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -1089,32 +1089,38 @@ dummy_func(
goto resume_frame;
}
- tier1 inst(YIELD_VALUE, (retval -- unused)) {
+ inst(YIELD_VALUE, (retval -- value)) {
// NOTE: It's important that YIELD_VALUE never raises an exception!
// The compiler treats any exception raised here as a failed close()
// or throw() call.
+ #if TIER_ONE
assert(frame != &entry_frame);
- frame->instr_ptr = next_instr;
+ #endif
+ frame->instr_ptr++;
PyGenObject *gen = _PyFrame_GetGenerator(frame);
assert(FRAME_SUSPENDED_YIELD_FROM == FRAME_SUSPENDED + 1);
assert(oparg == 0 || oparg == 1);
gen->gi_frame_state = FRAME_SUSPENDED + oparg;
- _PyFrame_SetStackPointer(frame, stack_pointer - 1);
+ SYNC_SP();
+ _PyFrame_SetStackPointer(frame, stack_pointer);
tstate->exc_info = gen->gi_exc_state.previous_item;
gen->gi_exc_state.previous_item = NULL;
_Py_LeaveRecursiveCallPy(tstate);
_PyInterpreterFrame *gen_frame = frame;
frame = tstate->current_frame = frame->previous;
gen_frame->previous = NULL;
- _PyFrame_StackPush(frame, retval);
/* We don't know which of these is relevant here, so keep them equal */
assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER);
+ #if TIER_ONE
assert(_PyOpcode_Deopt[frame->instr_ptr->op.code] == SEND ||
_PyOpcode_Deopt[frame->instr_ptr->op.code] == FOR_ITER ||
_PyOpcode_Deopt[frame->instr_ptr->op.code] == INTERPRETER_EXIT ||
_PyOpcode_Deopt[frame->instr_ptr->op.code] == ENTER_EXECUTOR);
+ #endif
LOAD_IP(1 + INLINE_CACHE_ENTRIES_SEND);
- goto resume_frame;
+ LOAD_SP();
+ value = retval;
+ LLTRACE_RESUME_FRAME();
}
inst(POP_EXCEPT, (exc_value -- )) {