OLD | NEW |
1 var _isolate_helper = dart.defineLibrary(_isolate_helper, {}); | 1 var _isolate_helper = dart.defineLibrary(_isolate_helper, {}); |
2 var core = dart.import(core); | 2 var core = dart.import(core); |
3 var _native_typed_data = dart.import(_native_typed_data); | 3 var _native_typed_data = dart.import(_native_typed_data); |
4 var _interceptors = dart.import(_interceptors); | 4 var _interceptors = dart.import(_interceptors); |
5 var _js_helper = dart.import(_js_helper); | 5 var _js_helper = dart.import(_js_helper); |
6 var isolate = dart.import(isolate); | 6 var isolate = dart.import(isolate); |
7 var _foreign_helper = dart.import(_foreign_helper); | 7 var _foreign_helper = dart.import(_foreign_helper); |
8 var _js_embedded_names = dart.import(_js_embedded_names); | 8 var _js_embedded_names = dart.import(_js_embedded_names); |
9 var collection = dart.import(collection); | 9 var collection = dart.import(collection); |
10 var async = dart.import(async); | 10 var async = dart.import(async); |
(...skipping 19 matching lines...) Expand all Loading... |
30 let _receivePortId = Symbol('_receivePortId'); | 30 let _receivePortId = Symbol('_receivePortId'); |
31 let _id = Symbol('_id'); | 31 let _id = Symbol('_id'); |
32 let _receivePort = Symbol('_receivePort'); | 32 let _receivePort = Symbol('_receivePort'); |
33 class _Serializer extends core.Object { | 33 class _Serializer extends core.Object { |
34 _Serializer(opts) { | 34 _Serializer(opts) { |
35 let serializeSendPorts = opts && 'serializeSendPorts' in opts ? opts.seria
lizeSendPorts : true; | 35 let serializeSendPorts = opts && 'serializeSendPorts' in opts ? opts.seria
lizeSendPorts : true; |
36 this.serializedObjectIds = core.Map$(core.Object, core.int).identity(); | 36 this.serializedObjectIds = core.Map$(core.Object, core.int).identity(); |
37 this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); | 37 this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); |
38 } | 38 } |
39 serialize(x) { | 39 serialize(x) { |
40 if (this.isPrimitive(x)) | 40 if (dart.notNull(this.isPrimitive(x))) |
41 return this.serializePrimitive(x); | 41 return this.serializePrimitive(x); |
42 let serializationId = this.serializedObjectIds.get(x); | 42 let serializationId = this.serializedObjectIds.get(x); |
43 if (serializationId != null) | 43 if (serializationId != null) |
44 return this.makeRef(serializationId); | 44 return this.makeRef(serializationId); |
45 serializationId = this.serializedObjectIds.length; | 45 serializationId = this.serializedObjectIds.length; |
46 this.serializedObjectIds.set(x, serializationId); | 46 this.serializedObjectIds.set(x, serializationId); |
47 if (dart.is(x, _native_typed_data.NativeByteBuffer)) | 47 if (dart.is(x, _native_typed_data.NativeByteBuffer)) |
48 return this.serializeByteBuffer(dart.as(x, _native_typed_data.NativeByte
Buffer)); | 48 return this.serializeByteBuffer(dart.as(x, _native_typed_data.NativeByte
Buffer)); |
49 if (dart.is(x, _native_typed_data.NativeTypedData)) | 49 if (dart.is(x, _native_typed_data.NativeTypedData)) |
50 return this.serializeTypedData(dart.as(x, _native_typed_data.NativeTyped
Data)); | 50 return this.serializeTypedData(dart.as(x, _native_typed_data.NativeTyped
Data)); |
(...skipping 20 matching lines...) Expand all Loading... |
71 if (message === void 0) | 71 if (message === void 0) |
72 message = null; | 72 message = null; |
73 if (message == null) | 73 if (message == null) |
74 message = "Can't transmit:"; | 74 message = "Can't transmit:"; |
75 throw new core.UnsupportedError(`${message} ${x}`); | 75 throw new core.UnsupportedError(`${message} ${x}`); |
76 } | 76 } |
77 makeRef(serializationId) { | 77 makeRef(serializationId) { |
78 return ["ref", serializationId]; | 78 return ["ref", serializationId]; |
79 } | 79 } |
80 isPrimitive(x) { | 80 isPrimitive(x) { |
81 return dart.notNull(x == null) || typeof x == 'string' || dart.is(x, core.
num) || typeof x == 'boolean'; | 81 return x == null || typeof x == 'string' || dart.is(x, core.num) || typeof
x == 'boolean'; |
82 } | 82 } |
83 serializePrimitive(primitive) { | 83 serializePrimitive(primitive) { |
84 return primitive; | 84 return primitive; |
85 } | 85 } |
86 serializeByteBuffer(buffer) { | 86 serializeByteBuffer(buffer) { |
87 return ["buffer", buffer]; | 87 return ["buffer", buffer]; |
88 } | 88 } |
89 serializeTypedData(data) { | 89 serializeTypedData(data) { |
90 return ["typed", data]; | 90 return ["typed", data]; |
91 } | 91 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 127 } |
128 let keys = dart.as(Object.keys(x), core.List); | 128 let keys = dart.as(Object.keys(x), core.List); |
129 let values = []; | 129 let values = []; |
130 values.length = keys.length; | 130 values.length = keys.length; |
131 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN
ull(i) + 1) { | 131 for (let i = 0; dart.notNull(i) < dart.notNull(keys.length); i = dart.notN
ull(i) + 1) { |
132 values[dartx.set](i, this.serialize(x[keys[dartx.get](i)])); | 132 values[dartx.set](i, this.serialize(x[keys[dartx.get](i)])); |
133 } | 133 } |
134 return ['js-object', keys, values]; | 134 return ['js-object', keys, values]; |
135 } | 135 } |
136 serializeWorkerSendPort(x) { | 136 serializeWorkerSendPort(x) { |
137 if (this[_serializeSendPorts]) { | 137 if (dart.notNull(this[_serializeSendPorts])) { |
138 return ['sendport', x[_workerId], x[_isolateId], x[_receivePortId]]; | 138 return ['sendport', x[_workerId], x[_isolateId], x[_receivePortId]]; |
139 } | 139 } |
140 return ['raw sendport', x]; | 140 return ['raw sendport', x]; |
141 } | 141 } |
142 serializeJsSendPort(x) { | 142 serializeJsSendPort(x) { |
143 if (this[_serializeSendPorts]) { | 143 if (dart.notNull(this[_serializeSendPorts])) { |
144 let workerId = exports._globalState.currentManagerId; | 144 let workerId = exports._globalState.currentManagerId; |
145 return ['sendport', workerId, x[_isolateId], x[_receivePort][_id]]; | 145 return ['sendport', workerId, x[_isolateId], x[_receivePort][_id]]; |
146 } | 146 } |
147 return ['raw sendport', x]; | 147 return ['raw sendport', x]; |
148 } | 148 } |
149 serializeCapability(x) { | 149 serializeCapability(x) { |
150 return ['capability', x[_id]]; | 150 return ['capability', x[_id]]; |
151 } | 151 } |
152 serializeClosure(x) { | 152 serializeClosure(x) { |
153 let name = IsolateNatives._getJSFunctionName(x); | 153 let name = IsolateNatives._getJSFunctionName(x); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 }) | 187 }) |
188 }); | 188 }); |
189 let _adjustSendPorts = Symbol('_adjustSendPorts'); | 189 let _adjustSendPorts = Symbol('_adjustSendPorts'); |
190 class _Deserializer extends core.Object { | 190 class _Deserializer extends core.Object { |
191 _Deserializer(opts) { | 191 _Deserializer(opts) { |
192 let adjustSendPorts = opts && 'adjustSendPorts' in opts ? opts.adjustSendP
orts : true; | 192 let adjustSendPorts = opts && 'adjustSendPorts' in opts ? opts.adjustSendP
orts : true; |
193 this.deserializedObjects = core.List.new(); | 193 this.deserializedObjects = core.List.new(); |
194 this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); | 194 this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); |
195 } | 195 } |
196 deserialize(x) { | 196 deserialize(x) { |
197 if (this.isPrimitive(x)) | 197 if (dart.notNull(this.isPrimitive(x))) |
198 return this.deserializePrimitive(x); | 198 return this.deserializePrimitive(x); |
199 if (!dart.is(x, _interceptors.JSArray)) | 199 if (!dart.is(x, _interceptors.JSArray)) |
200 throw new core.ArgumentError(`Bad serialized message: ${x}`); | 200 throw new core.ArgumentError(`Bad serialized message: ${x}`); |
201 switch (dart.dload(x, 'first')) { | 201 switch (dart.dload(x, 'first')) { |
202 case "ref": | 202 case "ref": |
203 { | 203 { |
204 return this.deserializeRef(x); | 204 return this.deserializeRef(x); |
205 } | 205 } |
206 case "buffer": | 206 case "buffer": |
207 { | 207 { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 { | 251 { |
252 return this.deserializeDartObject(x); | 252 return this.deserializeDartObject(x); |
253 } | 253 } |
254 default: | 254 default: |
255 { | 255 { |
256 throw `couldn't deserialize: ${x}`; | 256 throw `couldn't deserialize: ${x}`; |
257 } | 257 } |
258 } | 258 } |
259 } | 259 } |
260 isPrimitive(x) { | 260 isPrimitive(x) { |
261 return dart.notNull(x == null) || typeof x == 'string' || dart.is(x, core.
num) || typeof x == 'boolean'; | 261 return x == null || typeof x == 'string' || dart.is(x, core.num) || typeof
x == 'boolean'; |
262 } | 262 } |
263 deserializePrimitive(x) { | 263 deserializePrimitive(x) { |
264 return x; | 264 return x; |
265 } | 265 } |
266 deserializeRef(x) { | 266 deserializeRef(x) { |
267 dart.assert(dart.equals(dart.dindex(x, 0), 'ref')); | 267 dart.assert(dart.equals(dart.dindex(x, 0), 'ref')); |
268 let serializationId = dart.as(dart.dindex(x, 1), core.int); | 268 let serializationId = dart.as(dart.dindex(x, 1), core.int); |
269 return this.deserializedObjects[dartx.get](serializationId); | 269 return this.deserializedObjects[dartx.get](serializationId); |
270 } | 270 } |
271 deserializeByteBuffer(x) { | 271 deserializeByteBuffer(x) { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } | 428 } |
429 dart.fn(_currentIsolate, () => dart.functionType(_IsolateContext, [])); | 429 dart.fn(_currentIsolate, () => dart.functionType(_IsolateContext, [])); |
430 function startRootIsolate(entry, args) { | 430 function startRootIsolate(entry, args) { |
431 args = args; | 431 args = args; |
432 if (args == null) | 432 if (args == null) |
433 args = []; | 433 args = []; |
434 if (!dart.is(args, core.List)) { | 434 if (!dart.is(args, core.List)) { |
435 throw new core.ArgumentError(`Arguments to main must be a List: ${args}`); | 435 throw new core.ArgumentError(`Arguments to main must be a List: ${args}`); |
436 } | 436 } |
437 exports._globalState = new _Manager(dart.as(entry, core.Function)); | 437 exports._globalState = new _Manager(dart.as(entry, core.Function)); |
438 if (exports._globalState.isWorker) | 438 if (dart.notNull(exports._globalState.isWorker)) |
439 return; | 439 return; |
440 let rootContext = new _IsolateContext(); | 440 let rootContext = new _IsolateContext(); |
441 exports._globalState.rootContext = rootContext; | 441 exports._globalState.rootContext = rootContext; |
442 exports._globalState.currentContext = rootContext; | 442 exports._globalState.currentContext = rootContext; |
443 if (dart.is(entry, _MainFunctionArgs)) { | 443 if (dart.is(entry, _MainFunctionArgs)) { |
444 rootContext.eval(dart.fn(() => { | 444 rootContext.eval(dart.fn(() => { |
445 dart.dcall(entry, args); | 445 dart.dcall(entry, args); |
446 })); | 446 })); |
447 } else if (dart.is(entry, _MainFunctionArgsMessage)) { | 447 } else if (dart.is(entry, _MainFunctionArgsMessage)) { |
448 rootContext.eval(dart.fn(() => { | 448 rootContext.eval(dart.fn(() => { |
(...skipping 30 matching lines...) Expand all Loading... |
479 this.fromCommandLine = null; | 479 this.fromCommandLine = null; |
480 this.isWorker = null; | 480 this.isWorker = null; |
481 this.supportsWorkers = null; | 481 this.supportsWorkers = null; |
482 this.isolates = null; | 482 this.isolates = null; |
483 this.mainManager = null; | 483 this.mainManager = null; |
484 this.managers = null; | 484 this.managers = null; |
485 this[_nativeDetectEnvironment](); | 485 this[_nativeDetectEnvironment](); |
486 this.topEventLoop = new _EventLoop(); | 486 this.topEventLoop = new _EventLoop(); |
487 this.isolates = core.Map$(core.int, _IsolateContext).new(); | 487 this.isolates = core.Map$(core.int, _IsolateContext).new(); |
488 this.managers = core.Map$(core.int, core.Object).new(); | 488 this.managers = core.Map$(core.int, core.Object).new(); |
489 if (this.isWorker) { | 489 if (dart.notNull(this.isWorker)) { |
490 this.mainManager = new _MainManagerStub(); | 490 this.mainManager = new _MainManagerStub(); |
491 this[_nativeInitWorkerMessageHandler](); | 491 this[_nativeInitWorkerMessageHandler](); |
492 } | 492 } |
493 } | 493 } |
494 [_nativeDetectEnvironment]() { | 494 [_nativeDetectEnvironment]() { |
495 let isWindowDefined = exports.globalWindow != null; | 495 let isWindowDefined = exports.globalWindow != null; |
496 let isWorkerDefined = exports.globalWorker != null; | 496 let isWorkerDefined = exports.globalWorker != null; |
497 this.isWorker = !dart.notNull(isWindowDefined) && dart.notNull(exports.glo
balPostMessageDefined); | 497 this.isWorker = !dart.notNull(isWindowDefined) && dart.notNull(exports.glo
balPostMessageDefined); |
498 this.supportsWorkers = dart.notNull(this.isWorker) || dart.notNull(isWorke
rDefined) && IsolateNatives.thisScript != null; | 498 this.supportsWorkers = dart.notNull(this.isWorker) || dart.notNull(isWorke
rDefined) && IsolateNatives.thisScript != null; |
499 this.fromCommandLine = !dart.notNull(isWindowDefined) && !dart.notNull(thi
s.isWorker); | 499 this.fromCommandLine = !dart.notNull(isWindowDefined) && !dart.notNull(thi
s.isWorker); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 return; | 569 return; |
570 if (dart.notNull(this.pauseTokens.add(resume)) && !dart.notNull(this.isPau
sed)) { | 570 if (dart.notNull(this.pauseTokens.add(resume)) && !dart.notNull(this.isPau
sed)) { |
571 this.isPaused = true; | 571 this.isPaused = true; |
572 } | 572 } |
573 this[_updateGlobalState](); | 573 this[_updateGlobalState](); |
574 } | 574 } |
575 removePause(resume) { | 575 removePause(resume) { |
576 if (!dart.notNull(this.isPaused)) | 576 if (!dart.notNull(this.isPaused)) |
577 return; | 577 return; |
578 this.pauseTokens.remove(resume); | 578 this.pauseTokens.remove(resume); |
579 if (this.pauseTokens.isEmpty) { | 579 if (dart.notNull(this.pauseTokens.isEmpty)) { |
580 while (this.delayedEvents[dartx.isNotEmpty]) { | 580 while (dart.notNull(this.delayedEvents[dartx.isNotEmpty])) { |
581 let event = this.delayedEvents[dartx.removeLast](); | 581 let event = this.delayedEvents[dartx.removeLast](); |
582 exports._globalState.topEventLoop.prequeue(event); | 582 exports._globalState.topEventLoop.prequeue(event); |
583 } | 583 } |
584 this.isPaused = false; | 584 this.isPaused = false; |
585 } | 585 } |
586 this[_updateGlobalState](); | 586 this[_updateGlobalState](); |
587 } | 587 } |
588 addDoneListener(responsePort) { | 588 addDoneListener(responsePort) { |
589 if (this.doneHandlers == null) { | 589 if (this.doneHandlers == null) { |
590 this.doneHandlers = []; | 590 this.doneHandlers = []; |
591 } | 591 } |
592 if (dart.dsend(this.doneHandlers, 'contains', responsePort)) | 592 if (dart.notNull(dart.as(dart.dsend(this.doneHandlers, 'contains', respons
ePort), core.bool))) |
593 return; | 593 return; |
594 dart.dsend(this.doneHandlers, 'add', responsePort); | 594 dart.dsend(this.doneHandlers, 'add', responsePort); |
595 } | 595 } |
596 removeDoneListener(responsePort) { | 596 removeDoneListener(responsePort) { |
597 if (this.doneHandlers == null) | 597 if (this.doneHandlers == null) |
598 return; | 598 return; |
599 dart.dsend(this.doneHandlers, 'remove', responsePort); | 599 dart.dsend(this.doneHandlers, 'remove', responsePort); |
600 } | 600 } |
601 setErrorsFatal(authentification, errorsAreFatal) { | 601 setErrorsFatal(authentification, errorsAreFatal) { |
602 if (!dart.equals(this.terminateCapability, authentification)) | 602 if (!dart.equals(this.terminateCapability, authentification)) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 } | 639 } |
640 dart.dsend(this[_scheduledControlEvents], 'addLast', dart.bind(this, 'kill
')); | 640 dart.dsend(this[_scheduledControlEvents], 'addLast', dart.bind(this, 'kill
')); |
641 } | 641 } |
642 addErrorListener(port) { | 642 addErrorListener(port) { |
643 this.errorPorts.add(port); | 643 this.errorPorts.add(port); |
644 } | 644 } |
645 removeErrorListener(port) { | 645 removeErrorListener(port) { |
646 this.errorPorts.remove(port); | 646 this.errorPorts.remove(port); |
647 } | 647 } |
648 handleUncaughtError(error, stackTrace) { | 648 handleUncaughtError(error, stackTrace) { |
649 if (this.errorPorts.isEmpty) { | 649 if (dart.notNull(this.errorPorts.isEmpty)) { |
650 if (dart.notNull(this.errorsAreFatal) && dart.notNull(core.identical(thi
s, exports._globalState.rootContext))) { | 650 if (dart.notNull(this.errorsAreFatal) && dart.notNull(core.identical(thi
s, exports._globalState.rootContext))) { |
651 return; | 651 return; |
652 } | 652 } |
653 if (self.console && self.console.error) { | 653 if (self.console && self.console.error) { |
654 self.console.error(error, stackTrace); | 654 self.console.error(error, stackTrace); |
655 } else { | 655 } else { |
656 core.print(error); | 656 core.print(error); |
657 if (stackTrace != null) | 657 if (stackTrace != null) |
658 core.print(stackTrace); | 658 core.print(stackTrace); |
659 } | 659 } |
660 return; | 660 return; |
661 } | 661 } |
662 let message = core.List.new(2); | 662 let message = core.List.new(2); |
663 message[dartx.set](0, dart.toString(error)); | 663 message[dartx.set](0, dart.toString(error)); |
664 message[dartx.set](1, stackTrace == null ? null : dart.toString(stackTrace
)); | 664 message[dartx.set](1, stackTrace == null ? null : dart.toString(stackTrace
)); |
665 for (let port of this.errorPorts) | 665 for (let port of this.errorPorts) |
666 port.send(message); | 666 port.send(message); |
667 } | 667 } |
668 eval(code) { | 668 eval(code) { |
669 let old = exports._globalState.currentContext; | 669 let old = exports._globalState.currentContext; |
670 exports._globalState.currentContext = this; | 670 exports._globalState.currentContext = this; |
671 this[_setGlobals](); | 671 this[_setGlobals](); |
672 let result = null; | 672 let result = null; |
673 this[_isExecutingEvent] = true; | 673 this[_isExecutingEvent] = true; |
674 try { | 674 try { |
675 result = dart.dcall(code); | 675 result = dart.dcall(code); |
676 } catch (e) { | 676 } catch (e) { |
677 let s = dart.stackTrace(e); | 677 let s = dart.stackTrace(e); |
678 this.handleUncaughtError(e, s); | 678 this.handleUncaughtError(e, s); |
679 if (this.errorsAreFatal) { | 679 if (dart.notNull(this.errorsAreFatal)) { |
680 this.kill(); | 680 this.kill(); |
681 if (core.identical(this, exports._globalState.rootContext)) { | 681 if (dart.notNull(core.identical(this, exports._globalState.rootContext
))) { |
682 throw e; | 682 throw e; |
683 } | 683 } |
684 } | 684 } |
685 } | 685 } |
686 finally { | 686 finally { |
687 this[_isExecutingEvent] = false; | 687 this[_isExecutingEvent] = false; |
688 exports._globalState.currentContext = old; | 688 exports._globalState.currentContext = old; |
689 if (old != null) | 689 if (old != null) |
690 old[_setGlobals](); | 690 old[_setGlobals](); |
691 if (this[_scheduledControlEvents] != null) { | 691 if (this[_scheduledControlEvents] != null) { |
692 while (dart.dload(this[_scheduledControlEvents], 'isNotEmpty')) { | 692 while (dart.notNull(dart.as(dart.dload(this[_scheduledControlEvents],
'isNotEmpty'), core.bool))) { |
693 dart.dcall(dart.dsend(this[_scheduledControlEvents], 'removeFirst'))
; | 693 dart.dcall(dart.dsend(this[_scheduledControlEvents], 'removeFirst'))
; |
694 } | 694 } |
695 } | 695 } |
696 } | 696 } |
697 return result; | 697 return result; |
698 } | 698 } |
699 [_setGlobals]() { | 699 [_setGlobals]() { |
700 _foreign_helper.JS_SET_CURRENT_ISOLATE(this.isolateStatics); | 700 _foreign_helper.JS_SET_CURRENT_ISOLATE(this.isolateStatics); |
701 } | 701 } |
702 handleControlMessage(message) { | 702 handleControlMessage(message) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 this.removeErrorListener(dart.as(dart.dindex(message, 1), isolate.Send
Port)); | 746 this.removeErrorListener(dart.as(dart.dindex(message, 1), isolate.Send
Port)); |
747 break; | 747 break; |
748 } | 748 } |
749 default: | 749 default: |
750 } | 750 } |
751 } | 751 } |
752 lookup(portId) { | 752 lookup(portId) { |
753 return this.ports.get(portId); | 753 return this.ports.get(portId); |
754 } | 754 } |
755 [_addRegistration](portId, port) { | 755 [_addRegistration](portId, port) { |
756 if (this.ports.containsKey(portId)) { | 756 if (dart.notNull(this.ports.containsKey(portId))) { |
757 throw core.Exception.new("Registry: ports must be registered only once."
); | 757 throw core.Exception.new("Registry: ports must be registered only once."
); |
758 } | 758 } |
759 this.ports.set(portId, port); | 759 this.ports.set(portId, port); |
760 } | 760 } |
761 register(portId, port) { | 761 register(portId, port) { |
762 this[_addRegistration](portId, port); | 762 this[_addRegistration](portId, port); |
763 this[_updateGlobalState](); | 763 this[_updateGlobalState](); |
764 } | 764 } |
765 registerWeak(portId, port) { | 765 registerWeak(portId, port) { |
766 this.weakPorts.add(portId); | 766 this.weakPorts.add(portId); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 this.events = collection.Queue$(_IsolateEvent).new(); | 829 this.events = collection.Queue$(_IsolateEvent).new(); |
830 this[_activeJsAsyncCount] = 0; | 830 this[_activeJsAsyncCount] = 0; |
831 } | 831 } |
832 enqueue(isolate, fn, msg) { | 832 enqueue(isolate, fn, msg) { |
833 this.events.addLast(new _IsolateEvent(dart.as(isolate, _IsolateContext), d
art.as(fn, core.Function), dart.as(msg, core.String))); | 833 this.events.addLast(new _IsolateEvent(dart.as(isolate, _IsolateContext), d
art.as(fn, core.Function), dart.as(msg, core.String))); |
834 } | 834 } |
835 prequeue(event) { | 835 prequeue(event) { |
836 this.events.addFirst(event); | 836 this.events.addFirst(event); |
837 } | 837 } |
838 dequeue() { | 838 dequeue() { |
839 if (this.events.isEmpty) | 839 if (dart.notNull(this.events.isEmpty)) |
840 return null; | 840 return null; |
841 return this.events.removeFirst(); | 841 return this.events.removeFirst(); |
842 } | 842 } |
843 checkOpenReceivePortsFromCommandLine() { | 843 checkOpenReceivePortsFromCommandLine() { |
844 if (dart.notNull(exports._globalState.rootContext != null) && dart.notNull
(exports._globalState.isolates.containsKey(exports._globalState.rootContext.id))
&& dart.notNull(exports._globalState.fromCommandLine) && dart.notNull(exports._
globalState.rootContext.ports.isEmpty)) { | 844 if (exports._globalState.rootContext != null && dart.notNull(exports._glob
alState.isolates.containsKey(exports._globalState.rootContext.id)) && dart.notNu
ll(exports._globalState.fromCommandLine) && dart.notNull(exports._globalState.ro
otContext.ports.isEmpty)) { |
845 throw core.Exception.new("Program exited with open ReceivePorts."); | 845 throw core.Exception.new("Program exited with open ReceivePorts."); |
846 } | 846 } |
847 } | 847 } |
848 runIteration() { | 848 runIteration() { |
849 let event = this.dequeue(); | 849 let event = this.dequeue(); |
850 if (event == null) { | 850 if (event == null) { |
851 this.checkOpenReceivePortsFromCommandLine(); | 851 this.checkOpenReceivePortsFromCommandLine(); |
852 exports._globalState.maybeCloseWorker(); | 852 exports._globalState.maybeCloseWorker(); |
853 return false; | 853 return false; |
854 } | 854 } |
855 event.process(); | 855 event.process(); |
856 return true; | 856 return true; |
857 } | 857 } |
858 [_runHelper]() { | 858 [_runHelper]() { |
859 if (exports.globalWindow != null) { | 859 if (exports.globalWindow != null) { |
860 let next = () => { | 860 let next = () => { |
861 if (!dart.notNull(this.runIteration())) | 861 if (!dart.notNull(this.runIteration())) |
862 return; | 862 return; |
863 async.Timer.run(next); | 863 async.Timer.run(next); |
864 }; | 864 }; |
865 dart.fn(next); | 865 dart.fn(next); |
866 next(); | 866 next(); |
867 } else { | 867 } else { |
868 while (this.runIteration()) { | 868 while (dart.notNull(this.runIteration())) { |
869 } | 869 } |
870 } | 870 } |
871 } | 871 } |
872 run() { | 872 run() { |
873 if (!dart.notNull(exports._globalState.isWorker)) { | 873 if (!dart.notNull(exports._globalState.isWorker)) { |
874 this[_runHelper](); | 874 this[_runHelper](); |
875 } else { | 875 } else { |
876 try { | 876 try { |
877 this[_runHelper](); | 877 this[_runHelper](); |
878 } catch (e) { | 878 } catch (e) { |
(...skipping 16 matching lines...) Expand all Loading... |
895 run: [dart.void, []] | 895 run: [dart.void, []] |
896 }) | 896 }) |
897 }); | 897 }); |
898 class _IsolateEvent extends core.Object { | 898 class _IsolateEvent extends core.Object { |
899 _IsolateEvent(isolate, fn, message) { | 899 _IsolateEvent(isolate, fn, message) { |
900 this.isolate = isolate; | 900 this.isolate = isolate; |
901 this.fn = fn; | 901 this.fn = fn; |
902 this.message = message; | 902 this.message = message; |
903 } | 903 } |
904 process() { | 904 process() { |
905 if (this.isolate.isPaused) { | 905 if (dart.notNull(this.isolate.isPaused)) { |
906 this.isolate.delayedEvents[dartx.add](this); | 906 this.isolate.delayedEvents[dartx.add](this); |
907 return; | 907 return; |
908 } | 908 } |
909 this.isolate.eval(this.fn); | 909 this.isolate.eval(this.fn); |
910 } | 910 } |
911 } | 911 } |
912 dart.setSignature(_IsolateEvent, { | 912 dart.setSignature(_IsolateEvent, { |
913 constructors: () => ({_IsolateEvent: [_IsolateEvent, [_IsolateContext, core.
Function, core.String]]}), | 913 constructors: () => ({_IsolateEvent: [_IsolateEvent, [_IsolateContext, core.
Function, core.String]]}), |
914 methods: () => ({process: [dart.void, []]}) | 914 methods: () => ({process: [dart.void, []]}) |
915 }); | 915 }); |
(...skipping 20 matching lines...) Expand all Loading... |
936 }); | 936 }); |
937 let _MainFunction = dart.typedef('_MainFunction', () => dart.functionType(core
.Object, [])); | 937 let _MainFunction = dart.typedef('_MainFunction', () => dart.functionType(core
.Object, [])); |
938 let _MainFunctionArgs = dart.typedef('_MainFunctionArgs', () => dart.functionT
ype(core.Object, [dart.bottom])); | 938 let _MainFunctionArgs = dart.typedef('_MainFunctionArgs', () => dart.functionT
ype(core.Object, [dart.bottom])); |
939 let _MainFunctionArgsMessage = dart.typedef('_MainFunctionArgsMessage', () =>
dart.functionType(core.Object, [dart.bottom, dart.bottom])); | 939 let _MainFunctionArgsMessage = dart.typedef('_MainFunctionArgsMessage', () =>
dart.functionType(core.Object, [dart.bottom, dart.bottom])); |
940 class IsolateNatives extends core.Object { | 940 class IsolateNatives extends core.Object { |
941 static computeThisScript() { | 941 static computeThisScript() { |
942 let currentScript = document.currentScript; | 942 let currentScript = document.currentScript; |
943 if (currentScript != null) { | 943 if (currentScript != null) { |
944 return String(currentScript.src); | 944 return String(currentScript.src); |
945 } | 945 } |
946 if (_js_helper.Primitives.isD8) | 946 if (dart.notNull(_js_helper.Primitives.isD8)) |
947 return IsolateNatives.computeThisScriptD8(); | 947 return IsolateNatives.computeThisScriptD8(); |
948 if (_js_helper.Primitives.isJsshell) | 948 if (dart.notNull(_js_helper.Primitives.isJsshell)) |
949 return IsolateNatives.computeThisScriptJsshell(); | 949 return IsolateNatives.computeThisScriptJsshell(); |
950 if (exports._globalState.isWorker) | 950 if (dart.notNull(exports._globalState.isWorker)) |
951 return IsolateNatives.computeThisScriptFromTrace(); | 951 return IsolateNatives.computeThisScriptFromTrace(); |
952 return null; | 952 return null; |
953 } | 953 } |
954 static computeThisScriptJsshell() { | 954 static computeThisScriptJsshell() { |
955 return dart.as(thisFilename(), core.String); | 955 return dart.as(thisFilename(), core.String); |
956 } | 956 } |
957 static computeThisScriptD8() { | 957 static computeThisScriptD8() { |
958 return IsolateNatives.computeThisScriptFromTrace(); | 958 return IsolateNatives.computeThisScriptFromTrace(); |
959 } | 959 } |
960 static computeThisScriptFromTrace() { | 960 static computeThisScriptFromTrace() { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 exports._globalState.topEventLoop.run(); | 1028 exports._globalState.topEventLoop.run(); |
1029 break; | 1029 break; |
1030 } | 1030 } |
1031 case 'log': | 1031 case 'log': |
1032 { | 1032 { |
1033 IsolateNatives._log(dart.dindex(msg, 'msg')); | 1033 IsolateNatives._log(dart.dindex(msg, 'msg')); |
1034 break; | 1034 break; |
1035 } | 1035 } |
1036 case 'print': | 1036 case 'print': |
1037 { | 1037 { |
1038 if (exports._globalState.isWorker) { | 1038 if (dart.notNull(exports._globalState.isWorker)) { |
1039 exports._globalState.mainManager.postMessage(_serializeMessage(dart.
map({command: 'print', msg: msg}))); | 1039 exports._globalState.mainManager.postMessage(_serializeMessage(dart.
map({command: 'print', msg: msg}))); |
1040 } else { | 1040 } else { |
1041 core.print(dart.dindex(msg, 'msg')); | 1041 core.print(dart.dindex(msg, 'msg')); |
1042 } | 1042 } |
1043 break; | 1043 break; |
1044 } | 1044 } |
1045 case 'error': | 1045 case 'error': |
1046 { | 1046 { |
1047 throw dart.dindex(msg, 'msg'); | 1047 throw dart.dindex(msg, 'msg'); |
1048 } | 1048 } |
1049 } | 1049 } |
1050 } | 1050 } |
1051 static handleSpawnWorkerRequest(msg) { | 1051 static handleSpawnWorkerRequest(msg) { |
1052 let replyPort = dart.dindex(msg, 'replyPort'); | 1052 let replyPort = dart.dindex(msg, 'replyPort'); |
1053 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(dart.fn(msg => { | 1053 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(dart.fn(msg => { |
1054 dart.dsend(replyPort, 'send', msg); | 1054 dart.dsend(replyPort, 'send', msg); |
1055 }), {onError: dart.fn(errorMessage => { | 1055 }), {onError: dart.fn(errorMessage => { |
1056 dart.dsend(replyPort, 'send', [_SPAWN_FAILED_SIGNAL, errorMessage]); | 1056 dart.dsend(replyPort, 'send', [_SPAWN_FAILED_SIGNAL, errorMessage]); |
1057 }, core.Object, [core.String])}); | 1057 }, core.Object, [core.String])}); |
1058 } | 1058 } |
1059 static _log(msg) { | 1059 static _log(msg) { |
1060 if (exports._globalState.isWorker) { | 1060 if (dart.notNull(exports._globalState.isWorker)) { |
1061 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'log', msg: msg}))); | 1061 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'log', msg: msg}))); |
1062 } else { | 1062 } else { |
1063 try { | 1063 try { |
1064 IsolateNatives._consoleLog(msg); | 1064 IsolateNatives._consoleLog(msg); |
1065 } catch (e) { | 1065 } catch (e) { |
1066 let trace = dart.stackTrace(e); | 1066 let trace = dart.stackTrace(e); |
1067 throw core.Exception.new(trace); | 1067 throw core.Exception.new(trace); |
1068 } | 1068 } |
1069 | 1069 |
1070 } | 1070 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight
)) { | 1116 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight
)) { |
1117 IsolateNatives._startWorker(functionName, uri, args, message, isSpawnUri
, startPaused, signalReply, dart.fn(message => completer.completeError(message),
dart.void, [core.String])); | 1117 IsolateNatives._startWorker(functionName, uri, args, message, isSpawnUri
, startPaused, signalReply, dart.fn(message => completer.completeError(message),
dart.void, [core.String])); |
1118 } else { | 1118 } else { |
1119 IsolateNatives._startNonWorker(functionName, uri, args, message, isSpawn
Uri, startPaused, signalReply); | 1119 IsolateNatives._startNonWorker(functionName, uri, args, message, isSpawn
Uri, startPaused, signalReply); |
1120 } | 1120 } |
1121 return completer.future; | 1121 return completer.future; |
1122 } | 1122 } |
1123 static _startWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { | 1123 static _startWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { |
1124 if (args != null) | 1124 if (args != null) |
1125 args = core.List$(core.String).from(args); | 1125 args = core.List$(core.String).from(args); |
1126 if (exports._globalState.isWorker) { | 1126 if (dart.notNull(exports._globalState.isWorker)) { |
1127 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'spawn-worker', functionName: functionName, args: args, msg: message,
uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort
}))); | 1127 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'spawn-worker', functionName: functionName, args: args, msg: message,
uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort
}))); |
1128 } else { | 1128 } else { |
1129 IsolateNatives._spawnWorker(functionName, uri, args, message, isSpawnUri
, startPaused, replyPort, onError); | 1129 IsolateNatives._spawnWorker(functionName, uri, args, message, isSpawnUri
, startPaused, replyPort, onError); |
1130 } | 1130 } |
1131 } | 1131 } |
1132 static _startNonWorker(functionName, uri, args, message, isSpawnUri, startPa
used, replyPort) { | 1132 static _startNonWorker(functionName, uri, args, message, isSpawnUri, startPa
used, replyPort) { |
1133 if (uri != null) { | 1133 if (uri != null) { |
1134 throw new core.UnsupportedError("Currently spawnUri is not supported wit
hout web workers."); | 1134 throw new core.UnsupportedError("Currently spawnUri is not supported wit
hout web workers."); |
1135 } | 1135 } |
1136 message = _clone(message); | 1136 message = _clone(message); |
(...skipping 18 matching lines...) Expand all Loading... |
1155 dart.dcall(topLevel, message); | 1155 dart.dcall(topLevel, message); |
1156 } else if (dart.is(topLevel, _MainFunctionArgsMessage)) { | 1156 } else if (dart.is(topLevel, _MainFunctionArgsMessage)) { |
1157 dart.dcall(topLevel, args, message); | 1157 dart.dcall(topLevel, args, message); |
1158 } else if (dart.is(topLevel, _MainFunctionArgs)) { | 1158 } else if (dart.is(topLevel, _MainFunctionArgs)) { |
1159 dart.dcall(topLevel, args); | 1159 dart.dcall(topLevel, args); |
1160 } else { | 1160 } else { |
1161 dart.dcall(topLevel); | 1161 dart.dcall(topLevel); |
1162 } | 1162 } |
1163 }; | 1163 }; |
1164 dart.fn(runStartFunction, dart.void, []); | 1164 dart.fn(runStartFunction, dart.void, []); |
1165 if (startPaused) { | 1165 if (dart.notNull(startPaused)) { |
1166 context.addPause(context.pauseCapability, context.pauseCapability); | 1166 context.addPause(context.pauseCapability, context.pauseCapability); |
1167 exports._globalState.topEventLoop.enqueue(context, runStartFunction, 'st
art isolate'); | 1167 exports._globalState.topEventLoop.enqueue(context, runStartFunction, 'st
art isolate'); |
1168 } else { | 1168 } else { |
1169 runStartFunction(); | 1169 runStartFunction(); |
1170 } | 1170 } |
1171 } | 1171 } |
1172 static _spawnWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { | 1172 static _spawnWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { |
1173 if (uri == null) | 1173 if (uri == null) |
1174 uri = IsolateNatives.thisScript; | 1174 uri = IsolateNatives.thisScript; |
1175 let worker = new Worker(uri); | 1175 let worker = new Worker(uri); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 get workerIds() { | 1239 get workerIds() { |
1240 return new (core.Expando$(core.int))(); | 1240 return new (core.Expando$(core.int))(); |
1241 } | 1241 } |
1242 }); | 1242 }); |
1243 let _checkReplyTo = Symbol('_checkReplyTo'); | 1243 let _checkReplyTo = Symbol('_checkReplyTo'); |
1244 class _BaseSendPort extends core.Object { | 1244 class _BaseSendPort extends core.Object { |
1245 _BaseSendPort(isolateId) { | 1245 _BaseSendPort(isolateId) { |
1246 this[_isolateId] = isolateId; | 1246 this[_isolateId] = isolateId; |
1247 } | 1247 } |
1248 [_checkReplyTo](replyTo) { | 1248 [_checkReplyTo](replyTo) { |
1249 if (dart.notNull(replyTo != null) && !dart.is(replyTo, _NativeJsSendPort)
&& !dart.is(replyTo, _WorkerSendPort)) { | 1249 if (replyTo != null && !dart.is(replyTo, _NativeJsSendPort) && !dart.is(re
plyTo, _WorkerSendPort)) { |
1250 throw core.Exception.new("SendPort.send: Illegal replyTo port type"); | 1250 throw core.Exception.new("SendPort.send: Illegal replyTo port type"); |
1251 } | 1251 } |
1252 } | 1252 } |
1253 } | 1253 } |
1254 _BaseSendPort[dart.implements] = () => [isolate.SendPort]; | 1254 _BaseSendPort[dart.implements] = () => [isolate.SendPort]; |
1255 dart.setSignature(_BaseSendPort, { | 1255 dart.setSignature(_BaseSendPort, { |
1256 constructors: () => ({_BaseSendPort: [_BaseSendPort, [core.int]]}), | 1256 constructors: () => ({_BaseSendPort: [_BaseSendPort, [core.int]]}), |
1257 methods: () => ({[_checkReplyTo]: [dart.void, [isolate.SendPort]]}) | 1257 methods: () => ({[_checkReplyTo]: [dart.void, [isolate.SendPort]]}) |
1258 }); | 1258 }); |
1259 let _isClosed = Symbol('_isClosed'); | 1259 let _isClosed = Symbol('_isClosed'); |
1260 let _add = Symbol('_add'); | 1260 let _add = Symbol('_add'); |
1261 class _NativeJsSendPort extends _BaseSendPort { | 1261 class _NativeJsSendPort extends _BaseSendPort { |
1262 _NativeJsSendPort(receivePort, isolateId) { | 1262 _NativeJsSendPort(receivePort, isolateId) { |
1263 this[_receivePort] = receivePort; | 1263 this[_receivePort] = receivePort; |
1264 super._BaseSendPort(isolateId); | 1264 super._BaseSendPort(isolateId); |
1265 } | 1265 } |
1266 send(message) { | 1266 send(message) { |
1267 let isolate = exports._globalState.isolates.get(this[_isolateId]); | 1267 let isolate = exports._globalState.isolates.get(this[_isolateId]); |
1268 if (isolate == null) | 1268 if (isolate == null) |
1269 return; | 1269 return; |
1270 if (this[_receivePort][_isClosed]) | 1270 if (dart.notNull(this[_receivePort][_isClosed])) |
1271 return; | 1271 return; |
1272 let msg = _clone(message); | 1272 let msg = _clone(message); |
1273 if (dart.equals(isolate.controlPort, this[_receivePort])) { | 1273 if (dart.equals(isolate.controlPort, this[_receivePort])) { |
1274 isolate.handleControlMessage(msg); | 1274 isolate.handleControlMessage(msg); |
1275 return; | 1275 return; |
1276 } | 1276 } |
1277 exports._globalState.topEventLoop.enqueue(isolate, dart.fn(() => { | 1277 exports._globalState.topEventLoop.enqueue(isolate, dart.fn(() => { |
1278 if (!dart.notNull(this[_receivePort][_isClosed])) { | 1278 if (!dart.notNull(this[_receivePort][_isClosed])) { |
1279 this[_receivePort][_add](msg); | 1279 this[_receivePort][_add](msg); |
1280 } | 1280 } |
1281 }), `receive ${message}`); | 1281 }), `receive ${message}`); |
1282 } | 1282 } |
1283 ['=='](other) { | 1283 ['=='](other) { |
1284 return dart.is(other, _NativeJsSendPort) && dart.notNull(dart.equals(this[
_receivePort], dart.dload(other, _receivePort))); | 1284 return dart.is(other, _NativeJsSendPort) && dart.equals(this[_receivePort]
, dart.dload(other, _receivePort)); |
1285 } | 1285 } |
1286 get hashCode() { | 1286 get hashCode() { |
1287 return this[_receivePort][_id]; | 1287 return this[_receivePort][_id]; |
1288 } | 1288 } |
1289 } | 1289 } |
1290 _NativeJsSendPort[dart.implements] = () => [isolate.SendPort]; | 1290 _NativeJsSendPort[dart.implements] = () => [isolate.SendPort]; |
1291 dart.setSignature(_NativeJsSendPort, { | 1291 dart.setSignature(_NativeJsSendPort, { |
1292 constructors: () => ({_NativeJsSendPort: [_NativeJsSendPort, [RawReceivePort
Impl, core.int]]}), | 1292 constructors: () => ({_NativeJsSendPort: [_NativeJsSendPort, [RawReceivePort
Impl, core.int]]}), |
1293 methods: () => ({send: [dart.void, [core.Object]]}) | 1293 methods: () => ({send: [dart.void, [core.Object]]}) |
1294 }); | 1294 }); |
1295 class _WorkerSendPort extends _BaseSendPort { | 1295 class _WorkerSendPort extends _BaseSendPort { |
1296 _WorkerSendPort(workerId, isolateId, receivePortId) { | 1296 _WorkerSendPort(workerId, isolateId, receivePortId) { |
1297 this[_workerId] = workerId; | 1297 this[_workerId] = workerId; |
1298 this[_receivePortId] = receivePortId; | 1298 this[_receivePortId] = receivePortId; |
1299 super._BaseSendPort(isolateId); | 1299 super._BaseSendPort(isolateId); |
1300 } | 1300 } |
1301 send(message) { | 1301 send(message) { |
1302 let workerMessage = _serializeMessage(dart.map({command: 'message', port:
this, msg: message})); | 1302 let workerMessage = _serializeMessage(dart.map({command: 'message', port:
this, msg: message})); |
1303 if (exports._globalState.isWorker) { | 1303 if (dart.notNull(exports._globalState.isWorker)) { |
1304 exports._globalState.mainManager.postMessage(workerMessage); | 1304 exports._globalState.mainManager.postMessage(workerMessage); |
1305 } else { | 1305 } else { |
1306 let manager = exports._globalState.managers.get(this[_workerId]); | 1306 let manager = exports._globalState.managers.get(this[_workerId]); |
1307 if (manager != null) { | 1307 if (manager != null) { |
1308 manager.postMessage(workerMessage); | 1308 manager.postMessage(workerMessage); |
1309 } | 1309 } |
1310 } | 1310 } |
1311 } | 1311 } |
1312 ['=='](other) { | 1312 ['=='](other) { |
1313 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
)); | 1313 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
)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 this[_isClosed] = false; | 1349 this[_isClosed] = false; |
1350 } | 1350 } |
1351 set handler(newHandler) { | 1351 set handler(newHandler) { |
1352 this[_handler] = newHandler; | 1352 this[_handler] = newHandler; |
1353 } | 1353 } |
1354 [_close]() { | 1354 [_close]() { |
1355 this[_isClosed] = true; | 1355 this[_isClosed] = true; |
1356 this[_handler] = null; | 1356 this[_handler] = null; |
1357 } | 1357 } |
1358 close() { | 1358 close() { |
1359 if (this[_isClosed]) | 1359 if (dart.notNull(this[_isClosed])) |
1360 return; | 1360 return; |
1361 this[_isClosed] = true; | 1361 this[_isClosed] = true; |
1362 this[_handler] = null; | 1362 this[_handler] = null; |
1363 exports._globalState.currentContext.unregister(this[_id]); | 1363 exports._globalState.currentContext.unregister(this[_id]); |
1364 } | 1364 } |
1365 [_add](dataEvent) { | 1365 [_add](dataEvent) { |
1366 if (this[_isClosed]) | 1366 if (dart.notNull(this[_isClosed])) |
1367 return; | 1367 return; |
1368 dart.dcall(this[_handler], dataEvent); | 1368 dart.dcall(this[_handler], dataEvent); |
1369 } | 1369 } |
1370 get sendPort() { | 1370 get sendPort() { |
1371 return new _NativeJsSendPort(this, exports._globalState.currentContext.id)
; | 1371 return new _NativeJsSendPort(this, exports._globalState.currentContext.id)
; |
1372 } | 1372 } |
1373 } | 1373 } |
1374 RawReceivePortImpl[dart.implements] = () => [isolate.RawReceivePort]; | 1374 RawReceivePortImpl[dart.implements] = () => [isolate.RawReceivePort]; |
1375 dart.defineNamedConstructor(RawReceivePortImpl, 'weak'); | 1375 dart.defineNamedConstructor(RawReceivePortImpl, 'weak'); |
1376 dart.defineNamedConstructor(RawReceivePortImpl, '_controlPort'); | 1376 dart.defineNamedConstructor(RawReceivePortImpl, '_controlPort'); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 this[_handle] = null; | 1441 this[_handle] = null; |
1442 if (milliseconds == 0 && (!dart.notNull(hasTimer()) || dart.notNull(export
s._globalState.isWorker))) { | 1442 if (milliseconds == 0 && (!dart.notNull(hasTimer()) || dart.notNull(export
s._globalState.isWorker))) { |
1443 let internalCallback = () => { | 1443 let internalCallback = () => { |
1444 this[_handle] = null; | 1444 this[_handle] = null; |
1445 callback(); | 1445 callback(); |
1446 }; | 1446 }; |
1447 dart.fn(internalCallback, dart.void, []); | 1447 dart.fn(internalCallback, dart.void, []); |
1448 this[_handle] = 1; | 1448 this[_handle] = 1; |
1449 exports._globalState.topEventLoop.enqueue(exports._globalState.currentCo
ntext, internalCallback, 'timer'); | 1449 exports._globalState.topEventLoop.enqueue(exports._globalState.currentCo
ntext, internalCallback, 'timer'); |
1450 this[_inEventLoop] = true; | 1450 this[_inEventLoop] = true; |
1451 } else if (hasTimer()) { | 1451 } else if (dart.notNull(hasTimer())) { |
1452 let internalCallback = () => { | 1452 let internalCallback = () => { |
1453 this[_handle] = null; | 1453 this[_handle] = null; |
1454 leaveJsAsync(); | 1454 leaveJsAsync(); |
1455 callback(); | 1455 callback(); |
1456 }; | 1456 }; |
1457 dart.fn(internalCallback, dart.void, []); | 1457 dart.fn(internalCallback, dart.void, []); |
1458 enterJsAsync(); | 1458 enterJsAsync(); |
1459 this[_handle] = self.setTimeout(_js_helper.convertDartClosureToJS(intern
alCallback, 0), milliseconds); | 1459 this[_handle] = self.setTimeout(_js_helper.convertDartClosureToJS(intern
alCallback, 0), milliseconds); |
1460 } else { | 1460 } else { |
1461 dart.assert(dart.notNull(milliseconds) > 0); | 1461 dart.assert(dart.notNull(milliseconds) > 0); |
1462 throw new core.UnsupportedError("Timer greater than 0."); | 1462 throw new core.UnsupportedError("Timer greater than 0."); |
1463 } | 1463 } |
1464 } | 1464 } |
1465 periodic(milliseconds, callback) { | 1465 periodic(milliseconds, callback) { |
1466 this[_once] = false; | 1466 this[_once] = false; |
1467 this[_inEventLoop] = false; | 1467 this[_inEventLoop] = false; |
1468 this[_handle] = null; | 1468 this[_handle] = null; |
1469 if (hasTimer()) { | 1469 if (dart.notNull(hasTimer())) { |
1470 enterJsAsync(); | 1470 enterJsAsync(); |
1471 this[_handle] = self.setInterval(_js_helper.convertDartClosureToJS(dart.
fn(() => { | 1471 this[_handle] = self.setInterval(_js_helper.convertDartClosureToJS(dart.
fn(() => { |
1472 callback(this); | 1472 callback(this); |
1473 }), 0), milliseconds); | 1473 }), 0), milliseconds); |
1474 } else { | 1474 } else { |
1475 throw new core.UnsupportedError("Periodic timer."); | 1475 throw new core.UnsupportedError("Periodic timer."); |
1476 } | 1476 } |
1477 } | 1477 } |
1478 cancel() { | 1478 cancel() { |
1479 if (hasTimer()) { | 1479 if (dart.notNull(hasTimer())) { |
1480 if (this[_inEventLoop]) { | 1480 if (dart.notNull(this[_inEventLoop])) { |
1481 throw new core.UnsupportedError("Timer in event loop cannot be cancele
d."); | 1481 throw new core.UnsupportedError("Timer in event loop cannot be cancele
d."); |
1482 } | 1482 } |
1483 if (this[_handle] == null) | 1483 if (this[_handle] == null) |
1484 return; | 1484 return; |
1485 leaveJsAsync(); | 1485 leaveJsAsync(); |
1486 if (this[_once]) { | 1486 if (dart.notNull(this[_once])) { |
1487 self.clearTimeout(this[_handle]); | 1487 self.clearTimeout(this[_handle]); |
1488 } else { | 1488 } else { |
1489 self.clearInterval(this[_handle]); | 1489 self.clearInterval(this[_handle]); |
1490 } | 1490 } |
1491 this[_handle] = null; | 1491 this[_handle] = null; |
1492 } else { | 1492 } else { |
1493 throw new core.UnsupportedError("Canceling a timer."); | 1493 throw new core.UnsupportedError("Canceling a timer."); |
1494 } | 1494 } |
1495 } | 1495 } |
1496 get isActive() { | 1496 get isActive() { |
(...skipping 25 matching lines...) Expand all Loading... |
1522 hash = dart.notNull(hash) >> 0 ^ (dart.notNull(hash) / 4294967296).truncat
e(); | 1522 hash = dart.notNull(hash) >> 0 ^ (dart.notNull(hash) / 4294967296).truncat
e(); |
1523 hash = ~dart.notNull(hash) + (dart.notNull(hash) << 15) & 4294967295; | 1523 hash = ~dart.notNull(hash) + (dart.notNull(hash) << 15) & 4294967295; |
1524 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 12; | 1524 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 12; |
1525 hash = dart.notNull(hash) * 5 & 4294967295; | 1525 hash = dart.notNull(hash) * 5 & 4294967295; |
1526 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 4; | 1526 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 4; |
1527 hash = dart.notNull(hash) * 2057 & 4294967295; | 1527 hash = dart.notNull(hash) * 2057 & 4294967295; |
1528 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 16; | 1528 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 16; |
1529 return hash; | 1529 return hash; |
1530 } | 1530 } |
1531 ['=='](other) { | 1531 ['=='](other) { |
1532 if (core.identical(other, this)) | 1532 if (dart.notNull(core.identical(other, this))) |
1533 return true; | 1533 return true; |
1534 if (dart.is(other, CapabilityImpl)) { | 1534 if (dart.is(other, CapabilityImpl)) { |
1535 return core.identical(this[_id], other[_id]); | 1535 return core.identical(this[_id], other[_id]); |
1536 } | 1536 } |
1537 return false; | 1537 return false; |
1538 } | 1538 } |
1539 } | 1539 } |
1540 CapabilityImpl[dart.implements] = () => [isolate.Capability]; | 1540 CapabilityImpl[dart.implements] = () => [isolate.Capability]; |
1541 dart.defineNamedConstructor(CapabilityImpl, '_internal'); | 1541 dart.defineNamedConstructor(CapabilityImpl, '_internal'); |
1542 dart.setSignature(CapabilityImpl, { | 1542 dart.setSignature(CapabilityImpl, { |
1543 constructors: () => ({ | 1543 constructors: () => ({ |
1544 CapabilityImpl: [CapabilityImpl, []], | 1544 CapabilityImpl: [CapabilityImpl, []], |
1545 _internal: [CapabilityImpl, [core.int]] | 1545 _internal: [CapabilityImpl, [core.int]] |
1546 }), | 1546 }), |
1547 methods: () => ({'==': [core.bool, [core.Object]]}) | 1547 methods: () => ({'==': [core.bool, [core.Object]]}) |
1548 }); | 1548 }); |
1549 // Exports: | 1549 // Exports: |
1550 exports.enterJsAsync = enterJsAsync; | 1550 exports.enterJsAsync = enterJsAsync; |
1551 exports.leaveJsAsync = leaveJsAsync; | 1551 exports.leaveJsAsync = leaveJsAsync; |
1552 exports.isWorker = isWorker; | 1552 exports.isWorker = isWorker; |
1553 exports.startRootIsolate = startRootIsolate; | 1553 exports.startRootIsolate = startRootIsolate; |
1554 exports.IsolateNatives = IsolateNatives; | 1554 exports.IsolateNatives = IsolateNatives; |
1555 exports.RawReceivePortImpl = RawReceivePortImpl; | 1555 exports.RawReceivePortImpl = RawReceivePortImpl; |
1556 exports.ReceivePortImpl = ReceivePortImpl; | 1556 exports.ReceivePortImpl = ReceivePortImpl; |
1557 exports.TimerImpl = TimerImpl; | 1557 exports.TimerImpl = TimerImpl; |
1558 exports.hasTimer = hasTimer; | 1558 exports.hasTimer = hasTimer; |
1559 exports.CapabilityImpl = CapabilityImpl; | 1559 exports.CapabilityImpl = CapabilityImpl; |
1560 })(_isolate_helper, core, _native_typed_data, _interceptors, _js_helper, isolate
, _foreign_helper, _js_embedded_names, collection, async); | 1560 })(_isolate_helper, core, _native_typed_data, _interceptors, _js_helper, isolate
, _foreign_helper, _js_embedded_names, collection, async); |
OLD | NEW |