Skip to content
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

gh-106529: Split FOR_ITER_{LIST,TUPLE} into uops #106696

Merged
merged 13 commits into from Jul 14, 2023

Conversation

gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Jul 12, 2023

Same recipe as FOR_ITER_RANGE. I refactored the Tier 2 transformation code to handle similar cases. I had to fix a bug in the space reservation code, and decided to add some macros and an extra guard rail for that.

@gvanrossum
Copy link
Member Author

@iritkatriel Do you have time to look at the reservation code? The rest is on auto-pilot (I'm going to add FOR_ITER_TUPLE to the same PR.

@gvanrossum gvanrossum changed the title gh-106529: Split FOR_ITER_LIST into uops gh-106529: Split FOR_ITER_{LIST,TUPLE} into uops Jul 12, 2023
Python/bytecodes.c Outdated Show resolved Hide resolved
Python/bytecodes.c Outdated Show resolved Hide resolved
Python/bytecodes.c Outdated Show resolved Hide resolved
Python/optimizer.c Outdated Show resolved Hide resolved
@@ -378,13 +378,17 @@ translate_bytecode_to_trace(
_Py_CODEUNIT *initial_instr = instr;
int trace_length = 0;
int max_length = buffer_size;
int reserved = 0;
Copy link
Member

Choose a reason for hiding this comment

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

The point of reserve is to make sure that you won't error out in the middle of an opcode's translation to uops?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct. I'd rather reserve space ahead than having to bail out in the middle and undo some work already done (the undoing feels more brittle).

@gvanrossum
Copy link
Member Author

Assuming the tests pass this time I'll just merge.

@gvanrossum gvanrossum merged commit 025995f into python:main Jul 14, 2023
20 checks passed
@gvanrossum gvanrossum deleted the for-iter-list-tuple branch July 14, 2023 00:27
kgdiem pushed a commit to kgdiem/cpython that referenced this pull request Jul 14, 2023
Also rename `_ITER_EXHAUSTED_XXX` to `_IS_ITER_EXHAUSTED_XXX` to make it clear this is a test.
gvanrossum added a commit that referenced this pull request Jul 15, 2023
The Tier 2 opcode _IS_ITER_EXHAUSTED_LIST (and _TUPLE)
didn't set it->it_seq to NULL, causing a subtle bug
that resulted in test_exhausted_iterator in list_tests.py
to fail when running all tests with -Xuops.

The bug was introduced in gh-106696.

Added this as an explicit test.

Also fixed the dependencies for ceval.o -- it depends on executor_cases.c.h.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants