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

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

Issue 1291163002: Join embeder threads on Windows. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 va_start(arguments, format); 103 va_start(arguments, format);
104 Log::VPrintErr(format, arguments); 104 Log::VPrintErr(format, arguments);
105 va_end(arguments); 105 va_end(arguments);
106 fflush(stderr); 106 fflush(stderr);
107 107
108 Dart_ExitScope(); 108 Dart_ExitScope();
109 Dart_ShutdownIsolate(); 109 Dart_ShutdownIsolate();
110 110
111 Dart_Cleanup(); 111 Dart_Cleanup();
112 112
113 DebuggerConnectionHandler::StopHandler();
114 EventHandler::Stop();
113 exit(exit_code); 115 exit(exit_code);
114 } 116 }
115 117
116 118
117 // The environment provided through the command line using -D options. 119 // The environment provided through the command line using -D options.
118 static dart::HashMap* environment = NULL; 120 static dart::HashMap* environment = NULL;
119 121
120 static bool IsValidFlag(const char* name, 122 static bool IsValidFlag(const char* name,
121 const char* prefix, 123 const char* prefix,
122 intptr_t prefix_length) { 124 intptr_t prefix_length) {
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 // Initialize the Dart VM. 1033 // Initialize the Dart VM.
1032 if (!Dart_Initialize(vm_isolate_snapshot_buffer, 1034 if (!Dart_Initialize(vm_isolate_snapshot_buffer,
1033 CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate, 1035 CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate,
1034 DartUtils::OpenFile, 1036 DartUtils::OpenFile,
1035 DartUtils::ReadFile, 1037 DartUtils::ReadFile,
1036 DartUtils::WriteFile, 1038 DartUtils::WriteFile,
1037 DartUtils::CloseFile, 1039 DartUtils::CloseFile,
1038 DartUtils::EntropySource)) { 1040 DartUtils::EntropySource)) {
1039 fprintf(stderr, "%s", "VM initialization failed\n"); 1041 fprintf(stderr, "%s", "VM initialization failed\n");
1040 fflush(stderr); 1042 fflush(stderr);
1043 DebuggerConnectionHandler::StopHandler();
1044 EventHandler::Stop();
1041 exit(kErrorExitCode); 1045 exit(kErrorExitCode);
1042 } 1046 }
1043 1047
1044 Dart_RegisterIsolateServiceRequestCallback( 1048 Dart_RegisterIsolateServiceRequestCallback(
1045 "getIO", &ServiceGetIOHandler, NULL); 1049 "getIO", &ServiceGetIOHandler, NULL);
1046 Dart_SetServiceStreamCallbacks(&ServiceStreamListenCallback, 1050 Dart_SetServiceStreamCallbacks(&ServiceStreamListenCallback,
1047 &ServiceStreamCancelCallback); 1051 &ServiceStreamCancelCallback);
1048 1052
1049 // Call CreateIsolateAndSetup which creates an isolate and loads up 1053 // Call CreateIsolateAndSetup which creates an isolate and loads up
1050 // the specified application script. 1054 // the specified application script.
1051 char* error = NULL; 1055 char* error = NULL;
1052 int exit_code = 0; 1056 int exit_code = 0;
1053 char* isolate_name = BuildIsolateName(script_name, "main"); 1057 char* isolate_name = BuildIsolateName(script_name, "main");
1054 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name, 1058 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name,
1055 "main", 1059 "main",
1056 commandline_package_root, 1060 commandline_package_root,
1057 commandline_packages_file, 1061 commandline_packages_file,
1058 NULL, 1062 NULL,
1059 &error, 1063 &error,
1060 &exit_code); 1064 &exit_code);
1061 if (isolate == NULL) { 1065 if (isolate == NULL) {
1062 Log::PrintErr("%s\n", error); 1066 Log::PrintErr("%s\n", error);
1063 free(error); 1067 free(error);
1064 delete [] isolate_name; 1068 delete [] isolate_name;
1069 DebuggerConnectionHandler::StopHandler();
1070 EventHandler::Stop();
1065 exit((exit_code != 0) ? exit_code : kErrorExitCode); 1071 exit((exit_code != 0) ? exit_code : kErrorExitCode);
1066 } 1072 }
1067 delete [] isolate_name; 1073 delete [] isolate_name;
1068 1074
1069 Dart_EnterIsolate(isolate); 1075 Dart_EnterIsolate(isolate);
1070 ASSERT(isolate == Dart_CurrentIsolate()); 1076 ASSERT(isolate == Dart_CurrentIsolate());
1071 ASSERT(isolate != NULL); 1077 ASSERT(isolate != NULL);
1072 Dart_Handle result; 1078 Dart_Handle result;
1073 1079
1074 Dart_EnterScope(); 1080 Dart_EnterScope();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 } 1166 }
1161 1167
1162 Dart_ExitScope(); 1168 Dart_ExitScope();
1163 // Shutdown the isolate. 1169 // Shutdown the isolate.
1164 Dart_ShutdownIsolate(); 1170 Dart_ShutdownIsolate();
1165 // Terminate process exit-code handler. 1171 // Terminate process exit-code handler.
1166 Process::TerminateExitCodeHandler(); 1172 Process::TerminateExitCodeHandler();
1167 1173
1168 Dart_Cleanup(); 1174 Dart_Cleanup();
1169 1175
1176 DebuggerConnectionHandler::StopHandler();
1177 EventHandler::Stop();
1178
1170 // Free copied argument strings if converted. 1179 // Free copied argument strings if converted.
1171 if (argv_converted) { 1180 if (argv_converted) {
1172 for (int i = 0; i < argc; i++) free(argv[i]); 1181 for (int i = 0; i < argc; i++) free(argv[i]);
1173 } 1182 }
1174 1183
1175 // Free environment if any. 1184 // Free environment if any.
1176 if (environment != NULL) { 1185 if (environment != NULL) {
1177 for (HashMap::Entry* p = environment->Start(); 1186 for (HashMap::Entry* p = environment->Start();
1178 p != NULL; 1187 p != NULL;
1179 p = environment->Next(p)) { 1188 p = environment->Next(p)) {
1180 free(p->key); 1189 free(p->key);
1181 free(p->value); 1190 free(p->value);
1182 } 1191 }
1183 delete environment; 1192 delete environment;
1184 } 1193 }
1185 1194
1186 exit(Process::GlobalExitCode()); 1195 exit(Process::GlobalExitCode());
1187 } 1196 }
1188 1197
1189 } // namespace bin 1198 } // namespace bin
1190 } // namespace dart 1199 } // namespace dart
1191 1200
1192 int main(int argc, char** argv) { 1201 int main(int argc, char** argv) {
1193 dart::bin::main(argc, argv); 1202 dart::bin::main(argc, argv);
1194 UNREACHABLE(); 1203 UNREACHABLE();
1195 } 1204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698