Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Fold "cast(cast(obj, cls), cls)" to "cast(obj, cls)" #98337
Fold "cast(cast(obj, cls), cls)" to "cast(obj, cls)" #98337
Changes from 12 commits
4383fba
9dec5cc
04a82ee
72817ff
fae7647
76081b3
eff3ef8
d5a7088
80a8e2c
395c103
c9bc1f4
47a87d6
a46c811
b4ab4c5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Seems like commonly
tree
is a subtree ofsideEffectsSource
.If
tree
itself has side effects, do those get handled properly?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 is a good point, added a comment. Technically, it should be either a sideffect-free subtree of
sideEffectsSource
or pretty much any node with any sideffects if it's not a subtree. In two uses of this API wheretree
is a subnode ofsideEffectsSource
we do check it being side-effect free at the callsite. It's probably possible to be smarter here and extract the effects properly for any case, but not now. Setup-arg stuff in args makes it a bit more complicated 🙁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 don't see why it can't be invariant (and removed the GTF_GLOB_REF quirk). However, I most likely will have to unmark it as invariant in my "inlining for shared generics" work for certain cases, but it's irrelevant here.
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 was done for my snippet in the PR's description, otherwise two exactly the same runtime lookups had different conservative VNs.
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 would double-check this with somebody on the runtime team; getting this wrong can have subtle consequences.
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.
So from my understanding there are two types of runtime lookups:
The caller side is typically not invariant (at least in JIT) and requires a helper call + expansion machinery (checking for null/dictionary resize).
So if a runtime lookup doesn't need a helper-call/null check/size check - it's a fully invariant bunch of ind loads on top of TypeCtx.
It might be a bit more complicated if we implement inlining for shared generics where we're going to have both caller and callee lookups in the same method, but I will keep that in mind once I do that sort of inlining (as part of net9). Currently we never have such cases.
cc @jkotas to confirm.
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.
The generic dictionary slots that do not require helper-call/null check/size check can be treated as invariant. This change looks fine to me.
I am not sure what you mean. There is no distinction like this that I am aware of.
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.
Yes, please, ignore that part. There are just 4 types of lookups:
nullcheck + INDs (fast path)where INDs is [0..n] nested indirect loads.
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.
Nit: These do not exist. The null check needs a helper call slow path.