Skip to content
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

JS: Follow use-use flow after a post-update #17535

Open
wants to merge 38 commits into
base: js/shared-dataflow-branch
Choose a base branch
from

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Sep 20, 2024

Previously there was flow from a post-update node back to getALocalSource(), mirroring how side effects were tracked in the legacy data flow library. This PR changes it so use-use flow is followed after a post-update node. The use-use chain is represented as a new type of data flow node, which is hidden so as not to get confusing data flow paths.

Note however that there is still direct flow from the definition site to all uses/refinements; the use-use chain is only followed after a post-update.

The use-use chain is constructed using the shared SSA library. But we can't remove the old SSA library yet, as it is directly depended on by various components such as type inference. This is also why still have def-use flow, and only switch to use-use after a post-update.

The PR also contains some other changes that were needed to make this switch feasible:

  • Captured this is now tracked as a captured variable, alongside regular variables.
  • Implicit uses of this now have an explicit data flow node, so they can be part of the use-use chain. super calls and instance field initialisers contain an implicit this use.
  • Don't target the post-update node for stores into an object/array literal. Since these expressions may appear as an argument to a call, its associated post-update node should represent side effects in the call.

Evaluation:

  • Evaluation 1 covers all of the commits except the last, and results in:
    • 35 new TPs, mostly due to the fixes for captured variables
    • 13 fixed FPs
    • 14 new FPs (for a net gain of 1 FP)
    • A massive 72% performance improvement for vscode
    • Some regressions in a few projects, but those were recovered by the last commit, as shown in the next evaluation
  • Evaluation 2 shows the effect of the last commit in isolation, recovering the performance loss seen in evaluation 1.

We need these to return the dominator instead of declaring it in the parameter list, so that we can use it directly to fulfill part of the signature for the SSA library.

We can't rewrite it with an inline predicate since the SSA module calls with a transitive closure '*', which does not permit inline predicates.
JS: Remove with statement comment
…public

This exposes the predicates publicly, but will be hidden again in the next commit.
Indentation will be fixed in next commit
Only formatting changes
For a constructor call, the return value acts as the post-update node for the 'this' argument. The fact that constructor calls are sometimes PostUpdateNodes causes some of these harmless alerts.

The warnings have disappeared in some cases because we no longer target getALocalSource() so the target is no longer the constructor call.
The Immutable model uses the 'd' and 'f' properties to model Map content, but the test doesn't actually mention those properties, so they were missing from the PropertyName class.

The flow was previously found spuriously by the regular Map model, which also adds flow through the  get/set calls. This flow is however no longer found since it relied on a step from post-update back to getALocalSource which is no longer present.
This causes less wobbles in test outputs
…ot tracked precisely

With the capture library we sometimes bails out of handling certain functions for scalability reasons.

This means we have a notion of "captured but imprecisely-tracked" variables and 'this'. In these cases we go back to propagating flow from a post-update node to the local source.
This is a bit of a bandaid to cover issues with the push() method on next/router being
treated as an array push, which causes it to flow into other taint sources.
These were marked as 'NOT OK' in the test file, but weren't previously flagged for some reason
Only changes to nodes/edges for various reasons, no actual result changes
@asgerf asgerf added the no-change-note-required This PR does not need a change note label Oct 29, 2024
@asgerf asgerf marked this pull request as ready for review October 29, 2024 10:49
@asgerf asgerf requested a review from a team as a code owner October 29, 2024 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant