| 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 | 6 |
| 7 patch class ReceivePort { | 7 patch class ReceivePort { |
| 8 /* patch */ factory ReceivePort() = _ReceivePortImpl; | 8 /* patch */ factory ReceivePort() = _ReceivePortImpl; |
| 9 | 9 |
| 10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = | 10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 readyPort.close(); | 270 readyPort.close(); |
| 271 } | 271 } |
| 272 return new Future<Isolate>.error(e, st); | 272 return new Future<Isolate>.error(e, st); |
| 273 }; | 273 }; |
| 274 } | 274 } |
| 275 | 275 |
| 276 /* patch */ static Future<Isolate> spawnUri( | 276 /* patch */ static Future<Isolate> spawnUri( |
| 277 Uri uri, List<String> args, var message, | 277 Uri uri, List<String> args, var message, |
| 278 { bool paused: false, Uri packageRoot }) { | 278 { bool paused: false, Uri packageRoot }) { |
| 279 // `paused` isn't handled yet. | 279 // `paused` isn't handled yet. |
| 280 // `packageRoot` isn't handled yet. | |
| 281 if (packageRoot != null) throw new UnimplementedError("packageRoot"); | |
| 282 RawReceivePort readyPort; | 280 RawReceivePort readyPort; |
| 283 try { | 281 try { |
| 284 // The VM will invoke [_startIsolate] and not `main`. | 282 // The VM will invoke [_startIsolate] and not `main`. |
| 285 readyPort = new RawReceivePort(); | 283 readyPort = new RawReceivePort(); |
| 286 _spawnUri(readyPort.sendPort, uri.toString(), args, message); | 284 var packageRootString; |
| 285 if (packageRoot != null) { |
| 286 packageRootString = packageRoot.toString(); |
| 287 } |
| 288 _spawnUri( |
| 289 readyPort.sendPort, uri.toString(), args, message, packageRootString); |
| 287 Completer completer = new Completer<Isolate>.sync(); | 290 Completer completer = new Completer<Isolate>.sync(); |
| 288 readyPort.handler = (readyMessage) { | 291 readyPort.handler = (readyMessage) { |
| 289 readyPort.close(); | 292 readyPort.close(); |
| 290 assert(readyMessage is List); | 293 assert(readyMessage is List); |
| 291 assert(readyMessage.length == 2); | 294 assert(readyMessage.length == 2); |
| 292 SendPort controlPort = readyMessage[0]; | 295 SendPort controlPort = readyMessage[0]; |
| 293 List capabilities = readyMessage[1]; | 296 List capabilities = readyMessage[1]; |
| 294 completer.complete(new Isolate(controlPort, | 297 completer.complete(new Isolate(controlPort, |
| 295 pauseCapability: capabilities[0], | 298 pauseCapability: capabilities[0], |
| 296 terminateCapability: capabilities[1])); | 299 terminateCapability: capabilities[1])); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 309 // These values need to be kept in sync with the class IsolateMessageHandler | 312 // These values need to be kept in sync with the class IsolateMessageHandler |
| 310 // in vm/isolate.cc. | 313 // in vm/isolate.cc. |
| 311 static const _PAUSE = 1; | 314 static const _PAUSE = 1; |
| 312 static const _RESUME = 2; | 315 static const _RESUME = 2; |
| 313 | 316 |
| 314 static SendPort _spawnFunction(SendPort readyPort, Function topLevelFunction, | 317 static SendPort _spawnFunction(SendPort readyPort, Function topLevelFunction, |
| 315 var message) | 318 var message) |
| 316 native "Isolate_spawnFunction"; | 319 native "Isolate_spawnFunction"; |
| 317 | 320 |
| 318 static SendPort _spawnUri(SendPort readyPort, String uri, | 321 static SendPort _spawnUri(SendPort readyPort, String uri, |
| 319 List<String> args, var message) | 322 List<String> args, var message, |
| 323 String packageRoot) |
| 320 native "Isolate_spawnUri"; | 324 native "Isolate_spawnUri"; |
| 321 | 325 |
| 322 static void _sendOOB(port, msg) native "Isolate_sendOOB"; | 326 static void _sendOOB(port, msg) native "Isolate_sendOOB"; |
| 323 | 327 |
| 324 /* patch */ void _pause(Capability resumeCapability) { | 328 /* patch */ void _pause(Capability resumeCapability) { |
| 325 var msg = new List(4) | 329 var msg = new List(4) |
| 326 ..[0] = 0 // Make room for OOM message type. | 330 ..[0] = 0 // Make room for OOM message type. |
| 327 ..[1] = _PAUSE | 331 ..[1] = _PAUSE |
| 328 ..[2] = pauseCapability | 332 ..[2] = pauseCapability |
| 329 ..[3] = resumeCapability; | 333 ..[3] = resumeCapability; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 360 } | 364 } |
| 361 | 365 |
| 362 /* patch */ void addErrorListener(SendPort port) { | 366 /* patch */ void addErrorListener(SendPort port) { |
| 363 throw new UnsupportedError("addErrorListener"); | 367 throw new UnsupportedError("addErrorListener"); |
| 364 } | 368 } |
| 365 | 369 |
| 366 /* patch */ void removeErrorListener(SendPort port) { | 370 /* patch */ void removeErrorListener(SendPort port) { |
| 367 throw new UnsupportedError("removeErrorListener"); | 371 throw new UnsupportedError("removeErrorListener"); |
| 368 } | 372 } |
| 369 } | 373 } |
| OLD | NEW |