-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
let
vs var
generates a lot more instructions
#800
Comments
The fact that the code is in eval is the limiting factor for us, right? We could theoretically make the eval code gen close enough to non-eval code to make the optimizer’s life easier, but it would take some effort. Is this a synthetic test case? --Paul From: Michael Ferris [mailto:[email protected]] Sorry in advance I haven't been able to get a simpler repro case at this time. const n = 500; function getTest(name) { var fn; eval( return fn } var foo = getTest("Int8") var src = new Int8Array(n); src.fill(1); var dst = new Int8Array(n); foo(src, dst, 0, 250); foo(src, dst, 250, n); This code generates the following IR Function Entry
Every uses of
This IR makes it hard to make proper optimizations (in this case Array optimizations). If we change the let keyword for a var, i becomes a regular variable. — |
I'm not entirely sure, but it's true that I haven't been able to repro outside of eval. |
I don't see why we need to make a scope object for the for loop's scope in this case. Doesn't matter that it is in an eval, there is no nested eval nor any capture. |
Right, that's why I say that it's theoretically possible to fix this. My only question is the priority relative to RS1 bugs. -- Paul From: Ian Hallidaymailto:[email protected] I don't see why we need to make a scope object for the for loop's scope in this case. Doesn't matter that it is in an eval, there is no nested eval nor any capture. — |
Sorry in advance I haven't been able to get a simpler repro case at this time.
My test case is the following
This code generates the following IR
This IR makes it hard to make proper optimizations (in this case Array optimizations).
If we change the
let
keyword for avar
,i
becomes a regular variable.Is it possible to make
let
variables behave exactly the same as a regularvar
if there is no redefinition inside the function ?Should this be done at Bytecode level, IR Builder or Globopt ?
The text was updated successfully, but these errors were encountered: