dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.08k stars 1.56k forks source link

dart2js: minify 'call' selectors #16545

Open kasperl opened 10 years ago

kasperl commented 10 years ago

Right now, selectors for call invocations aren't minified even when using the --minify option. It's common to see code like this:

  E.Sv().call$0()

It's even worse when the call invocations include named parameters because these aren't minified either. It's not uncommon to see:

  E.Sv().call$1$foobar(87)

For certain coding styles, there's a significant minified output size reduction to be had from implementing this.

floitschG commented 10 years ago

Removed Type-Defect label. Added Type-Enhancement, Optimization labels.

ghost commented 10 years ago

As of r34640. call$0 is now minified to $0. I have tried minifying the named arguments, too, but that fails due to the way that [delegate] works in reflection. In essence, it has to decide, given some named arguments, what method to invoke. Minification would require us to keep a translation table around.

Can you quantify what significant means or do you have some workloads to look at?

kasperl commented 10 years ago

I basically grepped through the output for identifiers of the form call$n$... and found quite a number of them in Angular apps. When you implemented this (even it it was broken), what kind of code size impact did you see?