8000 gh-109052: Use the base opcode when comparing code objects by gaogaotiantian · Pull Request #109107 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-109052: Use the base opcode when comparing code objects #109107

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 3 commits into from
Sep 9, 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
Prev Previous commit
Do Deopt only once
  • Loading branch information
gaogaotiantian committed Sep 8, 2023
commit 70472dbfeb002112273686787d9184d8879c4f5c
6 changes: 2 additions & 4 deletions Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1805,20 +1805,18 @@ code_richcompare(PyObject *self, PyObject *other, int op)
if (co_code == ENTER_EXECUTOR) {
const int exec_index = co_arg;
_PyExecutorObject *exec = co->co_executors->executors[exec_index];
co_code = exec->vm_data.opcode;
co_code = _PyOpcode_Deopt[exec->vm_data.opcode];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. I think deopt_code should be doing this as well (it can't happen yet because these are all JUMP_BACKWARDs, which don't have specializations, but it could later when we start sticking executors in arbitrary locations).

I agree with @gvanrossum though that _Py_GetBaseOpcode should just be the one place where all of this logic is kept. @gaogaotiantian, would you be interested in teaching _Py_GetBaseOpcode about ENTER_EXECUTOR and cleaning up all of the places where we're using that and _PyOpcode_Deopt to do the right thing? I can do it if not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can work on that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So @gvanrossum mentioned we should NOT handle ENTER_EXECUTOR in _Py_GetBaseOpcode because of oparg. For this matter, it there any work to do? _Py_GetBaseOpcode already handles instrumentation and _PyOpcode_Deopt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the list of bullets in gh-107265.

co_arg = exec->vm_data.oparg;
}
assert(co_code != ENTER_EXECUTOR);
co_code = _PyOpcode_Deopt[co_code];

if (cp_code == ENTER_EXECUTOR) {
const int exec_index = cp_arg;
_PyExecutorObject *exec = cp->co_executors->executors[exec_index];
cp_code = exec->vm_data.opcode;
cp_code = _PyOpcode_Deopt[exec->vm_data.opcode];
cp_arg = exec->vm_data.oparg;
}
assert(cp_code != ENTER_EXECUTOR);
cp_code = _PyOpcode_Deopt[cp_code];

if (co_code != cp_code || co_arg != cp_arg) {
goto unequal;
Expand Down
0