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

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: 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 unified diff | Download patch
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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 } 800 }
801 801
802 // If the script is a Kernel binary, then we will try to bootstrap from the 802 // If the script is a Kernel binary, then we will try to bootstrap from the
803 // script. 803 // script.
804 const uint8_t* kernel_file = NULL; 804 const uint8_t* kernel_file = NULL;
805 intptr_t kernel_length = -1; 805 intptr_t kernel_length = -1;
806 const bool is_kernel = 806 const bool is_kernel =
807 !run_app_snapshot && 807 !run_app_snapshot &&
808 TryReadKernel(script_uri, &kernel_file, &kernel_length); 808 TryReadKernel(script_uri, &kernel_file, &kernel_length);
809 809
810 void* kernel_program = NULL;
811 if (is_kernel) {
812 kernel_program = Dart_ParseKernelBinary(kernel_file, kernel_length);
813 free(const_cast<uint8_t*>(kernel_file));
814 }
815
810 IsolateData* isolate_data = 816 IsolateData* isolate_data =
811 new IsolateData(script_uri, package_root, packages_config); 817 new IsolateData(script_uri, package_root, packages_config);
812 Dart_Isolate isolate = 818 Dart_Isolate isolate =
813 is_kernel ? Dart_CreateIsolateFromKernel(script_uri, main, kernel_file, 819 is_kernel ? Dart_CreateIsolateFromKernel(script_uri, main, kernel_program,
814 kernel_length, flags, 820 flags, isolate_data, error)
815 isolate_data, error)
816 : Dart_CreateIsolate(script_uri, main, isolate_snapshot_buffer, 821 : Dart_CreateIsolate(script_uri, main, isolate_snapshot_buffer,
817 flags, isolate_data, error); 822 flags, isolate_data, error);
818 if (is_kernel) {
819 free(const_cast<uint8_t*>(kernel_file));
820 }
821
822 if (isolate == NULL) { 823 if (isolate == NULL) {
823 delete isolate_data; 824 delete isolate_data;
824 return NULL; 825 return NULL;
825 } 826 }
826 827
827 Dart_EnterScope(); 828 Dart_EnterScope();
828 829
829 // Set up the library tag handler for this isolate. 830 // Set up the library tag handler for this isolate.
830 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); 831 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
831 CHECK_RESULT(result); 832 CHECK_RESULT(result);
832 833
833 if (is_kernel) { 834 if (is_kernel) {
834 // TODO(27590): We should not read the kernel file again! 835 Dart_Handle result = Dart_LoadKernel(kernel_program);
835 if (!TryReadKernel(script_uri, &kernel_file, &kernel_length)) {
836 FATAL("Failed to read kernel second time");
837 }
838 Dart_Handle result = Dart_LoadKernel(kernel_file, kernel_length);
839 free(const_cast<uint8_t*>(kernel_file));
840 CHECK_RESULT(result); 836 CHECK_RESULT(result);
841 } 837 }
842 if (is_kernel || (isolate_snapshot_buffer != NULL)) { 838 if (is_kernel || (isolate_snapshot_buffer != NULL)) {
843 // Setup the native resolver as the snapshot does not carry it. 839 // Setup the native resolver as the snapshot does not carry it.
844 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); 840 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
845 Builtin::SetNativeResolver(Builtin::kIOLibrary); 841 Builtin::SetNativeResolver(Builtin::kIOLibrary);
846 } 842 }
847 if (run_app_snapshot) { 843 if (run_app_snapshot) {
848 Dart_Handle result = Loader::ReloadNativeExtensions(); 844 Dart_Handle result = Loader::ReloadNativeExtensions();
849 CHECK_RESULT(result); 845 CHECK_RESULT(result);
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 Platform::Exit(Process::GlobalExitCode()); 1944 Platform::Exit(Process::GlobalExitCode());
1949 } 1945 }
1950 1946
1951 } // namespace bin 1947 } // namespace bin
1952 } // namespace dart 1948 } // namespace dart
1953 1949
1954 int main(int argc, char** argv) { 1950 int main(int argc, char** argv) {
1955 dart::bin::main(argc, argv); 1951 dart::bin::main(argc, argv);
1956 UNREACHABLE(); 1952 UNREACHABLE();
1957 } 1953 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698