What is the difference between Darth snapshots and Java bytecode?

I read Dart snapshots and they are often compared to Smalltalk images. But to me they sound just like Java bytecode.

For instance:

"A dant drot is just a binary serialization of a token stream created during code parsing. A snapshot is not a" snapshot of a running program, "it is generated before the markers are converted to machine code. The state of the program is written to the snapshot."

Plus they are cross-platform:

"The cross-platform snapshot format itself means that it works between 32-bit, 64-bit machines, etc. The format was made in such a way that it is quickly read into memory with an emphasis on minimizing additional work, such as pointers."

Am I mistaken somewhere?

Sources:
What is the concept of snapshot in a dart? http://www.infoq.com/articles/google-dart

+7
source share
3 answers

Snapshots contain VM data structures representing the loaded script, in a serialized form similar to Smalltalk images. To better understand what is contained in the snapshot, we should take a look at what the Dart VM creates when it reads the script:

  • Library objects that reference all top-level structures, such as classes or methods and top-level variables.
  • Class objects containing all objects that describe all methods and fields.
  • Script and Tokenstream objects representing all the downloaded source code.
  • String objects for all used identifiers and string constants in the source code.

This object graph is serialized to a file when creating a snapshot using a format that is not an agnostic of architecture. This allows the Dart VM to deserialize this snapshot file on 32-bit or 64-bit machines and re-create all the necessary internal VM data structures much faster than reading the source scripts from a set of files (see John's answer).

To clarify, John answered a bit. When you create a snapshot, Dart VM does not parse ALL of the source code. He only needs to analyze the upper level of the sources in order to be able to extract the definitions of classes, methods and fields, since they are presented in a serialized graph. In particular, the bodies of the methods are not analyzed, and, as is usually the case, for the scripting language errors will be reported only after the control reaches a certain method.

The goal of Java bytecodes is completely different, as Ladicek points out. You can create a snapshot of the VM data structures in the JVM after loading the bytecodes to get a similar effect.

In short: the snapshot contains an efficient view of all the data structures allocated in the VM dart heap that are needed to run the script.

-Ivan

+11
source

A Dart snapshot is just a convolution of all the source files that were parsed ahead of time. Dart's snapshot does not look like a Java bytecode file. A Java bytecode file consists of JVM machine code and is the result of a compilation, build, and build phase (into JVM machine code).

A drift dart is a binary file of the Dart program, as well as import / partially source files that were parsed into an abstract syntax tree and turned into a single file. Running a Dart snapshot can speed up startup time because:

  • Only one file must be downloaded from disk or from the network. On the contrary, a program that is not related to the snapshot should be selected, then you need to import any imported files, etc. Before each subsequent request for a source file can be made, the source file must be analyzed to see if it refers to additional source files. Imagine that your Dart program imported 10 libraries, each of which consisted of 10 source files. This means that 110 I / O requests and analyzes are performed one after another.
  • The analysis was done in advance. It is already known as syntactically correct and ready to compile Dart VM.

NTN, John

+8
source

I will just point out that with Dart 2+, there are several distinctive concepts when it comes to snapshots:

  • Kernel snapshot
  • JIT Snapshot
  • AOT Snapshot

You can read more here .

0
source

All Articles