Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Unified Diff: runtime/bin/main.cc

Issue 2463923002: Don't use IsolateData for the exit hook as multiple embedders share the dart/bin while using differ… (Closed)
Patch Set: check secondary Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/isolate_data.h ('k') | runtime/bin/process.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index c953b625dfeba5180a32e44ff605cab9a6622cc0..773fdda2eaa464b86dde15a0fff06adf98807e74 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -105,6 +105,9 @@ extern const char* kPrecompiledDataSymbolName;
static bool trace_loading = false;
+static Dart_Isolate main_isolate = NULL;
+
+
static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1";
static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181;
// VM Service options.
@@ -798,9 +801,6 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
IsolateData* isolate_data = new IsolateData(script_uri,
package_root,
packages_config);
- if (gen_snapshot_kind == kAppJIT) {
- isolate_data->set_exit_hook(SnapshotOnExitHook);
- }
Dart_Isolate isolate = Dart_CreateIsolate(script_uri,
main,
isolate_snapshot_buffer,
@@ -1539,6 +1539,11 @@ static void GenerateAppSnapshot() {
static void SnapshotOnExitHook(int64_t exit_code) {
+ if (Dart_CurrentIsolate() != main_isolate) {
+ Log::PrintErr("A snapshot was requested, but a secondary isolate "
+ "performed a hard exit (%" Pd64 ").\n", exit_code);
+ Platform::Exit(kErrorExitCode);
+ }
if (exit_code == 0) {
GenerateAppSnapshot();
}
@@ -1577,6 +1582,7 @@ bool RunMainIsolate(const char* script_name,
EventHandler::Stop();
Platform::Exit((exit_code != 0) ? exit_code : kErrorExitCode);
}
+ main_isolate = isolate;
delete [] isolate_name;
Dart_EnterIsolate(isolate);
@@ -1891,6 +1897,9 @@ void main(int argc, char** argv) {
#if defined(DART_PRECOMPILED_RUNTIME)
vm_options.AddArgument("--precompilation");
#endif
+ if (gen_snapshot_kind == kAppJIT) {
+ Process::SetExitHook(SnapshotOnExitHook);
+ }
Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
« no previous file with comments | « runtime/bin/isolate_data.h ('k') | runtime/bin/process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698