JIT: Make all static base helpers byref typed in async functions#130317
Draft
jakobbotsch wants to merge 3 commits into
Draft
JIT: Make all static base helpers byref typed in async functions#130317jakobbotsch wants to merge 3 commits into
jakobbotsch wants to merge 3 commits into
Conversation
This reverts commit 5867608.
There were a handful of static base helpers that we treated as returning `TYP_I_IMPL`. At the same time VN considers these helpers to be invariant, allowing them to be CSE'd. However, these helpers are not invariant in async functions. Initially I explicitly marked VNs referring to these helpers as killed across async suspensions in CSE (see first commits on this PR). However, figuring out which VNs refer to those helpers is actually non-trivial when you take VNPhiDef and other functions into account. Instead this PR just changes the type of these helpers to let the standard byref handling pick them up.
Contributor
|
Tagging subscribers to this area: @agocke |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes how the JIT types certain “static base” helper calls when compiling async state-machine methods, so that the existing byref-based handling in later phases naturally prevents incorrect CSE/availability across async suspension points.
Changes:
- In
fgGetStaticsCCtorHelper, returnTYP_BYREF(instead ofTYP_I_IMPL) for pinned static-base helpers whencompIsAsync()is true. - Add an explanatory comment for the async-specific typing choice.
Comment on lines
+761
to
+765
| // In async calls we model these helpers as byrefs to get "killed | ||
| // across suspensions" behavior for free, while also properly | ||
| // ensuring derived addresses are byref typed and are treated | ||
| // similarly. | ||
| type = compIsAsync() ? TYP_BYREF : TYP_I_IMPL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
There were a handful of static base helpers that we treated as returning
TYP_I_IMPL. At the same time VN considers these helpers to beinvariant, allowing them to be CSE'd. However, these helpers are not
invariant in async functions.
Initially I explicitly marked VNs referring to these helpers as killed
across async suspensions in CSE (see first commits on this PR). However,
figuring out which VNs refer to those helpers is actually non-trivial
when you take VNPhiDef and other functions into account. Instead this PR
just changes the type of these helpers to let the standard byref
handling pick them up.
A more ideal solution would be some kind of thread-SSA that worked like
memory SSA and were passed as an input to these VNs. But that's much
more complicated.