Chromium Code Reviews| Index: runtime/bin/main.cc |
| diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc |
| index b481a67980e4721ed264860c35b2811757340efb..b36681d8f02233e098a3a291c6bd34f21ea738bc 100644 |
| --- a/runtime/bin/main.cc |
| +++ b/runtime/bin/main.cc |
| @@ -799,10 +799,26 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
| return NULL; |
| } |
| + // If the script is a Kernel binary, then we will try to bootstrap from the |
| + // script. |
| + const uint8_t* kernel_file = NULL; |
| + intptr_t kernel_length = -1; |
| + const bool is_kernel = |
| + !run_app_snapshot && |
| + TryReadKernel(script_uri, &kernel_file, &kernel_length); |
| + |
| IsolateData* isolate_data = |
| new IsolateData(script_uri, package_root, packages_config); |
| - Dart_Isolate isolate = Dart_CreateIsolate( |
| - script_uri, main, isolate_snapshot_buffer, flags, isolate_data, error); |
| + Dart_Isolate isolate = |
| + is_kernel ? Dart_CreateIsolateFromKernel(script_uri, main, kernel_file, |
| + kernel_length, flags, |
| + isolate_data, error) |
| + : Dart_CreateIsolate(script_uri, main, isolate_snapshot_buffer, |
| + flags, isolate_data, error); |
| + if (is_kernel) { |
| + free(const_cast<uint8_t*>(kernel_file)); |
| + } |
| + |
| if (isolate == NULL) { |
| delete isolate_data; |
| return NULL; |
| @@ -810,7 +826,20 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
| Dart_EnterScope(); |
| - if (isolate_snapshot_buffer != NULL) { |
| + // Set up the library tag handler for this isolate. |
| + Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); |
| + CHECK_RESULT(result); |
| + |
| + if (is_kernel) { |
| + // TODO(27590): We should not read the kernel file again! |
| + if (!TryReadKernel(script_uri, &kernel_file, &kernel_length)) { |
| + FATAL("Failed to read kernel second time"); |
| + } |
| + Dart_Handle result = Dart_LoadKernel(kernel_file, kernel_length); |
|
siva
2016/11/16 05:49:34
The TODO says do not read the kernel file again, d
Vyacheslav Egorov (Google)
2016/11/16 12:47:46
There is a difference between snapshots we have an
|
| + free(const_cast<uint8_t*>(kernel_file)); |
| + CHECK_RESULT(result); |
| + } |
| + if (is_kernel || (isolate_snapshot_buffer != NULL)) { |
| // Setup the native resolver as the snapshot does not carry it. |
| Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| Builtin::SetNativeResolver(Builtin::kIOLibrary); |
| @@ -820,10 +849,6 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
| CHECK_RESULT(result); |
| } |
| - // Set up the library tag handler for this isolate. |
| - Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); |
| - CHECK_RESULT(result); |
| - |
| if (Dart_IsServiceIsolate(isolate)) { |
| // If this is the service isolate, load embedder specific bits and return. |
| bool skip_library_load = run_app_snapshot; |
| @@ -872,8 +897,10 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
| Dart_Handle uri = |
| DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri)); |
| CHECK_RESULT(uri); |
| - result = Loader::LibraryTagHandler(Dart_kScriptTag, Dart_Null(), uri); |
| - CHECK_RESULT(result); |
| + if (!is_kernel) { |
| + result = Loader::LibraryTagHandler(Dart_kScriptTag, Dart_Null(), uri); |
| + CHECK_RESULT(result); |
| + } |
| Dart_TimelineEvent("LoadScript", Dart_TimelineGetMicros(), |
| Dart_GetMainPortId(), Dart_Timeline_Event_Async_End, 0, |