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

Side by Side Diff: runtime/bin/main.cc

Issue 2525623002: VM: [Kernel] Split kernel API into 3 steps: ([read binary], parse-binary, bootstrap, load program) (Closed)
Patch Set: addressed comments Created 4 years 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/loader.cc ('k') | runtime/include/dart_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_tools_api.h" 10 #include "include/dart_tools_api.h"
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 } 799 }
800 800
801 // If the script is a Kernel binary, then we will try to bootstrap from the 801 // If the script is a Kernel binary, then we will try to bootstrap from the
802 // script. 802 // script.
803 const uint8_t* kernel_file = NULL; 803 const uint8_t* kernel_file = NULL;
804 intptr_t kernel_length = -1; 804 intptr_t kernel_length = -1;
805 const bool is_kernel = 805 const bool is_kernel =
806 !run_app_snapshot && 806 !run_app_snapshot &&
807 TryReadKernel(script_uri, &kernel_file, &kernel_length); 807 TryReadKernel(script_uri, &kernel_file, &kernel_length);
808 808
809 void* kernel_program = NULL;
810 if (is_kernel) {
811 kernel_program = Dart_ReadKernelBinary(kernel_file, kernel_length);
812 free(const_cast<uint8_t*>(kernel_file));
813 }
814
809 IsolateData* isolate_data = 815 IsolateData* isolate_data =
810 new IsolateData(script_uri, package_root, packages_config); 816 new IsolateData(script_uri, package_root, packages_config);
811 Dart_Isolate isolate = 817 Dart_Isolate isolate =
812 is_kernel ? Dart_CreateIsolateFromKernel(script_uri, main, kernel_file, 818 is_kernel ? Dart_CreateIsolateFromKernel(script_uri, main, kernel_program,
813 kernel_length, flags, 819 flags, isolate_data, error)
814 isolate_data, error)
815 : Dart_CreateIsolate(script_uri, main, isolate_snapshot_buffer, 820 : Dart_CreateIsolate(script_uri, main, isolate_snapshot_buffer,
816 flags, isolate_data, error); 821 flags, isolate_data, error);
817 if (is_kernel) {
818 free(const_cast<uint8_t*>(kernel_file));
819 }
820
821 if (isolate == NULL) { 822 if (isolate == NULL) {
822 delete isolate_data; 823 delete isolate_data;
823 return NULL; 824 return NULL;
824 } 825 }
825 826
826 Dart_EnterScope(); 827 Dart_EnterScope();
827 828
828 // Set up the library tag handler for this isolate. 829 // Set up the library tag handler for this isolate.
829 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); 830 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
830 CHECK_RESULT(result); 831 CHECK_RESULT(result);
831 832
832 if (is_kernel) { 833 if (is_kernel) {
833 // TODO(27590): We should not read the kernel file again! 834 Dart_Handle result = Dart_LoadKernel(kernel_program);
834 if (!TryReadKernel(script_uri, &kernel_file, &kernel_length)) {
835 FATAL("Failed to read kernel second time");
836 }
837 Dart_Handle result = Dart_LoadKernel(kernel_file, kernel_length);
838 free(const_cast<uint8_t*>(kernel_file));
839 CHECK_RESULT(result); 835 CHECK_RESULT(result);
840 } 836 }
841 if (is_kernel || (isolate_snapshot_buffer != NULL)) { 837 if (is_kernel || (isolate_snapshot_buffer != NULL)) {
842 // Setup the native resolver as the snapshot does not carry it. 838 // Setup the native resolver as the snapshot does not carry it.
843 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); 839 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
844 Builtin::SetNativeResolver(Builtin::kIOLibrary); 840 Builtin::SetNativeResolver(Builtin::kIOLibrary);
845 } 841 }
846 if (run_app_snapshot) { 842 if (run_app_snapshot) {
847 Dart_Handle result = Loader::ReloadNativeExtensions(); 843 Dart_Handle result = Loader::ReloadNativeExtensions();
848 CHECK_RESULT(result); 844 CHECK_RESULT(result);
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 Platform::Exit(Process::GlobalExitCode()); 1949 Platform::Exit(Process::GlobalExitCode());
1954 } 1950 }
1955 1951
1956 } // namespace bin 1952 } // namespace bin
1957 } // namespace dart 1953 } // namespace dart
1958 1954
1959 int main(int argc, char** argv) { 1955 int main(int argc, char** argv) {
1960 dart::bin::main(argc, argv); 1956 dart::bin::main(argc, argv);
1961 UNREACHABLE(); 1957 UNREACHABLE();
1962 } 1958 }
OLDNEW
« no previous file with comments | « runtime/bin/loader.cc ('k') | runtime/include/dart_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698