dart_shared_libray icon indicating copy to clipboard operation
dart_shared_libray copied to clipboard

Support vm usage AOT snapshot or Kernel IR to start

Open feipiao594 opened this issue 5 months ago • 3 comments

I am trying to use this repository to study Flutter. Is it feasible to make it support booting from an AOT snapshot?
Similarly, is booting from kernel IR feasible? However, the more important aspect is AOT.

feipiao594 avatar Aug 22 '25 10:08 feipiao594

Kernel IR / .dills should actually already work, though I haven't tested it recently (and it's not really documented).

Modifying the library to add AOT support is feasible, but I can't make any promises about being able to do it myself in the short term.

The main hurdle is setting up the build process to create two different shared libraries, and the interfaces to interact with them. This is because Dart itself uses two different targets to work with JIT code vs. AOT code, so this library would also need two different targets.

fuzzybinary avatar Aug 22 '25 17:08 fuzzybinary

Thanks, I'm also working on extending AOT for this repository. What you mentioned aligns with my attempts after posting this issue, although I haven't succeeded yet.
By the way, regarding Flutter, does the JIT in debug mode and AOT in release mode refer to the Dart VM operating on two different types of snapshots?

feipiao594 avatar Aug 22 '25 17:08 feipiao594

So far as I know, yes, Flutter uses JIT in debug and AOT in release, but to be honest I haven't looked into it too much. I am pretty sure, though, that Flutter doesn't build the source in the embedder like this library does. It builds a .dill externally using the flutter command, then loads that instead.

I do know that dart.exe is unable to load AOT compiled snapshots, there's a separate Dart executable to run it. More information is in the Dart documentation here

Something else to look out for -- though progress has been fairly slow, this change points to an officially supported embedding library in Dart's future (at least that's the hope). I had wanted to convert some of this code base over to using this change, but I haven't gotten around to it.

As you're working on something AOT related, it might be better to follow what Dart Engine is doing, as it's likely to be closer to what an official embedding solutions look like.

fuzzybinary avatar Aug 23 '25 02:08 fuzzybinary