Skip to content

Option to compile to machine code #39261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Nov 6, 2019 · 4 comments
Closed

Option to compile to machine code #39261

ghost opened this issue Nov 6, 2019 · 4 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. vm-native

Comments

@ghost
Copy link

ghost commented Nov 6, 2019

I had assumed that the executable created by dart2native was machine code.

It appears what is actually happening is that it is bytecode, and said bytecode
is concatenated with the Dart interpreter to create the final result.

This explains why the executable is destroyed when you strip it: what really
happens is the bytecode is just removed from the executable leaving only the
interpreter.

I am not sure if creating machine code is even possible with the Dart project,
so this issue can serve as a place for someone to clarify one way or the other.

@mraleph
Copy link
Member

mraleph commented Nov 6, 2019

Dart code is compiled to native code by the AOT compiler. This executable code is just not necessarily packaged in a platform specific executable format (e.g. ELF on Linux, Mach-O on Mac or PE on Windows). Instead we pack it into, what we call a snapshot which later can be loaded by the runtime system. Format of that snapshot is an implementation detail which should be irrelevant to the end user.

@mraleph mraleph closed this as completed Nov 6, 2019
@keertip keertip added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. vm-native labels Nov 6, 2019
@ghost
Copy link
Author

ghost commented Nov 6, 2019

@mraleph yeah, thats bytecode, not machine code, as it requires the Dart interpreter or Dart virtual machine to accompany the snapshot.

Its not the same thing as machine code, and shouldnt be marketed as such. Calling it AOT is a misnomer I would say.

@mraleph
Copy link
Member

mraleph commented Nov 6, 2019

@cup the AOT snapshot contains actual machine code which is directly executed by the CPU. This code was produced ahead of time (AOT) from your Dart source. There is no translation or interpretation. There is just a loading/linking step, which is similar to a step that OS does for you when you load a native executable format.

You are confusing several different things - executable format (ELF, etc) and format in which your Dart code is stored (eg machine code vs bytecode vs source).

@n8crwlr
Copy link

n8crwlr commented Nov 6, 2019

@cup

Whatever you call it, its not the same thing as what you get with C, C++ or Go.

This is nonsense and not neccessary. Dart is not a system programming language.

Having a single executable binary is all we need so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. vm-native
Projects
None yet
Development

No branches or pull requests

3 participants