How does the Dart VM work?

Dart’s compiler is used when executing a Dart program which translates the source program into a machine language equivalent.

The Dart compiler architecture enables a variety of code execution methods on different platforms:

  1. Native platform: Dart provides both a Dart virtual machine(VM) with just-in-time (JIT) compilation and an ahead-of-time (AOT) compiler for creating machine code for apps supporting both mobile and desktop platforms.

  2. Web platform: Dart is converted to JavaScript using its web compiler.

Native platform
1 of 2

Dart VM offers an execution environment known as an isolated Dart universe. Here are the properties of the isolated Dart universe offered by Dart VM:

  • Heap: The heap is a garbage collector controlling how much memory is allocated for each item the running code has assigned.

  • Isolate: Isolate is a computational unit that operates independently of other isolates within the same Dart virtual machine, enabling the concurrent and parallel execution of operations. Groups of isolates are called isolates. Isolate within the group share the same heap.

To communicate, isolates must send messages via ports because they are unable to directly share any mutable state. Isolates of the same group share the same Dart program.

  • Mutator thread: A mutator thread is a thread that uses the public C API of the virtual machine while running the Dart program. At any given moment, an isolate can only have one mutator thread connected to it.

Also, several helper threads may be connected to an isolate, for instance:

JIT compiler threads running in the background, concurrent GC marking threads, and GC sweeper threads.

Dart VM operation modes

Dart VM has two different operation modes, which are JIT(just-in-time) and AOT(ahead-of-time) modes.

JIT(just-in-time)

In the JIT mode, the Dart VM can dynamically import Dart source, parse it, and instantly compile it to native machine code so that it can be executed. Debugging, hot reloading, and other features are available in this mode, which is used when developing a program. JIT only compiles the exact amount of code required. JIT also features incremental recompilation, allowing it to only recompile the compiled code as required.

Using the JIT compiler in the development phase
Using the JIT compiler in the development phase

The common front-end (CFE), which is developed in Dart, transforms the source code into Kernel AST. The generated Kernel binary will then be executed by the virtual machine.

Note: For the production process, JIT is neither the best nor the most effective compiler.

AOT(ahead-of-time)

The dynamic loading, parsing, and assembly of Dart source code are not supported by the Dart VM in the AOT mode. It can only be used to import and run precompiled machine code. The entire source code is compiled into machine code that the platform can handle natively by the ahead-of-time compiler. This is done prior to the platform running the application.

Using the AOT compiler
Using the AOT compiler

Note: Production applications make use of the AOT compiler.

The disadvantages of the ahead-of-time compiler stem from the need to repeatedly compile the same code from start. Therefore, it is not the best for the development phase of an application.

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved