| OLD | NEW |
| 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 import "dart:collection" show HashMap; | 5 import "dart:collection" show HashMap; |
| 6 import "dart:_internal"; | 6 import "dart:_internal"; |
| 7 | 7 |
| 8 patch class ReceivePort { | 8 patch class ReceivePort { |
| 9 /* patch */ factory ReceivePort() = _ReceivePortImpl; | 9 /* patch */ factory ReceivePort() = _ReceivePortImpl; |
| 10 | 10 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } catch (e, st) { | 296 } catch (e, st) { |
| 297 if (readyPort != null) { | 297 if (readyPort != null) { |
| 298 readyPort.close(); | 298 readyPort.close(); |
| 299 } | 299 } |
| 300 return new Future<Isolate>.error(e, st); | 300 return new Future<Isolate>.error(e, st); |
| 301 }; | 301 }; |
| 302 } | 302 } |
| 303 | 303 |
| 304 /* patch */ static Future<Isolate> spawnUri( | 304 /* patch */ static Future<Isolate> spawnUri( |
| 305 Uri uri, List<String> args, var message, | 305 Uri uri, List<String> args, var message, |
| 306 { bool paused: false, Uri packageRoot }) { | 306 { bool paused: false, bool checked, Uri packageRoot }) { |
| 307 // `paused` isn't handled yet. | |
| 308 RawReceivePort readyPort; | 307 RawReceivePort readyPort; |
| 309 try { | 308 try { |
| 310 // The VM will invoke [_startIsolate] and not `main`. | 309 // The VM will invoke [_startIsolate] and not `main`. |
| 311 readyPort = new RawReceivePort(); | 310 readyPort = new RawReceivePort(); |
| 312 var packageRootString = | 311 var packageRootString = |
| 313 (packageRoot == null) ? null : packageRoot.toString(); | 312 (packageRoot == null) ? null : packageRoot.toString(); |
| 314 _spawnUri(readyPort.sendPort, uri.toString(), args, message, | 313 _spawnUri(readyPort.sendPort, uri.toString(), args, message, |
| 315 paused, packageRootString); | 314 paused, checked, packageRootString); |
| 316 Completer completer = new Completer<Isolate>.sync(); | 315 Completer completer = new Completer<Isolate>.sync(); |
| 317 readyPort.handler = (readyMessage) { | 316 readyPort.handler = (readyMessage) { |
| 318 readyPort.close(); | 317 readyPort.close(); |
| 319 assert(readyMessage is List); | 318 assert(readyMessage is List); |
| 320 assert(readyMessage.length == 2); | 319 assert(readyMessage.length == 2); |
| 321 SendPort controlPort = readyMessage[0]; | 320 SendPort controlPort = readyMessage[0]; |
| 322 List capabilities = readyMessage[1]; | 321 List capabilities = readyMessage[1]; |
| 323 completer.complete(new Isolate(controlPort, | 322 completer.complete(new Isolate(controlPort, |
| 324 pauseCapability: capabilities[0], | 323 pauseCapability: capabilities[0], |
| 325 terminateCapability: capabilities[1])); | 324 terminateCapability: capabilities[1])); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 347 static const _DEL_ERROR = 8; | 346 static const _DEL_ERROR = 8; |
| 348 static const _ERROR_FATAL = 9; | 347 static const _ERROR_FATAL = 9; |
| 349 | 348 |
| 350 | 349 |
| 351 static void _spawnFunction(SendPort readyPort, Function topLevelFunction, | 350 static void _spawnFunction(SendPort readyPort, Function topLevelFunction, |
| 352 var message, bool paused) | 351 var message, bool paused) |
| 353 native "Isolate_spawnFunction"; | 352 native "Isolate_spawnFunction"; |
| 354 | 353 |
| 355 static void _spawnUri(SendPort readyPort, String uri, | 354 static void _spawnUri(SendPort readyPort, String uri, |
| 356 List<String> args, var message, | 355 List<String> args, var message, |
| 357 bool paused, String packageRoot) | 356 bool paused, bool checked, String packageRoot) |
| 358 native "Isolate_spawnUri"; | 357 native "Isolate_spawnUri"; |
| 359 | 358 |
| 360 static void _sendOOB(port, msg) native "Isolate_sendOOB"; | 359 static void _sendOOB(port, msg) native "Isolate_sendOOB"; |
| 361 | 360 |
| 362 /* patch */ void _pause(Capability resumeCapability) { | 361 /* patch */ void _pause(Capability resumeCapability) { |
| 363 var msg = new List(4) | 362 var msg = new List(4) |
| 364 ..[0] = 0 // Make room for OOB message type. | 363 ..[0] = 0 // Make room for OOB message type. |
| 365 ..[1] = _PAUSE | 364 ..[1] = _PAUSE |
| 366 ..[2] = pauseCapability | 365 ..[2] = pauseCapability |
| 367 ..[3] = resumeCapability; | 366 ..[3] = resumeCapability; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 static Isolate _getCurrentIsolate() { | 442 static Isolate _getCurrentIsolate() { |
| 444 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); | 443 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); |
| 445 return new Isolate(portAndCapabilities[0], | 444 return new Isolate(portAndCapabilities[0], |
| 446 pauseCapability: portAndCapabilities[1], | 445 pauseCapability: portAndCapabilities[1], |
| 447 terminateCapability: portAndCapabilities[2]); | 446 terminateCapability: portAndCapabilities[2]); |
| 448 } | 447 } |
| 449 | 448 |
| 450 static List _getPortAndCapabilitiesOfCurrentIsolate() | 449 static List _getPortAndCapabilitiesOfCurrentIsolate() |
| 451 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; | 450 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate"; |
| 452 } | 451 } |
| OLD | NEW |