Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-106706: Streamline family syntax#106716
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
kgdiem commented Jul 13, 2023 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
bedevere-bot commented Jul 13, 2023
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
bedevere-bot commented Jul 13, 2023
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
| _tmp_3 = res; | ||
| } | ||
| next_instr += 5; | ||
| static_assert(INLINE_CACHE_ENTRIES_OP == 5, "incorrect cache size"); |
kgdiemJul 13, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't clear to me how/where the INLINE_CACHE_ENTRIES_OP instruction is generated.
Changing the test to pass w/o understanding doesn't inspire confidence on my end so any guidance or explanation here is greatly appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the second parameter to family.
bedevere-bot commented Jul 13, 2023
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
bedevere-bot commented Jul 13, 2023
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
gvanrossum left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I hope I've given you enough hints on what to do about the static assert -- if not, let me know.
Misc/NEWS.d/next/Tools-Demos/2023-07-13-12-08-35.gh-issue-106706.29zp8E.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
Python/executor_cases.c.h Outdated
| } | ||
| caseTO_BOOL_ALWAYS_TRUE:{ | ||
| static_assert(INLINE_CACHE_ENTRIES_TO_BOOL==3, "incorrect cache size"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it works, I think it's better to keep the static assert in the "family head".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still isn't resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think this might be related to the change in Lib/_opcode_metadata.pyas well; the op from the family name isn't getting inserted into instrs
I'm having some trouble getting the name into instrs / parsed as an instruction. Any advice?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| _tmp_3 = res; | ||
| } | ||
| next_instr += 5; | ||
| static_assert(INLINE_CACHE_ENTRIES_OP == 5, "incorrect cache size"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the second parameter to family.
gvanrossum left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you pushed a rebase? Please don't do that once review is in progress -- everything will be squashed when we merge into main.
Can you look into moving the static_assert back to the family head?
And I'm unsure why the metadata file was truncated. (Let me know if you need help figuring this out.)
| "STORE_SUBSCR_DICT", | ||
| "STORE_SUBSCR_LIST_INT", | ||
| ], | ||
| "SEND": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That this file changed surprises me. Maybe this points to a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't change originally, I think only after 178e300 ?
Python/executor_cases.c.h Outdated
| } | ||
| caseTO_BOOL_ALWAYS_TRUE:{ | ||
| static_assert(INLINE_CACHE_ENTRIES_TO_BOOL==3, "incorrect cache size"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still isn't resolved?
| iffamily.namenotinself.macro_instrsandfamily.namenotinself.instrs: | ||
| self.error( | ||
| f"Family {family.name!r} has unknown instruction {family.name!r}", | ||
| family, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
kgdiem commented Jul 15, 2023
Ya there was a conflict in one of the header files so I rebased and re-generated it. Will keep that in mind next time. |
gvanrossum commented Jul 15, 2023
The missing part of the metadata will be reconstructed if you simply run Not sure yet why the stat asserts moved, will look into it later. (Did you find where they are generated?) |
kgdiem commented Jul 15, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Yes, https://github.com/python/cpython/blob/main/Tools/cases_generator/generate_cases.py#L1555 I had changed this on my local from This condition is always falsy because That instruction misses in I'm thinking that there would be far fewer changes to eg I considered just starting fresh from there but thought I would check given we've been back and forth on this implementation for a couple days. |
gvanrossum commented Jul 15, 2023
Interesting idea. It would mean fewer changes, but some of the ugliness would remain as well (e.g. the several places where you have to slice As you point out, the problem is that the family head doesn't have diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index 48c082a429..4756f50b8f 100644 --- a/Tools/cases_generator/generate_cases.py+++ b/Tools/cases_generator/generate_cases.py@@ -438,7 +438,7 @@ def write(self, out: Formatter, tier: Tiers = TIER_ONE) -> None: """Write one instruction, sans prologue and epilogue.""" # Write a static assertion that a family's cache size is correct if family := self.family: - if self.name == family.members[0]:+ if self.name == family.name: if cache_size := family.size: out.emit( f"static_assert({cache_size} == " @@ -831,7 +831,7 @@ def find_predictions(self) -> None: def map_families(self) -> None: """Link instruction names back to their family, if they have one.""" for family in self.families.values(): - for member in family.members:+ for member in [family.name] + family.members: if member_instr := self.instrs.get(member): if member_instr.family not in (family, None): self.error( |
kgdiem commented Jul 15, 2023 via email
Awesome! I’ll get everything cleaned up in a little bit. …On Sat, Jul 15, 2023 at 14:15 Guido van Rossum ***@***.***> wrote: I'm thinking that there would be far fewer changes to generate_cases while keeping the desired syntax for a family template if the family name was added to the members here https://github.com/python/cpython/blob/main/Tools/cases_generator/parser.py#L347 eg ..., [tkn.txt] + members I considered just starting fresh from there but thought I would check given we've been back and forth on this implementation for a couple days. Interesting idea. It would mean fewer changes, but some of the ugliness would remain as well (e.g. the several places where you have to slice .members[1:]). As you point out, the problem is that the family head doesn't have self.family set to the family whose head it is. I think this will fix it: diff --git a/Tools/cases_generator/generate_cases.py b/Tools/cases_generator/generate_cases.py index 48c082a429..4756f50b8f 100644--- a/Tools/cases_generator/generate_cases.py+++ b/Tools/cases_generator/generate_cases.py@@ -438,7 +438,7 @@ def write(self, out: Formatter, tier: Tiers = TIER_ONE) -> None: """Write one instruction, sans prologue and epilogue.""" # Write a static assertion that a family's cache size is correct if family := self.family:- if self.name == family.members[0]:+ if self.name == family.name: if cache_size := family.size: out.emit( f"static_assert({cache_size} == "@@ -831,7 +831,7 @@ def find_predictions(self) -> None: def map_families(self) -> None: """Link instruction names back to their family, if they have one.""" for family in self.families.values():- for member in family.members:+ for member in [family.name] + family.members: if member_instr := self.instrs.get(member): if member_instr.family not in (family, None): self.error( — Reply to this email directly, view it on GitHub <#106716 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADEAQ5K6WG2BKIGMCJN7VFDXQLM4FANCNFSM6AAAAAA2I2HEUA> . You are receiving this because you authored the thread.Message ID: ***@***.***> |
kgdiem commented Jul 16, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I committed those changes but I'd actually outlined them in my previous comment:
|
kgdiem commented Jul 16, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Looks like the generated headers are now correct / unchanged and the test is testing for a macro instruction and what I described above is still missing here https://github.com/python/cpython/blob/main/Tools/cases_generator/generate_cases.py#L1555 But the generated header files after that change are correct. Makes a lot more sense now why the macro isn't in |
kgdiem commented Jul 16, 2023
Got it! Instead of checking the last instruction, get the family from |
gvanrossum left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! I'll merge.
generate_cases.pyto support >= 1 members and validate family name