gh-107265: Remove all ENTER_EXECUTOR when execute _Py_Instrument (gh-108539)

This commit is contained in:
Dong-hee Na 2023-09-07 09:53:54 +09:00 committed by GitHub
parent 19eddb515a
commit 3bfa24e29f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 32 deletions

View file

@ -1479,6 +1479,23 @@ clear_executors(PyCodeObject *co)
co->co_executors = NULL;
}
void
_PyCode_Clear_Executors(PyCodeObject *code) {
int code_len = (int)Py_SIZE(code);
for (int i = 0; i < code_len; i += _PyInstruction_GetLength(code, i)) {
_Py_CODEUNIT *instr = &_PyCode_CODE(code)[i];
uint8_t opcode = instr->op.code;
uint8_t oparg = instr->op.arg;
if (opcode == ENTER_EXECUTOR) {
_PyExecutorObject *exec = code->co_executors->executors[oparg];
assert(exec->vm_data.opcode != ENTER_EXECUTOR);
instr->op.code = exec->vm_data.opcode;
instr->op.arg = exec->vm_data.oparg;
}
}
clear_executors(code);
}
static void
deopt_code(PyCodeObject *code, _Py_CODEUNIT *instructions)
{