iOS and Dart

1,453 views
Skip to first unread message

kc

unread,
Nov 2, 2015, 7:34:06 AM11/2/15
to Dart Misc
How does the Dart VM with Flutter run on iOS without JIT?

Is the Fletch VM now more focused on IoT?

K.

Günter Zöchbauer

unread,
Nov 2, 2015, 9:05:28 AM11/2/15
to Dart Misc

Filipe Morgado

unread,
Nov 2, 2015, 11:53:59 AM11/2/15
to Dart Misc
I think iOS snapshots are a compact binary form of Dart code, just like any Dart snapshot on other platforms. They're not AoT native bytecode.

The Dart VM has a builtin interpreter, which is used on iOS without JIT optimizations.

Unless there's an unannounced experiment involving some kind of AoT compilation for iOS, I don't think we can run optimized Dart code, JIT or AoT (yet).

Kasper Lund

unread,
Nov 3, 2015, 2:33:44 AM11/3/15
to Dart Misc
The Dart VM with Flutter runs on iOS using precompilation to native code, and the Fletch VM is now more focused on embedded, low-footprint scenarios. 

Hope that helps.

Cheers,
Kasper

--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.

Filipe Morgado

unread,
Nov 3, 2015, 8:45:56 AM11/3/15
to Dart Misc
Wow, great to know!

But I'm confused. Shouldn't native precompilation produce a native executable? How are snapshots loaded if they contain native code?

Also, are there benchmarks comparing AoT compilation against interpretation and JIT on a similar Android devide?

Ivan Posva

unread,
Nov 3, 2015, 9:02:31 AM11/3/15
to General Dart Discussion
On Tue, Nov 3, 2015 at 5:45 AM, Filipe Morgado <pix...@gmail.com> wrote:
> Wow, great to know!
>
> But I'm confused. Shouldn't native precompilation produce a native executable? How are snapshots loaded if they contain native code?

Precompilation produces two outputs: A conventional snapshot and a .S
file which is then assembled and linked into the resulting binary. The
VM running on iOS has then special code to connect the two together.

Hope that helps,
-Ivan


> Also, are there benchmarks comparing AoT compilation against interpretation and JIT on a similar Android devide?
>

Srdjan Mitrovic

unread,
Nov 3, 2015, 11:49:38 AM11/3/15
to General Dart Discussion
On Mon, Nov 2, 2015 at 8:53 AM, Filipe Morgado <pix...@gmail.com> wrote:
I think iOS snapshots are a compact binary form of Dart code, just like any Dart snapshot on other platforms. They're not AoT native bytecode.

The Dart VM has a builtin interpreter, which is used on iOS without JIT optimizations.

Dart VM does not have an interpreter. In JIT based execution, JIT initially creates unoptimized code that is run until hot code is detected. Hot functions are optimized, unoptimized code is replaced with optimized code.  

Cheers,

- Srdjan


Unless there's an unannounced experiment involving some kind of AoT compilation for iOS, I don't think we can run optimized Dart code, JIT or AoT (yet).

Filipe Morgado

unread,
Nov 3, 2015, 2:28:20 PM11/3/15
to Dart Misc
Thanks for the explanation and the correction.

I thought I read in a Flutter thread that interpretation was used on iOS, but I could be mistaken.

Gen

unread,
Nov 3, 2015, 2:56:09 PM11/3/15
to mi...@dartlang.org
AFAIK you are not mistaken with regard to Flutter on iOS. Fletch is an interpreter because Apple does not allow JIT except the Javascript JIT in the browser.
PS: I do not not how much of Flutter is written in Dart.

Filipe Morgado

unread,
Nov 3, 2015, 4:21:37 PM11/3/15
to Dart Misc
Flutter doesn't use Fletch, not even on iOS.

I guess it just links parts of the Dart VM within the executable (gc, event-queue, APIs, snapshot loader?).

It's probably very early, but I'm curious regarding the performance characteristics of AoT Dart.

I suspect the gains could be significant if the compiler cares about types.

But I guess it would meen a whole new specification is required.

Ivan Posva

unread,
Nov 3, 2015, 6:00:36 PM11/3/15
to General Dart Discussion
There seems to have been quite a bit of a confusion on this topic. At
some point you might have heard that Flutter used an "interpreter" on
iOS, it didn't. As you probably also know we do have simulators for
the non-Intel instruction sets supported by the VM (arm, arm64 and
mips). This way we can develop and debug all of our JIT
implementations on our desktop machines.

In the initial bringup of Flutter on iOS we were running with the JIT
enabled. As we all know, on iOS we cannot execute the dynamically
generated instructions, instead we reused the existing simulator in
the VM. Some might have referred to this mode as "interpreted". We
refer to this mode as simulated. In contrast a real interpreter would
run bytecodes specifically designed for Dart execution and not ARM
instructions.

Since we now do have a precompilation step, the simulated execution on
iOS is not necessary any longer.

I hope this makes things a bit clearer.

Thanks,
-Ivan

Bob Nystrom

unread,
Nov 3, 2015, 7:02:05 PM11/3/15
to General Dart Discussion
On Tue, Nov 3, 2015 at 3:00 PM, 'Ivan Posva' via Dart Misc <mi...@dartlang.org> wrote:
There seems to have been quite a bit of a confusion on this topic. At
some point you might have heard that Flutter used an "interpreter" on
iOS, it didn't.

A while back, the team communicated that we were investigating using Fletch on iOS. Fletch is an interpreter.

That's where the confusing is coming from, I think.

– bob

Gen

unread,
Nov 4, 2015, 2:46:45 AM11/4/15
to Dart Misc
I had watched the video Dart for Mobile (https://www.youtube.com/watch?v=t8xdEO8LyL8) where Fletch was meant to run Dart on iOS.
Somehow I missed the comment in this thread where Kasper clarified that compilation to native code is used on iOS.
I still wonder how Dart allows compilation to native code; I had thought it was impossible to run Dart code fast without JIT optimizations or at least an interpreter.

With regard to Flutter (previously called Sky), I do not remember that it was advertised to be implemented in Dart.
But the repository contains Dart files and Flutter is meant to be used with Dart code which must run somehow.
Here is a picture showing the architecture of Sky: https://www.youtube.com/watch?v=PnIWl33YMwA#t=2m52s
The green color means Dart code.

Yegor Jbanov

unread,
Nov 4, 2015, 3:02:36 AM11/4/15
to Dart Misc
With regard to Flutter (previously called Sky), I do not remember that it was advertised to be implemented in Dart.
But the repository contains Dart files and Flutter is meant to be used with Dart code which must run somehow.

Check out http://flutter.io (tl;dr the lowest-level engine is C++/Skia/Mojo; developer-facing SDK is Dart; developer chooses how high- or low-level to go)

kc

unread,
Nov 11, 2015, 9:46:43 AM11/11/15
to Dart Misc
On Tuesday, November 3, 2015 at 4:49:38 PM UTC, Srdjan wrote:

Dart VM does not have an interpreter. In JIT based execution, JIT initially creates unoptimized code that is run until hot code is detected. Hot functions are optimized, unoptimized code is replaced with optimized code.  


Re precompilation on iOS. I can see how the intial 1st pass unoptimized code could be precompiled. But the 2nd optimized step for observed 'hot' functions at runtime?

I was thinking maybe at development time hot functions and paths could be traced/marked on the AST and/or snapshot and inform the precompilation (using Observatory infrastructure?).

K.

kc

unread,
Nov 11, 2015, 9:51:05 AM11/11/15
to Dart Misc
Right - Fletch was initially presented as a React Native style deal for iOS/Android to drive native interfaces. There was some overlap with the Flutter/Sky project so it's good to have a clearer story.

But I think the Dart team should be very clear and explicit when it changes direction.

K. 

Anders Sandholm

unread,
Nov 12, 2015, 10:41:47 AM11/12/15
to Public Dart List
Just to clarify, currently we're targeting the following setup
1) For Web deployment, dart2js is the tool to use. A lot of experimental work is also happening on the dev compiler.
2) For Mobile, flutter.io - using the Dart VM (with pre-compilation for iOS) - is the thing to check out. 
3) For Embedded, IoT-like devices, we're working on making Fletch a great fit. It's still early days for Fletch on embedded devices though - so stay tuned. 

/Anders

--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.



--
Anders Thorhauge Sandholm,
Product Manager, Google Denmark
CVR nr. 28 86 69 84

kc

unread,
Nov 23, 2015, 8:49:18 AM11/23/15
to Dart Misc
How does precompilation work with compiling observed hot code which requires runtime concrete type info and JIT (I think)?

K.
Reply all
Reply to author
Forward
0 new messages