OLD | NEW |
1 dart_library.library('dart/_isolate_helper', null, /* Imports */[ | 1 dart_library.library('dart/_isolate_helper', null, /* Imports */[ |
2 "dart/_runtime", | 2 "dart/_runtime", |
3 'dart/core', | 3 'dart/core', |
4 'dart/_interceptors', | 4 'dart/_interceptors', |
5 'dart/_js_helper', | 5 'dart/_js_helper', |
6 'dart/isolate', | 6 'dart/isolate', |
7 'dart/_foreign_helper', | 7 'dart/_foreign_helper', |
8 'dart/collection', | 8 'dart/collection', |
9 'dart/async' | 9 'dart/async' |
10 ], /* Lazy imports */[ | 10 ], /* Lazy imports */[ |
(...skipping 22 matching lines...) Expand all Loading... |
33 const _receivePortId = Symbol('_receivePortId'); | 33 const _receivePortId = Symbol('_receivePortId'); |
34 const _id = Symbol('_id'); | 34 const _id = Symbol('_id'); |
35 const _receivePort = Symbol('_receivePort'); | 35 const _receivePort = Symbol('_receivePort'); |
36 class _Serializer extends core.Object { | 36 class _Serializer extends core.Object { |
37 _Serializer(opts) { | 37 _Serializer(opts) { |
38 let serializeSendPorts = opts && 'serializeSendPorts' in opts ? opts.seria
lizeSendPorts : true; | 38 let serializeSendPorts = opts && 'serializeSendPorts' in opts ? opts.seria
lizeSendPorts : true; |
39 this.serializedObjectIds = core.Map$(dart.dynamic, core.int).identity(); | 39 this.serializedObjectIds = core.Map$(dart.dynamic, core.int).identity(); |
40 this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); | 40 this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); |
41 } | 41 } |
42 serialize(x) { | 42 serialize(x) { |
43 if (dart.notNull(this.isPrimitive(x))) | 43 if (dart.notNull(this.isPrimitive(x))) return this.serializePrimitive(x); |
44 return this.serializePrimitive(x); | |
45 let serializationId = this.serializedObjectIds.get(x); | 44 let serializationId = this.serializedObjectIds.get(x); |
46 if (serializationId != null) | 45 if (serializationId != null) return this.makeRef(serializationId); |
47 return this.makeRef(serializationId); | |
48 serializationId = this.serializedObjectIds.length; | 46 serializationId = this.serializedObjectIds.length; |
49 this.serializedObjectIds.set(x, serializationId); | 47 this.serializedObjectIds.set(x, serializationId); |
50 if (dart.is(x, _native_typed_data.NativeByteBuffer)) | 48 if (dart.is(x, _native_typed_data.NativeByteBuffer)) return this.serialize
ByteBuffer(dart.as(x, _native_typed_data.NativeByteBuffer)); |
51 return this.serializeByteBuffer(dart.as(x, _native_typed_data.NativeByte
Buffer)); | 49 if (dart.is(x, _native_typed_data.NativeTypedData)) return this.serializeT
ypedData(dart.as(x, _native_typed_data.NativeTypedData)); |
52 if (dart.is(x, _native_typed_data.NativeTypedData)) | 50 if (dart.is(x, _interceptors.JSIndexable)) return this.serializeJSIndexabl
e(dart.as(x, _interceptors.JSIndexable)); |
53 return this.serializeTypedData(dart.as(x, _native_typed_data.NativeTyped
Data)); | 51 if (dart.is(x, _js_helper.InternalMap)) return this.serializeMap(dart.as(x
, core.Map)); |
54 if (dart.is(x, _interceptors.JSIndexable)) | 52 if (dart.is(x, _interceptors.JSObject)) return this.serializeJSObject(dart
.as(x, _interceptors.JSObject)); |
55 return this.serializeJSIndexable(dart.as(x, _interceptors.JSIndexable)); | 53 if (dart.is(x, _interceptors.Interceptor)) this.unsupported(x); |
56 if (dart.is(x, _js_helper.InternalMap)) | |
57 return this.serializeMap(dart.as(x, core.Map)); | |
58 if (dart.is(x, _interceptors.JSObject)) | |
59 return this.serializeJSObject(dart.as(x, _interceptors.JSObject)); | |
60 if (dart.is(x, _interceptors.Interceptor)) | |
61 this.unsupported(x); | |
62 if (dart.is(x, isolate.RawReceivePort)) { | 54 if (dart.is(x, isolate.RawReceivePort)) { |
63 this.unsupported(x, "RawReceivePorts can't be transmitted:"); | 55 this.unsupported(x, "RawReceivePorts can't be transmitted:"); |
64 } | 56 } |
65 if (dart.is(x, _NativeJsSendPort)) | 57 if (dart.is(x, _NativeJsSendPort)) return this.serializeJsSendPort(dart.as
(x, _NativeJsSendPort)); |
66 return this.serializeJsSendPort(dart.as(x, _NativeJsSendPort)); | 58 if (dart.is(x, _WorkerSendPort)) return this.serializeWorkerSendPort(dart.
as(x, _WorkerSendPort)); |
67 if (dart.is(x, _WorkerSendPort)) | 59 if (dart.is(x, core.Function)) return this.serializeClosure(dart.as(x, cor
e.Function)); |
68 return this.serializeWorkerSendPort(dart.as(x, _WorkerSendPort)); | |
69 if (dart.is(x, core.Function)) | |
70 return this.serializeClosure(dart.as(x, core.Function)); | |
71 return this.serializeDartObject(x); | 60 return this.serializeDartObject(x); |
72 } | 61 } |
73 unsupported(x, message) { | 62 unsupported(x, message) { |
74 if (message === void 0) | 63 if (message === void 0) message = null; |
75 message = null; | 64 if (message == null) message = "Can't transmit:"; |
76 if (message == null) | |
77 message = "Can't transmit:"; | |
78 dart.throw(new core.UnsupportedError(`${message} ${x}`)); | 65 dart.throw(new core.UnsupportedError(`${message} ${x}`)); |
79 } | 66 } |
80 makeRef(serializationId) { | 67 makeRef(serializationId) { |
81 return ["ref", serializationId]; | 68 return ["ref", serializationId]; |
82 } | 69 } |
83 isPrimitive(x) { | 70 isPrimitive(x) { |
84 return x == null || typeof x == 'string' || typeof x == 'number' || typeof
x == 'boolean'; | 71 return x == null || typeof x == 'string' || typeof x == 'number' || typeof
x == 'boolean'; |
85 } | 72 } |
86 serializePrimitive(primitive) { | 73 serializePrimitive(primitive) { |
87 return primitive; | 74 return primitive; |
88 } | 75 } |
89 serializeByteBuffer(buffer) { | 76 serializeByteBuffer(buffer) { |
90 return ["buffer", buffer]; | 77 return ["buffer", buffer]; |
91 } | 78 } |
92 serializeTypedData(data) { | 79 serializeTypedData(data) { |
93 return ["typed", data]; | 80 return ["typed", data]; |
94 } | 81 } |
95 serializeJSIndexable(indexable) { | 82 serializeJSIndexable(indexable) { |
96 dart.assert(!(typeof indexable == 'string')); | 83 dart.assert(!(typeof indexable == 'string')); |
97 let serialized = dart.as(this.serializeArray(dart.as(indexable, _intercept
ors.JSArray)), core.List); | 84 let serialized = dart.as(this.serializeArray(dart.as(indexable, _intercept
ors.JSArray)), core.List); |
98 if (dart.is(indexable, _interceptors.JSFixedArray)) | 85 if (dart.is(indexable, _interceptors.JSFixedArray)) return ["fixed", seria
lized]; |
99 return ["fixed", serialized]; | 86 if (dart.is(indexable, _interceptors.JSExtendableArray)) return ["extendab
le", serialized]; |
100 if (dart.is(indexable, _interceptors.JSExtendableArray)) | 87 if (dart.is(indexable, _interceptors.JSMutableArray)) return ["mutable", s
erialized]; |
101 return ["extendable", serialized]; | 88 if (dart.is(indexable, _interceptors.JSArray)) return ["const", serialized
]; |
102 if (dart.is(indexable, _interceptors.JSMutableArray)) | |
103 return ["mutable", serialized]; | |
104 if (dart.is(indexable, _interceptors.JSArray)) | |
105 return ["const", serialized]; | |
106 this.unsupported(indexable, "Can't serialize indexable: "); | 89 this.unsupported(indexable, "Can't serialize indexable: "); |
107 return null; | 90 return null; |
108 } | 91 } |
109 serializeArray(x) { | 92 serializeArray(x) { |
110 let serialized = []; | 93 let serialized = []; |
111 serialized[dartx.length] = x[dartx.length]; | 94 serialized[dartx.length] = x[dartx.length]; |
112 for (let i = 0; dart.notNull(i) < dart.notNull(x[dartx.length]); i = dart.
notNull(i) + 1) { | 95 for (let i = 0; dart.notNull(i) < dart.notNull(x[dartx.length]); i = dart.
notNull(i) + 1) { |
113 serialized[dartx.set](i, this.serialize(x[dartx.get](i))); | 96 serialized[dartx.set](i, this.serialize(x[dartx.get](i))); |
114 } | 97 } |
115 return serialized; | 98 return serialized; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 }) | 173 }) |
191 }); | 174 }); |
192 const _adjustSendPorts = Symbol('_adjustSendPorts'); | 175 const _adjustSendPorts = Symbol('_adjustSendPorts'); |
193 class _Deserializer extends core.Object { | 176 class _Deserializer extends core.Object { |
194 _Deserializer(opts) { | 177 _Deserializer(opts) { |
195 let adjustSendPorts = opts && 'adjustSendPorts' in opts ? opts.adjustSendP
orts : true; | 178 let adjustSendPorts = opts && 'adjustSendPorts' in opts ? opts.adjustSendP
orts : true; |
196 this.deserializedObjects = core.List.new(); | 179 this.deserializedObjects = core.List.new(); |
197 this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); | 180 this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); |
198 } | 181 } |
199 deserialize(x) { | 182 deserialize(x) { |
200 if (dart.notNull(this.isPrimitive(x))) | 183 if (dart.notNull(this.isPrimitive(x))) return this.deserializePrimitive(x)
; |
201 return this.deserializePrimitive(x); | 184 if (!dart.is(x, _interceptors.JSArray)) dart.throw(new core.ArgumentError(
`Bad serialized message: ${x}`)); |
202 if (!dart.is(x, _interceptors.JSArray)) | |
203 dart.throw(new core.ArgumentError(`Bad serialized message: ${x}`)); | |
204 switch (dart.dload(x, 'first')) { | 185 switch (dart.dload(x, 'first')) { |
205 case "ref": | 186 case "ref": |
206 { | 187 { |
207 return this.deserializeRef(x); | 188 return this.deserializeRef(x); |
208 } | 189 } |
209 case "buffer": | 190 case "buffer": |
210 { | 191 { |
211 return this.deserializeByteBuffer(x); | 192 return this.deserializeByteBuffer(x); |
212 } | 193 } |
213 case "typed": | 194 case "typed": |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 return result; | 307 return result; |
327 } | 308 } |
328 deserializeSendPort(x) { | 309 deserializeSendPort(x) { |
329 dart.assert(dart.equals(dart.dindex(x, 0), 'sendport')); | 310 dart.assert(dart.equals(dart.dindex(x, 0), 'sendport')); |
330 let managerId = dart.as(dart.dindex(x, 1), core.int); | 311 let managerId = dart.as(dart.dindex(x, 1), core.int); |
331 let isolateId = dart.as(dart.dindex(x, 2), core.int); | 312 let isolateId = dart.as(dart.dindex(x, 2), core.int); |
332 let receivePortId = dart.as(dart.dindex(x, 3), core.int); | 313 let receivePortId = dart.as(dart.dindex(x, 3), core.int); |
333 let result = null; | 314 let result = null; |
334 if (managerId == exports._globalState.currentManagerId) { | 315 if (managerId == exports._globalState.currentManagerId) { |
335 let isolate = exports._globalState.isolates.get(isolateId); | 316 let isolate = exports._globalState.isolates.get(isolateId); |
336 if (isolate == null) | 317 if (isolate == null) return null; |
337 return null; | |
338 let receivePort = isolate.lookup(receivePortId); | 318 let receivePort = isolate.lookup(receivePortId); |
339 if (receivePort == null) | 319 if (receivePort == null) return null; |
340 return null; | |
341 result = new _NativeJsSendPort(receivePort, isolateId); | 320 result = new _NativeJsSendPort(receivePort, isolateId); |
342 } else { | 321 } else { |
343 result = new _WorkerSendPort(managerId, isolateId, receivePortId); | 322 result = new _WorkerSendPort(managerId, isolateId, receivePortId); |
344 } | 323 } |
345 this.deserializedObjects[dartx.add](result); | 324 this.deserializedObjects[dartx.add](result); |
346 return result; | 325 return result; |
347 } | 326 } |
348 deserializeRawSendPort(x) { | 327 deserializeRawSendPort(x) { |
349 dart.assert(dart.equals(dart.dindex(x, 0), 'raw sendport')); | 328 dart.assert(dart.equals(dart.dindex(x, 0), 'raw sendport')); |
350 let result = dart.as(dart.dindex(x, 1), isolate.SendPort); | 329 let result = dart.as(dart.dindex(x, 1), isolate.SendPort); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 function isWorker() { | 404 function isWorker() { |
426 return exports._globalState.isWorker; | 405 return exports._globalState.isWorker; |
427 } | 406 } |
428 dart.fn(isWorker, core.bool, []); | 407 dart.fn(isWorker, core.bool, []); |
429 function _currentIsolate() { | 408 function _currentIsolate() { |
430 return exports._globalState.currentContext; | 409 return exports._globalState.currentContext; |
431 } | 410 } |
432 dart.fn(_currentIsolate, () => dart.definiteFunctionType(_IsolateContext, []))
; | 411 dart.fn(_currentIsolate, () => dart.definiteFunctionType(_IsolateContext, []))
; |
433 function startRootIsolate(entry, args) { | 412 function startRootIsolate(entry, args) { |
434 args = args; | 413 args = args; |
435 if (args == null) | 414 if (args == null) args = []; |
436 args = []; | |
437 if (!dart.is(args, core.List)) { | 415 if (!dart.is(args, core.List)) { |
438 dart.throw(new core.ArgumentError(`Arguments to main must be a List: ${arg
s}`)); | 416 dart.throw(new core.ArgumentError(`Arguments to main must be a List: ${arg
s}`)); |
439 } | 417 } |
440 exports._globalState = new _Manager(dart.as(entry, core.Function)); | 418 exports._globalState = new _Manager(dart.as(entry, core.Function)); |
441 if (dart.notNull(exports._globalState.isWorker)) | 419 if (dart.notNull(exports._globalState.isWorker)) return; |
442 return; | |
443 let rootContext = new _IsolateContext(); | 420 let rootContext = new _IsolateContext(); |
444 exports._globalState.rootContext = rootContext; | 421 exports._globalState.rootContext = rootContext; |
445 exports._globalState.currentContext = rootContext; | 422 exports._globalState.currentContext = rootContext; |
446 if (dart.is(entry, _MainFunctionArgs)) { | 423 if (dart.is(entry, _MainFunctionArgs)) { |
447 rootContext.eval(dart.fn(() => { | 424 rootContext.eval(dart.fn(() => { |
448 dart.dcall(entry, args); | 425 dart.dcall(entry, args); |
449 })); | 426 })); |
450 } else if (dart.is(entry, _MainFunctionArgsMessage)) { | 427 } else if (dart.is(entry, _MainFunctionArgsMessage)) { |
451 rootContext.eval(dart.fn(() => { | 428 rootContext.eval(dart.fn(() => { |
452 dart.dcall(entry, args, null); | 429 dart.dcall(entry, args, null); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 this.errorPorts = core.Set$(isolate.SendPort).new(); | 538 this.errorPorts = core.Set$(isolate.SendPort).new(); |
562 this.initialized = false; | 539 this.initialized = false; |
563 this.isPaused = false; | 540 this.isPaused = false; |
564 this.doneHandlers = null; | 541 this.doneHandlers = null; |
565 this[_scheduledControlEvents] = null; | 542 this[_scheduledControlEvents] = null; |
566 this[_isExecutingEvent] = false; | 543 this[_isExecutingEvent] = false; |
567 this.errorsAreFatal = true; | 544 this.errorsAreFatal = true; |
568 this.registerWeak(this.controlPort[_id], this.controlPort); | 545 this.registerWeak(this.controlPort[_id], this.controlPort); |
569 } | 546 } |
570 addPause(authentification, resume) { | 547 addPause(authentification, resume) { |
571 if (!dart.equals(this.pauseCapability, authentification)) | 548 if (!dart.equals(this.pauseCapability, authentification)) return; |
572 return; | |
573 if (dart.notNull(this.pauseTokens.add(resume)) && !dart.notNull(this.isPau
sed)) { | 549 if (dart.notNull(this.pauseTokens.add(resume)) && !dart.notNull(this.isPau
sed)) { |
574 this.isPaused = true; | 550 this.isPaused = true; |
575 } | 551 } |
576 this[_updateGlobalState](); | 552 this[_updateGlobalState](); |
577 } | 553 } |
578 removePause(resume) { | 554 removePause(resume) { |
579 if (!dart.notNull(this.isPaused)) | 555 if (!dart.notNull(this.isPaused)) return; |
580 return; | |
581 this.pauseTokens.remove(resume); | 556 this.pauseTokens.remove(resume); |
582 if (dart.notNull(this.pauseTokens.isEmpty)) { | 557 if (dart.notNull(this.pauseTokens.isEmpty)) { |
583 while (dart.notNull(this.delayedEvents[dartx.isNotEmpty])) { | 558 while (dart.notNull(this.delayedEvents[dartx.isNotEmpty])) { |
584 let event = this.delayedEvents[dartx.removeLast](); | 559 let event = this.delayedEvents[dartx.removeLast](); |
585 exports._globalState.topEventLoop.prequeue(event); | 560 exports._globalState.topEventLoop.prequeue(event); |
586 } | 561 } |
587 this.isPaused = false; | 562 this.isPaused = false; |
588 } | 563 } |
589 this[_updateGlobalState](); | 564 this[_updateGlobalState](); |
590 } | 565 } |
591 addDoneListener(responsePort) { | 566 addDoneListener(responsePort) { |
592 if (this.doneHandlers == null) { | 567 if (this.doneHandlers == null) { |
593 this.doneHandlers = []; | 568 this.doneHandlers = []; |
594 } | 569 } |
595 if (dart.notNull(dart.as(dart.dsend(this.doneHandlers, 'contains', respons
ePort), core.bool))) | 570 if (dart.notNull(dart.as(dart.dsend(this.doneHandlers, 'contains', respons
ePort), core.bool))) return; |
596 return; | |
597 dart.dsend(this.doneHandlers, 'add', responsePort); | 571 dart.dsend(this.doneHandlers, 'add', responsePort); |
598 } | 572 } |
599 removeDoneListener(responsePort) { | 573 removeDoneListener(responsePort) { |
600 if (this.doneHandlers == null) | 574 if (this.doneHandlers == null) return; |
601 return; | |
602 dart.dsend(this.doneHandlers, 'remove', responsePort); | 575 dart.dsend(this.doneHandlers, 'remove', responsePort); |
603 } | 576 } |
604 setErrorsFatal(authentification, errorsAreFatal) { | 577 setErrorsFatal(authentification, errorsAreFatal) { |
605 if (!dart.equals(this.terminateCapability, authentification)) | 578 if (!dart.equals(this.terminateCapability, authentification)) return; |
606 return; | |
607 this.errorsAreFatal = errorsAreFatal; | 579 this.errorsAreFatal = errorsAreFatal; |
608 } | 580 } |
609 handlePing(responsePort, pingType) { | 581 handlePing(responsePort, pingType) { |
610 if (pingType == isolate.Isolate.IMMEDIATE || pingType == isolate.Isolate.B
EFORE_NEXT_EVENT && !dart.notNull(this[_isExecutingEvent])) { | 582 if (pingType == isolate.Isolate.IMMEDIATE || pingType == isolate.Isolate.B
EFORE_NEXT_EVENT && !dart.notNull(this[_isExecutingEvent])) { |
611 responsePort.send(null); | 583 responsePort.send(null); |
612 return; | 584 return; |
613 } | 585 } |
614 function respond() { | 586 function respond() { |
615 responsePort.send(null); | 587 responsePort.send(null); |
616 } | 588 } |
617 dart.fn(respond, dart.void, []); | 589 dart.fn(respond, dart.void, []); |
618 if (pingType == isolate.Isolate.AS_EVENT) { | 590 if (pingType == isolate.Isolate.AS_EVENT) { |
619 exports._globalState.topEventLoop.enqueue(this, respond, "ping"); | 591 exports._globalState.topEventLoop.enqueue(this, respond, "ping"); |
620 return; | 592 return; |
621 } | 593 } |
622 dart.assert(pingType == isolate.Isolate.BEFORE_NEXT_EVENT); | 594 dart.assert(pingType == isolate.Isolate.BEFORE_NEXT_EVENT); |
623 if (this[_scheduledControlEvents] == null) { | 595 if (this[_scheduledControlEvents] == null) { |
624 this[_scheduledControlEvents] = collection.Queue.new(); | 596 this[_scheduledControlEvents] = collection.Queue.new(); |
625 } | 597 } |
626 dart.dsend(this[_scheduledControlEvents], 'addLast', respond); | 598 dart.dsend(this[_scheduledControlEvents], 'addLast', respond); |
627 } | 599 } |
628 handleKill(authentification, priority) { | 600 handleKill(authentification, priority) { |
629 if (!dart.equals(this.terminateCapability, authentification)) | 601 if (!dart.equals(this.terminateCapability, authentification)) return; |
630 return; | |
631 if (priority == isolate.Isolate.IMMEDIATE || priority == isolate.Isolate.B
EFORE_NEXT_EVENT && !dart.notNull(this[_isExecutingEvent])) { | 602 if (priority == isolate.Isolate.IMMEDIATE || priority == isolate.Isolate.B
EFORE_NEXT_EVENT && !dart.notNull(this[_isExecutingEvent])) { |
632 this.kill(); | 603 this.kill(); |
633 return; | 604 return; |
634 } | 605 } |
635 if (priority == isolate.Isolate.AS_EVENT) { | 606 if (priority == isolate.Isolate.AS_EVENT) { |
636 exports._globalState.topEventLoop.enqueue(this, dart.bind(this, 'kill'),
"kill"); | 607 exports._globalState.topEventLoop.enqueue(this, dart.bind(this, 'kill'),
"kill"); |
637 return; | 608 return; |
638 } | 609 } |
639 dart.assert(priority == isolate.Isolate.BEFORE_NEXT_EVENT); | 610 dart.assert(priority == isolate.Isolate.BEFORE_NEXT_EVENT); |
640 if (this[_scheduledControlEvents] == null) { | 611 if (this[_scheduledControlEvents] == null) { |
641 this[_scheduledControlEvents] = collection.Queue.new(); | 612 this[_scheduledControlEvents] = collection.Queue.new(); |
642 } | 613 } |
643 dart.dsend(this[_scheduledControlEvents], 'addLast', dart.bind(this, 'kill
')); | 614 dart.dsend(this[_scheduledControlEvents], 'addLast', dart.bind(this, 'kill
')); |
644 } | 615 } |
645 addErrorListener(port) { | 616 addErrorListener(port) { |
646 this.errorPorts.add(port); | 617 this.errorPorts.add(port); |
647 } | 618 } |
648 removeErrorListener(port) { | 619 removeErrorListener(port) { |
649 this.errorPorts.remove(port); | 620 this.errorPorts.remove(port); |
650 } | 621 } |
651 handleUncaughtError(error, stackTrace) { | 622 handleUncaughtError(error, stackTrace) { |
652 if (dart.notNull(this.errorPorts.isEmpty)) { | 623 if (dart.notNull(this.errorPorts.isEmpty)) { |
653 if (dart.notNull(this.errorsAreFatal) && dart.notNull(core.identical(thi
s, exports._globalState.rootContext))) { | 624 if (dart.notNull(this.errorsAreFatal) && dart.notNull(core.identical(thi
s, exports._globalState.rootContext))) { |
654 return; | 625 return; |
655 } | 626 } |
656 if (self.console && self.console.error) { | 627 if (self.console && self.console.error) { |
657 self.console.error(error, stackTrace); | 628 self.console.error(error, stackTrace); |
658 } else { | 629 } else { |
659 core.print(error); | 630 core.print(error); |
660 if (stackTrace != null) | 631 if (stackTrace != null) core.print(stackTrace); |
661 core.print(stackTrace); | |
662 } | 632 } |
663 return; | 633 return; |
664 } | 634 } |
665 let message = core.List.new(2); | 635 let message = core.List.new(2); |
666 message[dartx.set](0, dart.toString(error)); | 636 message[dartx.set](0, dart.toString(error)); |
667 message[dartx.set](1, stackTrace == null ? null : dart.toString(stackTrace
)); | 637 message[dartx.set](1, stackTrace == null ? null : dart.toString(stackTrace
)); |
668 for (let port of this.errorPorts) | 638 for (let port of this.errorPorts) |
669 port.send(message); | 639 port.send(message); |
670 } | 640 } |
671 eval(code) { | 641 eval(code) { |
(...skipping 10 matching lines...) Expand all Loading... |
682 if (dart.notNull(this.errorsAreFatal)) { | 652 if (dart.notNull(this.errorsAreFatal)) { |
683 this.kill(); | 653 this.kill(); |
684 if (dart.notNull(core.identical(this, exports._globalState.rootContext
))) { | 654 if (dart.notNull(core.identical(this, exports._globalState.rootContext
))) { |
685 throw e; | 655 throw e; |
686 } | 656 } |
687 } | 657 } |
688 } | 658 } |
689 finally { | 659 finally { |
690 this[_isExecutingEvent] = false; | 660 this[_isExecutingEvent] = false; |
691 exports._globalState.currentContext = old; | 661 exports._globalState.currentContext = old; |
692 if (old != null) | 662 if (old != null) old[_setGlobals](); |
693 old[_setGlobals](); | |
694 if (this[_scheduledControlEvents] != null) { | 663 if (this[_scheduledControlEvents] != null) { |
695 while (dart.notNull(dart.as(dart.dload(this[_scheduledControlEvents],
'isNotEmpty'), core.bool))) { | 664 while (dart.notNull(dart.as(dart.dload(this[_scheduledControlEvents],
'isNotEmpty'), core.bool))) { |
696 dart.dcall(dart.dsend(this[_scheduledControlEvents], 'removeFirst'))
; | 665 dart.dcall(dart.dsend(this[_scheduledControlEvents], 'removeFirst'))
; |
697 } | 666 } |
698 } | 667 } |
699 } | 668 } |
700 return result; | 669 return result; |
701 } | 670 } |
702 [_setGlobals]() { | 671 [_setGlobals]() { |
703 _foreign_helper.JS_SET_CURRENT_ISOLATE(this.isolateStatics); | 672 _foreign_helper.JS_SET_CURRENT_ISOLATE(this.isolateStatics); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 this.events = collection.Queue$(_IsolateEvent).new(); | 801 this.events = collection.Queue$(_IsolateEvent).new(); |
833 this[_activeJsAsyncCount] = 0; | 802 this[_activeJsAsyncCount] = 0; |
834 } | 803 } |
835 enqueue(isolate, fn, msg) { | 804 enqueue(isolate, fn, msg) { |
836 this.events.addLast(new _IsolateEvent(dart.as(isolate, _IsolateContext), d
art.as(fn, core.Function), dart.as(msg, core.String))); | 805 this.events.addLast(new _IsolateEvent(dart.as(isolate, _IsolateContext), d
art.as(fn, core.Function), dart.as(msg, core.String))); |
837 } | 806 } |
838 prequeue(event) { | 807 prequeue(event) { |
839 this.events.addFirst(event); | 808 this.events.addFirst(event); |
840 } | 809 } |
841 dequeue() { | 810 dequeue() { |
842 if (dart.notNull(this.events.isEmpty)) | 811 if (dart.notNull(this.events.isEmpty)) return null; |
843 return null; | |
844 return this.events.removeFirst(); | 812 return this.events.removeFirst(); |
845 } | 813 } |
846 checkOpenReceivePortsFromCommandLine() { | 814 checkOpenReceivePortsFromCommandLine() { |
847 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)) { | 815 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)) { |
848 dart.throw(core.Exception.new("Program exited with open ReceivePorts."))
; | 816 dart.throw(core.Exception.new("Program exited with open ReceivePorts."))
; |
849 } | 817 } |
850 } | 818 } |
851 runIteration() { | 819 runIteration() { |
852 let event = this.dequeue(); | 820 let event = this.dequeue(); |
853 if (event == null) { | 821 if (event == null) { |
854 this.checkOpenReceivePortsFromCommandLine(); | 822 this.checkOpenReceivePortsFromCommandLine(); |
855 exports._globalState.maybeCloseWorker(); | 823 exports._globalState.maybeCloseWorker(); |
856 return false; | 824 return false; |
857 } | 825 } |
858 event.process(); | 826 event.process(); |
859 return true; | 827 return true; |
860 } | 828 } |
861 [_runHelper]() { | 829 [_runHelper]() { |
862 if (exports.globalWindow != null) { | 830 if (exports.globalWindow != null) { |
863 const next = (function() { | 831 const next = (function() { |
864 if (!dart.notNull(this.runIteration())) | 832 if (!dart.notNull(this.runIteration())) return; |
865 return; | |
866 async.Timer.run(next); | 833 async.Timer.run(next); |
867 }).bind(this); | 834 }).bind(this); |
868 dart.fn(next); | 835 dart.fn(next); |
869 next(); | 836 next(); |
870 } else { | 837 } else { |
871 while (dart.notNull(this.runIteration())) { | 838 while (dart.notNull(this.runIteration())) { |
872 } | 839 } |
873 } | 840 } |
874 } | 841 } |
875 run() { | 842 run() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 }); | 907 }); |
941 const _MainFunction = dart.typedef('_MainFunction', () => dart.functionType(da
rt.dynamic, [])); | 908 const _MainFunction = dart.typedef('_MainFunction', () => dart.functionType(da
rt.dynamic, [])); |
942 const _MainFunctionArgs = dart.typedef('_MainFunctionArgs', () => dart.functio
nType(dart.dynamic, [dart.dynamic])); | 909 const _MainFunctionArgs = dart.typedef('_MainFunctionArgs', () => dart.functio
nType(dart.dynamic, [dart.dynamic])); |
943 const _MainFunctionArgsMessage = dart.typedef('_MainFunctionArgsMessage', () =
> dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic])); | 910 const _MainFunctionArgsMessage = dart.typedef('_MainFunctionArgsMessage', () =
> dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic])); |
944 class IsolateNatives extends core.Object { | 911 class IsolateNatives extends core.Object { |
945 static computeThisScript() { | 912 static computeThisScript() { |
946 let currentScript = document.currentScript; | 913 let currentScript = document.currentScript; |
947 if (currentScript != null) { | 914 if (currentScript != null) { |
948 return String(currentScript.src); | 915 return String(currentScript.src); |
949 } | 916 } |
950 if (dart.notNull(_js_helper.Primitives.isD8)) | 917 if (dart.notNull(_js_helper.Primitives.isD8)) return IsolateNatives.comput
eThisScriptD8(); |
951 return IsolateNatives.computeThisScriptD8(); | 918 if (dart.notNull(_js_helper.Primitives.isJsshell)) return IsolateNatives.c
omputeThisScriptJsshell(); |
952 if (dart.notNull(_js_helper.Primitives.isJsshell)) | |
953 return IsolateNatives.computeThisScriptJsshell(); | |
954 if (exports._globalState != null && dart.notNull(exports._globalState.isWo
rker)) { | 919 if (exports._globalState != null && dart.notNull(exports._globalState.isWo
rker)) { |
955 return IsolateNatives.computeThisScriptFromTrace(); | 920 return IsolateNatives.computeThisScriptFromTrace(); |
956 } | 921 } |
957 return null; | 922 return null; |
958 } | 923 } |
959 static computeThisScriptJsshell() { | 924 static computeThisScriptJsshell() { |
960 return dart.as(thisFilename(), core.String); | 925 return dart.as(thisFilename(), core.String); |
961 } | 926 } |
962 static computeThisScriptD8() { | 927 static computeThisScriptD8() { |
963 return IsolateNatives.computeThisScriptFromTrace(); | 928 return IsolateNatives.computeThisScriptFromTrace(); |
964 } | 929 } |
965 static computeThisScriptFromTrace() { | 930 static computeThisScriptFromTrace() { |
966 let stack = new Error().stack; | 931 let stack = new Error().stack; |
967 if (stack == null) { | 932 if (stack == null) { |
968 stack = (function() { | 933 stack = (function() { |
969 try { | 934 try { |
970 throw new Error(); | 935 throw new Error(); |
971 } catch (e) { | 936 } catch (e) { |
972 return e.stack; | 937 return e.stack; |
973 } | 938 } |
974 | 939 |
975 })(); | 940 })(); |
976 if (stack == null) | 941 if (stack == null) dart.throw(new core.UnsupportedError('No stack trace'
)); |
977 dart.throw(new core.UnsupportedError('No stack trace')); | |
978 } | 942 } |
979 let pattern = null, matches = null; | 943 let pattern = null, matches = null; |
980 pattern = new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m"); | 944 pattern = new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m"); |
981 matches = stack.match(pattern); | 945 matches = stack.match(pattern); |
982 if (matches != null) | 946 if (matches != null) return matches[1]; |
983 return matches[1]; | |
984 pattern = new RegExp("^[^@]*@(.*):[0-9]*$", "m"); | 947 pattern = new RegExp("^[^@]*@(.*):[0-9]*$", "m"); |
985 matches = stack.match(pattern); | 948 matches = stack.match(pattern); |
986 if (matches != null) | 949 if (matches != null) return matches[1]; |
987 return matches[1]; | |
988 dart.throw(new core.UnsupportedError(`Cannot extract URI from "${stack}"`)
); | 950 dart.throw(new core.UnsupportedError(`Cannot extract URI from "${stack}"`)
); |
989 } | 951 } |
990 static _getEventData(e) { | 952 static _getEventData(e) { |
991 return e.data; | 953 return e.data; |
992 } | 954 } |
993 static _processWorkerMessage(sender, e) { | 955 static _processWorkerMessage(sender, e) { |
994 let msg = _deserializeMessage(IsolateNatives._getEventData(e)); | 956 let msg = _deserializeMessage(IsolateNatives._getEventData(e)); |
995 switch (dart.dindex(msg, 'command')) { | 957 switch (dart.dindex(msg, 'command')) { |
996 case 'start': | 958 case 'start': |
997 { | 959 { |
998 exports._globalState.currentManagerId = dart.as(dart.dindex(msg, 'id')
, core.int); | 960 exports._globalState.currentManagerId = dart.as(dart.dindex(msg, 'id')
, core.int); |
999 let functionName = dart.as(dart.dindex(msg, 'functionName'), core.Stri
ng); | 961 let functionName = dart.as(dart.dindex(msg, 'functionName'), core.Stri
ng); |
1000 let entryPoint = functionName == null ? exports._globalState.entry : d
art.as(IsolateNatives._getJSFunctionFromName(functionName), core.Function); | 962 let entryPoint = functionName == null ? exports._globalState.entry : d
art.as(IsolateNatives._getJSFunctionFromName(functionName), core.Function); |
1001 let args = dart.dindex(msg, 'args'); | 963 let args = dart.dindex(msg, 'args'); |
1002 let message = _deserializeMessage(dart.dindex(msg, 'msg')); | 964 let message = _deserializeMessage(dart.dindex(msg, 'msg')); |
1003 let isSpawnUri = dart.dindex(msg, 'isSpawnUri'); | 965 let isSpawnUri = dart.dindex(msg, 'isSpawnUri'); |
1004 let startPaused = dart.dindex(msg, 'startPaused'); | 966 let startPaused = dart.dindex(msg, 'startPaused'); |
1005 let replyTo = _deserializeMessage(dart.dindex(msg, 'replyTo')); | 967 let replyTo = _deserializeMessage(dart.dindex(msg, 'replyTo')); |
1006 let context = new _IsolateContext(); | 968 let context = new _IsolateContext(); |
1007 exports._globalState.topEventLoop.enqueue(context, dart.fn(() => { | 969 exports._globalState.topEventLoop.enqueue(context, dart.fn(() => { |
1008 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)); | 970 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)); |
1009 }), 'worker-start'); | 971 }), 'worker-start'); |
1010 exports._globalState.currentContext = context; | 972 exports._globalState.currentContext = context; |
1011 exports._globalState.topEventLoop.run(); | 973 exports._globalState.topEventLoop.run(); |
1012 break; | 974 break; |
1013 } | 975 } |
1014 case 'spawn-worker': | 976 case 'spawn-worker': |
1015 { | 977 { |
1016 if (IsolateNatives.enableSpawnWorker != null) | 978 if (IsolateNatives.enableSpawnWorker != null) IsolateNatives.handleSpa
wnWorkerRequest(msg); |
1017 IsolateNatives.handleSpawnWorkerRequest(msg); | |
1018 break; | 979 break; |
1019 } | 980 } |
1020 case 'message': | 981 case 'message': |
1021 { | 982 { |
1022 let port = dart.as(dart.dindex(msg, 'port'), isolate.SendPort); | 983 let port = dart.as(dart.dindex(msg, 'port'), isolate.SendPort); |
1023 if (port != null) { | 984 if (port != null) { |
1024 dart.dsend(dart.dindex(msg, 'port'), 'send', dart.dindex(msg, 'msg')
); | 985 dart.dsend(dart.dindex(msg, 'port'), 'send', dart.dindex(msg, 'msg')
); |
1025 } | 986 } |
1026 exports._globalState.topEventLoop.run(); | 987 exports._globalState.topEventLoop.run(); |
1027 break; | 988 break; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 })); | 1080 })); |
1120 let signalReply = port.sendPort; | 1081 let signalReply = port.sendPort; |
1121 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight
)) { | 1082 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight
)) { |
1122 IsolateNatives._startWorker(functionName, uri, args, message, isSpawnUri
, startPaused, signalReply, dart.fn(message => completer.completeError(message),
dart.void, [core.String])); | 1083 IsolateNatives._startWorker(functionName, uri, args, message, isSpawnUri
, startPaused, signalReply, dart.fn(message => completer.completeError(message),
dart.void, [core.String])); |
1123 } else { | 1084 } else { |
1124 IsolateNatives._startNonWorker(functionName, uri, args, message, isSpawn
Uri, startPaused, signalReply); | 1085 IsolateNatives._startNonWorker(functionName, uri, args, message, isSpawn
Uri, startPaused, signalReply); |
1125 } | 1086 } |
1126 return completer.future; | 1087 return completer.future; |
1127 } | 1088 } |
1128 static _startWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { | 1089 static _startWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { |
1129 if (args != null) | 1090 if (args != null) args = core.List$(core.String).from(args); |
1130 args = core.List$(core.String).from(args); | |
1131 if (dart.notNull(exports._globalState.isWorker)) { | 1091 if (dart.notNull(exports._globalState.isWorker)) { |
1132 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'spawn-worker', functionName: functionName, args: args, msg: message,
uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort
}))); | 1092 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'spawn-worker', functionName: functionName, args: args, msg: message,
uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort
}))); |
1133 } else { | 1093 } else { |
1134 IsolateNatives._spawnWorker(functionName, uri, args, message, isSpawnUri
, startPaused, replyPort, onError); | 1094 IsolateNatives._spawnWorker(functionName, uri, args, message, isSpawnUri
, startPaused, replyPort, onError); |
1135 } | 1095 } |
1136 } | 1096 } |
1137 static _startNonWorker(functionName, uri, args, message, isSpawnUri, startPa
used, replyPort) { | 1097 static _startNonWorker(functionName, uri, args, message, isSpawnUri, startPa
used, replyPort) { |
1138 if (uri != null) { | 1098 if (uri != null) { |
1139 dart.throw(new core.UnsupportedError("Currently spawnUri is not supporte
d without web workers.")); | 1099 dart.throw(new core.UnsupportedError("Currently spawnUri is not supporte
d without web workers.")); |
1140 } | 1100 } |
1141 message = _clone(message); | 1101 message = _clone(message); |
1142 if (args != null) | 1102 if (args != null) args = core.List$(core.String).from(args); |
1143 args = core.List$(core.String).from(args); | |
1144 exports._globalState.topEventLoop.enqueue(new _IsolateContext(), dart.fn((
) => { | 1103 exports._globalState.topEventLoop.enqueue(new _IsolateContext(), dart.fn((
) => { |
1145 let func = IsolateNatives._getJSFunctionFromName(functionName); | 1104 let func = IsolateNatives._getJSFunctionFromName(functionName); |
1146 IsolateNatives._startIsolate(dart.as(func, core.Function), args, message
, isSpawnUri, startPaused, replyPort); | 1105 IsolateNatives._startIsolate(dart.as(func, core.Function), args, message
, isSpawnUri, startPaused, replyPort); |
1147 }), 'nonworker start'); | 1106 }), 'nonworker start'); |
1148 } | 1107 } |
1149 static get currentIsolate() { | 1108 static get currentIsolate() { |
1150 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); | 1109 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); |
1151 return new isolate.Isolate(context.controlPort.sendPort, {pauseCapability:
context.pauseCapability, terminateCapability: context.terminateCapability}); | 1110 return new isolate.Isolate(context.controlPort.sendPort, {pauseCapability:
context.pauseCapability, terminateCapability: context.terminateCapability}); |
1152 } | 1111 } |
1153 static _startIsolate(topLevel, args, message, isSpawnUri, startPaused, reply
To) { | 1112 static _startIsolate(topLevel, args, message, isSpawnUri, startPaused, reply
To) { |
(...skipping 14 matching lines...) Expand all Loading... |
1168 } | 1127 } |
1169 dart.fn(runStartFunction, dart.void, []); | 1128 dart.fn(runStartFunction, dart.void, []); |
1170 if (dart.notNull(startPaused)) { | 1129 if (dart.notNull(startPaused)) { |
1171 context.addPause(context.pauseCapability, context.pauseCapability); | 1130 context.addPause(context.pauseCapability, context.pauseCapability); |
1172 exports._globalState.topEventLoop.enqueue(context, runStartFunction, 'st
art isolate'); | 1131 exports._globalState.topEventLoop.enqueue(context, runStartFunction, 'st
art isolate'); |
1173 } else { | 1132 } else { |
1174 runStartFunction(); | 1133 runStartFunction(); |
1175 } | 1134 } |
1176 } | 1135 } |
1177 static _spawnWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { | 1136 static _spawnWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { |
1178 if (uri == null) | 1137 if (uri == null) uri = IsolateNatives.thisScript; |
1179 uri = IsolateNatives.thisScript; | |
1180 let worker = new Worker(uri); | 1138 let worker = new Worker(uri); |
1181 let onerrorTrampoline = (function(f, u, c) { | 1139 let onerrorTrampoline = (function(f, u, c) { |
1182 return function(e) { | 1140 return function(e) { |
1183 return f(e, u, c); | 1141 return f(e, u, c); |
1184 }; | 1142 }; |
1185 })(IsolateNatives.workerOnError, uri, onError); | 1143 })(IsolateNatives.workerOnError, uri, onError); |
1186 worker.onerror = onerrorTrampoline; | 1144 worker.onerror = onerrorTrampoline; |
1187 let processWorkerMessageTrampoline = (function(f, a) { | 1145 let processWorkerMessageTrampoline = (function(f, a) { |
1188 return function(e) { | 1146 return function(e) { |
1189 e.onerror = null; | 1147 e.onerror = null; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 }); | 1221 }); |
1264 const _isClosed = Symbol('_isClosed'); | 1222 const _isClosed = Symbol('_isClosed'); |
1265 const _add = Symbol('_add'); | 1223 const _add = Symbol('_add'); |
1266 class _NativeJsSendPort extends _BaseSendPort { | 1224 class _NativeJsSendPort extends _BaseSendPort { |
1267 _NativeJsSendPort(receivePort, isolateId) { | 1225 _NativeJsSendPort(receivePort, isolateId) { |
1268 this[_receivePort] = receivePort; | 1226 this[_receivePort] = receivePort; |
1269 super._BaseSendPort(isolateId); | 1227 super._BaseSendPort(isolateId); |
1270 } | 1228 } |
1271 send(message) { | 1229 send(message) { |
1272 let isolate = exports._globalState.isolates.get(this[_isolateId]); | 1230 let isolate = exports._globalState.isolates.get(this[_isolateId]); |
1273 if (isolate == null) | 1231 if (isolate == null) return; |
1274 return; | 1232 if (dart.notNull(this[_receivePort][_isClosed])) return; |
1275 if (dart.notNull(this[_receivePort][_isClosed])) | |
1276 return; | |
1277 let msg = _clone(message); | 1233 let msg = _clone(message); |
1278 if (dart.equals(isolate.controlPort, this[_receivePort])) { | 1234 if (dart.equals(isolate.controlPort, this[_receivePort])) { |
1279 isolate.handleControlMessage(msg); | 1235 isolate.handleControlMessage(msg); |
1280 return; | 1236 return; |
1281 } | 1237 } |
1282 exports._globalState.topEventLoop.enqueue(isolate, dart.fn((() => { | 1238 exports._globalState.topEventLoop.enqueue(isolate, dart.fn((() => { |
1283 if (!dart.notNull(this[_receivePort][_isClosed])) { | 1239 if (!dart.notNull(this[_receivePort][_isClosed])) { |
1284 this[_receivePort][_add](msg); | 1240 this[_receivePort][_add](msg); |
1285 } | 1241 } |
1286 }).bind(this)), `receive ${message}`); | 1242 }).bind(this)), `receive ${message}`); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 this[_isClosed] = false; | 1310 this[_isClosed] = false; |
1355 } | 1311 } |
1356 set handler(newHandler) { | 1312 set handler(newHandler) { |
1357 this[_handler] = newHandler; | 1313 this[_handler] = newHandler; |
1358 } | 1314 } |
1359 [_close]() { | 1315 [_close]() { |
1360 this[_isClosed] = true; | 1316 this[_isClosed] = true; |
1361 this[_handler] = null; | 1317 this[_handler] = null; |
1362 } | 1318 } |
1363 close() { | 1319 close() { |
1364 if (dart.notNull(this[_isClosed])) | 1320 if (dart.notNull(this[_isClosed])) return; |
1365 return; | |
1366 this[_isClosed] = true; | 1321 this[_isClosed] = true; |
1367 this[_handler] = null; | 1322 this[_handler] = null; |
1368 exports._globalState.currentContext.unregister(this[_id]); | 1323 exports._globalState.currentContext.unregister(this[_id]); |
1369 } | 1324 } |
1370 [_add](dataEvent) { | 1325 [_add](dataEvent) { |
1371 if (dart.notNull(this[_isClosed])) | 1326 if (dart.notNull(this[_isClosed])) return; |
1372 return; | |
1373 dart.dcall(this[_handler], dataEvent); | 1327 dart.dcall(this[_handler], dataEvent); |
1374 } | 1328 } |
1375 get sendPort() { | 1329 get sendPort() { |
1376 return new _NativeJsSendPort(this, exports._globalState.currentContext.id)
; | 1330 return new _NativeJsSendPort(this, exports._globalState.currentContext.id)
; |
1377 } | 1331 } |
1378 } | 1332 } |
1379 RawReceivePortImpl[dart.implements] = () => [isolate.RawReceivePort]; | 1333 RawReceivePortImpl[dart.implements] = () => [isolate.RawReceivePort]; |
1380 dart.defineNamedConstructor(RawReceivePortImpl, 'weak'); | 1334 dart.defineNamedConstructor(RawReceivePortImpl, 'weak'); |
1381 dart.defineNamedConstructor(RawReceivePortImpl, '_controlPort'); | 1335 dart.defineNamedConstructor(RawReceivePortImpl, '_controlPort'); |
1382 dart.setSignature(RawReceivePortImpl, { | 1336 dart.setSignature(RawReceivePortImpl, { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 }).bind(this)), milliseconds); | 1432 }).bind(this)), milliseconds); |
1479 } else { | 1433 } else { |
1480 dart.throw(new core.UnsupportedError("Periodic timer.")); | 1434 dart.throw(new core.UnsupportedError("Periodic timer.")); |
1481 } | 1435 } |
1482 } | 1436 } |
1483 cancel() { | 1437 cancel() { |
1484 if (dart.notNull(hasTimer())) { | 1438 if (dart.notNull(hasTimer())) { |
1485 if (dart.notNull(this[_inEventLoop])) { | 1439 if (dart.notNull(this[_inEventLoop])) { |
1486 dart.throw(new core.UnsupportedError("Timer in event loop cannot be ca
nceled.")); | 1440 dart.throw(new core.UnsupportedError("Timer in event loop cannot be ca
nceled.")); |
1487 } | 1441 } |
1488 if (this[_handle] == null) | 1442 if (this[_handle] == null) return; |
1489 return; | |
1490 leaveJsAsync(); | 1443 leaveJsAsync(); |
1491 if (dart.notNull(this[_once])) { | 1444 if (dart.notNull(this[_once])) { |
1492 self.clearTimeout(this[_handle]); | 1445 self.clearTimeout(this[_handle]); |
1493 } else { | 1446 } else { |
1494 self.clearInterval(this[_handle]); | 1447 self.clearInterval(this[_handle]); |
1495 } | 1448 } |
1496 this[_handle] = null; | 1449 this[_handle] = null; |
1497 } else { | 1450 } else { |
1498 dart.throw(new core.UnsupportedError("Canceling a timer.")); | 1451 dart.throw(new core.UnsupportedError("Canceling a timer.")); |
1499 } | 1452 } |
(...skipping 27 matching lines...) Expand all Loading... |
1527 hash = dart.notNull(hash) >> 0 ^ (dart.notNull(hash) / 4294967296)[dartx.t
runcate](); | 1480 hash = dart.notNull(hash) >> 0 ^ (dart.notNull(hash) / 4294967296)[dartx.t
runcate](); |
1528 hash = ~dart.notNull(hash) + (dart.notNull(hash) << 15) & 4294967295; | 1481 hash = ~dart.notNull(hash) + (dart.notNull(hash) << 15) & 4294967295; |
1529 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 12; | 1482 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 12; |
1530 hash = dart.notNull(hash) * 5 & 4294967295; | 1483 hash = dart.notNull(hash) * 5 & 4294967295; |
1531 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 4; | 1484 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 4; |
1532 hash = dart.notNull(hash) * 2057 & 4294967295; | 1485 hash = dart.notNull(hash) * 2057 & 4294967295; |
1533 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 16; | 1486 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 16; |
1534 return hash; | 1487 return hash; |
1535 } | 1488 } |
1536 ['=='](other) { | 1489 ['=='](other) { |
1537 if (dart.notNull(core.identical(other, this))) | 1490 if (dart.notNull(core.identical(other, this))) return true; |
1538 return true; | |
1539 if (dart.is(other, CapabilityImpl)) { | 1491 if (dart.is(other, CapabilityImpl)) { |
1540 return core.identical(this[_id], other[_id]); | 1492 return core.identical(this[_id], other[_id]); |
1541 } | 1493 } |
1542 return false; | 1494 return false; |
1543 } | 1495 } |
1544 } | 1496 } |
1545 CapabilityImpl[dart.implements] = () => [isolate.Capability]; | 1497 CapabilityImpl[dart.implements] = () => [isolate.Capability]; |
1546 dart.defineNamedConstructor(CapabilityImpl, '_internal'); | 1498 dart.defineNamedConstructor(CapabilityImpl, '_internal'); |
1547 dart.setSignature(CapabilityImpl, { | 1499 dart.setSignature(CapabilityImpl, { |
1548 constructors: () => ({ | 1500 constructors: () => ({ |
1549 CapabilityImpl: [CapabilityImpl, []], | 1501 CapabilityImpl: [CapabilityImpl, []], |
1550 _internal: [CapabilityImpl, [core.int]] | 1502 _internal: [CapabilityImpl, [core.int]] |
1551 }), | 1503 }), |
1552 methods: () => ({'==': [core.bool, [core.Object]]}) | 1504 methods: () => ({'==': [core.bool, [core.Object]]}) |
1553 }); | 1505 }); |
1554 // Exports: | 1506 // Exports: |
1555 exports.enterJsAsync = enterJsAsync; | 1507 exports.enterJsAsync = enterJsAsync; |
1556 exports.leaveJsAsync = leaveJsAsync; | 1508 exports.leaveJsAsync = leaveJsAsync; |
1557 exports.isWorker = isWorker; | 1509 exports.isWorker = isWorker; |
1558 exports.startRootIsolate = startRootIsolate; | 1510 exports.startRootIsolate = startRootIsolate; |
1559 exports.IsolateNatives = IsolateNatives; | 1511 exports.IsolateNatives = IsolateNatives; |
1560 exports.RawReceivePortImpl = RawReceivePortImpl; | 1512 exports.RawReceivePortImpl = RawReceivePortImpl; |
1561 exports.ReceivePortImpl = ReceivePortImpl; | 1513 exports.ReceivePortImpl = ReceivePortImpl; |
1562 exports.TimerImpl = TimerImpl; | 1514 exports.TimerImpl = TimerImpl; |
1563 exports.hasTimer = hasTimer; | 1515 exports.hasTimer = hasTimer; |
1564 exports.CapabilityImpl = CapabilityImpl; | 1516 exports.CapabilityImpl = CapabilityImpl; |
1565 }); | 1517 }); |
OLD | NEW |