Skip to content

gh-107265: Remove all ENTER_EXECUTOR when execute _Py_Instrument #108539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Sep 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Revert "gh-107265: Fix initialize/remove_tools for ENTER_EXECUTOR case (
gh-108482)"

This reverts commit 6cb48f0.
  • Loading branch information
corona10 committed Aug 27, 2023
commit 23e1f48ba38795114e0d7a2811d34a125022333a
36 changes: 4 additions & 32 deletions Python/instrumentation.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,7 @@ de_instrument(PyCodeObject *code, int i, int event)
_Py_CODEUNIT *instr = &_PyCode_CODE(code)[i];
uint8_t *opcode_ptr = &instr->op.code;
int opcode = *opcode_ptr;
if (opcode == ENTER_EXECUTOR) {
int oparg = instr->op.arg;
_PyExecutorObject *exec = code->co_executors->executors[oparg];
opcode_ptr = &exec->vm_data.opcode;
opcode = *opcode_ptr;
assert(opcode != ENTER_EXECUTOR);
}
assert(opcode != ENTER_EXECUTOR);
if (opcode == INSTRUMENTED_LINE) {
opcode_ptr = &code->_co_monitoring->lines[i].original_opcode;
opcode = *opcode_ptr;
Expand Down Expand Up @@ -717,22 +711,7 @@ remove_tools(PyCodeObject * code, int offset, int event, int tools)
assert(event != PY_MONITORING_EVENT_LINE);
assert(event != PY_MONITORING_EVENT_INSTRUCTION);
assert(PY_MONITORING_IS_INSTRUMENTED_EVENT(event));
#ifndef NDEBUG
_Py_CODEUNIT co_instr = _PyCode_CODE(code)[offset];
uint8_t opcode = co_instr.op.code;
uint8_t oparg = co_instr.op.arg;
if (opcode == ENTER_EXECUTOR) {
_PyExecutorObject *exec = code->co_executors->executors[oparg];
assert(exec->vm_data.opcode != ENTER_EXECUTOR);
opcode = _PyOpcode_Deopt[exec->vm_data.opcode];
opcode = exec->vm_data.oparg;
}
else {
opcode = _Py_GetBaseOpcode(code, offset);
}
assert(opcode != ENTER_EXECUTOR);
assert(opcode_has_event(opcode));
#endif
assert(opcode_has_event(_Py_GetBaseOpcode(code, offset)));
_PyCoMonitoringData *monitoring = code->_co_monitoring;
if (monitoring && monitoring->tools) {
monitoring->tools[offset] &= ~tools;
Expand Down Expand Up @@ -1303,16 +1282,9 @@ initialize_tools(PyCodeObject *code)
for (int i = 0; i < code_len; i++) {
_Py_CODEUNIT *instr = &_PyCode_CODE(code)[i];
int opcode = instr->op.code;
int oparg = instr->op.arg;
if (opcode == ENTER_EXECUTOR) {
_PyExecutorObject *exec = code->co_executors->executors[oparg];
opcode = exec->vm_data.opcode;
oparg = exec->vm_data.oparg;
}
else if (opcode == INSTRUMENTED_LINE) {
if (opcode == INSTRUMENTED_LINE) {
opcode = code->_co_monitoring->lines[i].original_opcode;
}
assert(opcode != ENTER_EXECUTOR);
bool instrumented = is_instrumented(opcode);
if (instrumented) {
opcode = DE_INSTRUMENT[opcode];
Expand All @@ -1323,7 +1295,7 @@ initialize_tools(PyCodeObject *code)
if (instrumented) {
int8_t event;
if (opcode == RESUME) {
event = oparg != 0;
event = instr->op.arg != 0;
}
else {
event = EVENT_FOR_OPCODE[opcode];
Expand Down