Thanks to visit codestin.com
Credit goes to github.com

Skip to content

GH-112383: Fix test_loop_quicken when an executor is installed #113153

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
Dec 15, 2023
Merged
Changes from all commits
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
9 changes: 7 additions & 2 deletions Lib/test/test_dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,13 @@ def test_loop_quicken(self):
got = self.get_disassembly(loop_test, adaptive=True)
expected = dis_loop_test_quickened_code
if _testinternalcapi.get_optimizer():
# We *may* see ENTER_EXECUTOR in the disassembly
got = got.replace("ENTER_EXECUTOR", "JUMP_BACKWARD ")
# We *may* see ENTER_EXECUTOR in the disassembly. This is a
# temporary hack to keep the test working until dis is able to
# handle the instruction correctly (GH-112383):
got = got.replace(
"ENTER_EXECUTOR 16",
"JUMP_BACKWARD 16 (to L1)",
Comment on lines +1216 to +1217
Copy link
Member

Choose a reason for hiding this comment

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

We really need an API on executor objects so you can access the vm_data field. We the API to get the executors should be an (unstable) method on PyCodeObject, not a function in _testinternalcapi.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we need it though? Given the code object, we can always recover the original opcode and oparg using co_code (instead of _co_code_adaptive, which gives us the executor and index).

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that works too. I guess my main point was that we shouldn't blindly assume ENTER_EXECUTOR sits on top of JUMP_BACKWARD. Although that is currently the case (and will still be so if/when my side-exits PR lands).

)
self.do_disassembly_compare(got, expected)

@cpython_only
Expand Down