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

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

Issue 456983002: Refactor isolate startup code in preparation for making isolate spawning more truly non-blocking. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/isolate.cc » ('j') | 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_debugger_api.h" 10 #include "include/dart_debugger_api.h"
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 if (Dart_IsError(result)) { 1118 if (Dart_IsError(result)) {
1119 ErrorExit(kErrorExitCode, 1119 ErrorExit(kErrorExitCode,
1120 "Error setting breakpoint at '%s': %s\n", 1120 "Error setting breakpoint at '%s': %s\n",
1121 breakpoint_at, 1121 breakpoint_at,
1122 Dart_GetError(result)); 1122 Dart_GetError(result));
1123 } 1123 }
1124 } 1124 }
1125 1125
1126 // Call _startIsolate in the isolate library to enable dispatching the 1126 // Call _startIsolate in the isolate library to enable dispatching the
1127 // initial startup message. 1127 // initial startup message.
1128 Dart_Handle isolate_args[2]; 1128 const intptr_t kNumIsolateArgs = 7;
1129 isolate_args[0] = main_closure; 1129 Dart_Handle isolate_args[kNumIsolateArgs];
1130 isolate_args[1] = Dart_True(); 1130 isolate_args[0] = Dart_Null(); // no parent port
1131 isolate_args[1] = main_closure; // entryPoint
1132 isolate_args[2] = CreateRuntimeOptions(&dart_options); // args
1133 isolate_args[3] = Dart_Null(); // no message
1134 isolate_args[4] = Dart_True(); // isSpawnUri
1135 isolate_args[5] = Dart_Null(); // no control port
1136 isolate_args[6] = Dart_Null(); // no capabilities
1131 1137
1132 Dart_Handle isolate_lib = Dart_LookupLibrary( 1138 Dart_Handle isolate_lib = Dart_LookupLibrary(
1133 Dart_NewStringFromCString("dart:isolate")); 1139 Dart_NewStringFromCString("dart:isolate"));
1134 result = Dart_Invoke(isolate_lib, 1140 result = Dart_Invoke(isolate_lib,
1135 Dart_NewStringFromCString("_startIsolate"), 1141 Dart_NewStringFromCString("_startIsolate"),
1136 2, isolate_args); 1142 kNumIsolateArgs, isolate_args);
1137
1138 // Setup the arguments in the initial startup message and leave the
1139 // replyTo and message fields empty.
1140 Dart_Handle initial_startup_msg = Dart_NewList(3);
1141 result = Dart_ListSetAt(initial_startup_msg, 1,
1142 CreateRuntimeOptions(&dart_options));
1143 DartExitOnError(result); 1143 DartExitOnError(result);
1144 Dart_Port main_port = Dart_GetMainPortId();
1145 bool posted = Dart_Post(main_port, initial_startup_msg);
1146 if (!posted) {
1147 ErrorExit(kErrorExitCode,
1148 "Failed posting startup message to main "
1149 "isolate control port.");
1150 }
1151 1144
1152 // Keep handling messages until the last active receive port is closed. 1145 // Keep handling messages until the last active receive port is closed.
1153 result = Dart_RunLoop(); 1146 result = Dart_RunLoop();
1154 DartExitOnError(result); 1147 DartExitOnError(result);
1155 } 1148 }
1156 } 1149 }
1157 1150
1158 Dart_ExitScope(); 1151 Dart_ExitScope();
1159 // Shutdown the isolate. 1152 // Shutdown the isolate.
1160 Dart_ShutdownIsolate(); 1153 Dart_ShutdownIsolate();
(...skipping 21 matching lines...) Expand all
1182 exit(Process::GlobalExitCode()); 1175 exit(Process::GlobalExitCode());
1183 } 1176 }
1184 1177
1185 } // namespace bin 1178 } // namespace bin
1186 } // namespace dart 1179 } // namespace dart
1187 1180
1188 int main(int argc, char** argv) { 1181 int main(int argc, char** argv) {
1189 dart::bin::main(argc, argv); 1182 dart::bin::main(argc, argv);
1190 UNREACHABLE(); 1183 UNREACHABLE();
1191 } 1184 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698