| Index: runtime/bin/main.cc
|
| diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
|
| index 10861340c162816ac3e1d4c67d8264fb2068cce5..d95a6073a25d7e18120a52d4c9d43a7d52be57d0 100644
|
| --- a/runtime/bin/main.cc
|
| +++ b/runtime/bin/main.cc
|
| @@ -775,6 +775,9 @@ static Dart_Handle EnvironmentCallback(Dart_Handle name) {
|
| } \
|
|
|
|
|
| +static void SnapshotOnExitHook(int64_t exit_code);
|
| +
|
| +
|
| // Returns true on success, false on failure.
|
| static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| const char* main,
|
| @@ -801,6 +804,10 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| IsolateData* isolate_data = new IsolateData(script_uri,
|
| package_root,
|
| packages_config);
|
| + if ((gen_snapshot_kind == kAppAfterRun) ||
|
| + (gen_snapshot_kind == kAppJITAfterRun)) {
|
| + isolate_data->set_exit_hook(SnapshotOnExitHook);
|
| + }
|
| Dart_Isolate isolate = Dart_CreateIsolate(script_uri,
|
| main,
|
| isolate_snapshot_buffer,
|
| @@ -1521,6 +1528,18 @@ static void GenerateFullSnapshot() {
|
| }
|
|
|
|
|
| +static void SnapshotOnExitHook(int64_t exit_code) {
|
| + if (exit_code == 0) {
|
| + if (gen_snapshot_kind == kAppAfterRun) {
|
| + GenerateFullSnapshot();
|
| + } else {
|
| + Dart_PrecompileJIT();
|
| + GeneratePrecompiledJITSnapshot();
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| bool RunMainIsolate(const char* script_name,
|
| CommandLineOptions* dart_options) {
|
| // Call CreateIsolateAndSetup which creates an isolate and loads up
|
|
|