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

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: simplify locking Created 5 years, 3 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 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 // Initialize the Dart VM. 1037 // Initialize the Dart VM.
1036 if (!Dart_Initialize(vm_isolate_snapshot_buffer, 1038 if (!Dart_Initialize(vm_isolate_snapshot_buffer,
1037 CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate, 1039 CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate,
1038 DartUtils::OpenFile, 1040 DartUtils::OpenFile,
1039 DartUtils::ReadFile, 1041 DartUtils::ReadFile,
1040 DartUtils::WriteFile, 1042 DartUtils::WriteFile,
1041 DartUtils::CloseFile, 1043 DartUtils::CloseFile,
1042 DartUtils::EntropySource)) { 1044 DartUtils::EntropySource)) {
1043 fprintf(stderr, "%s", "VM initialization failed\n"); 1045 fprintf(stderr, "%s", "VM initialization failed\n");
1044 fflush(stderr); 1046 fflush(stderr);
1047 DebuggerConnectionHandler::StopHandler();
1048 EventHandler::Stop();
1045 exit(kErrorExitCode); 1049 exit(kErrorExitCode);
1046 } 1050 }
1047 1051
1048 Dart_RegisterIsolateServiceRequestCallback( 1052 Dart_RegisterIsolateServiceRequestCallback(
1049 "getIO", &ServiceGetIOHandler, NULL); 1053 "getIO", &ServiceGetIOHandler, NULL);
1050 Dart_SetServiceStreamCallbacks(&ServiceStreamListenCallback, 1054 Dart_SetServiceStreamCallbacks(&ServiceStreamListenCallback,
1051 &ServiceStreamCancelCallback); 1055 &ServiceStreamCancelCallback);
1052 1056
1053 // Call CreateIsolateAndSetup which creates an isolate and loads up 1057 // Call CreateIsolateAndSetup which creates an isolate and loads up
1054 // the specified application script. 1058 // the specified application script.
1055 char* error = NULL; 1059 char* error = NULL;
1056 int exit_code = 0; 1060 int exit_code = 0;
1057 char* isolate_name = BuildIsolateName(script_name, "main"); 1061 char* isolate_name = BuildIsolateName(script_name, "main");
1058 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name, 1062 Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name,
1059 "main", 1063 "main",
1060 commandline_package_root, 1064 commandline_package_root,
1061 commandline_packages_file, 1065 commandline_packages_file,
1062 NULL, 1066 NULL,
1063 &error, 1067 &error,
1064 &exit_code); 1068 &exit_code);
1065 if (isolate == NULL) { 1069 if (isolate == NULL) {
1066 Log::PrintErr("%s\n", error); 1070 Log::PrintErr("%s\n", error);
1067 free(error); 1071 free(error);
1068 delete [] isolate_name; 1072 delete [] isolate_name;
1073 DebuggerConnectionHandler::StopHandler();
1074 EventHandler::Stop();
1069 exit((exit_code != 0) ? exit_code : kErrorExitCode); 1075 exit((exit_code != 0) ? exit_code : kErrorExitCode);
1070 } 1076 }
1071 delete [] isolate_name; 1077 delete [] isolate_name;
1072 1078
1073 Dart_EnterIsolate(isolate); 1079 Dart_EnterIsolate(isolate);
1074 ASSERT(isolate == Dart_CurrentIsolate()); 1080 ASSERT(isolate == Dart_CurrentIsolate());
1075 ASSERT(isolate != NULL); 1081 ASSERT(isolate != NULL);
1076 Dart_Handle result; 1082 Dart_Handle result;
1077 1083
1078 Dart_EnterScope(); 1084 Dart_EnterScope();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 } 1170 }
1165 1171
1166 Dart_ExitScope(); 1172 Dart_ExitScope();
1167 // Shutdown the isolate. 1173 // Shutdown the isolate.
1168 Dart_ShutdownIsolate(); 1174 Dart_ShutdownIsolate();
1169 // Terminate process exit-code handler. 1175 // Terminate process exit-code handler.
1170 Process::TerminateExitCodeHandler(); 1176 Process::TerminateExitCodeHandler();
1171 1177
1172 Dart_Cleanup(); 1178 Dart_Cleanup();
1173 1179
1180 DebuggerConnectionHandler::StopHandler();
1181 EventHandler::Stop();
1182
1174 // Free copied argument strings if converted. 1183 // Free copied argument strings if converted.
1175 if (argv_converted) { 1184 if (argv_converted) {
1176 for (int i = 0; i < argc; i++) free(argv[i]); 1185 for (int i = 0; i < argc; i++) free(argv[i]);
1177 } 1186 }
1178 1187
1179 // Free environment if any. 1188 // Free environment if any.
1180 if (environment != NULL) { 1189 if (environment != NULL) {
1181 for (HashMap::Entry* p = environment->Start(); 1190 for (HashMap::Entry* p = environment->Start();
1182 p != NULL; 1191 p != NULL;
1183 p = environment->Next(p)) { 1192 p = environment->Next(p)) {
1184 free(p->key); 1193 free(p->key);
1185 free(p->value); 1194 free(p->value);
1186 } 1195 }
1187 delete environment; 1196 delete environment;
1188 } 1197 }
1189 1198
1190 exit(Process::GlobalExitCode()); 1199 exit(Process::GlobalExitCode());
1191 } 1200 }
1192 1201
1193 } // namespace bin 1202 } // namespace bin
1194 } // namespace dart 1203 } // namespace dart
1195 1204
1196 int main(int argc, char** argv) { 1205 int main(int argc, char** argv) {
1197 dart::bin::main(argc, argv); 1206 dart::bin::main(argc, argv);
1198 UNREACHABLE(); 1207 UNREACHABLE();
1199 } 1208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698