Uh oh!
There was an error while loading. Please reload this page.
gh-133273: Keep instruction definitions in bytecodes.c and optimizer_bytecodes.c in sync - #133320
Conversation
Uh oh!
There was an error while loading. Please reload this page.
brandtbucher
commented
May 2, 2025
Thanks! Personally, I'm not sure that requiring the names to be in sync gains us anything. What's really useful is making sure that the stack effects are the same; if not, it's a serious bug in the optimizer. Making the names match just sort of creates busywork for anyone adding new optimizer cases. And I think it's totally normal for something that's used in the bytecodes to be unused in the optimizer, and vice-versa. So I'd rather just have a special case for when one is I'll wait for others to chime in, though. It's not a huge deal. |
| (void)counter; | ||
| } | ||
| op(_UNPACK_SEQUENCE, (seq -- unused[oparg], top[0])) { |
There was a problem hiding this comment.
Would it be possible to tell the validator that unused matches anything (both ways)?
So unused in optimizer_bytecodes/bytecodes isn't name-validated.
Fidget-Spinner
commented
May 2, 2025
I agree on the unused part (see the comment above), but I think having names matching is useful, if just for the sake of standardization. |
Thanks for the feedback! I updated the PR:
Thanks to special-casing I also added (I'll wait for the CI to pass and then mark it as ready) |
| } | ||
| op(_CREATE_INIT_FRAME, (self, init, args[oparg] -- init_frame: _Py_UOpsAbstractFrame *)) { | ||
| op(_CREATE_INIT_FRAME, (init, self, args[oparg] -- init_frame: _Py_UOpsAbstractFrame *)) { |
There was a problem hiding this comment.
Looks like we found one case where checking the name is useful
There was a problem hiding this comment.
Awesome. This is exactly what we need this for!
Fidget-Spinner
commented
May 6, 2025
I plan to merge this after 3.14 beta 1 |
tomasr8
commented
May 8, 2025
(fixed a conflict) |
Fidget-Spinner
commented
May 8, 2025
@brandtbucher merging this in the next 24 hours. Watch out for merge conflicts! |
…ptimizer_bytecodes.c` in sync (pythonGH-133320)
…ptimizer_bytecodes.c` in sync (pythonGH-133320)
This implements the currently empty
validate_uop.It requires that instructions in
bytecodes.candoptimizer_bytecodes.c:Should we also validate the type/size?
I needed rename a few variables in
bytecodes.cfromunusedto an actual name, otherwise changes arekept to
optimizer_bytecodes.c. There are some things I'm not sure about, I'll add comments to the relevant lines.bytecodes.candoptimizer_bytecodes.cin sync #133273