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

Unified Diff: runtime/bin/main.cc

Issue 2925203002: Load service isolate from the kernel binary. (Closed)
Patch Set: Remove whitespace Created 3 years, 6 months 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
Index: runtime/bin/main.cc
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index 61d76f7a80bf32c58a635f0493746ab9ee7dc76b..6fde4afddb9218133c0966e7e7448f6a08b3b162 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -390,6 +390,16 @@ static bool ProcessPlatformOption(const char* filename,
dfe.set_platform_binary_filename(filename);
return true;
}
+
+static bool ProcessVmServiceIOOption(const char* filename,
+ CommandLineOptions* vm_options) {
+ ASSERT(filename != NULL);
+ if (filename[0] == '\0') {
+ return false;
+ }
+ dfe.set_vmservice_io_binary_filename(filename);
+ return true;
+}
#endif
@@ -617,6 +627,7 @@ static struct {
#if !defined(DART_PRECOMPILED_RUNTIME)
{"--dfe=", ProcessFrontendOption},
{"--platform=", ProcessPlatformOption},
+ {"--vmservice_io=", ProcessVmServiceIOOption},
siva 2017/06/13 02:12:02 Can we derive the location of this file from the e
sivachandra 2017/06/14 19:25:57 I proposed a way to reduce the number of options h
#endif
{"--enable-vm-service", ProcessEnableVmServiceOption},
{"--disable-service-origin-check", ProcessDisableServiceOriginCheckOption},
@@ -1028,23 +1039,45 @@ static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri,
#if defined(DART_PRECOMPILED_RUNTIME)
// AOT: All isolates start from the app snapshot.
- bool isolate_run_app_snapshot = true;
+ bool skip_library_load = true;
const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data;
const uint8_t* isolate_snapshot_instructions =
app_isolate_snapshot_instructions;
#else
// JIT: Service isolate uses the core libraries snapshot.
- bool isolate_run_app_snapshot = false;
+ bool skip_library_load = false;
const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data;
const uint8_t* isolate_snapshot_instructions =
core_isolate_snapshot_instructions;
#endif // !defined(DART_PRECOMPILED_RUNTIME)
+ Dart_Isolate isolate = NULL;
IsolateData* isolate_data =
new IsolateData(script_uri, package_root, packages_config, NULL);
- Dart_Isolate isolate = Dart_CreateIsolate(
- script_uri, main, isolate_snapshot_data, isolate_snapshot_instructions,
- flags, isolate_data, error);
+#if defined(DART_PRECOMPILED_RUNTIME)
+ isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data,
+ isolate_snapshot_instructions, flags,
+ isolate_data, error);
+#else
+ if (dfe.UsePlatformBinary()) {
+ isolate = Dart_CreateIsolateFromKernel(
+ script_uri, NULL, dfe.kernel_platform(), flags, isolate_data, error);
+ if (isolate != NULL) {
+ Dart_EnterScope();
+ Dart_Handle library = Dart_LoadKernel(dfe.kernel_vmservice_io());
+ if (Dart_IsError(library)) {
+ Dart_ShutdownIsolate();
siva 2017/06/13 02:12:02 Why does shutdown isolate need to be called here?
sivachandra 2017/06/14 19:25:57 I thought ShutdownIsolate reverses the side effect
siva 2017/06/21 20:01:26 You are right I did not see that the isolate was c
+ isolate = NULL;
+ } else {
+ skip_library_load = true;
+ }
+ }
+ } else {
+ isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data,
+ isolate_snapshot_instructions, flags,
+ isolate_data, error);
+ }
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
if (isolate == NULL) {
delete isolate_data;
return NULL;
@@ -1056,7 +1089,6 @@ static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri,
CHECK_RESULT(result);
// Load embedder specific bits and return.
- bool skip_library_load = isolate_run_app_snapshot;
if (!VmService::Setup(vm_service_server_ip, vm_service_server_port,
skip_library_load, vm_service_dev_mode,
trace_loading)) {
@@ -1830,6 +1862,22 @@ void main(int argc, char** argv) {
Process::SetExitHook(SnapshotOnExitHook);
}
+#if !defined(DART_PRECOMPILED_RUNTIME)
+ // If a kernel platform binary file is specified, read it. This
+ // step will become redundant once we have the snapshot version
+ // of the kernel core/platform libraries.
+ if (dfe.UsePlatformBinary()) {
+ if (dfe.ReadPlatform() == NULL) {
+ Log::PrintErr("The platform binary is not a valid Dart Kernel file.");
+ Platform::Exit(kErrorExitCode);
+ }
+ if (dfe.ReadVMServiceIO() == NULL) {
+ Log::PrintErr("Could not read dart:vmservice_io binary file.");
+ Platform::Exit(kErrorExitCode);
+ }
+ }
+#endif
+
Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
// Start event handler.
@@ -1864,18 +1912,6 @@ void main(int argc, char** argv) {
&ServiceStreamCancelCallback);
Dart_SetFileModifiedCallback(&FileModifiedCallback);
-#if !defined(DART_PRECOMPILED_RUNTIME)
- // If a kernel platform binary file is specified, read it. This
- // step will become redundant once we have the snapshot version
- // of the kernel core/platform libraries.
- if (dfe.UsePlatformBinary()) {
- if (dfe.ReadPlatform() == NULL) {
- Log::PrintErr("The platform binary is not a valid Dart Kernel file.");
- Platform::Exit(kErrorExitCode);
- }
- }
-#endif
-
// Run the main isolate until we aren't told to restart.
while (RunMainIsolate(script_name, &dart_options)) {
Log::PrintErr("Restarting VM\n");

Powered by Google App Engine
This is Rietveld 408576698