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: Add class harness to recover localFieldStep edges #18302

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

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Dec 17, 2024

Synthesizes a callable for each class, which invokes the class constructor and every
instance method with the same value of this.

This ensures flow between methods in a class when the source originated "within the class",
but not when the flow into the field came from an argument.

For example:

class C {
  constructor(arg) {
    this.x = sourceOfTaint();
    this.y = arg;
  }
  method() {
    sink(this.x); // sourceOfTaint() flows here
    sink(this.y); // but 'arg' does not flow here (only through real call sites)
  }
}

The class harness for a class C can roughly be thought of as the following code:

function classHarness() {
  var c = new C();
  while (true) {
    // call an arbitrary instance methods in the loop
    c.arbitraryInstaceMethod();
  }
}

This is realized with the following data flow graph:

[Call to constructor]
    |
    | post-update for 'this' argument
    V
[Data flow node]   <----------------------+
    |                                     |
    | 'this' argument                     | post-update for 'this' argument
    V                                     |
 [Call to an instance method]  -----------+

Evaluation shows an 85% slowdown in vscode, so more work is needed before this can be merged.

@github-actions github-actions bot added the JS label Dec 17, 2024
@asgerf asgerf added the WIP This is a work-in-progress, do not merge yet! label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS WIP This is a work-in-progress, do not merge yet!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant