Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 "A snapshot was requested, but a secondary isolate " | 818 "A snapshot was requested, but a secondary isolate " |
| 819 "performed a hard exit (%" Pd64 ").\n", | 819 "performed a hard exit (%" Pd64 ").\n", |
| 820 exit_code); | 820 exit_code); |
| 821 Platform::Exit(kErrorExitCode); | 821 Platform::Exit(kErrorExitCode); |
| 822 } | 822 } |
| 823 if (exit_code == 0) { | 823 if (exit_code == 0) { |
| 824 Snapshot::GenerateAppJIT(snapshot_filename); | 824 Snapshot::GenerateAppJIT(snapshot_filename); |
| 825 } | 825 } |
| 826 } | 826 } |
| 827 | 827 |
| 828 // Returns newly created Isolate on success, NULL on failure. | |
| 829 static Dart_Isolate CreateIsolateAndSetupHelper(bool is_main_isolate, | |
| 830 const char* script_uri, | |
| 831 const char* main, | |
| 832 const char* package_root, | |
| 833 const char* packages_config, | |
| 834 Dart_IsolateFlags* flags, | |
| 835 char** error, | |
| 836 int* exit_code) { | |
| 837 ASSERT(script_uri != NULL); | |
| 838 void* kernel_platform = NULL; | |
| 839 void* kernel_program = NULL; | |
| 840 AppSnapshot* app_snapshot = NULL; | |
| 841 | 828 |
| 842 #if defined(DART_PRECOMPILED_RUNTIME) | 829 static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate, |
| 843 // AOT: All isolates start from the app snapshot. | 830 bool is_main_isolate, |
| 844 bool isolate_run_app_snapshot = true; | 831 const char* script_uri, |
| 845 const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data; | 832 const char* package_root, |
| 846 const uint8_t* isolate_snapshot_instructions = | 833 const char* packages_config, |
| 847 app_isolate_snapshot_instructions; | 834 void* kernel_program, |
| 848 #else | 835 bool set_native_resolvers, |
| 849 // JIT: Main isolate starts from the app snapshot, if any. Other isolates | 836 bool isolate_run_app_snapshot, |
| 850 // use the core libraries snapshot. | 837 char** error, |
| 851 bool isolate_run_app_snapshot = false; | 838 int* exit_code) { |
| 852 const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data; | |
| 853 const uint8_t* isolate_snapshot_instructions = | |
| 854 core_isolate_snapshot_instructions; | |
| 855 const bool is_kernel_isolate = | |
| 856 strcmp(script_uri, DART_KERNEL_ISOLATE_NAME) == 0; | |
| 857 if (is_kernel_isolate) { | |
| 858 if (!dfe.UseDartFrontend()) { | |
| 859 *error = strdup("Kernel isolate not supported."); | |
| 860 return NULL; | |
| 861 } | |
| 862 script_uri = dfe.frontend_filename(); | |
| 863 if (packages_config == NULL) { | |
| 864 packages_config = commandline_packages_file; | |
| 865 } | |
| 866 } | |
| 867 if ((app_isolate_snapshot_data != NULL) && | |
| 868 (is_main_isolate || ((app_script_uri != NULL) && | |
| 869 (strcmp(script_uri, app_script_uri) == 0)))) { | |
| 870 isolate_run_app_snapshot = true; | |
| 871 isolate_snapshot_data = app_isolate_snapshot_data; | |
| 872 isolate_snapshot_instructions = app_isolate_snapshot_instructions; | |
| 873 } else if (!is_main_isolate) { | |
| 874 app_snapshot = Snapshot::TryReadAppSnapshot(script_uri); | |
| 875 if (app_snapshot != NULL) { | |
| 876 isolate_run_app_snapshot = true; | |
| 877 const uint8_t* ignore_vm_snapshot_data; | |
| 878 const uint8_t* ignore_vm_snapshot_instructions; | |
| 879 app_snapshot->SetBuffers( | |
| 880 &ignore_vm_snapshot_data, &ignore_vm_snapshot_instructions, | |
| 881 &isolate_snapshot_data, &isolate_snapshot_instructions); | |
| 882 } | |
| 883 } | |
| 884 const bool is_service_isolate = | |
| 885 strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0; | |
| 886 if (!is_kernel_isolate && !is_service_isolate) { | |
| 887 const uint8_t* platform_file = NULL; | |
| 888 if (dfe.UsePlatformBinary()) { | |
| 889 intptr_t platform_length = -1; | |
| 890 bool success = dfe.TryReadKernelFile(dfe.platform_binary_filename(), | |
| 891 &platform_file, &platform_length); | |
| 892 if (!success) { | |
| 893 *error = strdup("The platform binary is not a valid Dart Kernel file."); | |
| 894 *exit_code = kErrorExitCode; | |
| 895 return NULL; | |
| 896 } | |
| 897 kernel_platform = Dart_ReadKernelBinary(platform_file, platform_length); | |
| 898 } | |
| 899 | |
| 900 bool is_kernel = false; | |
| 901 const uint8_t* kernel_file = NULL; | |
| 902 intptr_t kernel_length = -1; | |
| 903 if (dfe.UseDartFrontend()) { | |
| 904 Dart_KernelCompilationResult result = Dart_CompileToKernel(script_uri); | |
| 905 *error = result.error; // Copy error message (if any). | |
| 906 switch (result.status) { | |
| 907 case Dart_KernelCompilationStatus_Ok: | |
| 908 is_kernel = true; | |
| 909 kernel_file = result.kernel; | |
| 910 kernel_length = result.kernel_size; | |
| 911 break; | |
| 912 case Dart_KernelCompilationStatus_Error: | |
| 913 *exit_code = kCompilationErrorExitCode; | |
| 914 break; | |
| 915 case Dart_KernelCompilationStatus_Crash: | |
| 916 *exit_code = kDartFrontendErrorExitCode; | |
| 917 break; | |
| 918 case Dart_KernelCompilationStatus_Unknown: | |
| 919 *exit_code = kErrorExitCode; | |
| 920 break; | |
| 921 } | |
| 922 if (!is_kernel) { | |
| 923 free(const_cast<uint8_t*>(platform_file)); | |
| 924 delete reinterpret_cast<kernel::Program*>(kernel_platform); | |
| 925 return NULL; | |
| 926 } | |
| 927 } else if (!isolate_run_app_snapshot) { | |
| 928 is_kernel = | |
| 929 dfe.TryReadKernelFile(script_uri, &kernel_file, &kernel_length); | |
| 930 } | |
| 931 | |
| 932 if (is_kernel) { | |
| 933 kernel_program = Dart_ReadKernelBinary(kernel_file, kernel_length); | |
| 934 } | |
| 935 } | |
| 936 #endif // !defined(DART_PRECOMPILED_RUNTIME) | |
| 937 | |
| 938 IsolateData* isolate_data = | |
| 939 new IsolateData(script_uri, package_root, packages_config, app_snapshot); | |
| 940 if (is_main_isolate && (snapshot_deps_filename != NULL)) { | |
| 941 isolate_data->set_dependencies(new MallocGrowableArray<char*>()); | |
| 942 } | |
| 943 Dart_Isolate isolate = NULL; | |
| 944 if (kernel_platform != NULL) { | |
| 945 isolate = Dart_CreateIsolateFromKernel(script_uri, main, kernel_platform, | |
| 946 flags, isolate_data, error); | |
| 947 } else if (kernel_program != NULL) { | |
| 948 isolate = Dart_CreateIsolateFromKernel(script_uri, main, kernel_program, | |
| 949 flags, isolate_data, error); | |
| 950 } else { | |
| 951 isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data, | |
| 952 isolate_snapshot_instructions, flags, | |
| 953 isolate_data, error); | |
| 954 } | |
| 955 if (isolate == NULL) { | |
| 956 delete isolate_data; | |
| 957 return NULL; | |
| 958 } | |
| 959 | |
| 960 Dart_EnterScope(); | 839 Dart_EnterScope(); |
| 961 | 840 |
| 962 // Set up the library tag handler for this isolate. | 841 // Set up the library tag handler for this isolate. |
| 963 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); | 842 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); |
| 964 CHECK_RESULT(result); | 843 CHECK_RESULT(result); |
| 965 | 844 |
| 966 if (kernel_program != NULL) { | 845 if (kernel_program != NULL) { |
| 967 Dart_Handle result = Dart_LoadKernel(kernel_program); | 846 Dart_Handle result = Dart_LoadKernel(kernel_program); |
| 968 CHECK_RESULT(result); | 847 CHECK_RESULT(result); |
| 969 } | 848 } |
| 970 if ((kernel_platform != NULL) || (isolate_snapshot_data != NULL)) { | 849 if (set_native_resolvers) { |
| 971 // Setup the native resolver as the snapshot does not carry it. | 850 // Setup the native resolver as the snapshot does not carry it. |
| 972 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 851 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| 973 Builtin::SetNativeResolver(Builtin::kIOLibrary); | 852 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
| 974 } | 853 } |
| 975 if (isolate_run_app_snapshot) { | 854 if (isolate_run_app_snapshot) { |
| 976 Dart_Handle result = Loader::ReloadNativeExtensions(); | 855 Dart_Handle result = Loader::ReloadNativeExtensions(); |
| 977 CHECK_RESULT(result); | 856 CHECK_RESULT(result); |
| 978 } | 857 } |
| 979 | 858 |
| 980 if (Dart_IsServiceIsolate(isolate)) { | |
| 981 // If this is the service isolate, load embedder specific bits and return. | |
| 982 bool skip_library_load = isolate_run_app_snapshot; | |
| 983 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port, | |
| 984 skip_library_load, vm_service_dev_mode, | |
| 985 trace_loading)) { | |
| 986 *error = strdup(VmService::GetErrorMessage()); | |
| 987 return NULL; | |
| 988 } | |
| 989 if (compile_all) { | |
| 990 result = Dart_CompileAll(); | |
| 991 CHECK_RESULT(result); | |
| 992 } | |
| 993 result = Dart_SetEnvironmentCallback(EnvironmentCallback); | |
| 994 CHECK_RESULT(result); | |
| 995 Dart_ExitScope(); | |
| 996 Dart_ExitIsolate(); | |
| 997 return isolate; | |
| 998 } | |
| 999 | |
| 1000 // Prepare builtin and other core libraries for use to resolve URIs. | 859 // Prepare builtin and other core libraries for use to resolve URIs. |
| 1001 // Set up various closures, e.g: printing, timers etc. | 860 // Set up various closures, e.g: printing, timers etc. |
| 1002 // Set up 'package root' for URI resolution. | 861 // Set up 'package root' for URI resolution. |
| 1003 result = DartUtils::PrepareForScriptLoading(false, trace_loading); | 862 result = DartUtils::PrepareForScriptLoading(false, trace_loading); |
| 1004 CHECK_RESULT(result); | 863 CHECK_RESULT(result); |
| 1005 | 864 |
| 1006 // Set up the load port provided by the service isolate so that we can | 865 // Set up the load port provided by the service isolate so that we can |
| 1007 // load scripts. | 866 // load scripts. |
| 1008 result = DartUtils::SetupServiceLoadPort(); | 867 result = DartUtils::SetupServiceLoadPort(); |
| 1009 CHECK_RESULT(result); | 868 CHECK_RESULT(result); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1063 if (!retval) { | 922 if (!retval) { |
| 1064 *error = strdup("Invalid isolate state - Unable to make it runnable"); | 923 *error = strdup("Invalid isolate state - Unable to make it runnable"); |
| 1065 Dart_EnterIsolate(isolate); | 924 Dart_EnterIsolate(isolate); |
| 1066 Dart_ShutdownIsolate(); | 925 Dart_ShutdownIsolate(); |
| 1067 return NULL; | 926 return NULL; |
| 1068 } | 927 } |
| 1069 | 928 |
| 1070 return isolate; | 929 return isolate; |
| 1071 } | 930 } |
| 1072 | 931 |
| 932 | |
| 933 #if !defined(DART_PRECOMPILED_RUNTIME) | |
| 934 // Returns newly created Kernel Isolate on success, NULL on failure. | |
| 935 // For now we only support the kernel isolate coming up from an | |
| 936 // application snapshot or from sources which are compiled by the | |
| 937 // VM parser. | |
| 938 static Dart_Isolate CreateAndSetupKernelIsolate(const char* main, | |
| 939 const char* package_root, | |
| 940 const char* packages_config, | |
| 941 Dart_IsolateFlags* flags, | |
| 942 char** error, | |
| 943 int* exit_code) { | |
| 944 if (!dfe.UseDartFrontend()) { | |
| 945 *error = strdup("Kernel isolate not supported."); | |
| 946 return NULL; | |
| 947 } | |
| 948 const char* script_uri = dfe.frontend_filename(); | |
| 949 if (packages_config == NULL) { | |
| 950 packages_config = commandline_packages_file; | |
| 951 } | |
| 952 | |
| 953 // Kernel isolate uses an app snapshot or the core libraries snapshot. | |
| 954 bool isolate_run_app_snapshot = false; | |
| 955 const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data; | |
| 956 const uint8_t* isolate_snapshot_instructions = | |
| 957 core_isolate_snapshot_instructions; | |
| 958 AppSnapshot* app_snapshot = Snapshot::TryReadAppSnapshot(script_uri); | |
| 959 if (app_snapshot != NULL) { | |
| 960 isolate_run_app_snapshot = true; | |
| 961 const uint8_t* ignore_vm_snapshot_data; | |
| 962 const uint8_t* ignore_vm_snapshot_instructions; | |
| 963 app_snapshot->SetBuffers( | |
| 964 &ignore_vm_snapshot_data, &ignore_vm_snapshot_instructions, | |
| 965 &isolate_snapshot_data, &isolate_snapshot_instructions); | |
| 966 } | |
| 967 | |
| 968 IsolateData* isolate_data = | |
| 969 new IsolateData(script_uri, package_root, packages_config, app_snapshot); | |
| 970 Dart_Isolate isolate = Dart_CreateIsolate( | |
| 971 script_uri, main, isolate_snapshot_data, isolate_snapshot_instructions, | |
| 972 flags, isolate_data, error); | |
| 973 if (isolate == NULL) { | |
| 974 delete isolate_data; | |
| 975 return NULL; | |
| 976 } | |
| 977 | |
| 978 return IsolateSetupHelper(isolate, false, script_uri, package_root, | |
| 979 packages_config, NULL, isolate_snapshot_data, | |
| 980 isolate_run_app_snapshot, error, exit_code); | |
| 981 } | |
| 982 #endif // !defined(DART_PRECOMPILED_RUNTIME) | |
| 983 | |
| 984 | |
| 985 // Returns newly created Service Isolate on success, NULL on failure. | |
| 986 // For now we only support the service isolate coming up from sources | |
| 987 // which are compiled by the VM parser. | |
| 988 static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri, | |
| 989 const char* main, | |
| 990 const char* package_root, | |
| 991 const char* packages_config, | |
| 992 Dart_IsolateFlags* flags, | |
| 993 char** error, | |
| 994 int* exit_code) { | |
| 995 ASSERT(script_uri != NULL); | |
| 996 | |
| 997 #if defined(DART_PRECOMPILED_RUNTIME) | |
| 998 // AOT: All isolates start from the app snapshot. | |
| 999 bool isolate_run_app_snapshot = true; | |
| 1000 const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data; | |
| 1001 const uint8_t* isolate_snapshot_instructions = | |
| 1002 app_isolate_snapshot_instructions; | |
| 1003 #else | |
| 1004 // JIT: Service isolate uses the core libraries snapshot or an | |
| 1005 // app snapshot if the script_uri points to one. | |
|
rmacnak
2017/06/02 17:03:44
This code is assuming it isn't an app snapshot.
siva
2017/06/02 17:38:57
Fixed the comment.
| |
| 1006 bool isolate_run_app_snapshot = false; | |
| 1007 const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data; | |
| 1008 const uint8_t* isolate_snapshot_instructions = | |
| 1009 core_isolate_snapshot_instructions; | |
| 1010 #endif // !defined(DART_PRECOMPILED_RUNTIME) | |
| 1011 | |
| 1012 IsolateData* isolate_data = | |
| 1013 new IsolateData(script_uri, package_root, packages_config, NULL); | |
| 1014 Dart_Isolate isolate = Dart_CreateIsolate( | |
| 1015 script_uri, main, isolate_snapshot_data, isolate_snapshot_instructions, | |
| 1016 flags, isolate_data, error); | |
| 1017 if (isolate == NULL) { | |
| 1018 delete isolate_data; | |
| 1019 return NULL; | |
| 1020 } | |
| 1021 | |
| 1022 Dart_EnterScope(); | |
| 1023 | |
| 1024 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); | |
| 1025 CHECK_RESULT(result); | |
| 1026 | |
| 1027 // Load embedder specific bits and return. | |
| 1028 bool skip_library_load = isolate_run_app_snapshot; | |
| 1029 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port, | |
| 1030 skip_library_load, vm_service_dev_mode, | |
| 1031 trace_loading)) { | |
| 1032 *error = strdup(VmService::GetErrorMessage()); | |
| 1033 return NULL; | |
| 1034 } | |
| 1035 if (compile_all) { | |
| 1036 result = Dart_CompileAll(); | |
| 1037 CHECK_RESULT(result); | |
| 1038 } | |
| 1039 result = Dart_SetEnvironmentCallback(EnvironmentCallback); | |
| 1040 CHECK_RESULT(result); | |
| 1041 Dart_ExitScope(); | |
| 1042 Dart_ExitIsolate(); | |
| 1043 return isolate; | |
| 1044 } | |
| 1045 | |
| 1046 | |
| 1047 // Returns newly created Isolate on success, NULL on failure. | |
| 1048 static Dart_Isolate CreateIsolateAndSetupHelper(bool is_main_isolate, | |
| 1049 const char* script_uri, | |
| 1050 const char* main, | |
| 1051 const char* package_root, | |
| 1052 const char* packages_config, | |
| 1053 Dart_IsolateFlags* flags, | |
| 1054 char** error, | |
| 1055 int* exit_code) { | |
| 1056 ASSERT(script_uri != NULL); | |
| 1057 void* kernel_platform = NULL; | |
| 1058 void* kernel_program = NULL; | |
| 1059 AppSnapshot* app_snapshot = NULL; | |
| 1060 | |
| 1061 #if defined(DART_PRECOMPILED_RUNTIME) | |
| 1062 // AOT: All isolates start from the app snapshot. | |
| 1063 bool isolate_run_app_snapshot = true; | |
| 1064 const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data; | |
| 1065 const uint8_t* isolate_snapshot_instructions = | |
| 1066 app_isolate_snapshot_instructions; | |
| 1067 #else | |
| 1068 // JIT: Main isolate starts from the app snapshot, if any. Other isolates | |
| 1069 // use the core libraries snapshot. | |
| 1070 bool isolate_run_app_snapshot = false; | |
| 1071 const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data; | |
| 1072 const uint8_t* isolate_snapshot_instructions = | |
| 1073 core_isolate_snapshot_instructions; | |
| 1074 if ((app_isolate_snapshot_data != NULL) && | |
| 1075 (is_main_isolate || ((app_script_uri != NULL) && | |
| 1076 (strcmp(script_uri, app_script_uri) == 0)))) { | |
| 1077 isolate_run_app_snapshot = true; | |
| 1078 isolate_snapshot_data = app_isolate_snapshot_data; | |
| 1079 isolate_snapshot_instructions = app_isolate_snapshot_instructions; | |
| 1080 } else if (!is_main_isolate) { | |
| 1081 app_snapshot = Snapshot::TryReadAppSnapshot(script_uri); | |
| 1082 if (app_snapshot != NULL) { | |
| 1083 isolate_run_app_snapshot = true; | |
| 1084 const uint8_t* ignore_vm_snapshot_data; | |
| 1085 const uint8_t* ignore_vm_snapshot_instructions; | |
| 1086 app_snapshot->SetBuffers( | |
| 1087 &ignore_vm_snapshot_data, &ignore_vm_snapshot_instructions, | |
| 1088 &isolate_snapshot_data, &isolate_snapshot_instructions); | |
| 1089 } | |
| 1090 } | |
| 1091 const uint8_t* platform_file = NULL; | |
| 1092 if (dfe.UsePlatformBinary()) { | |
| 1093 intptr_t platform_length = -1; | |
| 1094 bool success = dfe.TryReadKernelFile(dfe.platform_binary_filename(), | |
| 1095 &platform_file, &platform_length); | |
| 1096 if (!success) { | |
| 1097 *error = strdup("The platform binary is not a valid Dart Kernel file."); | |
| 1098 *exit_code = kErrorExitCode; | |
| 1099 return NULL; | |
| 1100 } | |
| 1101 kernel_platform = Dart_ReadKernelBinary(platform_file, platform_length); | |
| 1102 } | |
| 1103 | |
| 1104 bool is_kernel = false; | |
| 1105 const uint8_t* kernel_file = NULL; | |
| 1106 intptr_t kernel_length = -1; | |
| 1107 if (dfe.UseDartFrontend()) { | |
| 1108 Dart_KernelCompilationResult result = Dart_CompileToKernel(script_uri); | |
| 1109 *error = result.error; // Copy error message (if any). | |
| 1110 switch (result.status) { | |
| 1111 case Dart_KernelCompilationStatus_Ok: | |
| 1112 is_kernel = true; | |
| 1113 kernel_file = result.kernel; | |
| 1114 kernel_length = result.kernel_size; | |
| 1115 break; | |
| 1116 case Dart_KernelCompilationStatus_Error: | |
| 1117 *exit_code = kCompilationErrorExitCode; | |
| 1118 break; | |
| 1119 case Dart_KernelCompilationStatus_Crash: | |
| 1120 *exit_code = kDartFrontendErrorExitCode; | |
| 1121 break; | |
| 1122 case Dart_KernelCompilationStatus_Unknown: | |
| 1123 *exit_code = kErrorExitCode; | |
| 1124 break; | |
| 1125 } | |
| 1126 if (!is_kernel) { | |
| 1127 free(const_cast<uint8_t*>(platform_file)); | |
| 1128 delete reinterpret_cast<kernel::Program*>(kernel_platform); | |
| 1129 return NULL; | |
| 1130 } | |
| 1131 } else if (!isolate_run_app_snapshot) { | |
| 1132 is_kernel = dfe.TryReadKernelFile(script_uri, &kernel_file, &kernel_length); | |
| 1133 } | |
| 1134 | |
| 1135 if (is_kernel) { | |
| 1136 kernel_program = Dart_ReadKernelBinary(kernel_file, kernel_length); | |
| 1137 } | |
| 1138 #endif // !defined(DART_PRECOMPILED_RUNTIME) | |
| 1139 | |
| 1140 IsolateData* isolate_data = | |
| 1141 new IsolateData(script_uri, package_root, packages_config, app_snapshot); | |
| 1142 if (is_main_isolate && (snapshot_deps_filename != NULL)) { | |
| 1143 isolate_data->set_dependencies(new MallocGrowableArray<char*>()); | |
| 1144 } | |
| 1145 Dart_Isolate isolate = NULL; | |
| 1146 if (kernel_platform != NULL) { | |
| 1147 isolate = Dart_CreateIsolateFromKernel(script_uri, main, kernel_platform, | |
| 1148 flags, isolate_data, error); | |
| 1149 } else if (kernel_program != NULL) { | |
| 1150 isolate = Dart_CreateIsolateFromKernel(script_uri, main, kernel_program, | |
| 1151 flags, isolate_data, error); | |
| 1152 } else { | |
| 1153 isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data, | |
| 1154 isolate_snapshot_instructions, flags, | |
| 1155 isolate_data, error); | |
| 1156 } | |
| 1157 if (isolate == NULL) { | |
| 1158 delete isolate_data; | |
| 1159 return NULL; | |
| 1160 } | |
| 1161 | |
| 1162 return IsolateSetupHelper(isolate, is_main_isolate, script_uri, package_root, | |
| 1163 packages_config, kernel_program, | |
| 1164 (kernel_program || isolate_snapshot_data), | |
| 1165 isolate_run_app_snapshot, error, exit_code); | |
| 1166 } | |
| 1167 | |
| 1073 #undef CHECK_RESULT | 1168 #undef CHECK_RESULT |
| 1074 | 1169 |
| 1075 | 1170 |
| 1076 static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, | 1171 static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, |
| 1077 const char* main, | 1172 const char* main, |
| 1078 const char* package_root, | 1173 const char* package_root, |
| 1079 const char* package_config, | 1174 const char* package_config, |
| 1080 Dart_IsolateFlags* flags, | 1175 Dart_IsolateFlags* flags, |
| 1081 void* data, | 1176 void* data, |
| 1082 char** error) { | 1177 char** error) { |
| 1083 // The VM should never call the isolate helper with a NULL flags. | 1178 // The VM should never call the isolate helper with a NULL flags. |
| 1084 ASSERT(flags != NULL); | 1179 ASSERT(flags != NULL); |
| 1085 ASSERT(flags->version == DART_FLAGS_CURRENT_VERSION); | 1180 ASSERT(flags->version == DART_FLAGS_CURRENT_VERSION); |
| 1086 if ((package_root != NULL) && (package_config != NULL)) { | 1181 if ((package_root != NULL) && (package_config != NULL)) { |
| 1087 *error = strdup( | 1182 *error = strdup( |
| 1088 "Invalid arguments - Cannot simultaneously specify " | 1183 "Invalid arguments - Cannot simultaneously specify " |
| 1089 "package root and package map."); | 1184 "package root and package map."); |
| 1090 return NULL; | 1185 return NULL; |
| 1091 } | 1186 } |
| 1092 | 1187 |
| 1188 int exit_code = 0; | |
| 1189 #if !defined(DART_PRECOMPILED_RUNTIME) | |
| 1190 if (strcmp(script_uri, DART_KERNEL_ISOLATE_NAME) == 0) { | |
| 1191 return CreateAndSetupKernelIsolate(main, package_root, package_config, | |
| 1192 flags, error, &exit_code); | |
| 1193 } | |
| 1194 #endif | |
| 1195 if (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0) { | |
| 1196 return CreateAndSetupServiceIsolate(script_uri, main, package_root, | |
| 1197 package_config, flags, error, | |
| 1198 &exit_code); | |
| 1199 } | |
| 1093 bool is_main_isolate = false; | 1200 bool is_main_isolate = false; |
| 1094 int exit_code = 0; | |
| 1095 return CreateIsolateAndSetupHelper(is_main_isolate, script_uri, main, | 1201 return CreateIsolateAndSetupHelper(is_main_isolate, script_uri, main, |
| 1096 package_root, package_config, flags, error, | 1202 package_root, package_config, flags, error, |
| 1097 &exit_code); | 1203 &exit_code); |
| 1098 } | 1204 } |
| 1099 | 1205 |
| 1100 | 1206 |
| 1101 static void PrintVersion() { | 1207 static void PrintVersion() { |
| 1102 Log::PrintErr("Dart VM version: %s\n", Dart_VersionString()); | 1208 Log::PrintErr("Dart VM version: %s\n", Dart_VersionString()); |
| 1103 } | 1209 } |
| 1104 | 1210 |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1770 Platform::Exit(Process::GlobalExitCode()); | 1876 Platform::Exit(Process::GlobalExitCode()); |
| 1771 } | 1877 } |
| 1772 | 1878 |
| 1773 } // namespace bin | 1879 } // namespace bin |
| 1774 } // namespace dart | 1880 } // namespace dart |
| 1775 | 1881 |
| 1776 int main(int argc, char** argv) { | 1882 int main(int argc, char** argv) { |
| 1777 dart::bin::main(argc, argv); | 1883 dart::bin::main(argc, argv); |
| 1778 UNREACHABLE(); | 1884 UNREACHABLE(); |
| 1779 } | 1885 } |
| OLD | NEW |