-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-133273: Keep instruction definitions in bytecodes.c
and optimizer_bytecodes.c
in sync
#133320
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
base: main
Are you sure you want to change the base?
Conversation
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. |
Python/bytecodes.c
Outdated
@@ -1542,7 +1542,7 @@ dummy_func( | |||
(void)counter; | |||
} | |||
|
|||
op(_UNPACK_SEQUENCE, (seq -- unused[oparg], top[0])) { |
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.
Would it be possible to tell the validator that unused
matches anything (both ways)?
So unused
in optimizer_bytecodes/bytecodes isn't name-validated.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we found one case where checking the name is useful
This implements the currently empty
validate_uop
.It requires that instructions in
bytecodes.c
andoptimizer_bytecodes.c
:Should we also validate the type/size?
I needed rename a few variables in
bytecodes.c
fromunused
to 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.c
andoptimizer_bytecodes.c
in sync #133273