summaryrefslogtreecommitdiffstats
path: root/Objects/codeobject.c
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na@python.org>2023-09-07 00:53:54 (GMT)
committerGitHub <noreply@github.com>2023-09-07 00:53:54 (GMT)
commit3bfa24e29f286cbc1f42bdb4d2b1c0c9d643c8d6 (patch)
tree59dcd711f7985d20765694702ed0c32efa94cdd7 /Objects/codeobject.c
parent19eddb515a8cf87df7aaa347379b3e56c324385b (diff)
downloadcpython-3bfa24e29f286cbc1f42bdb4d2b1c0c9d643c8d6.zip
cpython-3bfa24e29f286cbc1f42bdb4d2b1c0c9d643c8d6.tar.gz
cpython-3bfa24e29f286cbc1f42bdb4d2b1c0c9d643c8d6.tar.bz2
gh-107265: Remove all ENTER_EXECUTOR when execute _Py_Instrument (gh-108539)
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r--Objects/codeobject.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 5830607..1443027 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -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)
{