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

Generated range of value replaced in the inlined function #101

Open
nicolo-ribaudo opened this issue Jun 25, 2024 · 0 comments
Open

Generated range of value replaced in the inlined function #101

nicolo-ribaudo opened this issue Jun 25, 2024 · 0 comments

Comments

@nicolo-ribaudo
Copy link
Member

Consider this example:

function inlineMe(param) {
  beforeI;
  console.log(param + 3);
  afterI;
}

function fn(param) {
  beforeF;
  inlineMe(4 * otherFn(param));
  afterF;
}

fn(1);

That is compiled to

function fn(param) {
  beforeF;
  beforeI;
  console.log(4 * otherFn(param) + 3);
  afterI;
  afterF;
}

fn(1);

My initial naive implementation was to have three generated ranges:

  • one for the whole program
  • one going from beforeF to afterF, pointing to fn's original scope
  • one going from beforeI to afterI, pointing to inlineMe's original scope

However, with those generated ranges, when placing a breakpoint right before the otherFn(param) call you would see the value for param as 4 rather than 1.

I think the correct generated ranges are either:

  • one for the whole program
  • one going from beforeF to afterF, pointing to fn's original scope
  • one going from beforeI to afterI, pointing to inlineMe's original scope
  • one covering 4 * otherFn(param), pointing to fn's original scope

or:

  • one for the whole program
  • one going from beforeF to afterF, pointing to fn's original scope
  • one going from beforeI to right before 4 * otherFn(param), pointing to inlineMe's original scope
  • one going from + 3 to afterI, pointing to inlineMe's original scope

And I also think that the first one is slightly better since it better represents the stack trace when paused at that breakpoint.

Am I interpreting this correctly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant