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-113657: Add back missing _SET_IP uops in tier two #113662

Merged
merged 3 commits into from Jan 2, 2024

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Jan 2, 2024

Looks like these macro uses weren't updated when the metadata for tier one and tier two instructions was split in GH-113287.

@brandtbucher brandtbucher added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jan 2, 2024
@brandtbucher brandtbucher self-assigned this Jan 2, 2024
@gvanrossum
Copy link
Member

Who, doesn't this imply that all the OPCODE_HAS_<FLAG> macros are wrong? Just fixing those two occurrences doesn't seem the right fix.

@gvanrossum
Copy link
Member

Oh wait, it's worse. The macros apply to Tier 1 opcodes, but were incorrectly applied to Tier 2 here. I'll approve. But we need to think more about how to avoid such mistakes.

@brandtbucher
Copy link
Member Author

But we need to think more about how to avoid such mistakes.

Agreed. Probably the best thing to do is define equivalent macros for uops, and assert the valid ranges for each (although this is tricky, since tier one is in range(0, 256) and tier two is in range(0, MAX_UOP_ID)... so they overlap).

If there's no major convenience added by allowing tier one and tier two to overlap like that, maybe they should each get their own distinct range? Then it would be easier to catch mistakes like this.

@brandtbucher brandtbucher merged commit b0fb074 into python:main Jan 2, 2024
37 checks passed
@gvanrossum
Copy link
Member

Agreed. Probably the best thing to do is define equivalent macros for uops, and assert the valid ranges for each (although this is tricky, since tier one is in range(0, 256) and tier two is in range(0, MAX_UOP_ID)... so they overlap).

If there's no major convenience added by allowing tier one and tier two to overlap like that, maybe they should each get their own distinct range? Then it would be easier to catch mistakes like this.

Actually, currently uops are in the range [300, MAX_UOP_ID] while bytecode ops are in [0, 255]. So they are distinct and we can add range checks to the macros.

However, I believe @markshannon is planning to make the ranges overlapping, so we can store uops in a single byte. The uop_id_generator.py script already has a -n (--namespace) flag to do so.

(The lowest uop is 300 instead of 256 because we need some space for pseudo ops etc.)

@brandtbucher
Copy link
Member Author

I'm seeing numbers that are below 256 in tier two for certain instructions. For example, _IS_OP (tier two) is defined as IS_OP (tier one) which is defined as 76.

@brandtbucher
Copy link
Member Author

I think it's just for instructions that translate 1-1 between tiers? Check out Include/internal/pycore_uop_ids.h.

@gvanrossum
Copy link
Member

I think it's just for instructions that translate 1-1 between tiers? Check out Include/internal/pycore_uop_ids.h.

Oh, the work isn't as far along as I thought. Shame on me for not remembering what I saw in that PR. It just introduces separate names, but the numeric IDs aren't separately allocated yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants