| 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 library _isolate_helper; | 5 library _isolate_helper; |
| 6 | 6 |
| 7 import 'dart:_js_embedded_names' show | 7 import 'dart:_js_embedded_names' show |
| 8 CLASS_ID_EXTRACTOR, | 8 CLASS_ID_EXTRACTOR, |
| 9 CLASS_FIELDS_EXTRACTOR, | 9 CLASS_FIELDS_EXTRACTOR, |
| 10 CREATE_NEW_ISOLATE, |
| 10 CURRENT_SCRIPT, | 11 CURRENT_SCRIPT, |
| 11 GLOBAL_FUNCTIONS, | 12 GLOBAL_FUNCTIONS, |
| 12 INITIALIZE_EMPTY_INSTANCE, | 13 INITIALIZE_EMPTY_INSTANCE, |
| 13 INSTANCE_FROM_CLASS_ID; | 14 INSTANCE_FROM_CLASS_ID; |
| 14 | 15 |
| 15 import 'dart:async'; | 16 import 'dart:async'; |
| 16 import 'dart:collection' show Queue, HashMap; | 17 import 'dart:collection' show Queue, HashMap; |
| 17 import 'dart:isolate'; | 18 import 'dart:isolate'; |
| 18 import 'dart:_native_typed_data' show NativeByteBuffer, NativeTypedData; | 19 import 'dart:_native_typed_data' show NativeByteBuffer, NativeTypedData; |
| 19 | 20 |
| 20 import 'dart:_js_helper' show | 21 import 'dart:_js_helper' show |
| 21 Closure, | 22 Closure, |
| 22 InternalMap, | 23 InternalMap, |
| 23 Null, | 24 Null, |
| 24 Primitives, | 25 Primitives, |
| 25 convertDartClosureToJS, | 26 convertDartClosureToJS, |
| 26 random64, | 27 random64, |
| 27 requiresPreamble; | 28 requiresPreamble; |
| 28 | 29 |
| 29 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, | 30 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, |
| 30 JS, | 31 JS, |
| 31 JS_CREATE_ISOLATE, | |
| 32 JS_CURRENT_ISOLATE_CONTEXT, | 32 JS_CURRENT_ISOLATE_CONTEXT, |
| 33 JS_CURRENT_ISOLATE, | 33 JS_CURRENT_ISOLATE, |
| 34 JS_EMBEDDED_GLOBAL, | 34 JS_EMBEDDED_GLOBAL, |
| 35 JS_SET_CURRENT_ISOLATE, | 35 JS_SET_CURRENT_ISOLATE, |
| 36 IsolateContext; | 36 IsolateContext; |
| 37 | 37 |
| 38 import 'dart:_interceptors' show Interceptor, | 38 import 'dart:_interceptors' show Interceptor, |
| 39 JSArray, | 39 JSArray, |
| 40 JSExtendableArray, | 40 JSExtendableArray, |
| 41 JSFixedArray, | 41 JSFixedArray, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 final int id = _globalState.nextIsolateId++; | 282 final int id = _globalState.nextIsolateId++; |
| 283 | 283 |
| 284 /** Registry of receive ports currently active on this isolate. */ | 284 /** Registry of receive ports currently active on this isolate. */ |
| 285 final Map<int, RawReceivePortImpl> ports = new Map<int, RawReceivePortImpl>(); | 285 final Map<int, RawReceivePortImpl> ports = new Map<int, RawReceivePortImpl>(); |
| 286 | 286 |
| 287 /** Registry of weak receive ports currently active on this isolate. */ | 287 /** Registry of weak receive ports currently active on this isolate. */ |
| 288 final Set<int> weakPorts = new Set<int>(); | 288 final Set<int> weakPorts = new Set<int>(); |
| 289 | 289 |
| 290 /** Holds isolate globals (statics and top-level properties). */ | 290 /** Holds isolate globals (statics and top-level properties). */ |
| 291 // native object containing all globals of an isolate. | 291 // native object containing all globals of an isolate. |
| 292 final isolateStatics = JS_CREATE_ISOLATE(); | 292 final isolateStatics = |
| 293 JS('', "#()", JS_EMBEDDED_GLOBAL('', CREATE_NEW_ISOLATE)); |
| 293 | 294 |
| 294 final RawReceivePortImpl controlPort = new RawReceivePortImpl._controlPort(); | 295 final RawReceivePortImpl controlPort = new RawReceivePortImpl._controlPort(); |
| 295 | 296 |
| 296 final Capability pauseCapability = new Capability(); | 297 final Capability pauseCapability = new Capability(); |
| 297 final Capability terminateCapability = new Capability(); // License to kill. | 298 final Capability terminateCapability = new Capability(); // License to kill. |
| 298 | 299 |
| 299 /// Boolean flag set when the initial method of the isolate has been executed. | 300 /// Boolean flag set when the initial method of the isolate has been executed. |
| 300 /// | 301 /// |
| 301 /// Used to avoid considering the isolate dead when it has no open | 302 /// Used to avoid considering the isolate dead when it has no open |
| 302 /// receive ports and no scheduled timers, because it hasn't had time to | 303 /// receive ports and no scheduled timers, because it hasn't had time to |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 } | 1446 } |
| 1446 | 1447 |
| 1447 bool operator==(Object other) { | 1448 bool operator==(Object other) { |
| 1448 if (identical(other, this)) return true; | 1449 if (identical(other, this)) return true; |
| 1449 if (other is CapabilityImpl) { | 1450 if (other is CapabilityImpl) { |
| 1450 return identical(_id, other._id); | 1451 return identical(_id, other._id); |
| 1451 } | 1452 } |
| 1452 return false; | 1453 return false; |
| 1453 } | 1454 } |
| 1454 } | 1455 } |
| OLD | NEW |