diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 698e88483569d1..1bc63f6b43adc7 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -1090,13 +1090,27 @@ static int _PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg) { // This only works when opcode is a non-quickened form: + assert(opcode != ENTER_EXECUTOR); assert(_PyOpcode_Deopt[opcode] == opcode); int check_oparg = 0; - for (_Py_CODEUNIT *instruction = _PyCode_CODE(_PyFrame_GetCode(frame)); + PyCodeObject *code = _PyFrame_GetCode(frame); + for (_Py_CODEUNIT *instruction = _PyCode_CODE(code); instruction < frame->instr_ptr; instruction++) { - int check_opcode = _PyOpcode_Deopt[instruction->op.code]; - check_oparg |= instruction->op.arg; + int check_opcode = -1; + if (instruction->op.code == ENTER_EXECUTOR) { + int exec_index = instruction->op.arg; + _PyExecutorObject *exec = code->co_executors->executors[exec_index]; + check_opcode = _PyOpcode_Deopt[exec->vm_data.opcode]; + check_oparg |= exec->vm_data.oparg; + } + else { + check_opcode = _PyOpcode_Deopt[instruction->op.code]; + check_oparg |= instruction->op.arg; + } + + assert(check_opcode != ENTER_EXECUTOR); + if (check_opcode == opcode && check_oparg == oparg) { return 1; }