-
Notifications
You must be signed in to change notification settings - Fork 5k
JIT: refactor escape analysis to be more bv-centric #115213
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
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Make the "bv index" the primary concept for computations; translate from local var nums to their indices when needed. Allocate all the connection BVs at once, since the connection matrix will now have a dense set of entries. This is prep work for tracking fields of stack allocatable objects, where we will introduce new classes of things tracked by the connection graph.
719e653
to
929c5fe
Compare
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.
Pull Request Overview
This PR refactors the escape analysis in the JIT to focus on bitvector (bv) indices rather than local variable numbers. Key changes include renaming pseudo-local variables to pseudo-indices, replacing HasIndex with IsTrackedLocal in escape checks, and introducing new index-based functions for stack allocation analysis.
Comments suppressed due to low confidence (1)
src/coreclr/jit/objectalloc.h:187
- The parameter name 'lclNum' in MarkIndexAsEscaping is inconsistent with other index-based functions; consider renaming it to 'index' for clarity.
void MarkIndexAsEscaping(unsigned int lclNum);
PTAL @dotnet/jit-contrib No diffs. Likely somewhat tedious to review. Quite a bit of renaming (eg "pseudo var/local" - > "pseudo"), and trying to consistently use BV indices to describe non-local things, and to use Small TP win as we no longer repeatedly translate back and forth from local to index, eg in I reran this because of some infra issues, so the diff report has duplicated sections. |
@@ -360,9 +373,9 @@ void ObjectAllocator::PrepareAnalysis() | |||
// | |||
// If conditional escape analysis is enabled, we reserve the range [N...N+M-1] | |||
// for locals allocated during the conditional escape analysis expansions, | |||
// where N is the maximum number of pseudo-vars. | |||
// where N is the maximum number of pseudos. |
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.
Did you mean M
?
// where N is the maximum number of pseudos. | |
// where M is the maximum number of pseudos. |
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.
Yeah. I will fix that in a subsequent PR, if there isn't any other feedback here.
@dotnet/jit-contrib ping |
// | ||
BitVec pseudoLocalAdjacencies = m_ConnGraphAdjacencyMatrix[LocalToIndex(pseudoLocal)]; | ||
BitVec PseudoAdjacencies = m_ConnGraphAdjacencyMatrix[pseudoIndex]; |
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: naming conventions
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.
Will fix this in the next stage...
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.
LGTM. Looks simpler now without the multiple numbering schemes.
I didn't see it here, but do we limit the sizes of the bit vectors we create somewhere? Seems we should do that since the closure computation is inherently superlinear.
No limits right now (other than implicitly limited by the number of escape-tracked locals). I can add something similar to the limit we have for regular tracked locals. |
Make the "bv index" the primary concept for computations; translate
from local var nums to their indices when needed.
Allocate all the connection BVs at once, since the connection matrix
will now have a dense set of entries.
This is prep work for tracking fields of stack allocatable objects,
where we will introduce new classes of things tracked by the
connection graph.