| OLD | NEW |
| 1 var _isolate_helper; | 1 var _isolate_helper; |
| 2 (function(exports) { | 2 (function(exports) { |
| 3 'use strict'; | 3 'use strict'; |
| 4 // Function _serializeMessage: (dynamic) → dynamic | 4 // Function _serializeMessage: (dynamic) → dynamic |
| 5 function _serializeMessage(message) { | 5 function _serializeMessage(message) { |
| 6 return new _Serializer().serialize(message); | 6 return new _Serializer().serialize(message); |
| 7 } | 7 } |
| 8 // Function _deserializeMessage: (dynamic) → dynamic | 8 // Function _deserializeMessage: (dynamic) → dynamic |
| 9 function _deserializeMessage(message) { | 9 function _deserializeMessage(message) { |
| 10 return new _Deserializer().deserialize(message); | 10 return new _Deserializer().deserialize(message); |
| 11 } | 11 } |
| 12 // Function _clone: (dynamic) → dynamic | 12 // Function _clone: (dynamic) → dynamic |
| 13 function _clone(message) { | 13 function _clone(message) { |
| 14 let serializer = new _Serializer({serializeSendPorts: false}); | 14 let serializer = new _Serializer({serializeSendPorts: false}); |
| 15 let deserializer = new _Deserializer(); | 15 let deserializer = new _Deserializer(); |
| 16 return deserializer.deserialize(serializer.serialize(message)); | 16 return deserializer.deserialize(serializer.serialize(message)); |
| 17 } | 17 } |
| 18 let _serializeSendPorts = Symbol('_serializeSendPorts'); | 18 let _serializeSendPorts = Symbol('_serializeSendPorts'); |
| 19 let _workerId = Symbol('_workerId'); | 19 let _workerId = Symbol('_workerId'); |
| 20 let _isolateId = Symbol('_isolateId'); | 20 let _isolateId = Symbol('_isolateId'); |
| 21 let _receivePortId = Symbol('_receivePortId'); | 21 let _receivePortId = Symbol('_receivePortId'); |
| 22 let _id = Symbol('_id'); | 22 let _id = Symbol('_id'); |
| 23 let _receivePort = Symbol('_receivePort'); | 23 let _receivePort = Symbol('_receivePort'); |
| 24 let _getJSFunctionName = Symbol('_getJSFunctionName'); | |
| 25 class _Serializer extends core.Object { | 24 class _Serializer extends core.Object { |
| 26 _Serializer(opts) { | 25 _Serializer(opts) { |
| 27 let serializeSendPorts = opts && 'serializeSendPorts' in opts ? opts.seria
lizeSendPorts : true; | 26 let serializeSendPorts = opts && 'serializeSendPorts' in opts ? opts.seria
lizeSendPorts : true; |
| 28 this.serializedObjectIds = new core.Map$(dart.dynamic, core.int).identity(
); | 27 this.serializedObjectIds = new core.Map$(dart.dynamic, core.int).identity(
); |
| 29 this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); | 28 this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); |
| 30 } | 29 } |
| 31 serialize(x) { | 30 serialize(x) { |
| 32 if (this.isPrimitive(x)) | 31 if (this.isPrimitive(x)) |
| 33 return this.serializePrimitive(x); | 32 return this.serializePrimitive(x); |
| 34 let serializationId = this.serializedObjectIds.get(x); | 33 let serializationId = this.serializedObjectIds.get(x); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 if (this[_serializeSendPorts]) { | 134 if (this[_serializeSendPorts]) { |
| 136 let workerId = exports._globalState.currentManagerId; | 135 let workerId = exports._globalState.currentManagerId; |
| 137 return ['sendport', workerId, x[_isolateId], x[_receivePort][_id]]; | 136 return ['sendport', workerId, x[_isolateId], x[_receivePort][_id]]; |
| 138 } | 137 } |
| 139 return ['raw sendport', x]; | 138 return ['raw sendport', x]; |
| 140 } | 139 } |
| 141 serializeCapability(x) { | 140 serializeCapability(x) { |
| 142 return ['capability', x[_id]]; | 141 return ['capability', x[_id]]; |
| 143 } | 142 } |
| 144 serializeClosure(x) { | 143 serializeClosure(x) { |
| 145 let name = IsolateNatives[_getJSFunctionName](x); | 144 let name = IsolateNatives._getJSFunctionName(x); |
| 146 if (name == null) { | 145 if (name == null) { |
| 147 this.unsupported(x, "Closures can't be transmitted:"); | 146 this.unsupported(x, "Closures can't be transmitted:"); |
| 148 } | 147 } |
| 149 return ['function', name]; | 148 return ['function', name]; |
| 150 } | 149 } |
| 151 serializeDartObject(x) { | 150 serializeDartObject(x) { |
| 152 let classExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_n
ames.CLASS_ID_EXTRACTOR); | 151 let classExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_n
ames.CLASS_ID_EXTRACTOR); |
| 153 let fieldsExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_
names.CLASS_FIELDS_EXTRACTOR); | 152 let fieldsExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_
names.CLASS_FIELDS_EXTRACTOR); |
| 154 let classId = classExtractor(x); | 153 let classId = classExtractor(x); |
| 155 let fields = dart.as(fieldsExtractor(x), core.List); | 154 let fields = dart.as(fieldsExtractor(x), core.List); |
| 156 return ['dart', classId, this.serializeArrayInPlace(dart.as(fields, _inter
ceptors.JSArray))]; | 155 return ['dart', classId, this.serializeArrayInPlace(dart.as(fields, _inter
ceptors.JSArray))]; |
| 157 } | 156 } |
| 158 } | 157 } |
| 159 let _adjustSendPorts = Symbol('_adjustSendPorts'); | 158 let _adjustSendPorts = Symbol('_adjustSendPorts'); |
| 160 let _getJSFunctionFromName = Symbol('_getJSFunctionFromName'); | |
| 161 class _Deserializer extends core.Object { | 159 class _Deserializer extends core.Object { |
| 162 _Deserializer(opts) { | 160 _Deserializer(opts) { |
| 163 let adjustSendPorts = opts && 'adjustSendPorts' in opts ? opts.adjustSendP
orts : true; | 161 let adjustSendPorts = opts && 'adjustSendPorts' in opts ? opts.adjustSendP
orts : true; |
| 164 this.deserializedObjects = new core.List(); | 162 this.deserializedObjects = new core.List(); |
| 165 this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); | 163 this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); |
| 166 } | 164 } |
| 167 deserialize(x) { | 165 deserialize(x) { |
| 168 if (this.isPrimitive(x)) | 166 if (this.isPrimitive(x)) |
| 169 return this.deserializePrimitive(x); | 167 return this.deserializePrimitive(x); |
| 170 if (!dart.is(x, _interceptors.JSArray)) | 168 if (!dart.is(x, _interceptors.JSArray)) |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 let o = {}; | 324 let o = {}; |
| 327 this.deserializedObjects[core.$add](o); | 325 this.deserializedObjects[core.$add](o); |
| 328 for (let i = 0; dart.notNull(i) < dart.notNull(keys[core.$length]); i = da
rt.notNull(i) + 1) { | 326 for (let i = 0; dart.notNull(i) < dart.notNull(keys[core.$length]); i = da
rt.notNull(i) + 1) { |
| 329 o[keys[core.$get](i)] = this.deserialize(values[core.$get](i)); | 327 o[keys[core.$get](i)] = this.deserialize(values[core.$get](i)); |
| 330 } | 328 } |
| 331 return o; | 329 return o; |
| 332 } | 330 } |
| 333 deserializeClosure(x) { | 331 deserializeClosure(x) { |
| 334 dart.assert(dart.equals(dart.dindex(x, 0), 'function')); | 332 dart.assert(dart.equals(dart.dindex(x, 0), 'function')); |
| 335 let name = dart.as(dart.dindex(x, 1), core.String); | 333 let name = dart.as(dart.dindex(x, 1), core.String); |
| 336 let result = dart.as(IsolateNatives[_getJSFunctionFromName](name), core.Fu
nction); | 334 let result = dart.as(IsolateNatives._getJSFunctionFromName(name), core.Fun
ction); |
| 337 this.deserializedObjects[core.$add](result); | 335 this.deserializedObjects[core.$add](result); |
| 338 return result; | 336 return result; |
| 339 } | 337 } |
| 340 deserializeDartObject(x) { | 338 deserializeDartObject(x) { |
| 341 dart.assert(dart.equals(dart.dindex(x, 0), 'dart')); | 339 dart.assert(dart.equals(dart.dindex(x, 0), 'dart')); |
| 342 let classId = dart.as(dart.dindex(x, 1), core.String); | 340 let classId = dart.as(dart.dindex(x, 1), core.String); |
| 343 let fields = dart.as(dart.dindex(x, 2), core.List); | 341 let fields = dart.as(dart.dindex(x, 2), core.List); |
| 344 let instanceFromClassId = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embed
ded_names.INSTANCE_FROM_CLASS_ID); | 342 let instanceFromClassId = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embed
ded_names.INSTANCE_FROM_CLASS_ID); |
| 345 let initializeObject = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded
_names.INITIALIZE_EMPTY_INSTANCE); | 343 let initializeObject = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded
_names.INITIALIZE_EMPTY_INSTANCE); |
| 346 let emptyInstance = instanceFromClassId(classId); | 344 let emptyInstance = instanceFromClassId(classId); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 dart.copyProperties(exports, { | 404 dart.copyProperties(exports, { |
| 407 get _globalState() { | 405 get _globalState() { |
| 408 return dart.as(init.globalState, _Manager); | 406 return dart.as(init.globalState, _Manager); |
| 409 }, | 407 }, |
| 410 set _globalState(val) { | 408 set _globalState(val) { |
| 411 init.globalState = val; | 409 init.globalState = val; |
| 412 } | 410 } |
| 413 }); | 411 }); |
| 414 let _nativeDetectEnvironment = Symbol('_nativeDetectEnvironment'); | 412 let _nativeDetectEnvironment = Symbol('_nativeDetectEnvironment'); |
| 415 let _nativeInitWorkerMessageHandler = Symbol('_nativeInitWorkerMessageHandler'
); | 413 let _nativeInitWorkerMessageHandler = Symbol('_nativeInitWorkerMessageHandler'
); |
| 416 let _processWorkerMessage = Symbol('_processWorkerMessage'); | |
| 417 let _serializePrintMessage = Symbol('_serializePrintMessage'); | |
| 418 class _Manager extends core.Object { | 414 class _Manager extends core.Object { |
| 419 get useWorkers() { | 415 get useWorkers() { |
| 420 return this.supportsWorkers; | 416 return this.supportsWorkers; |
| 421 } | 417 } |
| 422 _Manager(entry) { | 418 _Manager(entry) { |
| 423 this.entry = entry; | 419 this.entry = entry; |
| 424 this.nextIsolateId = 0; | 420 this.nextIsolateId = 0; |
| 425 this.currentManagerId = 0; | 421 this.currentManagerId = 0; |
| 426 this.nextManagerId = 1; | 422 this.nextManagerId = 1; |
| 427 this.currentContext = null; | 423 this.currentContext = null; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 447 let isWorkerDefined = exports.globalWorker != null; | 443 let isWorkerDefined = exports.globalWorker != null; |
| 448 this.isWorker = !dart.notNull(isWindowDefined) && dart.notNull(exports.glo
balPostMessageDefined); | 444 this.isWorker = !dart.notNull(isWindowDefined) && dart.notNull(exports.glo
balPostMessageDefined); |
| 449 this.supportsWorkers = dart.notNull(this.isWorker) || dart.notNull(isWorke
rDefined) && IsolateNatives.thisScript != null; | 445 this.supportsWorkers = dart.notNull(this.isWorker) || dart.notNull(isWorke
rDefined) && IsolateNatives.thisScript != null; |
| 450 this.fromCommandLine = !dart.notNull(isWindowDefined) && !dart.notNull(thi
s.isWorker); | 446 this.fromCommandLine = !dart.notNull(isWindowDefined) && !dart.notNull(thi
s.isWorker); |
| 451 } | 447 } |
| 452 [_nativeInitWorkerMessageHandler]() { | 448 [_nativeInitWorkerMessageHandler]() { |
| 453 let func = function(f, a) { | 449 let func = function(f, a) { |
| 454 return function(e) { | 450 return function(e) { |
| 455 f(a, e); | 451 f(a, e); |
| 456 }; | 452 }; |
| 457 }(_foreign_helper.DART_CLOSURE_TO_JS(dart.bind(IsolateNatives, _processWor
kerMessage)), this.mainManager); | 453 }(_foreign_helper.DART_CLOSURE_TO_JS(dart.bind(IsolateNatives, '_processWo
rkerMessage')), this.mainManager); |
| 458 self.onmessage = func; | 454 self.onmessage = func; |
| 459 self.dartPrint = self.dartPrint || function(serialize) { | 455 self.dartPrint = self.dartPrint || function(serialize) { |
| 460 return function(object) { | 456 return function(object) { |
| 461 if (self.console && self.console.log) { | 457 if (self.console && self.console.log) { |
| 462 self.console.log(object); | 458 self.console.log(object); |
| 463 } else { | 459 } else { |
| 464 self.postMessage(serialize(object)); | 460 self.postMessage(serialize(object)); |
| 465 } | 461 } |
| 466 }; | 462 }; |
| 467 }(_foreign_helper.DART_CLOSURE_TO_JS(_Manager[_serializePrintMessage])); | 463 }(_foreign_helper.DART_CLOSURE_TO_JS(_Manager._serializePrintMessage)); |
| 468 } | 464 } |
| 469 static [_serializePrintMessage](object) { | 465 static _serializePrintMessage(object) { |
| 470 return _serializeMessage(dart.map({command: "print", msg: object})); | 466 return _serializeMessage(dart.map({command: "print", msg: object})); |
| 471 } | 467 } |
| 472 maybeCloseWorker() { | 468 maybeCloseWorker() { |
| 473 if (dart.notNull(this.isWorker) && dart.notNull(this.isolates.isEmpty) &&
this.topEventLoop[_activeJsAsyncCount] == 0) { | 469 if (dart.notNull(this.isWorker) && dart.notNull(this.isolates.isEmpty) &&
this.topEventLoop[_activeJsAsyncCount] == 0) { |
| 474 this.mainManager.postMessage(_serializeMessage(dart.map({command: 'close
'}))); | 470 this.mainManager.postMessage(_serializeMessage(dart.map({command: 'close
'}))); |
| 475 } | 471 } |
| 476 } | 472 } |
| 477 } | 473 } |
| 478 let _controlPort = Symbol('_controlPort'); | 474 let _controlPort = Symbol('_controlPort'); |
| 479 let _scheduledControlEvents = Symbol('_scheduledControlEvents'); | 475 let _scheduledControlEvents = Symbol('_scheduledControlEvents'); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 return self.Worker; | 828 return self.Worker; |
| 833 }, | 829 }, |
| 834 get globalPostMessageDefined() { | 830 get globalPostMessageDefined() { |
| 835 _js_helper.requiresPreamble(); | 831 _js_helper.requiresPreamble(); |
| 836 return !!self.postMessage; | 832 return !!self.postMessage; |
| 837 } | 833 } |
| 838 }); | 834 }); |
| 839 let _MainFunction = dart.typedef('_MainFunction', () => dart.functionType(dart
.dynamic, [])); | 835 let _MainFunction = dart.typedef('_MainFunction', () => dart.functionType(dart
.dynamic, [])); |
| 840 let _MainFunctionArgs = dart.typedef('_MainFunctionArgs', () => dart.functionT
ype(dart.dynamic, [dart.dynamic])); | 836 let _MainFunctionArgs = dart.typedef('_MainFunctionArgs', () => dart.functionT
ype(dart.dynamic, [dart.dynamic])); |
| 841 let _MainFunctionArgsMessage = dart.typedef('_MainFunctionArgsMessage', () =>
dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic])); | 837 let _MainFunctionArgsMessage = dart.typedef('_MainFunctionArgsMessage', () =>
dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic])); |
| 842 let _getEventData = Symbol('_getEventData'); | |
| 843 let _startIsolate = Symbol('_startIsolate'); | |
| 844 let _log = Symbol('_log'); | |
| 845 let _consoleLog = Symbol('_consoleLog'); | |
| 846 let _allocate = Symbol('_allocate'); | |
| 847 let _startWorker = Symbol('_startWorker'); | |
| 848 let _startNonWorker = Symbol('_startNonWorker'); | |
| 849 let _spawnWorker = Symbol('_spawnWorker'); | |
| 850 class IsolateNatives extends core.Object { | 838 class IsolateNatives extends core.Object { |
| 851 static computeThisScript() { | 839 static computeThisScript() { |
| 852 let currentScript = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_na
mes.CURRENT_SCRIPT); | 840 let currentScript = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_na
mes.CURRENT_SCRIPT); |
| 853 if (currentScript != null) { | 841 if (currentScript != null) { |
| 854 return String(currentScript.src); | 842 return String(currentScript.src); |
| 855 } | 843 } |
| 856 if (_js_helper.Primitives.isD8) | 844 if (_js_helper.Primitives.isD8) |
| 857 return IsolateNatives.computeThisScriptD8(); | 845 return IsolateNatives.computeThisScriptD8(); |
| 858 if (_js_helper.Primitives.isJsshell) | 846 if (_js_helper.Primitives.isJsshell) |
| 859 return IsolateNatives.computeThisScriptJsshell(); | 847 return IsolateNatives.computeThisScriptJsshell(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 885 pattern = new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m"); | 873 pattern = new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m"); |
| 886 matches = stack.match(pattern); | 874 matches = stack.match(pattern); |
| 887 if (matches != null) | 875 if (matches != null) |
| 888 return matches[1]; | 876 return matches[1]; |
| 889 pattern = new RegExp("^[^@]*@(.*):[0-9]*$", "m"); | 877 pattern = new RegExp("^[^@]*@(.*):[0-9]*$", "m"); |
| 890 matches = stack.match(pattern); | 878 matches = stack.match(pattern); |
| 891 if (matches != null) | 879 if (matches != null) |
| 892 return matches[1]; | 880 return matches[1]; |
| 893 throw new core.UnsupportedError(`Cannot extract URI from "${stack}"`); | 881 throw new core.UnsupportedError(`Cannot extract URI from "${stack}"`); |
| 894 } | 882 } |
| 895 static [_getEventData](e) { | 883 static _getEventData(e) { |
| 896 return e.data; | 884 return e.data; |
| 897 } | 885 } |
| 898 static [_processWorkerMessage](sender, e) { | 886 static _processWorkerMessage(sender, e) { |
| 899 let msg = _deserializeMessage(IsolateNatives[_getEventData](e)); | 887 let msg = _deserializeMessage(IsolateNatives._getEventData(e)); |
| 900 switch (dart.dindex(msg, 'command')) { | 888 switch (dart.dindex(msg, 'command')) { |
| 901 case 'start': | 889 case 'start': |
| 902 { | 890 { |
| 903 exports._globalState.currentManagerId = dart.as(dart.dindex(msg, 'id')
, core.int); | 891 exports._globalState.currentManagerId = dart.as(dart.dindex(msg, 'id')
, core.int); |
| 904 let functionName = dart.as(dart.dindex(msg, 'functionName'), core.Stri
ng); | 892 let functionName = dart.as(dart.dindex(msg, 'functionName'), core.Stri
ng); |
| 905 let entryPoint = dart.as(functionName == null ? exports._globalState.e
ntry : IsolateNatives[_getJSFunctionFromName](functionName), core.Function); | 893 let entryPoint = dart.as(functionName == null ? exports._globalState.e
ntry : IsolateNatives._getJSFunctionFromName(functionName), core.Function); |
| 906 let args = dart.dindex(msg, 'args'); | 894 let args = dart.dindex(msg, 'args'); |
| 907 let message = _deserializeMessage(dart.dindex(msg, 'msg')); | 895 let message = _deserializeMessage(dart.dindex(msg, 'msg')); |
| 908 let isSpawnUri = dart.dindex(msg, 'isSpawnUri'); | 896 let isSpawnUri = dart.dindex(msg, 'isSpawnUri'); |
| 909 let startPaused = dart.dindex(msg, 'startPaused'); | 897 let startPaused = dart.dindex(msg, 'startPaused'); |
| 910 let replyTo = _deserializeMessage(dart.dindex(msg, 'replyTo')); | 898 let replyTo = _deserializeMessage(dart.dindex(msg, 'replyTo')); |
| 911 let context = new _IsolateContext(); | 899 let context = new _IsolateContext(); |
| 912 exports._globalState.topEventLoop.enqueue(context, () => { | 900 exports._globalState.topEventLoop.enqueue(context, () => { |
| 913 IsolateNatives[_startIsolate](entryPoint, dart.as(args, core.List$(c
ore.String)), message, dart.as(isSpawnUri, core.bool), dart.as(startPaused, core
.bool), dart.as(replyTo, isolate.SendPort)); | 901 IsolateNatives._startIsolate(entryPoint, dart.as(args, core.List$(co
re.String)), message, dart.as(isSpawnUri, core.bool), dart.as(startPaused, core.
bool), dart.as(replyTo, isolate.SendPort)); |
| 914 }, 'worker-start'); | 902 }, 'worker-start'); |
| 915 exports._globalState.currentContext = context; | 903 exports._globalState.currentContext = context; |
| 916 exports._globalState.topEventLoop.run(); | 904 exports._globalState.topEventLoop.run(); |
| 917 break; | 905 break; |
| 918 } | 906 } |
| 919 case 'spawn-worker': | 907 case 'spawn-worker': |
| 920 { | 908 { |
| 921 if (IsolateNatives.enableSpawnWorker != null) | 909 if (IsolateNatives.enableSpawnWorker != null) |
| 922 IsolateNatives.handleSpawnWorkerRequest(msg); | 910 IsolateNatives.handleSpawnWorkerRequest(msg); |
| 923 break; | 911 break; |
| 924 } | 912 } |
| 925 case 'message': | 913 case 'message': |
| 926 { | 914 { |
| 927 let port = dart.as(dart.dindex(msg, 'port'), isolate.SendPort); | 915 let port = dart.as(dart.dindex(msg, 'port'), isolate.SendPort); |
| 928 if (port != null) { | 916 if (port != null) { |
| 929 dart.dsend(dart.dindex(msg, 'port'), 'send', dart.dindex(msg, 'msg')
); | 917 dart.dsend(dart.dindex(msg, 'port'), 'send', dart.dindex(msg, 'msg')
); |
| 930 } | 918 } |
| 931 exports._globalState.topEventLoop.run(); | 919 exports._globalState.topEventLoop.run(); |
| 932 break; | 920 break; |
| 933 } | 921 } |
| 934 case 'close': | 922 case 'close': |
| 935 { | 923 { |
| 936 exports._globalState.managers.remove(IsolateNatives.workerIds.get(send
er)); | 924 exports._globalState.managers.remove(IsolateNatives.workerIds.get(send
er)); |
| 937 sender.terminate(); | 925 sender.terminate(); |
| 938 exports._globalState.topEventLoop.run(); | 926 exports._globalState.topEventLoop.run(); |
| 939 break; | 927 break; |
| 940 } | 928 } |
| 941 case 'log': | 929 case 'log': |
| 942 { | 930 { |
| 943 IsolateNatives[_log](dart.dindex(msg, 'msg')); | 931 IsolateNatives._log(dart.dindex(msg, 'msg')); |
| 944 break; | 932 break; |
| 945 } | 933 } |
| 946 case 'print': | 934 case 'print': |
| 947 { | 935 { |
| 948 if (exports._globalState.isWorker) { | 936 if (exports._globalState.isWorker) { |
| 949 exports._globalState.mainManager.postMessage(_serializeMessage(dart.
map({command: 'print', msg: msg}))); | 937 exports._globalState.mainManager.postMessage(_serializeMessage(dart.
map({command: 'print', msg: msg}))); |
| 950 } else { | 938 } else { |
| 951 core.print(dart.dindex(msg, 'msg')); | 939 core.print(dart.dindex(msg, 'msg')); |
| 952 } | 940 } |
| 953 break; | 941 break; |
| 954 } | 942 } |
| 955 case 'error': | 943 case 'error': |
| 956 { | 944 { |
| 957 throw dart.dindex(msg, 'msg'); | 945 throw dart.dindex(msg, 'msg'); |
| 958 } | 946 } |
| 959 } | 947 } |
| 960 } | 948 } |
| 961 static handleSpawnWorkerRequest(msg) { | 949 static handleSpawnWorkerRequest(msg) { |
| 962 let replyPort = dart.dindex(msg, 'replyPort'); | 950 let replyPort = dart.dindex(msg, 'replyPort'); |
| 963 IsolateNatives.spawn(dart.as(dart.dindex(msg, 'functionName'), core.String
), dart.as(dart.dindex(msg, 'uri'), core.String), dart.as(dart.dindex(msg, 'args
'), core.List$(core.String)), dart.dindex(msg, 'msg'), false, dart.as(dart.dinde
x(msg, 'isSpawnUri'), core.bool), dart.as(dart.dindex(msg, 'startPaused'), core.
bool)).then(msg => { | 951 IsolateNatives.spawn(dart.as(dart.dindex(msg, 'functionName'), core.String
), dart.as(dart.dindex(msg, 'uri'), core.String), dart.as(dart.dindex(msg, 'args
'), core.List$(core.String)), dart.dindex(msg, 'msg'), false, dart.as(dart.dinde
x(msg, 'isSpawnUri'), core.bool), dart.as(dart.dindex(msg, 'startPaused'), core.
bool)).then(msg => { |
| 964 dart.dsend(replyPort, 'send', msg); | 952 dart.dsend(replyPort, 'send', msg); |
| 965 }, { | 953 }, { |
| 966 onError: errorMessage => { | 954 onError: errorMessage => { |
| 967 dart.dsend(replyPort, 'send', [_SPAWN_FAILED_SIGNAL, errorMessage]); | 955 dart.dsend(replyPort, 'send', [_SPAWN_FAILED_SIGNAL, errorMessage]); |
| 968 } | 956 } |
| 969 }); | 957 }); |
| 970 } | 958 } |
| 971 static [_log](msg) { | 959 static _log(msg) { |
| 972 if (exports._globalState.isWorker) { | 960 if (exports._globalState.isWorker) { |
| 973 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'log', msg: msg}))); | 961 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'log', msg: msg}))); |
| 974 } else { | 962 } else { |
| 975 try { | 963 try { |
| 976 IsolateNatives[_consoleLog](msg); | 964 IsolateNatives._consoleLog(msg); |
| 977 } catch (e) { | 965 } catch (e) { |
| 978 let trace = dart.stackTrace(e); | 966 let trace = dart.stackTrace(e); |
| 979 throw new core.Exception(trace); | 967 throw new core.Exception(trace); |
| 980 } | 968 } |
| 981 | 969 |
| 982 } | 970 } |
| 983 } | 971 } |
| 984 static [_consoleLog](msg) { | 972 static _consoleLog(msg) { |
| 985 _js_helper.requiresPreamble(); | 973 _js_helper.requiresPreamble(); |
| 986 self.console.log(msg); | 974 self.console.log(msg); |
| 987 } | 975 } |
| 988 static [_getJSFunctionFromName](functionName) { | 976 static _getJSFunctionFromName(functionName) { |
| 989 let globalFunctionsContainer = _foreign_helper.JS_EMBEDDED_GLOBAL("", _js_
embedded_names.GLOBAL_FUNCTIONS); | 977 let globalFunctionsContainer = _foreign_helper.JS_EMBEDDED_GLOBAL("", _js_
embedded_names.GLOBAL_FUNCTIONS); |
| 990 return globalFunctionsContainer[functionName](); | 978 return globalFunctionsContainer[functionName](); |
| 991 } | 979 } |
| 992 static [_getJSFunctionName](f) { | 980 static _getJSFunctionName(f) { |
| 993 return dart.as(dart.is(f, _js_helper.Closure) ? f.$name : null, core.Strin
g); | 981 return dart.as(dart.is(f, _js_helper.Closure) ? f.$name : null, core.Strin
g); |
| 994 } | 982 } |
| 995 static [_allocate](ctor) { | 983 static _allocate(ctor) { |
| 996 return new ctor(); | 984 return new ctor(); |
| 997 } | 985 } |
| 998 static spawnFunction(topLevelFunction, message, startPaused) { | 986 static spawnFunction(topLevelFunction, message, startPaused) { |
| 999 IsolateNatives.enableSpawnWorker = true; | 987 IsolateNatives.enableSpawnWorker = true; |
| 1000 let name = IsolateNatives[_getJSFunctionName](topLevelFunction); | 988 let name = IsolateNatives._getJSFunctionName(topLevelFunction); |
| 1001 if (name == null) { | 989 if (name == null) { |
| 1002 throw new core.UnsupportedError("only top-level functions can be spawned
."); | 990 throw new core.UnsupportedError("only top-level functions can be spawned
."); |
| 1003 } | 991 } |
| 1004 let isLight = false; | 992 let isLight = false; |
| 1005 let isSpawnUri = false; | 993 let isSpawnUri = false; |
| 1006 return IsolateNatives.spawn(name, null, null, message, isLight, isSpawnUri
, startPaused); | 994 return IsolateNatives.spawn(name, null, null, message, isLight, isSpawnUri
, startPaused); |
| 1007 } | 995 } |
| 1008 static spawnUri(uri, args, message, startPaused) { | 996 static spawnUri(uri, args, message, startPaused) { |
| 1009 IsolateNatives.enableSpawnWorker = true; | 997 IsolateNatives.enableSpawnWorker = true; |
| 1010 let isLight = false; | 998 let isLight = false; |
| 1011 let isSpawnUri = true; | 999 let isSpawnUri = true; |
| 1012 return IsolateNatives.spawn(null, dart.toString(uri), args, message, isLig
ht, isSpawnUri, startPaused); | 1000 return IsolateNatives.spawn(null, dart.toString(uri), args, message, isLig
ht, isSpawnUri, startPaused); |
| 1013 } | 1001 } |
| 1014 static spawn(functionName, uri, args, message, isLight, isSpawnUri, startPau
sed) { | 1002 static spawn(functionName, uri, args, message, isLight, isSpawnUri, startPau
sed) { |
| 1015 if (uri != null && dart.notNull(uri.endsWith(".dart"))) { | 1003 if (uri != null && dart.notNull(uri.endsWith(".dart"))) { |
| 1016 uri = dart.notNull(uri) + ".js"; | 1004 uri = dart.notNull(uri) + ".js"; |
| 1017 } | 1005 } |
| 1018 let port = new isolate.ReceivePort(); | 1006 let port = new isolate.ReceivePort(); |
| 1019 let completer = new (async.Completer$(core.List))(); | 1007 let completer = new (async.Completer$(core.List))(); |
| 1020 port.first.then(msg => { | 1008 port.first.then(msg => { |
| 1021 if (dart.equals(dart.dindex(msg, 0), _SPAWNED_SIGNAL)) { | 1009 if (dart.equals(dart.dindex(msg, 0), _SPAWNED_SIGNAL)) { |
| 1022 completer.complete(msg); | 1010 completer.complete(msg); |
| 1023 } else { | 1011 } else { |
| 1024 dart.assert(dart.equals(dart.dindex(msg, 0), _SPAWN_FAILED_SIGNAL)); | 1012 dart.assert(dart.equals(dart.dindex(msg, 0), _SPAWN_FAILED_SIGNAL)); |
| 1025 completer.completeError(dart.dindex(msg, 1)); | 1013 completer.completeError(dart.dindex(msg, 1)); |
| 1026 } | 1014 } |
| 1027 }); | 1015 }); |
| 1028 let signalReply = port.sendPort; | 1016 let signalReply = port.sendPort; |
| 1029 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight
)) { | 1017 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight
)) { |
| 1030 IsolateNatives[_startWorker](functionName, uri, args, message, isSpawnUr
i, startPaused, signalReply, message => completer.completeError(message)); | 1018 IsolateNatives._startWorker(functionName, uri, args, message, isSpawnUri
, startPaused, signalReply, message => completer.completeError(message)); |
| 1031 } else { | 1019 } else { |
| 1032 IsolateNatives[_startNonWorker](functionName, uri, args, message, isSpaw
nUri, startPaused, signalReply); | 1020 IsolateNatives._startNonWorker(functionName, uri, args, message, isSpawn
Uri, startPaused, signalReply); |
| 1033 } | 1021 } |
| 1034 return completer.future; | 1022 return completer.future; |
| 1035 } | 1023 } |
| 1036 static [_startWorker](functionName, uri, args, message, isSpawnUri, startPau
sed, replyPort, onError) { | 1024 static _startWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { |
| 1037 if (args != null) | 1025 if (args != null) |
| 1038 args = new core.List$(core.String).from(args); | 1026 args = new core.List$(core.String).from(args); |
| 1039 if (exports._globalState.isWorker) { | 1027 if (exports._globalState.isWorker) { |
| 1040 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'spawn-worker', functionName: functionName, args: args, msg: message,
uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort
}))); | 1028 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'spawn-worker', functionName: functionName, args: args, msg: message,
uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort
}))); |
| 1041 } else { | 1029 } else { |
| 1042 IsolateNatives[_spawnWorker](functionName, uri, args, message, isSpawnUr
i, startPaused, replyPort, onError); | 1030 IsolateNatives._spawnWorker(functionName, uri, args, message, isSpawnUri
, startPaused, replyPort, onError); |
| 1043 } | 1031 } |
| 1044 } | 1032 } |
| 1045 static [_startNonWorker](functionName, uri, args, message, isSpawnUri, start
Paused, replyPort) { | 1033 static _startNonWorker(functionName, uri, args, message, isSpawnUri, startPa
used, replyPort) { |
| 1046 if (uri != null) { | 1034 if (uri != null) { |
| 1047 throw new core.UnsupportedError("Currently spawnUri is not supported wit
hout web workers."); | 1035 throw new core.UnsupportedError("Currently spawnUri is not supported wit
hout web workers."); |
| 1048 } | 1036 } |
| 1049 message = _clone(message); | 1037 message = _clone(message); |
| 1050 if (args != null) | 1038 if (args != null) |
| 1051 args = new core.List$(core.String).from(args); | 1039 args = new core.List$(core.String).from(args); |
| 1052 exports._globalState.topEventLoop.enqueue(new _IsolateContext(), () => { | 1040 exports._globalState.topEventLoop.enqueue(new _IsolateContext(), () => { |
| 1053 let func = IsolateNatives[_getJSFunctionFromName](functionName); | 1041 let func = IsolateNatives._getJSFunctionFromName(functionName); |
| 1054 IsolateNatives[_startIsolate](dart.as(func, core.Function), args, messag
e, isSpawnUri, startPaused, replyPort); | 1042 IsolateNatives._startIsolate(dart.as(func, core.Function), args, message
, isSpawnUri, startPaused, replyPort); |
| 1055 }, 'nonworker start'); | 1043 }, 'nonworker start'); |
| 1056 } | 1044 } |
| 1057 static get currentIsolate() { | 1045 static get currentIsolate() { |
| 1058 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); | 1046 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); |
| 1059 return new isolate.Isolate(context.controlPort.sendPort, {pauseCapability:
context.pauseCapability, terminateCapability: context.terminateCapability}); | 1047 return new isolate.Isolate(context.controlPort.sendPort, {pauseCapability:
context.pauseCapability, terminateCapability: context.terminateCapability}); |
| 1060 } | 1048 } |
| 1061 static [_startIsolate](topLevel, args, message, isSpawnUri, startPaused, rep
lyTo) { | 1049 static _startIsolate(topLevel, args, message, isSpawnUri, startPaused, reply
To) { |
| 1062 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); | 1050 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); |
| 1063 _js_helper.Primitives.initializeStatics(context.id); | 1051 _js_helper.Primitives.initializeStatics(context.id); |
| 1064 replyTo.send([_SPAWNED_SIGNAL, context.controlPort.sendPort, context.pause
Capability, context.terminateCapability]); | 1052 replyTo.send([_SPAWNED_SIGNAL, context.controlPort.sendPort, context.pause
Capability, context.terminateCapability]); |
| 1065 // Function runStartFunction: () → void | 1053 // Function runStartFunction: () → void |
| 1066 function runStartFunction() { | 1054 function runStartFunction() { |
| 1067 context.initialized = true; | 1055 context.initialized = true; |
| 1068 if (!dart.notNull(isSpawnUri)) { | 1056 if (!dart.notNull(isSpawnUri)) { |
| 1069 dart.dcall(topLevel, message); | 1057 dart.dcall(topLevel, message); |
| 1070 } else if (dart.is(topLevel, _MainFunctionArgsMessage)) { | 1058 } else if (dart.is(topLevel, _MainFunctionArgsMessage)) { |
| 1071 dart.dcall(topLevel, args, message); | 1059 dart.dcall(topLevel, args, message); |
| 1072 } else if (dart.is(topLevel, _MainFunctionArgs)) { | 1060 } else if (dart.is(topLevel, _MainFunctionArgs)) { |
| 1073 dart.dcall(topLevel, args); | 1061 dart.dcall(topLevel, args); |
| 1074 } else { | 1062 } else { |
| 1075 dart.dcall(topLevel); | 1063 dart.dcall(topLevel); |
| 1076 } | 1064 } |
| 1077 } | 1065 } |
| 1078 if (startPaused) { | 1066 if (startPaused) { |
| 1079 context.addPause(context.pauseCapability, context.pauseCapability); | 1067 context.addPause(context.pauseCapability, context.pauseCapability); |
| 1080 exports._globalState.topEventLoop.enqueue(context, runStartFunction, 'st
art isolate'); | 1068 exports._globalState.topEventLoop.enqueue(context, runStartFunction, 'st
art isolate'); |
| 1081 } else { | 1069 } else { |
| 1082 runStartFunction(); | 1070 runStartFunction(); |
| 1083 } | 1071 } |
| 1084 } | 1072 } |
| 1085 static [_spawnWorker](functionName, uri, args, message, isSpawnUri, startPau
sed, replyPort, onError) { | 1073 static _spawnWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { |
| 1086 if (uri == null) | 1074 if (uri == null) |
| 1087 uri = IsolateNatives.thisScript; | 1075 uri = IsolateNatives.thisScript; |
| 1088 let worker = new Worker(uri); | 1076 let worker = new Worker(uri); |
| 1089 let onerrorTrampoline = function(f, u, c) { | 1077 let onerrorTrampoline = function(f, u, c) { |
| 1090 return function(e) { | 1078 return function(e) { |
| 1091 return f(e, u, c); | 1079 return f(e, u, c); |
| 1092 }; | 1080 }; |
| 1093 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives.workerOnError), uri, o
nError); | 1081 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives.workerOnError), uri, o
nError); |
| 1094 worker.onerror = onerrorTrampoline; | 1082 worker.onerror = onerrorTrampoline; |
| 1095 let processWorkerMessageTrampoline = function(f, a) { | 1083 let processWorkerMessageTrampoline = function(f, a) { |
| 1096 return function(e) { | 1084 return function(e) { |
| 1097 e.onerror = null; | 1085 e.onerror = null; |
| 1098 return f(a, e); | 1086 return f(a, e); |
| 1099 }; | 1087 }; |
| 1100 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives[_processWorkerMessage]
), worker); | 1088 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives._processWorkerMessage)
, worker); |
| 1101 worker.onmessage = processWorkerMessageTrampoline; | 1089 worker.onmessage = processWorkerMessageTrampoline; |
| 1102 let o = exports._globalState; | 1090 let o = exports._globalState; |
| 1103 let workerId = o.nextManagerId; | 1091 let workerId = o.nextManagerId; |
| 1104 o.nextManagerId = dart.notNull(workerId) + 1; | 1092 o.nextManagerId = dart.notNull(workerId) + 1; |
| 1105 IsolateNatives.workerIds.set(worker, workerId); | 1093 IsolateNatives.workerIds.set(worker, workerId); |
| 1106 exports._globalState.managers.set(workerId, worker); | 1094 exports._globalState.managers.set(workerId, worker); |
| 1107 worker.postMessage(_serializeMessage(dart.map({command: 'start', id: worke
rId, replyTo: _serializeMessage(replyPort), args: args, msg: _serializeMessage(m
essage), isSpawnUri: isSpawnUri, startPaused: startPaused, functionName: functio
nName}))); | 1095 worker.postMessage(_serializeMessage(dart.map({command: 'start', id: worke
rId, replyTo: _serializeMessage(replyPort), args: args, msg: _serializeMessage(m
essage), isSpawnUri: isSpawnUri, startPaused: startPaused, functionName: functio
nName}))); |
| 1108 } | 1096 } |
| 1109 static workerOnError(event, uri, onError) { | 1097 static workerOnError(event, uri, onError) { |
| 1110 event.preventDefault(); | 1098 event.preventDefault(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 } | 1178 } |
| 1191 } | 1179 } |
| 1192 ['=='](other) { | 1180 ['=='](other) { |
| 1193 return dart.is(other, _WorkerSendPort) && dart.equals(this[_workerId], dar
t.dload(other, _workerId)) && dart.equals(this[_isolateId], dart.dload(other, _i
solateId)) && dart.equals(this[_receivePortId], dart.dload(other, _receivePortId
)); | 1181 return dart.is(other, _WorkerSendPort) && dart.equals(this[_workerId], dar
t.dload(other, _workerId)) && dart.equals(this[_isolateId], dart.dload(other, _i
solateId)) && dart.equals(this[_receivePortId], dart.dload(other, _receivePortId
)); |
| 1194 } | 1182 } |
| 1195 get hashCode() { | 1183 get hashCode() { |
| 1196 return dart.notNull(this[_workerId]) << 16 ^ dart.notNull(this[_isolateId]
) << 8 ^ dart.notNull(this[_receivePortId]); | 1184 return dart.notNull(this[_workerId]) << 16 ^ dart.notNull(this[_isolateId]
) << 8 ^ dart.notNull(this[_receivePortId]); |
| 1197 } | 1185 } |
| 1198 } | 1186 } |
| 1199 _WorkerSendPort[dart.implements] = () => [isolate.SendPort]; | 1187 _WorkerSendPort[dart.implements] = () => [isolate.SendPort]; |
| 1200 let _nextFreeId = Symbol('_nextFreeId'); | |
| 1201 let _handler = Symbol('_handler'); | 1188 let _handler = Symbol('_handler'); |
| 1202 class RawReceivePortImpl extends core.Object { | 1189 class RawReceivePortImpl extends core.Object { |
| 1203 RawReceivePortImpl(handler) { | 1190 RawReceivePortImpl(handler) { |
| 1204 this[_handler] = handler; | 1191 this[_handler] = handler; |
| 1205 this[_id] = (() => { | 1192 this[_id] = (() => { |
| 1206 let x = RawReceivePortImpl[_nextFreeId]; | 1193 let x = RawReceivePortImpl._nextFreeId; |
| 1207 RawReceivePortImpl[_nextFreeId] = dart.notNull(x) + 1; | 1194 RawReceivePortImpl._nextFreeId = dart.notNull(x) + 1; |
| 1208 return x; | 1195 return x; |
| 1209 })(); | 1196 })(); |
| 1210 this[_isClosed] = false; | 1197 this[_isClosed] = false; |
| 1211 exports._globalState.currentContext.register(this[_id], this); | 1198 exports._globalState.currentContext.register(this[_id], this); |
| 1212 } | 1199 } |
| 1213 weak(handler) { | 1200 weak(handler) { |
| 1214 this[_handler] = handler; | 1201 this[_handler] = handler; |
| 1215 this[_id] = (() => { | 1202 this[_id] = (() => { |
| 1216 let x = RawReceivePortImpl[_nextFreeId]; | 1203 let x = RawReceivePortImpl._nextFreeId; |
| 1217 RawReceivePortImpl[_nextFreeId] = dart.notNull(x) + 1; | 1204 RawReceivePortImpl._nextFreeId = dart.notNull(x) + 1; |
| 1218 return x; | 1205 return x; |
| 1219 })(); | 1206 })(); |
| 1220 this[_isClosed] = false; | 1207 this[_isClosed] = false; |
| 1221 exports._globalState.currentContext.registerWeak(this[_id], this); | 1208 exports._globalState.currentContext.registerWeak(this[_id], this); |
| 1222 } | 1209 } |
| 1223 [_controlPort]() { | 1210 _controlPort() { |
| 1224 this[_handler] = null; | 1211 this[_handler] = null; |
| 1225 this[_id] = 0; | 1212 this[_id] = 0; |
| 1226 this[_isClosed] = false; | 1213 this[_isClosed] = false; |
| 1227 } | 1214 } |
| 1228 set handler(newHandler) { | 1215 set handler(newHandler) { |
| 1229 this[_handler] = newHandler; | 1216 this[_handler] = newHandler; |
| 1230 } | 1217 } |
| 1231 [_close]() { | 1218 [_close]() { |
| 1232 this[_isClosed] = true; | 1219 this[_isClosed] = true; |
| 1233 this[_handler] = null; | 1220 this[_handler] = null; |
| 1234 } | 1221 } |
| 1235 close() { | 1222 close() { |
| 1236 if (this[_isClosed]) | 1223 if (this[_isClosed]) |
| 1237 return; | 1224 return; |
| 1238 this[_isClosed] = true; | 1225 this[_isClosed] = true; |
| 1239 this[_handler] = null; | 1226 this[_handler] = null; |
| 1240 exports._globalState.currentContext.unregister(this[_id]); | 1227 exports._globalState.currentContext.unregister(this[_id]); |
| 1241 } | 1228 } |
| 1242 [_add](dataEvent) { | 1229 [_add](dataEvent) { |
| 1243 if (this[_isClosed]) | 1230 if (this[_isClosed]) |
| 1244 return; | 1231 return; |
| 1245 dart.dcall(this[_handler], dataEvent); | 1232 dart.dcall(this[_handler], dataEvent); |
| 1246 } | 1233 } |
| 1247 get sendPort() { | 1234 get sendPort() { |
| 1248 return new _NativeJsSendPort(this, exports._globalState.currentContext.id)
; | 1235 return new _NativeJsSendPort(this, exports._globalState.currentContext.id)
; |
| 1249 } | 1236 } |
| 1250 } | 1237 } |
| 1251 RawReceivePortImpl[dart.implements] = () => [isolate.RawReceivePort]; | 1238 RawReceivePortImpl[dart.implements] = () => [isolate.RawReceivePort]; |
| 1252 dart.defineNamedConstructor(RawReceivePortImpl, 'weak'); | 1239 dart.defineNamedConstructor(RawReceivePortImpl, 'weak'); |
| 1253 dart.defineNamedConstructor(RawReceivePortImpl, _controlPort); | 1240 dart.defineNamedConstructor(RawReceivePortImpl, '_controlPort'); |
| 1254 RawReceivePortImpl._nextFreeId = 1; | 1241 RawReceivePortImpl._nextFreeId = 1; |
| 1255 let _rawPort = Symbol('_rawPort'); | 1242 let _rawPort = Symbol('_rawPort'); |
| 1256 let _controller = Symbol('_controller'); | 1243 let _controller = Symbol('_controller'); |
| 1257 class ReceivePortImpl extends async.Stream { | 1244 class ReceivePortImpl extends async.Stream { |
| 1258 ReceivePortImpl() { | 1245 ReceivePortImpl() { |
| 1259 this.fromRawReceivePort(new RawReceivePortImpl(null)); | 1246 this.fromRawReceivePort(new RawReceivePortImpl(null)); |
| 1260 } | 1247 } |
| 1261 weak() { | 1248 weak() { |
| 1262 this.fromRawReceivePort(new RawReceivePortImpl.weak(null)); | 1249 this.fromRawReceivePort(new RawReceivePortImpl.weak(null)); |
| 1263 } | 1250 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 return this[_handle] != null; | 1338 return this[_handle] != null; |
| 1352 } | 1339 } |
| 1353 } | 1340 } |
| 1354 TimerImpl[dart.implements] = () => [async.Timer]; | 1341 TimerImpl[dart.implements] = () => [async.Timer]; |
| 1355 dart.defineNamedConstructor(TimerImpl, 'periodic'); | 1342 dart.defineNamedConstructor(TimerImpl, 'periodic'); |
| 1356 // Function hasTimer: () → bool | 1343 // Function hasTimer: () → bool |
| 1357 function hasTimer() { | 1344 function hasTimer() { |
| 1358 _js_helper.requiresPreamble(); | 1345 _js_helper.requiresPreamble(); |
| 1359 return self.setTimeout != null; | 1346 return self.setTimeout != null; |
| 1360 } | 1347 } |
| 1361 let _internal = Symbol('_internal'); | |
| 1362 class CapabilityImpl extends core.Object { | 1348 class CapabilityImpl extends core.Object { |
| 1363 CapabilityImpl() { | 1349 CapabilityImpl() { |
| 1364 this[_internal](_js_helper.random64()); | 1350 this._internal(_js_helper.random64()); |
| 1365 } | 1351 } |
| 1366 [_internal](id) { | 1352 _internal(id) { |
| 1367 this[_id] = id; | 1353 this[_id] = id; |
| 1368 } | 1354 } |
| 1369 get hashCode() { | 1355 get hashCode() { |
| 1370 let hash = this[_id]; | 1356 let hash = this[_id]; |
| 1371 hash = dart.notNull(hash) >> 0 ^ (dart.notNull(hash) / 4294967296).truncat
e(); | 1357 hash = dart.notNull(hash) >> 0 ^ (dart.notNull(hash) / 4294967296).truncat
e(); |
| 1372 hash = ~dart.notNull(hash) + (dart.notNull(hash) << 15) & 4294967295; | 1358 hash = ~dart.notNull(hash) + (dart.notNull(hash) << 15) & 4294967295; |
| 1373 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 12; | 1359 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 12; |
| 1374 hash = dart.notNull(hash) * 5 & 4294967295; | 1360 hash = dart.notNull(hash) * 5 & 4294967295; |
| 1375 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 4; | 1361 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 4; |
| 1376 hash = dart.notNull(hash) * 2057 & 4294967295; | 1362 hash = dart.notNull(hash) * 2057 & 4294967295; |
| 1377 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 16; | 1363 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 16; |
| 1378 return hash; | 1364 return hash; |
| 1379 } | 1365 } |
| 1380 ['=='](other) { | 1366 ['=='](other) { |
| 1381 if (core.identical(other, this)) | 1367 if (core.identical(other, this)) |
| 1382 return true; | 1368 return true; |
| 1383 if (dart.is(other, CapabilityImpl)) { | 1369 if (dart.is(other, CapabilityImpl)) { |
| 1384 return core.identical(this[_id], other[_id]); | 1370 return core.identical(this[_id], other[_id]); |
| 1385 } | 1371 } |
| 1386 return false; | 1372 return false; |
| 1387 } | 1373 } |
| 1388 } | 1374 } |
| 1389 CapabilityImpl[dart.implements] = () => [isolate.Capability]; | 1375 CapabilityImpl[dart.implements] = () => [isolate.Capability]; |
| 1390 dart.defineNamedConstructor(CapabilityImpl, _internal); | 1376 dart.defineNamedConstructor(CapabilityImpl, '_internal'); |
| 1391 // Exports: | 1377 // Exports: |
| 1392 exports.enterJsAsync = enterJsAsync; | 1378 exports.enterJsAsync = enterJsAsync; |
| 1393 exports.leaveJsAsync = leaveJsAsync; | 1379 exports.leaveJsAsync = leaveJsAsync; |
| 1394 exports.isWorker = isWorker; | 1380 exports.isWorker = isWorker; |
| 1395 exports.startRootIsolate = startRootIsolate; | 1381 exports.startRootIsolate = startRootIsolate; |
| 1396 exports.IsolateNatives = IsolateNatives; | 1382 exports.IsolateNatives = IsolateNatives; |
| 1397 exports.RawReceivePortImpl = RawReceivePortImpl; | 1383 exports.RawReceivePortImpl = RawReceivePortImpl; |
| 1398 exports.ReceivePortImpl = ReceivePortImpl; | 1384 exports.ReceivePortImpl = ReceivePortImpl; |
| 1399 exports.TimerImpl = TimerImpl; | 1385 exports.TimerImpl = TimerImpl; |
| 1400 exports.hasTimer = hasTimer; | 1386 exports.hasTimer = hasTimer; |
| 1401 exports.CapabilityImpl = CapabilityImpl; | 1387 exports.CapabilityImpl = CapabilityImpl; |
| 1402 })(_isolate_helper || (_isolate_helper = {})); | 1388 })(_isolate_helper || (_isolate_helper = {})); |
| OLD | NEW |