[3.14] gh-137030: Fix YIELD_VALUE bytecode assertion (#149184) (#149383)

gh-137030: Fix YIELD_VALUE bytecode assertion (#149184)


(cherry picked from commit 952784af47)

Co-authored-by: Mark Shannon <mark@hotpy.org>
This commit is contained in:
Victor Stinner
2026-05-04 23:41:19 +02:00
committed by GitHub
parent 96b81d527c
commit 690b2bb615
5 changed files with 28 additions and 30 deletions
+6 -7
View File
@@ -1388,13 +1388,12 @@ dummy_func(
gen_frame->previous = NULL;
/* 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(frame->instr_ptr->op.code == INSTRUMENTED_LINE ||
frame->instr_ptr->op.code == INSTRUMENTED_INSTRUCTION ||
_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);
#if TIER_ONE && defined(Py_DEBUG)
if (!PyStackRef_IsNone(frame->f_executable)) {
int i = frame->instr_ptr - _PyFrame_GetBytecode(frame);
int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code;
assert(opcode == SEND || opcode == FOR_ITER);
}
#endif
RELOAD_STACK();
LOAD_IP(1 + INLINE_CACHE_ENTRIES_SEND);
+6 -7
View File
@@ -1975,13 +1975,12 @@
frame = tstate->current_frame = frame->previous;
gen_frame->previous = NULL;
assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER);
#if TIER_ONE
assert(frame->instr_ptr->op.code == INSTRUMENTED_LINE ||
frame->instr_ptr->op.code == INSTRUMENTED_INSTRUCTION ||
_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);
#if TIER_ONE && defined(Py_DEBUG)
if (!PyStackRef_IsNone(frame->f_executable)) {
int i = frame->instr_ptr - _PyFrame_GetBytecode(frame);
int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code;
assert(opcode == SEND || opcode == FOR_ITER);
}
#endif
stack_pointer = _PyFrame_GetStackPointer(frame);
LOAD_IP(1 + INLINE_CACHE_ENTRIES_SEND);
+14 -14
View File
@@ -7617,6 +7617,7 @@
frame->instr_ptr = next_instr;
next_instr += 1;
INSTRUCTION_STATS(INSTRUMENTED_YIELD_VALUE);
opcode = INSTRUMENTED_YIELD_VALUE;
_PyStackRef val;
_PyStackRef retval;
_PyStackRef value;
@@ -7656,13 +7657,12 @@
frame = tstate->current_frame = frame->previous;
gen_frame->previous = NULL;
assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER);
#if TIER_ONE
assert(frame->instr_ptr->op.code == INSTRUMENTED_LINE ||
frame->instr_ptr->op.code == INSTRUMENTED_INSTRUCTION ||
_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);
#if TIER_ONE && defined(Py_DEBUG)
if (!PyStackRef_IsNone(frame->f_executable)) {
int i = frame->instr_ptr - _PyFrame_GetBytecode(frame);
int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code;
assert(opcode == SEND || opcode == FOR_ITER);
}
#endif
stack_pointer = _PyFrame_GetStackPointer(frame);
LOAD_IP(1 + INLINE_CACHE_ENTRIES_SEND);
@@ -12320,6 +12320,7 @@
frame->instr_ptr = next_instr;
next_instr += 1;
INSTRUCTION_STATS(YIELD_VALUE);
opcode = YIELD_VALUE;
_PyStackRef retval;
_PyStackRef value;
retval = stack_pointer[-1];
@@ -12340,13 +12341,12 @@
frame = tstate->current_frame = frame->previous;
gen_frame->previous = NULL;
assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER);
#if TIER_ONE
assert(frame->instr_ptr->op.code == INSTRUMENTED_LINE ||
frame->instr_ptr->op.code == INSTRUMENTED_INSTRUCTION ||
_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);
#if TIER_ONE && defined(Py_DEBUG)
if (!PyStackRef_IsNone(frame->f_executable)) {
int i = frame->instr_ptr - _PyFrame_GetBytecode(frame);
int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code;
assert(opcode == SEND || opcode == FOR_ITER);
}
#endif
stack_pointer = _PyFrame_GetStackPointer(frame);
LOAD_IP(1 + INLINE_CACHE_ENTRIES_SEND);