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

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

Issue 2990833002: Fix for issue 29819 (Closed)
Patch Set: Created 3 years, 4 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/loader.cc ('k') | no next file » | 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 <stdio.h> 5 #include <stdio.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.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 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 exit_code); 815 exit_code);
816 Platform::Exit(kErrorExitCode); 816 Platform::Exit(kErrorExitCode);
817 } 817 }
818 if (exit_code == 0) { 818 if (exit_code == 0) {
819 Snapshot::GenerateAppJIT(snapshot_filename); 819 Snapshot::GenerateAppJIT(snapshot_filename);
820 } 820 }
821 } 821 }
822 822
823 static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate, 823 static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
824 bool is_main_isolate, 824 bool is_main_isolate,
825 bool kernel_file_specified,
826 const char* script_uri, 825 const char* script_uri,
827 const char* package_root, 826 const char* package_root,
828 const char* packages_config, 827 const char* packages_config,
829 bool set_native_resolvers, 828 bool set_native_resolvers,
830 bool isolate_run_app_snapshot, 829 bool isolate_run_app_snapshot,
831 char** error, 830 char** error,
832 int* exit_code) { 831 int* exit_code) {
833 Dart_EnterScope(); 832 Dart_EnterScope();
834 IsolateData* isolate_data = 833 IsolateData* isolate_data =
835 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate)); 834 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate));
836 void* kernel_program = isolate_data->kernel_program; 835 void* kernel_program = isolate_data->kernel_program;
837 836
838 // Set up the library tag handler for this isolate. 837 // Set up the library tag handler for this isolate.
839 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); 838 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
840 CHECK_RESULT(result); 839 CHECK_RESULT(result);
841 840
842 // Prepare builtin and other core libraries for use to resolve URIs. 841 // Prepare builtin and other core libraries for use to resolve URIs.
843 // Set up various closures, e.g: printing, timers etc. 842 // Set up various closures, e.g: printing, timers etc.
844 // Set up 'package root' for URI resolution. 843 // Set up 'package root' for URI resolution.
845 result = DartUtils::PrepareForScriptLoading(false, trace_loading); 844 result = DartUtils::PrepareForScriptLoading(false, trace_loading);
846 CHECK_RESULT(result); 845 CHECK_RESULT(result);
847 846
848 if (kernel_file_specified) { 847 #if !defined(DART_PRECOMPILED_RUNTIME)
848 if (dfe.kernel_file_specified()) {
849 ASSERT(kernel_program != NULL); 849 ASSERT(kernel_program != NULL);
850 result = Dart_LoadKernel(kernel_program); 850 result = Dart_LoadKernel(kernel_program);
851 } else { 851 } else {
852 if (kernel_program != NULL) { 852 if (kernel_program != NULL) {
853 Dart_Handle uri = Dart_NewStringFromCString(script_uri); 853 Dart_Handle uri = Dart_NewStringFromCString(script_uri);
854 CHECK_RESULT(uri); 854 CHECK_RESULT(uri);
855 Dart_Handle resolved_script_uri = DartUtils::ResolveScript(uri); 855 Dart_Handle resolved_script_uri = DartUtils::ResolveScript(uri);
856 CHECK_RESULT(resolved_script_uri); 856 CHECK_RESULT(resolved_script_uri);
857 result = 857 result =
858 Dart_LoadScript(uri, resolved_script_uri, 858 Dart_LoadScript(uri, resolved_script_uri,
859 reinterpret_cast<Dart_Handle>(kernel_program), 0, 0); 859 reinterpret_cast<Dart_Handle>(kernel_program), 0, 0);
860 CHECK_RESULT(result); 860 CHECK_RESULT(result);
861 } 861 }
862 } 862 }
863 #endif // !defined(DART_PRECOMPILED_RUNTIME)
864
863 if (set_native_resolvers) { 865 if (set_native_resolvers) {
864 // Setup the native resolver as the snapshot does not carry it. 866 // Setup the native resolver as the snapshot does not carry it.
865 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); 867 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
866 Builtin::SetNativeResolver(Builtin::kIOLibrary); 868 Builtin::SetNativeResolver(Builtin::kIOLibrary);
867 } 869 }
868 if (isolate_run_app_snapshot) { 870 if (isolate_run_app_snapshot) {
869 Dart_Handle result = Loader::ReloadNativeExtensions(); 871 Dart_Handle result = Loader::ReloadNativeExtensions();
870 CHECK_RESULT(result); 872 CHECK_RESULT(result);
871 } 873 }
872 874
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 IsolateData* isolate_data = 977 IsolateData* isolate_data =
976 new IsolateData(script_uri, package_root, packages_config, app_snapshot); 978 new IsolateData(script_uri, package_root, packages_config, app_snapshot);
977 Dart_Isolate isolate = Dart_CreateIsolate( 979 Dart_Isolate isolate = Dart_CreateIsolate(
978 script_uri, main, isolate_snapshot_data, isolate_snapshot_instructions, 980 script_uri, main, isolate_snapshot_data, isolate_snapshot_instructions,
979 flags, isolate_data, error); 981 flags, isolate_data, error);
980 if (isolate == NULL) { 982 if (isolate == NULL) {
981 delete isolate_data; 983 delete isolate_data;
982 return NULL; 984 return NULL;
983 } 985 }
984 986
985 return IsolateSetupHelper(isolate, false, false, script_uri, package_root, 987 return IsolateSetupHelper(isolate, false, script_uri, package_root,
986 packages_config, isolate_snapshot_data, 988 packages_config, isolate_snapshot_data,
987 isolate_run_app_snapshot, error, exit_code); 989 isolate_run_app_snapshot, error, exit_code);
988 } 990 }
989 #endif // !defined(DART_PRECOMPILED_RUNTIME) 991 #endif // !defined(DART_PRECOMPILED_RUNTIME)
990 992
991 // Returns newly created Service Isolate on success, NULL on failure. 993 // Returns newly created Service Isolate on success, NULL on failure.
992 // For now we only support the service isolate coming up from sources 994 // For now we only support the service isolate coming up from sources
993 // which are compiled by the VM parser. 995 // which are compiled by the VM parser.
994 static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri, 996 static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri,
995 const char* main, 997 const char* main,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 const char* main, 1075 const char* main,
1074 const char* package_root, 1076 const char* package_root,
1075 const char* packages_config, 1077 const char* packages_config,
1076 Dart_IsolateFlags* flags, 1078 Dart_IsolateFlags* flags,
1077 char** error, 1079 char** error,
1078 int* exit_code) { 1080 int* exit_code) {
1079 ASSERT(script_uri != NULL); 1081 ASSERT(script_uri != NULL);
1080 void* kernel_platform = NULL; 1082 void* kernel_platform = NULL;
1081 void* kernel_program = NULL; 1083 void* kernel_program = NULL;
1082 AppSnapshot* app_snapshot = NULL; 1084 AppSnapshot* app_snapshot = NULL;
1083 bool kernel_file_specified = false;
1084 1085
1085 IsolateData* isolate_data = 1086 IsolateData* isolate_data =
1086 new IsolateData(script_uri, package_root, packages_config, app_snapshot); 1087 new IsolateData(script_uri, package_root, packages_config, app_snapshot);
1087 if (is_main_isolate && (snapshot_deps_filename != NULL)) { 1088 if (is_main_isolate && (snapshot_deps_filename != NULL)) {
1088 isolate_data->set_dependencies(new MallocGrowableArray<char*>()); 1089 isolate_data->set_dependencies(new MallocGrowableArray<char*>());
1089 } 1090 }
1090 1091
1091 #if defined(DART_PRECOMPILED_RUNTIME) 1092 #if defined(DART_PRECOMPILED_RUNTIME)
1092 // AOT: All isolates start from the app snapshot. 1093 // AOT: All isolates start from the app snapshot.
1093 bool isolate_run_app_snapshot = true; 1094 bool isolate_run_app_snapshot = true;
(...skipping 23 matching lines...) Expand all
1117 &ignore_vm_snapshot_data, &ignore_vm_snapshot_instructions, 1118 &ignore_vm_snapshot_data, &ignore_vm_snapshot_instructions,
1118 &isolate_snapshot_data, &isolate_snapshot_instructions); 1119 &isolate_snapshot_data, &isolate_snapshot_instructions);
1119 } 1120 }
1120 } 1121 }
1121 if (!isolate_run_app_snapshot) { 1122 if (!isolate_run_app_snapshot) {
1122 kernel_platform = dfe.kernel_platform(); 1123 kernel_platform = dfe.kernel_platform();
1123 kernel_program = dfe.ReadScript(script_uri); 1124 kernel_program = dfe.ReadScript(script_uri);
1124 if (kernel_program != NULL) { 1125 if (kernel_program != NULL) {
1125 // A kernel file was specified on the command line instead of a source 1126 // A kernel file was specified on the command line instead of a source
1126 // file. Load that kernel file directly. 1127 // file. Load that kernel file directly.
1127 kernel_file_specified = true; 1128 dfe.set_kernel_file_specified(true);
1128 } else if (dfe.UseDartFrontend()) { 1129 } else if (dfe.UseDartFrontend()) {
1129 kernel_program = dfe.CompileAndReadScript(script_uri, error, exit_code); 1130 kernel_program = dfe.CompileAndReadScript(script_uri, error, exit_code);
1130 if (kernel_program == NULL) { 1131 if (kernel_program == NULL) {
1131 return NULL; 1132 return NULL;
1132 } 1133 }
1133 } 1134 }
1134 isolate_data->kernel_program = kernel_program; 1135 isolate_data->kernel_program = kernel_program;
1135 } 1136 }
1136 #endif // !defined(DART_PRECOMPILED_RUNTIME) 1137 #endif // !defined(DART_PRECOMPILED_RUNTIME)
1137 1138
1138 Dart_Isolate isolate = NULL; 1139 Dart_Isolate isolate = NULL;
1139 if (kernel_platform != NULL) { 1140 if (kernel_platform != NULL) {
1140 isolate = Dart_CreateIsolateFromKernel(script_uri, main, kernel_platform, 1141 isolate = Dart_CreateIsolateFromKernel(script_uri, main, kernel_platform,
1141 flags, isolate_data, error); 1142 flags, isolate_data, error);
1142 } else if (kernel_program != NULL) { 1143 } else if (kernel_program != NULL) {
1143 isolate = Dart_CreateIsolateFromKernel(script_uri, main, kernel_program, 1144 isolate = Dart_CreateIsolateFromKernel(script_uri, main, kernel_program,
1144 flags, isolate_data, error); 1145 flags, isolate_data, error);
1145 } else { 1146 } else {
1146 isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data, 1147 isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data,
1147 isolate_snapshot_instructions, flags, 1148 isolate_snapshot_instructions, flags,
1148 isolate_data, error); 1149 isolate_data, error);
1149 } 1150 }
1150 if (isolate == NULL) { 1151 if (isolate == NULL) {
1151 delete isolate_data; 1152 delete isolate_data;
1152 return NULL; 1153 return NULL;
1153 } 1154 }
1154 1155
1155 bool set_native_resolvers = (kernel_program || isolate_snapshot_data); 1156 bool set_native_resolvers = (kernel_program || isolate_snapshot_data);
1156 return IsolateSetupHelper(isolate, is_main_isolate, kernel_file_specified, 1157 return IsolateSetupHelper(isolate, is_main_isolate, script_uri, package_root,
1157 script_uri, package_root, packages_config, 1158 packages_config, set_native_resolvers,
1158 set_native_resolvers, isolate_run_app_snapshot, 1159 isolate_run_app_snapshot, error, exit_code);
1159 error, exit_code);
1160 } 1160 }
1161 1161
1162 #undef CHECK_RESULT 1162 #undef CHECK_RESULT
1163 1163
1164 static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, 1164 static Dart_Isolate CreateIsolateAndSetup(const char* script_uri,
1165 const char* main, 1165 const char* main,
1166 const char* package_root, 1166 const char* package_root,
1167 const char* package_config, 1167 const char* package_config,
1168 Dart_IsolateFlags* flags, 1168 Dart_IsolateFlags* flags,
1169 void* data, 1169 void* data,
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 Platform::Exit(Process::GlobalExitCode()); 1904 Platform::Exit(Process::GlobalExitCode());
1905 } 1905 }
1906 1906
1907 } // namespace bin 1907 } // namespace bin
1908 } // namespace dart 1908 } // namespace dart
1909 1909
1910 int main(int argc, char** argv) { 1910 int main(int argc, char** argv) {
1911 dart::bin::main(argc, argv); 1911 dart::bin::main(argc, argv);
1912 UNREACHABLE(); 1912 UNREACHABLE();
1913 } 1913 }
OLDNEW
« no previous file with comments | « runtime/bin/loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698