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

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

Issue 2947243002: Revert "Load service isolate from a .dill file." (Closed)
Patch Set: Created 3 years, 6 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/dfe.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 <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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 if (value != NULL) { 819 if (value != NULL) {
820 result = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(value), 820 result = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(value),
821 strlen(value)); 821 strlen(value));
822 } 822 }
823 free(name_chars); 823 free(name_chars);
824 } 824 }
825 return result; 825 return result;
826 } 826 }
827 827
828 828
829 #define SAVE_ERROR_AND_EXIT(result) \
830 *error = strdup(Dart_GetError(result)); \
831 if (Dart_IsCompilationError(result)) { \
832 *exit_code = kCompilationErrorExitCode; \
833 } else if (Dart_IsApiError(result)) { \
834 *exit_code = kApiErrorExitCode; \
835 } else { \
836 *exit_code = kErrorExitCode; \
837 } \
838 Dart_ExitScope(); \
839 Dart_ShutdownIsolate(); \
840 return NULL;
841
842
843 #define CHECK_RESULT(result) \ 829 #define CHECK_RESULT(result) \
844 if (Dart_IsError(result)) { \ 830 if (Dart_IsError(result)) { \
845 SAVE_ERROR_AND_EXIT(result); \ 831 *error = strdup(Dart_GetError(result)); \
832 if (Dart_IsCompilationError(result)) { \
833 *exit_code = kCompilationErrorExitCode; \
834 } else if (Dart_IsApiError(result)) { \
835 *exit_code = kApiErrorExitCode; \
836 } else { \
837 *exit_code = kErrorExitCode; \
838 } \
839 Dart_ExitScope(); \
840 Dart_ShutdownIsolate(); \
841 return NULL; \
846 } 842 }
847 843
848 844
849 #define CHECK_RESULT_CLEANUP(result, cleanup) \
850 if (Dart_IsError(result)) { \
851 delete (cleanup); \
852 SAVE_ERROR_AND_EXIT(result); \
853 }
854
855
856 static void SnapshotOnExitHook(int64_t exit_code) { 845 static void SnapshotOnExitHook(int64_t exit_code) {
857 if (Dart_CurrentIsolate() != main_isolate) { 846 if (Dart_CurrentIsolate() != main_isolate) {
858 Log::PrintErr( 847 Log::PrintErr(
859 "A snapshot was requested, but a secondary isolate " 848 "A snapshot was requested, but a secondary isolate "
860 "performed a hard exit (%" Pd64 ").\n", 849 "performed a hard exit (%" Pd64 ").\n",
861 exit_code); 850 exit_code);
862 Platform::Exit(kErrorExitCode); 851 Platform::Exit(kErrorExitCode);
863 } 852 }
864 if (exit_code == 0) { 853 if (exit_code == 0) {
865 Snapshot::GenerateAppJIT(snapshot_filename); 854 Snapshot::GenerateAppJIT(snapshot_filename);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 const char* main, 1021 const char* main,
1033 const char* package_root, 1022 const char* package_root,
1034 const char* packages_config, 1023 const char* packages_config,
1035 Dart_IsolateFlags* flags, 1024 Dart_IsolateFlags* flags,
1036 char** error, 1025 char** error,
1037 int* exit_code) { 1026 int* exit_code) {
1038 ASSERT(script_uri != NULL); 1027 ASSERT(script_uri != NULL);
1039 1028
1040 #if defined(DART_PRECOMPILED_RUNTIME) 1029 #if defined(DART_PRECOMPILED_RUNTIME)
1041 // AOT: All isolates start from the app snapshot. 1030 // AOT: All isolates start from the app snapshot.
1042 bool skip_library_load = true; 1031 bool isolate_run_app_snapshot = true;
1043 const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data; 1032 const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data;
1044 const uint8_t* isolate_snapshot_instructions = 1033 const uint8_t* isolate_snapshot_instructions =
1045 app_isolate_snapshot_instructions; 1034 app_isolate_snapshot_instructions;
1046 #else 1035 #else
1047 // JIT: Service isolate uses the core libraries snapshot. 1036 // JIT: Service isolate uses the core libraries snapshot.
1048 bool skip_library_load = false; 1037 bool isolate_run_app_snapshot = false;
1049 const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data; 1038 const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data;
1050 const uint8_t* isolate_snapshot_instructions = 1039 const uint8_t* isolate_snapshot_instructions =
1051 core_isolate_snapshot_instructions; 1040 core_isolate_snapshot_instructions;
1052 #endif // !defined(DART_PRECOMPILED_RUNTIME) 1041 #endif // !defined(DART_PRECOMPILED_RUNTIME)
1053 1042
1054 Dart_Isolate isolate = NULL;
1055 IsolateData* isolate_data = 1043 IsolateData* isolate_data =
1056 new IsolateData(script_uri, package_root, packages_config, NULL); 1044 new IsolateData(script_uri, package_root, packages_config, NULL);
1057 #if defined(DART_PRECOMPILED_RUNTIME) 1045 Dart_Isolate isolate = Dart_CreateIsolate(
1058 isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data, 1046 script_uri, main, isolate_snapshot_data, isolate_snapshot_instructions,
1059 isolate_snapshot_instructions, flags, 1047 flags, isolate_data, error);
1060 isolate_data, error);
1061 #else
1062 if (dfe.UsePlatformBinary()) {
1063 isolate = Dart_CreateIsolateFromKernel(
1064 script_uri, NULL, dfe.kernel_platform(), flags, isolate_data, error);
1065 } else {
1066 isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data,
1067 isolate_snapshot_instructions, flags,
1068 isolate_data, error);
1069 }
1070 #endif // !defined(DART_PRECOMPILED_RUNTIME)
1071 if (isolate == NULL) { 1048 if (isolate == NULL) {
1072 delete isolate_data; 1049 delete isolate_data;
1073 return NULL; 1050 return NULL;
1074 } 1051 }
1075 1052
1076 Dart_EnterScope(); 1053 Dart_EnterScope();
1077 1054
1078 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); 1055 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
1079 CHECK_RESULT(result); 1056 CHECK_RESULT(result);
1080 1057
1081 #if !defined(DART_PRECOMPILED_RUNTIME)
1082 if (dfe.UsePlatformBinary()) {
1083 Dart_Handle library = Dart_LoadKernel(dfe.kernel_vmservice_io());
1084 CHECK_RESULT_CLEANUP(library, isolate_data);
1085 skip_library_load = true;
1086 }
1087 #endif // !defined(DART_PRECOMPILED_RUNTIME)
1088
1089 // Load embedder specific bits and return. 1058 // Load embedder specific bits and return.
1059 bool skip_library_load = isolate_run_app_snapshot;
1090 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port, 1060 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port,
1091 skip_library_load, vm_service_dev_mode, 1061 skip_library_load, vm_service_dev_mode,
1092 trace_loading)) { 1062 trace_loading)) {
1093 *error = strdup(VmService::GetErrorMessage()); 1063 *error = strdup(VmService::GetErrorMessage());
1094 return NULL; 1064 return NULL;
1095 } 1065 }
1096 if (compile_all) { 1066 if (compile_all) {
1097 result = Dart_CompileAll(); 1067 result = Dart_CompileAll();
1098 CHECK_RESULT(result); 1068 CHECK_RESULT(result);
1099 } 1069 }
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 if (gen_snapshot_kind == kAppAOT) { 1825 if (gen_snapshot_kind == kAppAOT) {
1856 vm_options.AddArgument("--precompilation"); 1826 vm_options.AddArgument("--precompilation");
1857 } 1827 }
1858 #if defined(DART_PRECOMPILED_RUNTIME) 1828 #if defined(DART_PRECOMPILED_RUNTIME)
1859 vm_options.AddArgument("--precompilation"); 1829 vm_options.AddArgument("--precompilation");
1860 #endif 1830 #endif
1861 if (gen_snapshot_kind == kAppJIT) { 1831 if (gen_snapshot_kind == kAppJIT) {
1862 Process::SetExitHook(SnapshotOnExitHook); 1832 Process::SetExitHook(SnapshotOnExitHook);
1863 } 1833 }
1864 1834
1865 #if !defined(DART_PRECOMPILED_RUNTIME)
1866 // If a kernel platform binary file is specified, read it. This
1867 // step will become redundant once we have the snapshot version
1868 // of the kernel core/platform libraries.
1869 if (dfe.UsePlatformBinary()) {
1870 if (dfe.ReadPlatform() == NULL) {
1871 Log::PrintErr("The platform binary is not a valid Dart Kernel file.");
1872 Platform::Exit(kErrorExitCode);
1873 }
1874 if (dfe.ReadVMServiceIO() == NULL) {
1875 Log::PrintErr("Could not read dart:vmservice_io binary file.");
1876 Platform::Exit(kErrorExitCode);
1877 }
1878 }
1879 #endif
1880
1881 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); 1835 Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
1882 1836
1883 // Start event handler. 1837 // Start event handler.
1884 TimerUtils::InitOnce(); 1838 TimerUtils::InitOnce();
1885 EventHandler::Start(); 1839 EventHandler::Start();
1886 1840
1887 // Initialize the Dart VM. 1841 // Initialize the Dart VM.
1888 Dart_InitializeParams init_params; 1842 Dart_InitializeParams init_params;
1889 memset(&init_params, 0, sizeof(init_params)); 1843 memset(&init_params, 0, sizeof(init_params));
1890 init_params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION; 1844 init_params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION;
(...skipping 14 matching lines...) Expand all
1905 EventHandler::Stop(); 1859 EventHandler::Stop();
1906 Log::PrintErr("VM initialization failed: %s\n", error); 1860 Log::PrintErr("VM initialization failed: %s\n", error);
1907 free(error); 1861 free(error);
1908 Platform::Exit(kErrorExitCode); 1862 Platform::Exit(kErrorExitCode);
1909 } 1863 }
1910 1864
1911 Dart_SetServiceStreamCallbacks(&ServiceStreamListenCallback, 1865 Dart_SetServiceStreamCallbacks(&ServiceStreamListenCallback,
1912 &ServiceStreamCancelCallback); 1866 &ServiceStreamCancelCallback);
1913 Dart_SetFileModifiedCallback(&FileModifiedCallback); 1867 Dart_SetFileModifiedCallback(&FileModifiedCallback);
1914 1868
1869 #if !defined(DART_PRECOMPILED_RUNTIME)
1870 // If a kernel platform binary file is specified, read it. This
1871 // step will become redundant once we have the snapshot version
1872 // of the kernel core/platform libraries.
1873 if (dfe.UsePlatformBinary()) {
1874 if (dfe.ReadPlatform() == NULL) {
1875 Log::PrintErr("The platform binary is not a valid Dart Kernel file.");
1876 Platform::Exit(kErrorExitCode);
1877 }
1878 }
1879 #endif
1880
1915 // Run the main isolate until we aren't told to restart. 1881 // Run the main isolate until we aren't told to restart.
1916 while (RunMainIsolate(script_name, &dart_options)) { 1882 while (RunMainIsolate(script_name, &dart_options)) {
1917 Log::PrintErr("Restarting VM\n"); 1883 Log::PrintErr("Restarting VM\n");
1918 } 1884 }
1919 1885
1920 // Terminate process exit-code handler. 1886 // Terminate process exit-code handler.
1921 Process::TerminateExitCodeHandler(); 1887 Process::TerminateExitCodeHandler();
1922 1888
1923 error = Dart_Cleanup(); 1889 error = Dart_Cleanup();
1924 if (error != NULL) { 1890 if (error != NULL) {
(...skipping 26 matching lines...) Expand all
1951 Platform::Exit(Process::GlobalExitCode()); 1917 Platform::Exit(Process::GlobalExitCode());
1952 } 1918 }
1953 1919
1954 } // namespace bin 1920 } // namespace bin
1955 } // namespace dart 1921 } // namespace dart
1956 1922
1957 int main(int argc, char** argv) { 1923 int main(int argc, char** argv) {
1958 dart::bin::main(argc, argv); 1924 dart::bin::main(argc, argv);
1959 UNREACHABLE(); 1925 UNREACHABLE();
1960 } 1926 }
OLDNEW
« no previous file with comments | « runtime/bin/dfe.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698