-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[frontend] IIFEs could be made cheaper? #52694
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
Comments
I don't actually understand why you'd want an IIFE there (or at all). To me it doesn't seem to provide anything of value as blocks are also close to where its used. |
The code that I've provided in the issue description is only meant to demonstrate the difference in performance. This dart-lang/site-www#4613 issue contains more about the why aspect of IIFEs. Edit: In short, IIFEs are expressions and can be used to "localize" lists of statements where only expressions are being expected. |
Isn't this more the VM that should inline it but apparently doesn't?
though I might be reading it wrong. /cc @mraleph (this was on this modified code btw: for (int i = 0; i < iterations; i++) {
(){
total += i;
}();
} ) |
This issue contains a small benchmark that attempts to show that the performance of IIFEs could be improved.
In short, It looks like IIFEs are not being converted to Kernel BlockExpressions (which have no equivalent on the Dart level), and it looks like they could be converted to BlockExpressions as an optimization.
Consider the following:
AOT:
JIT:
IIFEs are useful for keeping code close to where it is being used which reduces the effort needed to reason about code. I think that making IIFEs cheaper would be great.
The text was updated successfully, but these errors were encountered: