Awesome, thanks for the detailed explanation!


On Sat, Nov 23, 2013 at 8:40 AM, Devon Carew <notifications@github.com>wrote:

> In ide/app/spark_polymer.dart:
>
> > @@ -22,30 +24,69 @@ void main() {
> >  class SparkPolymer extends Spark {
> >    SparkPolymer(bool developerMode) : super(developerMode);
> >
> > +  //
> > +  // Override some parts of the parent's ctor:
> > +  //
> > +
> > +  @override
> > +  String get appName => super.appName + "Polymer";
> > +
> > +  @override
> > +  void initAnalytics() => super.initAnalytics();
>
>  and this is not by mistake
>
> cool
>
> is there any performance hit, even slightest, when doing things like that
> in Dart?
>
> I think the answer is, a very very slight performance hit. Nothing that
> trumps having additional clarity in the code.
>
> We have two runtimes, dart2js and the Dart VM. Dart2js does do a lot of
> compiler optimizations but my guess is that it does not do this one. It
> would need to in-line the code for initAnalytics() into the site's which
> call it. Easy enough to check though, by looking at the generated
> javascript.
>
> The Dart VM may do this optimization, but would only do it on it's 2nd
> pass compile. It uses a two stage compiler process, like V8's crankshaft.
> The first compile generates machine code, including code which instruments
> the method. At some trigger, the runtime will re-compile the method with an
> optimizing compiler using data gathered from the instrumentation.
>
> Last I checked, the trigger to re-compile a method was pretty simple. It
> did it after 4000 invocations. This logic may very well have gotten more
> sophisticated, but generally, the person calling initAnalytics() would need
> to be called a lot to trigger an optimized compile.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/dart-lang/spark/pull/276/files#r7876112>
> .
>