3 ms·
GWT has been doing this for years, i'm actually surprised Dart has only just got it, given that both come from google.
by marchopy 14y ago
GWT has been doing this for years, i'm actually surprised Dart has only just got it, given that both come from google.
- pohl 14y agoThey probably couldn't just yank the type-inferencer and resulting optimizer out of the GWT compiler and re-use it: it's probably too tied-up in Java syntax and semantics. They probably had to write it all over again.
- sethladd 14y agoGood point, Dart2js isn't the only compiler that can apply optimizations. I believe Closure Compiler also performs optimizations. Both GWT and Closure have been out for years, to be fair. :) [disclaimer: I work on the Dart team]
- cromwellian 14y agoWe do some global inferencing in GWT, but we don't do range check elimination. There was a 20% contributor who added it at one point, but it never landed. We tighten types by looking at flow into and out of methods globally and locally (e.g. if you method says it return Object, but you return new Foo(), we consider the method as actually returning Foo). We also do nullability analysis, so for example, we can short circuit an if(x instanceof Foo) if x is known to be null, or Foo is a null type (never instantiated anywhere)