JS: Enumerate type-tracking steps through global access paths #9081
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.
This changes how type-tracking steps are generated through global access paths.
Previously type tracking steps through global access paths went through the
globalRootPseudoNode
:This PR changes it to simply generate an edge for each corresponding write/read pair:
As hinted in the above diagram, this generates N^2 edges when there are N writes and N reads of the same property/access path, which is why we used the
globalRootPseudoNode
to begin with.However, when type-tracking through the
globalRootPseudoNode
, the original layout is inefficient due to the huge number of infeasible edges leading out of that node. We end up scanning all outgoing edges and it's only when we join withSmallStep::append
that the infeasiable edges are discarded. When there are many iterations oftrackUseNode
going throughglobalRootPseudoNode
, the end up enumerating all these edge at every iteration.We already imposed the restriction that all writes must occur in the same file, and I believe this prevents the N^2 edge problem from occurring in practice.
Evaluation looks good:
closure-library
and a minor win overall