-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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-131798: JIT: Narrow the return type of _BINARY_OP_SUBSCR_STR_INT
to str
#132153
Conversation
The constant checking is sort of a relic. We don't even do anything with it. So it's fine to leave it out for now. |
Just a quick note on this: "constant" here means anything the JIT knows to be a constant value at runtime, not just things that are statically constant in the source. So it could be something like
I disagree, constant symbols are pretty powerful, and we should be using them more. For example, knowing constant values currently allows us to entirely remove conditional branches, type version checks, etc. @savannahostrowski also added the new I agree that it's probably not worth adding to this uop specifically (at least not without some examples of real-world code it would optimize), but I do think that tracking constant values in general is a good thing. |
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 good. Want to tidy up the test before I merge?
Co-authored-by: Brandt Bucher <[email protected]>
Thanks for the clarification about the meaning of constants in the JIT! That's an important distinction to make for sure. |
I tested this by finding another instruction which contains a unicode guard, in this case
BINARY_OP_ADD_UNICODE
and checking that the guard is removed if one of the operands is the result of_BINARY_OP_SUBSCR_STR_INT
. Let me know if there's a better way to test this!I also noticed that some other uops like
_BINARY_OP_ADD_UNICODE
check if the operands are constants. Should we add it here as well? I don't know if we gain much from that though, code like'foo'[0]
is not very common.