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

Side by Side Diff: runtime/lib/isolate_patch.dart

Issue 47233002: - Revert parts of r29315 while attempting to reproduce (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 | « runtime/lib/isolate.cc ('k') | runtime/vm/bootstrap_natives.h » ('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 patch class ReceivePort { 5 patch class ReceivePort {
6 /* patch */ factory ReceivePort() = _ReceivePortImpl; 6 /* patch */ factory ReceivePort() = _ReceivePortImpl;
7 7
8 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = 8 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) =
9 _ReceivePortImpl.fromRawReceivePort; 9 _ReceivePortImpl.fromRawReceivePort;
10 } 10 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 // Forward the implementation of sending messages to the VM. Only port ids 146 // Forward the implementation of sending messages to the VM. Only port ids
147 // are being handed to the VM. 147 // are being handed to the VM.
148 static _sendInternal(int sendId, int replyId, var message) 148 static _sendInternal(int sendId, int replyId, var message)
149 native "SendPortImpl_sendInternal_"; 149 native "SendPortImpl_sendInternal_";
150 150
151 final int _id; 151 final int _id;
152 } 152 }
153 153
154 _getPortInternal() native "isolate_getPortInternal";
155
154 typedef _MainFunction(); 156 typedef _MainFunction();
155 typedef _MainFunctionArgs(args); 157 typedef _MainFunctionArgs(args);
156 typedef _MainFunctionArgsMessage(args, message); 158 typedef _MainFunctionArgsMessage(args, message);
157 159
158 /** 160 /**
159 * Takes the real entry point as argument and invokes it with the initial 161 * Takes the real entry point as argument and invokes it with the initial
160 * message. 162 * message.
161 * 163 *
162 * The initial message is received through the control port variable. 164 * The initial message is (currently) received through the global port variable.
163 */ 165 */
164 void _startIsolate(Function entryPoint, bool isSpawnUri) { 166 void _startIsolate(Function entryPoint, bool isSpawnUri) {
165 ignoreHandler(message) { 167 Isolate._port.first.then((message) {
166 // Messages on the current Isolate's control port are dropped after the
167 // initial startup message has been received.
168 }
169
170 isolateStartHandler(message) {
171 // We received the initial startup message. Ignore all further messages.
172 Isolate._self.handler = ignoreHandler;
173
174 SendPort replyTo = message[0]; 168 SendPort replyTo = message[0];
175 // TODO(floitsch): don't send ok-message if we can't find the entry point. 169 // TODO(floitsch): don't send ok-message if we can't find the entry point.
176 replyTo.send("started"); 170 replyTo.send("started");
177 if (isSpawnUri) { 171 if (isSpawnUri) {
178 assert(message.length == 3); 172 assert(message.length == 3);
179 List<String> args = message[1]; 173 List<String> args = message[1];
180 var isolateMessage = message[2]; 174 var isolateMessage = message[2];
181 if (entryPoint is _MainFunctionArgsMessage) { 175 if (entryPoint is _MainFunctionArgsMessage) {
182 entryPoint(args, isolateMessage); 176 entryPoint(args, isolateMessage);
183 } else if (entryPoint is _MainFunctionArgs) { 177 } else if (entryPoint is _MainFunctionArgs) {
184 entryPoint(args); 178 entryPoint(args);
185 } else { 179 } else {
186 entryPoint(); 180 entryPoint();
187 } 181 }
188 } else { 182 } else {
189 assert(message.length == 2); 183 assert(message.length == 2);
190 var entryMessage = message[1]; 184 var entryMessage = message[1];
191 entryPoint(entryMessage); 185 entryPoint(entryMessage);
192 } 186 }
193 } 187 });
194
195 Isolate._self.handler = isolateStartHandler;
196 } 188 }
197 189
198 patch class Isolate { 190 patch class Isolate {
199 /* patch */ static Future<Isolate> spawn( 191 /* patch */ static Future<Isolate> spawn(
200 void entryPoint(message), var message) { 192 void entryPoint(message), var message) {
201 Completer completer = new Completer<Isolate>.sync(); 193 Completer completer = new Completer<Isolate>.sync();
202 try { 194 try {
203 // The VM will invoke [_startIsolate] with entryPoint as argument. 195 // The VM will invoke [_startIsolate] with entryPoint as argument.
204 SendPort controlPort = _spawnFunction(entryPoint); 196 SendPort controlPort = _spawnFunction(entryPoint);
205 RawReceivePort readyPort = new RawReceivePort(); 197 RawReceivePort readyPort = new RawReceivePort();
(...skipping 23 matching lines...) Expand all
229 readyPort.close(); 221 readyPort.close();
230 completer.complete(new Isolate._fromControlPort(controlPort)); 222 completer.complete(new Isolate._fromControlPort(controlPort));
231 }; 223 };
232 } catch(e, st) { 224 } catch(e, st) {
233 // TODO(floitsch): we want errors to go into the returned future. 225 // TODO(floitsch): we want errors to go into the returned future.
234 rethrow; 226 rethrow;
235 }; 227 };
236 return completer.future; 228 return completer.future;
237 } 229 }
238 230
239 static final RawReceivePort _self = _mainPort; 231 static final ReceivePort _port =
240 static RawReceivePort get _mainPort native "Isolate_mainPort"; 232 new ReceivePort.fromRawReceivePort(_getPortInternal());
241 233
242 static SendPort _spawnFunction(Function topLevelFunction) 234 static SendPort _spawnFunction(Function topLevelFunction)
243 native "Isolate_spawnFunction"; 235 native "isolate_spawnFunction";
244 236
245 static SendPort _spawnUri(String uri) native "Isolate_spawnUri"; 237 static SendPort _spawnUri(String uri) native "isolate_spawnUri";
246 } 238 }
OLDNEW
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698