OLD | NEW |
1 var _isolate_helper; | 1 var _isolate_helper; |
2 (function(_isolate_helper) { | 2 (function(_isolate_helper) { |
3 'use strict'; | 3 'use strict'; |
| 4 let _activeJsAsyncCount = Symbol('_activeJsAsyncCount'); |
| 5 let _nativeDetectEnvironment = Symbol('_nativeDetectEnvironment'); |
| 6 let _nativeInitWorkerMessageHandler = Symbol('_nativeInitWorkerMessageHandler'
); |
| 7 let _processWorkerMessage = Symbol('_processWorkerMessage'); |
| 8 let _serializePrintMessage = Symbol('_serializePrintMessage'); |
| 9 let _scheduledControlEvents = Symbol('_scheduledControlEvents'); |
| 10 let _isExecutingEvent = Symbol('_isExecutingEvent'); |
| 11 let _id = Symbol('_id'); |
| 12 let _updateGlobalState = Symbol('_updateGlobalState'); |
| 13 let _setGlobals = Symbol('_setGlobals'); |
| 14 let _addRegistration = Symbol('_addRegistration'); |
| 15 let _runHelper = Symbol('_runHelper'); |
| 16 let _getEventData = Symbol('_getEventData'); |
| 17 let _log = Symbol('_log'); |
| 18 let _consoleLog = Symbol('_consoleLog'); |
| 19 let _getJSFunctionFromName = Symbol('_getJSFunctionFromName'); |
| 20 let _getJSFunctionName = Symbol('_getJSFunctionName'); |
| 21 let _allocate = Symbol('_allocate'); |
| 22 let _startWorker = Symbol('_startWorker'); |
| 23 let _startNonWorker = Symbol('_startNonWorker'); |
| 24 let _startIsolate = Symbol('_startIsolate'); |
| 25 let _spawnWorker = Symbol('_spawnWorker'); |
| 26 let _isolateId = Symbol('_isolateId'); |
| 27 let _checkReplyTo = Symbol('_checkReplyTo'); |
| 28 let _receivePort = Symbol('_receivePort'); |
| 29 let _isClosed = Symbol('_isClosed'); |
| 30 let _workerId = Symbol('_workerId'); |
| 31 let _receivePortId = Symbol('_receivePortId'); |
| 32 let _handler = Symbol('_handler'); |
| 33 let _close = Symbol('_close'); |
| 34 let _add = Symbol('_add'); |
| 35 let _rawPort = Symbol('_rawPort'); |
| 36 let _controller = Symbol('_controller'); |
| 37 let _once = Symbol('_once'); |
| 38 let _inEventLoop = Symbol('_inEventLoop'); |
| 39 let _handle = Symbol('_handle'); |
| 40 let _serializeSendPorts = Symbol('_serializeSendPorts'); |
| 41 let _adjustSendPorts = Symbol('_adjustSendPorts'); |
4 // Function _callInIsolate: (_IsolateContext, Function) → dynamic | 42 // Function _callInIsolate: (_IsolateContext, Function) → dynamic |
5 function _callInIsolate(isolate, function) { | 43 function _callInIsolate(isolate, function) { |
6 let result = isolate.eval(function); | 44 let result = isolate.eval(function); |
7 _isolate_helper._globalState.topEventLoop.run(); | 45 _isolate_helper._globalState.topEventLoop.run(); |
8 return result; | 46 return result; |
9 } | 47 } |
10 // Function enterJsAsync: () → dynamic | 48 // Function enterJsAsync: () → dynamic |
11 function enterJsAsync() { | 49 function enterJsAsync() { |
12 _isolate_helper._globalState.topEventLoop._activeJsAsyncCount++; | 50 _isolate_helper._globalState.topEventLoop[_activeJsAsyncCount]++; |
13 } | 51 } |
14 // Function leaveJsAsync: () → dynamic | 52 // Function leaveJsAsync: () → dynamic |
15 function leaveJsAsync() { | 53 function leaveJsAsync() { |
16 _isolate_helper._globalState.topEventLoop._activeJsAsyncCount--; | 54 _isolate_helper._globalState.topEventLoop[_activeJsAsyncCount]--; |
17 dart.assert(_isolate_helper._globalState.topEventLoop._activeJsAsyncCount >=
0); | 55 dart.assert(_isolate_helper._globalState.topEventLoop[_activeJsAsyncCount] >
= 0); |
18 } | 56 } |
19 // Function isWorker: () → bool | 57 // Function isWorker: () → bool |
20 function isWorker() { | 58 function isWorker() { |
21 return _isolate_helper._globalState.isWorker; | 59 return _isolate_helper._globalState.isWorker; |
22 } | 60 } |
23 // Function _currentIsolate: () → _IsolateContext | 61 // Function _currentIsolate: () → _IsolateContext |
24 function _currentIsolate() { | 62 function _currentIsolate() { |
25 return _isolate_helper._globalState.currentContext; | 63 return _isolate_helper._globalState.currentContext; |
26 } | 64 } |
27 // Function startRootIsolate: (dynamic, dynamic) → void | 65 // Function startRootIsolate: (dynamic, dynamic) → void |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 this.nextManagerId = 1; | 108 this.nextManagerId = 1; |
71 this.currentContext = null; | 109 this.currentContext = null; |
72 this.rootContext = null; | 110 this.rootContext = null; |
73 this.topEventLoop = null; | 111 this.topEventLoop = null; |
74 this.fromCommandLine = null; | 112 this.fromCommandLine = null; |
75 this.isWorker = null; | 113 this.isWorker = null; |
76 this.supportsWorkers = null; | 114 this.supportsWorkers = null; |
77 this.isolates = null; | 115 this.isolates = null; |
78 this.mainManager = null; | 116 this.mainManager = null; |
79 this.managers = null; | 117 this.managers = null; |
80 this._nativeDetectEnvironment(); | 118 this[_nativeDetectEnvironment](); |
81 this.topEventLoop = new _EventLoop(); | 119 this.topEventLoop = new _EventLoop(); |
82 this.isolates = new core.Map(); | 120 this.isolates = new core.Map(); |
83 this.managers = new core.Map(); | 121 this.managers = new core.Map(); |
84 if (this.isWorker) { | 122 if (this.isWorker) { |
85 this.mainManager = new _MainManagerStub(); | 123 this.mainManager = new _MainManagerStub(); |
86 this._nativeInitWorkerMessageHandler(); | 124 this[_nativeInitWorkerMessageHandler](); |
87 } | 125 } |
88 } | 126 } |
89 _nativeDetectEnvironment() { | 127 [_nativeDetectEnvironment]() { |
90 let isWindowDefined = _isolate_helper.globalWindow !== null; | 128 let isWindowDefined = _isolate_helper.globalWindow !== null; |
91 let isWorkerDefined = _isolate_helper.globalWorker !== null; | 129 let isWorkerDefined = _isolate_helper.globalWorker !== null; |
92 this.isWorker = dart.notNull(!dart.notNull(isWindowDefined)) && dart.notNu
ll(_isolate_helper.globalPostMessageDefined); | 130 this.isWorker = dart.notNull(!dart.notNull(isWindowDefined)) && dart.notNu
ll(_isolate_helper.globalPostMessageDefined); |
93 this.supportsWorkers = dart.notNull(this.isWorker) || dart.notNull(dart.no
tNull(isWorkerDefined) && dart.notNull(IsolateNatives.thisScript !== null)); | 131 this.supportsWorkers = dart.notNull(this.isWorker) || dart.notNull(dart.no
tNull(isWorkerDefined) && dart.notNull(IsolateNatives.thisScript !== null)); |
94 this.fromCommandLine = dart.notNull(!dart.notNull(isWindowDefined)) && dar
t.notNull(!dart.notNull(this.isWorker)); | 132 this.fromCommandLine = dart.notNull(!dart.notNull(isWindowDefined)) && dar
t.notNull(!dart.notNull(this.isWorker)); |
95 } | 133 } |
96 _nativeInitWorkerMessageHandler() { | 134 [_nativeInitWorkerMessageHandler]() { |
97 let function = function(f, a) { | 135 let function = function(f, a) { |
98 return function(e) { | 136 return function(e) { |
99 f(a, e); | 137 f(a, e); |
100 }; | 138 }; |
101 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives._processWorkerMessage)
, this.mainManager); | 139 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives[_processWorkerMessage]
), this.mainManager); |
102 self.onmessage = function; | 140 self.onmessage = function; |
103 self.dartPrint = self.dartPrint || function(serialize) { | 141 self.dartPrint = self.dartPrint || function(serialize) { |
104 return function(object) { | 142 return function(object) { |
105 if (self.console && self.console.log) { | 143 if (self.console && self.console.log) { |
106 self.console.log(object); | 144 self.console.log(object); |
107 } else { | 145 } else { |
108 self.postMessage(serialize(object)); | 146 self.postMessage(serialize(object)); |
109 } | 147 } |
110 }; | 148 }; |
111 }(_foreign_helper.DART_CLOSURE_TO_JS(_serializePrintMessage)); | 149 }(_foreign_helper.DART_CLOSURE_TO_JS(_serializePrintMessage)); |
112 } | 150 } |
113 static _serializePrintMessage(object) { | 151 static [_serializePrintMessage](object) { |
114 return _serializeMessage(dart.map({command: "print", msg: object})); | 152 return _serializeMessage(dart.map({command: "print", msg: object})); |
115 } | 153 } |
116 maybeCloseWorker() { | 154 maybeCloseWorker() { |
117 if (dart.notNull(dart.notNull(this.isWorker) && dart.notNull(this.isolates
.isEmpty)) && dart.notNull(this.topEventLoop._activeJsAsyncCount === 0)) { | 155 if (dart.notNull(dart.notNull(this.isWorker) && dart.notNull(this.isolates
.isEmpty)) && dart.notNull(this.topEventLoop[_activeJsAsyncCount] === 0)) { |
118 this.mainManager.postMessage(_serializeMessage(dart.map({command: 'close
'}))); | 156 this.mainManager.postMessage(_serializeMessage(dart.map({command: 'close
'}))); |
119 } | 157 } |
120 } | 158 } |
121 } | 159 } |
122 class _IsolateContext extends dart.Object { | 160 class _IsolateContext extends dart.Object { |
123 _IsolateContext() { | 161 _IsolateContext() { |
124 this.id = _isolate_helper._globalState.nextIsolateId++; | 162 this.id = _isolate_helper._globalState.nextIsolateId++; |
125 this.ports = new core.Map(); | 163 this.ports = new core.Map(); |
126 this.weakPorts = new core.Set(); | 164 this.weakPorts = new core.Set(); |
127 this.isolateStatics = _foreign_helper.JS_CREATE_ISOLATE(); | 165 this.isolateStatics = _foreign_helper.JS_CREATE_ISOLATE(); |
128 this.controlPort = new RawReceivePortImpl._controlPort(); | 166 this.controlPort = new RawReceivePortImpl._controlPort(); |
129 this.pauseCapability = new isolate.Capability(); | 167 this.pauseCapability = new isolate.Capability(); |
130 this.terminateCapability = new isolate.Capability(); | 168 this.terminateCapability = new isolate.Capability(); |
131 this.delayedEvents = dart.as(new List.from([]), core.List$(_IsolateEvent))
; | 169 this.delayedEvents = dart.as(new List.from([]), core.List$(_IsolateEvent))
; |
132 this.pauseTokens = dart.as(new core.Set(), core.Set$(isolate.Capability)); | 170 this.pauseTokens = dart.as(new core.Set(), core.Set$(isolate.Capability)); |
133 this.errorPorts = dart.as(new core.Set(), core.Set$(isolate.SendPort)); | 171 this.errorPorts = dart.as(new core.Set(), core.Set$(isolate.SendPort)); |
134 this.initialized = false; | 172 this.initialized = false; |
135 this.isPaused = false; | 173 this.isPaused = false; |
136 this.doneHandlers = null; | 174 this.doneHandlers = null; |
137 this._scheduledControlEvents = null; | 175 this[_scheduledControlEvents] = null; |
138 this._isExecutingEvent = false; | 176 this[_isExecutingEvent] = false; |
139 this.errorsAreFatal = true; | 177 this.errorsAreFatal = true; |
140 this.registerWeak(this.controlPort._id, this.controlPort); | 178 this.registerWeak(this.controlPort[_id], this.controlPort); |
141 } | 179 } |
142 addPause(authentification, resume) { | 180 addPause(authentification, resume) { |
143 if (!dart.equals(this.pauseCapability, authentification)) | 181 if (!dart.equals(this.pauseCapability, authentification)) |
144 return; | 182 return; |
145 if (dart.notNull(this.pauseTokens.add(resume)) && dart.notNull(!dart.notNu
ll(this.isPaused))) { | 183 if (dart.notNull(this.pauseTokens.add(resume)) && dart.notNull(!dart.notNu
ll(this.isPaused))) { |
146 this.isPaused = true; | 184 this.isPaused = true; |
147 } | 185 } |
148 this._updateGlobalState(); | 186 this[_updateGlobalState](); |
149 } | 187 } |
150 removePause(resume) { | 188 removePause(resume) { |
151 if (!dart.notNull(this.isPaused)) | 189 if (!dart.notNull(this.isPaused)) |
152 return; | 190 return; |
153 this.pauseTokens.remove(resume); | 191 this.pauseTokens.remove(resume); |
154 if (this.pauseTokens.isEmpty) { | 192 if (this.pauseTokens.isEmpty) { |
155 while (this.delayedEvents.isNotEmpty) { | 193 while (this.delayedEvents.isNotEmpty) { |
156 let event = this.delayedEvents.removeLast(); | 194 let event = this.delayedEvents.removeLast(); |
157 _isolate_helper._globalState.topEventLoop.prequeue(event); | 195 _isolate_helper._globalState.topEventLoop.prequeue(event); |
158 } | 196 } |
159 this.isPaused = false; | 197 this.isPaused = false; |
160 } | 198 } |
161 this._updateGlobalState(); | 199 this[_updateGlobalState](); |
162 } | 200 } |
163 addDoneListener(responsePort) { | 201 addDoneListener(responsePort) { |
164 if (this.doneHandlers === null) { | 202 if (this.doneHandlers === null) { |
165 this.doneHandlers = new List.from([]); | 203 this.doneHandlers = new List.from([]); |
166 } | 204 } |
167 if (dart.dinvoke(this.doneHandlers, 'contains', responsePort)) | 205 if (dart.dinvoke(this.doneHandlers, 'contains', responsePort)) |
168 return; | 206 return; |
169 dart.dinvoke(this.doneHandlers, 'add', responsePort); | 207 dart.dinvoke(this.doneHandlers, 'add', responsePort); |
170 } | 208 } |
171 removeDoneListener(responsePort) { | 209 removeDoneListener(responsePort) { |
172 if (this.doneHandlers === null) | 210 if (this.doneHandlers === null) |
173 return; | 211 return; |
174 dart.dinvoke(this.doneHandlers, 'remove', responsePort); | 212 dart.dinvoke(this.doneHandlers, 'remove', responsePort); |
175 } | 213 } |
176 setErrorsFatal(authentification, errorsAreFatal) { | 214 setErrorsFatal(authentification, errorsAreFatal) { |
177 if (!dart.equals(this.terminateCapability, authentification)) | 215 if (!dart.equals(this.terminateCapability, authentification)) |
178 return; | 216 return; |
179 this.errorsAreFatal = errorsAreFatal; | 217 this.errorsAreFatal = errorsAreFatal; |
180 } | 218 } |
181 handlePing(responsePort, pingType) { | 219 handlePing(responsePort, pingType) { |
182 if (dart.notNull(pingType === isolate.Isolate.IMMEDIATE) || dart.notNull(d
art.notNull(pingType === isolate.Isolate.BEFORE_NEXT_EVENT) && dart.notNull(!dar
t.notNull(this._isExecutingEvent)))) { | 220 if (dart.notNull(pingType === isolate.Isolate.IMMEDIATE) || dart.notNull(d
art.notNull(pingType === isolate.Isolate.BEFORE_NEXT_EVENT) && dart.notNull(!dar
t.notNull(this[_isExecutingEvent])))) { |
183 responsePort.send(null); | 221 responsePort.send(null); |
184 return; | 222 return; |
185 } | 223 } |
186 // Function respond: () → void | 224 // Function respond: () → void |
187 function respond() { | 225 function respond() { |
188 responsePort.send(null); | 226 responsePort.send(null); |
189 } | 227 } |
190 if (pingType === isolate.Isolate.AS_EVENT) { | 228 if (pingType === isolate.Isolate.AS_EVENT) { |
191 _isolate_helper._globalState.topEventLoop.enqueue(this, respond, "ping")
; | 229 _isolate_helper._globalState.topEventLoop.enqueue(this, respond, "ping")
; |
192 return; | 230 return; |
193 } | 231 } |
194 dart.assert(pingType === isolate.Isolate.BEFORE_NEXT_EVENT); | 232 dart.assert(pingType === isolate.Isolate.BEFORE_NEXT_EVENT); |
195 if (this._scheduledControlEvents === null) { | 233 if (this[_scheduledControlEvents] === null) { |
196 this._scheduledControlEvents = new collection.Queue(); | 234 this[_scheduledControlEvents] = new collection.Queue(); |
197 } | 235 } |
198 dart.dinvoke(this._scheduledControlEvents, 'addLast', respond); | 236 dart.dinvoke(this[_scheduledControlEvents], 'addLast', respond); |
199 } | 237 } |
200 handleKill(authentification, priority) { | 238 handleKill(authentification, priority) { |
201 if (!dart.equals(this.terminateCapability, authentification)) | 239 if (!dart.equals(this.terminateCapability, authentification)) |
202 return; | 240 return; |
203 if (dart.notNull(priority === isolate.Isolate.IMMEDIATE) || dart.notNull(d
art.notNull(priority === isolate.Isolate.BEFORE_NEXT_EVENT) && dart.notNull(!dar
t.notNull(this._isExecutingEvent)))) { | 241 if (dart.notNull(priority === isolate.Isolate.IMMEDIATE) || dart.notNull(d
art.notNull(priority === isolate.Isolate.BEFORE_NEXT_EVENT) && dart.notNull(!dar
t.notNull(this[_isExecutingEvent])))) { |
204 this.kill(); | 242 this.kill(); |
205 return; | 243 return; |
206 } | 244 } |
207 if (priority === isolate.Isolate.AS_EVENT) { | 245 if (priority === isolate.Isolate.AS_EVENT) { |
208 _isolate_helper._globalState.topEventLoop.enqueue(this, this.kill, "kill
"); | 246 _isolate_helper._globalState.topEventLoop.enqueue(this, this.kill, "kill
"); |
209 return; | 247 return; |
210 } | 248 } |
211 dart.assert(priority === isolate.Isolate.BEFORE_NEXT_EVENT); | 249 dart.assert(priority === isolate.Isolate.BEFORE_NEXT_EVENT); |
212 if (this._scheduledControlEvents === null) { | 250 if (this[_scheduledControlEvents] === null) { |
213 this._scheduledControlEvents = new collection.Queue(); | 251 this[_scheduledControlEvents] = new collection.Queue(); |
214 } | 252 } |
215 dart.dinvoke(this._scheduledControlEvents, 'addLast', this.kill); | 253 dart.dinvoke(this[_scheduledControlEvents], 'addLast', this.kill); |
216 } | 254 } |
217 addErrorListener(port) { | 255 addErrorListener(port) { |
218 this.errorPorts.add(port); | 256 this.errorPorts.add(port); |
219 } | 257 } |
220 removeErrorListener(port) { | 258 removeErrorListener(port) { |
221 this.errorPorts.remove(port); | 259 this.errorPorts.remove(port); |
222 } | 260 } |
223 handleUncaughtError(error, stackTrace) { | 261 handleUncaughtError(error, stackTrace) { |
224 if (this.errorPorts.isEmpty) { | 262 if (this.errorPorts.isEmpty) { |
225 if (dart.notNull(this.errorsAreFatal) && dart.notNull(core.identical(thi
s, _isolate_helper._globalState.rootContext))) { | 263 if (dart.notNull(this.errorsAreFatal) && dart.notNull(core.identical(thi
s, _isolate_helper._globalState.rootContext))) { |
(...skipping 12 matching lines...) Expand all Loading... |
238 message.set(0, dart.dinvoke(error, 'toString')); | 276 message.set(0, dart.dinvoke(error, 'toString')); |
239 message.set(1, stackTrace === null ? null : stackTrace.toString()); | 277 message.set(1, stackTrace === null ? null : stackTrace.toString()); |
240 for (let port of this.errorPorts) | 278 for (let port of this.errorPorts) |
241 port.send(message); | 279 port.send(message); |
242 } | 280 } |
243 eval(code) { | 281 eval(code) { |
244 let old = _isolate_helper._globalState.currentContext; | 282 let old = _isolate_helper._globalState.currentContext; |
245 _isolate_helper._globalState.currentContext = this; | 283 _isolate_helper._globalState.currentContext = this; |
246 this._setGlobals(); | 284 this._setGlobals(); |
247 let result = null; | 285 let result = null; |
248 this._isExecutingEvent = true; | 286 this[_isExecutingEvent] = true; |
249 try { | 287 try { |
250 result = dart.dinvokef(code); | 288 result = dart.dinvokef(code); |
251 } catch (e) { | 289 } catch (e) { |
252 let s = dart.stackTrace(e); | 290 let s = dart.stackTrace(e); |
253 this.handleUncaughtError(e, s); | 291 this.handleUncaughtError(e, s); |
254 if (this.errorsAreFatal) { | 292 if (this.errorsAreFatal) { |
255 this.kill(); | 293 this.kill(); |
256 if (core.identical(this, _isolate_helper._globalState.rootContext)) { | 294 if (core.identical(this, _isolate_helper._globalState.rootContext)) { |
257 dart.throw_("Unimplemented RethrowExpression: rethrow"); | 295 dart.throw_("Unimplemented RethrowExpression: rethrow"); |
258 } | 296 } |
259 } | 297 } |
260 } | 298 } |
261 finally { | 299 finally { |
262 this._isExecutingEvent = false; | 300 this[_isExecutingEvent] = false; |
263 _isolate_helper._globalState.currentContext = old; | 301 _isolate_helper._globalState.currentContext = old; |
264 if (old !== null) | 302 if (old !== null) |
265 old._setGlobals(); | 303 old._setGlobals(); |
266 if (this._scheduledControlEvents !== null) { | 304 if (this[_scheduledControlEvents] !== null) { |
267 while (dart.dload(this._scheduledControlEvents, 'isNotEmpty')) { | 305 while (dart.dload(this[_scheduledControlEvents], 'isNotEmpty')) { |
268 dart.dinvokef(dart.dinvoke(this._scheduledControlEvents, 'removeFirs
t')); | 306 dart.dinvokef(dart.dinvoke(this[_scheduledControlEvents], 'removeFir
st')); |
269 } | 307 } |
270 } | 308 } |
271 } | 309 } |
272 return result; | 310 return result; |
273 } | 311 } |
274 _setGlobals() { | 312 [_setGlobals]() { |
275 _foreign_helper.JS_SET_CURRENT_ISOLATE(this.isolateStatics); | 313 _foreign_helper.JS_SET_CURRENT_ISOLATE(this.isolateStatics); |
276 } | 314 } |
277 handleControlMessage(message) { | 315 handleControlMessage(message) { |
278 switch (dart.dindex(message, 0)) { | 316 switch (dart.dindex(message, 0)) { |
279 case "pause": | 317 case "pause": |
280 this.addPause(dart.as(dart.dindex(message, 1), isolate.Capability), da
rt.as(dart.dindex(message, 2), isolate.Capability)); | 318 this.addPause(dart.as(dart.dindex(message, 1), isolate.Capability), da
rt.as(dart.dindex(message, 2), isolate.Capability)); |
281 break; | 319 break; |
282 case "resume": | 320 case "resume": |
283 this.removePause(dart.as(dart.dindex(message, 1), isolate.Capability))
; | 321 this.removePause(dart.as(dart.dindex(message, 1), isolate.Capability))
; |
284 break; | 322 break; |
(...skipping 17 matching lines...) Expand all Loading... |
302 break; | 340 break; |
303 case "stopErrors": | 341 case "stopErrors": |
304 this.removeErrorListener(dart.as(dart.dindex(message, 1), isolate.Send
Port)); | 342 this.removeErrorListener(dart.as(dart.dindex(message, 1), isolate.Send
Port)); |
305 break; | 343 break; |
306 default: | 344 default: |
307 } | 345 } |
308 } | 346 } |
309 lookup(portId) { | 347 lookup(portId) { |
310 return this.ports.get(portId); | 348 return this.ports.get(portId); |
311 } | 349 } |
312 _addRegistration(portId, port) { | 350 [_addRegistration](portId, port) { |
313 if (this.ports.containsKey(portId)) { | 351 if (this.ports.containsKey(portId)) { |
314 throw new core.Exception("Registry: ports must be registered only once."
); | 352 throw new core.Exception("Registry: ports must be registered only once."
); |
315 } | 353 } |
316 this.ports.set(portId, port); | 354 this.ports.set(portId, port); |
317 } | 355 } |
318 register(portId, port) { | 356 register(portId, port) { |
319 this._addRegistration(portId, port); | 357 this[_addRegistration](portId, port); |
320 this._updateGlobalState(); | 358 this[_updateGlobalState](); |
321 } | 359 } |
322 registerWeak(portId, port) { | 360 registerWeak(portId, port) { |
323 this.weakPorts.add(portId); | 361 this.weakPorts.add(portId); |
324 this._addRegistration(portId, port); | 362 this[_addRegistration](portId, port); |
325 } | 363 } |
326 _updateGlobalState() { | 364 [_updateGlobalState]() { |
327 if (dart.notNull(dart.notNull(this.ports.length - this.weakPorts.length >
0) || dart.notNull(this.isPaused)) || dart.notNull(!dart.notNull(this.initialize
d))) { | 365 if (dart.notNull(dart.notNull(this.ports.length - this.weakPorts.length >
0) || dart.notNull(this.isPaused)) || dart.notNull(!dart.notNull(this.initialize
d))) { |
328 _isolate_helper._globalState.isolates.set(this.id, this); | 366 _isolate_helper._globalState.isolates.set(this.id, this); |
329 } else { | 367 } else { |
330 this.kill(); | 368 this.kill(); |
331 } | 369 } |
332 } | 370 } |
333 kill() { | 371 kill() { |
334 if (this._scheduledControlEvents !== null) { | 372 if (this[_scheduledControlEvents] !== null) { |
335 dart.dinvoke(this._scheduledControlEvents, 'clear'); | 373 dart.dinvoke(this[_scheduledControlEvents], 'clear'); |
336 } | 374 } |
337 for (let port of this.ports.values) { | 375 for (let port of this.ports.values) { |
338 dart.dinvoke(port, '_close'); | 376 dart.dinvoke(port, '_close'); |
339 } | 377 } |
340 this.ports.clear(); | 378 this.ports.clear(); |
341 this.weakPorts.clear(); | 379 this.weakPorts.clear(); |
342 _isolate_helper._globalState.isolates.remove(this.id); | 380 _isolate_helper._globalState.isolates.remove(this.id); |
343 this.errorPorts.clear(); | 381 this.errorPorts.clear(); |
344 if (this.doneHandlers !== null) { | 382 if (this.doneHandlers !== null) { |
345 for (let port of this.doneHandlers) { | 383 for (let port of this.doneHandlers) { |
346 port.send(null); | 384 port.send(null); |
347 } | 385 } |
348 this.doneHandlers = null; | 386 this.doneHandlers = null; |
349 } | 387 } |
350 } | 388 } |
351 unregister(portId) { | 389 unregister(portId) { |
352 this.ports.remove(portId); | 390 this.ports.remove(portId); |
353 this.weakPorts.remove(portId); | 391 this.weakPorts.remove(portId); |
354 this._updateGlobalState(); | 392 this[_updateGlobalState](); |
355 } | 393 } |
356 } | 394 } |
357 class _EventLoop extends dart.Object { | 395 class _EventLoop extends dart.Object { |
358 _EventLoop() { | 396 _EventLoop() { |
359 this.events = new collection.Queue(); | 397 this.events = new collection.Queue(); |
360 this._activeJsAsyncCount = 0; | 398 this[_activeJsAsyncCount] = 0; |
361 } | 399 } |
362 enqueue(isolate, fn, msg) { | 400 enqueue(isolate, fn, msg) { |
363 this.events.addLast(new _IsolateEvent(dart.as(isolate, _IsolateContext), d
art.as(fn, core.Function), dart.as(msg, core.String))); | 401 this.events.addLast(new _IsolateEvent(dart.as(isolate, _IsolateContext), d
art.as(fn, core.Function), dart.as(msg, core.String))); |
364 } | 402 } |
365 prequeue(event) { | 403 prequeue(event) { |
366 this.events.addFirst(event); | 404 this.events.addFirst(event); |
367 } | 405 } |
368 dequeue() { | 406 dequeue() { |
369 if (this.events.isEmpty) | 407 if (this.events.isEmpty) |
370 return null; | 408 return null; |
371 return this.events.removeFirst(); | 409 return this.events.removeFirst(); |
372 } | 410 } |
373 checkOpenReceivePortsFromCommandLine() { | 411 checkOpenReceivePortsFromCommandLine() { |
374 if (dart.notNull(dart.notNull(dart.notNull(_isolate_helper._globalState.ro
otContext !== null) && dart.notNull(_isolate_helper._globalState.isolates.contai
nsKey(_isolate_helper._globalState.rootContext.id))) && dart.notNull(_isolate_he
lper._globalState.fromCommandLine)) && dart.notNull(_isolate_helper._globalState
.rootContext.ports.isEmpty)) { | 412 if (dart.notNull(dart.notNull(dart.notNull(_isolate_helper._globalState.ro
otContext !== null) && dart.notNull(_isolate_helper._globalState.isolates.contai
nsKey(_isolate_helper._globalState.rootContext.id))) && dart.notNull(_isolate_he
lper._globalState.fromCommandLine)) && dart.notNull(_isolate_helper._globalState
.rootContext.ports.isEmpty)) { |
375 throw new core.Exception("Program exited with open ReceivePorts."); | 413 throw new core.Exception("Program exited with open ReceivePorts."); |
376 } | 414 } |
377 } | 415 } |
378 runIteration() { | 416 runIteration() { |
379 let event = this.dequeue(); | 417 let event = this.dequeue(); |
380 if (event === null) { | 418 if (event === null) { |
381 this.checkOpenReceivePortsFromCommandLine(); | 419 this.checkOpenReceivePortsFromCommandLine(); |
382 _isolate_helper._globalState.maybeCloseWorker(); | 420 _isolate_helper._globalState.maybeCloseWorker(); |
383 return false; | 421 return false; |
384 } | 422 } |
385 event.process(); | 423 event.process(); |
386 return true; | 424 return true; |
387 } | 425 } |
388 _runHelper() { | 426 [_runHelper]() { |
389 if (_isolate_helper.globalWindow !== null) { | 427 if (_isolate_helper.globalWindow !== null) { |
390 // Function next: () → void | 428 // Function next: () → void |
391 function next() { | 429 function next() { |
392 if (!dart.notNull(this.runIteration())) | 430 if (!dart.notNull(this.runIteration())) |
393 return; | 431 return; |
394 async.Timer.run(next); | 432 async.Timer.run(next); |
395 } | 433 } |
396 next(); | 434 next(); |
397 } else { | 435 } else { |
398 while (this.runIteration()) { | 436 while (this.runIteration()) { |
399 } | 437 } |
400 } | 438 } |
401 } | 439 } |
402 run() { | 440 run() { |
403 if (!dart.notNull(_isolate_helper._globalState.isWorker)) { | 441 if (!dart.notNull(_isolate_helper._globalState.isWorker)) { |
404 this._runHelper(); | 442 this[_runHelper](); |
405 } else { | 443 } else { |
406 try { | 444 try { |
407 this._runHelper(); | 445 this[_runHelper](); |
408 } catch (e) { | 446 } catch (e) { |
409 let trace = dart.stackTrace(e); | 447 let trace = dart.stackTrace(e); |
410 _isolate_helper._globalState.mainManager.postMessage(_serializeMessage
(dart.map({command: 'error', msg: `${e}\n${trace}`}))); | 448 _isolate_helper._globalState.mainManager.postMessage(_serializeMessage
(dart.map({command: 'error', msg: `${e}\n${trace}`}))); |
411 } | 449 } |
412 | 450 |
413 } | 451 } |
414 } | 452 } |
415 } | 453 } |
416 class _IsolateEvent extends dart.Object { | 454 class _IsolateEvent extends dart.Object { |
417 _IsolateEvent(isolate, fn, message) { | 455 _IsolateEvent(isolate, fn, message) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 pattern = new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m"); | 525 pattern = new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m"); |
488 matches = stack.match(pattern); | 526 matches = stack.match(pattern); |
489 if (matches !== null) | 527 if (matches !== null) |
490 return matches[1]; | 528 return matches[1]; |
491 pattern = new RegExp("^[^@]*@(.*):[0-9]*$", "m"); | 529 pattern = new RegExp("^[^@]*@(.*):[0-9]*$", "m"); |
492 matches = stack.match(pattern); | 530 matches = stack.match(pattern); |
493 if (matches !== null) | 531 if (matches !== null) |
494 return matches[1]; | 532 return matches[1]; |
495 throw new core.UnsupportedError(`Cannot extract URI from "${stack}"`); | 533 throw new core.UnsupportedError(`Cannot extract URI from "${stack}"`); |
496 } | 534 } |
497 static _getEventData(e) { | 535 static [_getEventData](e) { |
498 return e.data; | 536 return e.data; |
499 } | 537 } |
500 static _processWorkerMessage(sender, e) { | 538 static [_processWorkerMessage](sender, e) { |
501 let msg = _deserializeMessage(_getEventData(e)); | 539 let msg = _deserializeMessage(_getEventData(e)); |
502 switch (dart.dindex(msg, 'command')) { | 540 switch (dart.dindex(msg, 'command')) { |
503 case 'start': | 541 case 'start': |
504 _isolate_helper._globalState.currentManagerId = dart.as(dart.dindex(ms
g, 'id'), core.int); | 542 _isolate_helper._globalState.currentManagerId = dart.as(dart.dindex(ms
g, 'id'), core.int); |
505 let functionName = dart.as(dart.dindex(msg, 'functionName'), core.Stri
ng); | 543 let functionName = dart.as(dart.dindex(msg, 'functionName'), core.Stri
ng); |
506 let entryPoint = dart.as(functionName === null ? _isolate_helper._glob
alState.entry : _getJSFunctionFromName(functionName), core.Function); | 544 let entryPoint = dart.as(functionName === null ? _isolate_helper._glob
alState.entry : _getJSFunctionFromName(functionName), core.Function); |
507 let args = dart.dindex(msg, 'args'); | 545 let args = dart.dindex(msg, 'args'); |
508 let message = _deserializeMessage(dart.dindex(msg, 'msg')); | 546 let message = _deserializeMessage(dart.dindex(msg, 'msg')); |
509 let isSpawnUri = dart.dindex(msg, 'isSpawnUri'); | 547 let isSpawnUri = dart.dindex(msg, 'isSpawnUri'); |
510 let startPaused = dart.dindex(msg, 'startPaused'); | 548 let startPaused = dart.dindex(msg, 'startPaused'); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 static handleSpawnWorkerRequest(msg) { | 587 static handleSpawnWorkerRequest(msg) { |
550 let replyPort = dart.dindex(msg, 'replyPort'); | 588 let replyPort = dart.dindex(msg, 'replyPort'); |
551 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.dindex(msg, 'isSpawn
Uri'), core.bool), dart.as(dart.dindex(msg, 'startPaused'), core.bool)).then((ms
g) => { | 589 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.dindex(msg, 'isSpawn
Uri'), core.bool), dart.as(dart.dindex(msg, 'startPaused'), core.bool)).then((ms
g) => { |
552 dart.dinvoke(replyPort, 'send', msg); | 590 dart.dinvoke(replyPort, 'send', msg); |
553 }, { | 591 }, { |
554 onError: (errorMessage) => { | 592 onError: (errorMessage) => { |
555 dart.dinvoke(replyPort, 'send', new List.from([_SPAWN_FAILED_SIGNAL, e
rrorMessage])); | 593 dart.dinvoke(replyPort, 'send', new List.from([_SPAWN_FAILED_SIGNAL, e
rrorMessage])); |
556 } | 594 } |
557 }); | 595 }); |
558 } | 596 } |
559 static _log(msg) { | 597 static [_log](msg) { |
560 if (_isolate_helper._globalState.isWorker) { | 598 if (_isolate_helper._globalState.isWorker) { |
561 _isolate_helper._globalState.mainManager.postMessage(_serializeMessage(d
art.map({command: 'log', msg: msg}))); | 599 _isolate_helper._globalState.mainManager.postMessage(_serializeMessage(d
art.map({command: 'log', msg: msg}))); |
562 } else { | 600 } else { |
563 try { | 601 try { |
564 _consoleLog(msg); | 602 _consoleLog(msg); |
565 } catch (e) { | 603 } catch (e) { |
566 let trace = dart.stackTrace(e); | 604 let trace = dart.stackTrace(e); |
567 throw new core.Exception(trace); | 605 throw new core.Exception(trace); |
568 } | 606 } |
569 | 607 |
570 } | 608 } |
571 } | 609 } |
572 static _consoleLog(msg) { | 610 static [_consoleLog](msg) { |
573 _js_helper.requiresPreamble(); | 611 _js_helper.requiresPreamble(); |
574 self.console.log(msg); | 612 self.console.log(msg); |
575 } | 613 } |
576 static _getJSFunctionFromName(functionName) { | 614 static [_getJSFunctionFromName](functionName) { |
577 let globalFunctionsContainer = _foreign_helper.JS_EMBEDDED_GLOBAL("", dart
.as(_js_embedded_names.GLOBAL_FUNCTIONS, core.String)); | 615 let globalFunctionsContainer = _foreign_helper.JS_EMBEDDED_GLOBAL("", dart
.as(_js_embedded_names.GLOBAL_FUNCTIONS, core.String)); |
578 return globalFunctionsContainer[functionName](); | 616 return globalFunctionsContainer[functionName](); |
579 } | 617 } |
580 static _getJSFunctionName(f) { | 618 static [_getJSFunctionName](f) { |
581 return dart.as(dart.is(f, _js_helper.Closure) ? f.$name : null, core.Strin
g); | 619 return dart.as(dart.is(f, _js_helper.Closure) ? f.$name : null, core.Strin
g); |
582 } | 620 } |
583 static _allocate(ctor) { | 621 static [_allocate](ctor) { |
584 return new ctor(); | 622 return new ctor(); |
585 } | 623 } |
586 static spawnFunction(topLevelFunction, message, startPaused) { | 624 static spawnFunction(topLevelFunction, message, startPaused) { |
587 IsolateNatives.enableSpawnWorker = true; | 625 IsolateNatives.enableSpawnWorker = true; |
588 let name = _getJSFunctionName(topLevelFunction); | 626 let name = _getJSFunctionName(topLevelFunction); |
589 if (name === null) { | 627 if (name === null) { |
590 throw new core.UnsupportedError("only top-level functions can be spawned
."); | 628 throw new core.UnsupportedError("only top-level functions can be spawned
."); |
591 } | 629 } |
592 let isLight = false; | 630 let isLight = false; |
593 let isSpawnUri = false; | 631 let isSpawnUri = false; |
(...skipping 19 matching lines...) Expand all Loading... |
613 } | 651 } |
614 }).bind(this)); | 652 }).bind(this)); |
615 let signalReply = port.sendPort; | 653 let signalReply = port.sendPort; |
616 if (dart.notNull(_isolate_helper._globalState.useWorkers) && dart.notNull(
!dart.notNull(isLight))) { | 654 if (dart.notNull(_isolate_helper._globalState.useWorkers) && dart.notNull(
!dart.notNull(isLight))) { |
617 _startWorker(functionName, uri, args, message, isSpawnUri, startPaused,
signalReply, ((message) => completer.completeError(message)).bind(this)); | 655 _startWorker(functionName, uri, args, message, isSpawnUri, startPaused,
signalReply, ((message) => completer.completeError(message)).bind(this)); |
618 } else { | 656 } else { |
619 _startNonWorker(functionName, uri, args, message, isSpawnUri, startPause
d, signalReply); | 657 _startNonWorker(functionName, uri, args, message, isSpawnUri, startPause
d, signalReply); |
620 } | 658 } |
621 return completer.future; | 659 return completer.future; |
622 } | 660 } |
623 static _startWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { | 661 static [_startWorker](functionName, uri, args, message, isSpawnUri, startPau
sed, replyPort, onError) { |
624 if (args !== null) | 662 if (args !== null) |
625 args = new core.List.from(args); | 663 args = new core.List.from(args); |
626 if (_isolate_helper._globalState.isWorker) { | 664 if (_isolate_helper._globalState.isWorker) { |
627 _isolate_helper._globalState.mainManager.postMessage(_serializeMessage(d
art.map({command: 'spawn-worker', functionName: functionName, args: args, msg: m
essage, uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: r
eplyPort}))); | 665 _isolate_helper._globalState.mainManager.postMessage(_serializeMessage(d
art.map({command: 'spawn-worker', functionName: functionName, args: args, msg: m
essage, uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: r
eplyPort}))); |
628 } else { | 666 } else { |
629 _spawnWorker(functionName, uri, args, message, isSpawnUri, startPaused,
replyPort, onError); | 667 _spawnWorker(functionName, uri, args, message, isSpawnUri, startPaused,
replyPort, onError); |
630 } | 668 } |
631 } | 669 } |
632 static _startNonWorker(functionName, uri, args, message, isSpawnUri, startPa
used, replyPort) { | 670 static [_startNonWorker](functionName, uri, args, message, isSpawnUri, start
Paused, replyPort) { |
633 if (uri !== null) { | 671 if (uri !== null) { |
634 throw new core.UnsupportedError("Currently spawnUri is not supported wit
hout web workers."); | 672 throw new core.UnsupportedError("Currently spawnUri is not supported wit
hout web workers."); |
635 } | 673 } |
636 message = _clone(message); | 674 message = _clone(message); |
637 if (args !== null) | 675 if (args !== null) |
638 args = new core.List.from(args); | 676 args = new core.List.from(args); |
639 _isolate_helper._globalState.topEventLoop.enqueue(new _IsolateContext(), (
) => { | 677 _isolate_helper._globalState.topEventLoop.enqueue(new _IsolateContext(), (
) => { |
640 let func = _getJSFunctionFromName(functionName); | 678 let func = _getJSFunctionFromName(functionName); |
641 _startIsolate(dart.as(func, core.Function), args, message, isSpawnUri, s
tartPaused, replyPort); | 679 _startIsolate(dart.as(func, core.Function), args, message, isSpawnUri, s
tartPaused, replyPort); |
642 }, 'nonworker start'); | 680 }, 'nonworker start'); |
643 } | 681 } |
644 static get currentIsolate() { | 682 static get currentIsolate() { |
645 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); | 683 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); |
646 return new isolate.Isolate(context.controlPort.sendPort, {pauseCapability:
context.pauseCapability, terminateCapability: context.terminateCapability}); | 684 return new isolate.Isolate(context.controlPort.sendPort, {pauseCapability:
context.pauseCapability, terminateCapability: context.terminateCapability}); |
647 } | 685 } |
648 static _startIsolate(topLevel, args, message, isSpawnUri, startPaused, reply
To) { | 686 static [_startIsolate](topLevel, args, message, isSpawnUri, startPaused, rep
lyTo) { |
649 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); | 687 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola
teContext); |
650 _js_helper.Primitives.initializeStatics(context.id); | 688 _js_helper.Primitives.initializeStatics(context.id); |
651 replyTo.send(new List.from([_SPAWNED_SIGNAL, context.controlPort.sendPort,
context.pauseCapability, context.terminateCapability])); | 689 replyTo.send(new List.from([_SPAWNED_SIGNAL, context.controlPort.sendPort,
context.pauseCapability, context.terminateCapability])); |
652 // Function runStartFunction: () → void | 690 // Function runStartFunction: () → void |
653 function runStartFunction() { | 691 function runStartFunction() { |
654 context.initialized = true; | 692 context.initialized = true; |
655 if (!dart.notNull(isSpawnUri)) { | 693 if (!dart.notNull(isSpawnUri)) { |
656 dart.dinvokef(topLevel, message); | 694 dart.dinvokef(topLevel, message); |
657 } else if (dart.is(topLevel, _MainFunctionArgsMessage)) { | 695 } else if (dart.is(topLevel, _MainFunctionArgsMessage)) { |
658 dart.dinvokef(topLevel, args, message); | 696 dart.dinvokef(topLevel, args, message); |
659 } else if (dart.is(topLevel, _MainFunctionArgs)) { | 697 } else if (dart.is(topLevel, _MainFunctionArgs)) { |
660 dart.dinvokef(topLevel, args); | 698 dart.dinvokef(topLevel, args); |
661 } else { | 699 } else { |
662 dart.dinvokef(topLevel); | 700 dart.dinvokef(topLevel); |
663 } | 701 } |
664 } | 702 } |
665 if (startPaused) { | 703 if (startPaused) { |
666 context.addPause(context.pauseCapability, context.pauseCapability); | 704 context.addPause(context.pauseCapability, context.pauseCapability); |
667 _isolate_helper._globalState.topEventLoop.enqueue(context, runStartFunct
ion, 'start isolate'); | 705 _isolate_helper._globalState.topEventLoop.enqueue(context, runStartFunct
ion, 'start isolate'); |
668 } else { | 706 } else { |
669 runStartFunction(); | 707 runStartFunction(); |
670 } | 708 } |
671 } | 709 } |
672 static _spawnWorker(functionName, uri, args, message, isSpawnUri, startPause
d, replyPort, onError) { | 710 static [_spawnWorker](functionName, uri, args, message, isSpawnUri, startPau
sed, replyPort, onError) { |
673 if (uri === null) | 711 if (uri === null) |
674 uri = thisScript; | 712 uri = thisScript; |
675 let worker = new Worker(uri); | 713 let worker = new Worker(uri); |
676 let onerrorTrampoline = function(f, u, c) { | 714 let onerrorTrampoline = function(f, u, c) { |
677 return function(e) { | 715 return function(e) { |
678 return f(e, u, c); | 716 return f(e, u, c); |
679 }; | 717 }; |
680 }(_foreign_helper.DART_CLOSURE_TO_JS(workerOnError), uri, onError); | 718 }(_foreign_helper.DART_CLOSURE_TO_JS(workerOnError), uri, onError); |
681 worker.onerror = onerrorTrampoline; | 719 worker.onerror = onerrorTrampoline; |
682 let processWorkerMessageTrampoline = function(f, a) { | 720 let processWorkerMessageTrampoline = function(f, a) { |
(...skipping 24 matching lines...) Expand all Loading... |
707 dart.defineLazyProperties(IsolateNatives, { | 745 dart.defineLazyProperties(IsolateNatives, { |
708 get thisScript() { | 746 get thisScript() { |
709 return computeThisScript(); | 747 return computeThisScript(); |
710 }, | 748 }, |
711 set thisScript() {}, | 749 set thisScript() {}, |
712 get workerIds() { | 750 get workerIds() { |
713 return new core.Expando(); | 751 return new core.Expando(); |
714 } | 752 } |
715 }); | 753 }); |
716 class _BaseSendPort extends dart.Object { | 754 class _BaseSendPort extends dart.Object { |
717 _BaseSendPort(_isolateId) { | 755 _BaseSendPort($_isolateId) { |
718 this._isolateId = _isolateId; | 756 this[_isolateId] = $_isolateId; |
719 } | 757 } |
720 _checkReplyTo(replyTo) { | 758 [_checkReplyTo](replyTo) { |
721 if (dart.notNull(dart.notNull(replyTo !== null) && dart.notNull(!dart.is(r
eplyTo, _NativeJsSendPort))) && dart.notNull(!dart.is(replyTo, _WorkerSendPort))
) { | 759 if (dart.notNull(dart.notNull(replyTo !== null) && dart.notNull(!dart.is(r
eplyTo, _NativeJsSendPort))) && dart.notNull(!dart.is(replyTo, _WorkerSendPort))
) { |
722 throw new core.Exception("SendPort.send: Illegal replyTo port type"); | 760 throw new core.Exception("SendPort.send: Illegal replyTo port type"); |
723 } | 761 } |
724 } | 762 } |
725 } | 763 } |
726 class _NativeJsSendPort extends _BaseSendPort { | 764 class _NativeJsSendPort extends _BaseSendPort { |
727 _NativeJsSendPort(_receivePort, isolateId) { | 765 _NativeJsSendPort($_receivePort, isolateId) { |
728 this._receivePort = _receivePort; | 766 this[_receivePort] = $_receivePort; |
729 super._BaseSendPort(isolateId); | 767 super._BaseSendPort(isolateId); |
730 } | 768 } |
731 send(message) { | 769 send(message) { |
732 let isolate = _isolate_helper._globalState.isolates.get(this._isolateId); | 770 let isolate = _isolate_helper._globalState.isolates.get(this[_isolateId]); |
733 if (isolate === null) | 771 if (isolate === null) |
734 return; | 772 return; |
735 if (this._receivePort._isClosed) | 773 if (this[_receivePort][_isClosed]) |
736 return; | 774 return; |
737 let msg = _clone(message); | 775 let msg = _clone(message); |
738 if (dart.equals(isolate.controlPort, this._receivePort)) { | 776 if (dart.equals(isolate.controlPort, this[_receivePort])) { |
739 isolate.handleControlMessage(msg); | 777 isolate.handleControlMessage(msg); |
740 return; | 778 return; |
741 } | 779 } |
742 _isolate_helper._globalState.topEventLoop.enqueue(isolate, (() => { | 780 _isolate_helper._globalState.topEventLoop.enqueue(isolate, (() => { |
743 if (!dart.notNull(this._receivePort._isClosed)) { | 781 if (!dart.notNull(this[_receivePort][_isClosed])) { |
744 this._receivePort._add(msg); | 782 this[_receivePort]._add(msg); |
745 } | 783 } |
746 }).bind(this), `receive ${message}`); | 784 }).bind(this), `receive ${message}`); |
747 } | 785 } |
748 ['=='](other) { | 786 ['=='](other) { |
749 return dart.notNull(dart.is(other, _NativeJsSendPort)) && dart.notNull(dar
t.equals(this._receivePort, dart.dload(other, '_receivePort'))); | 787 return dart.notNull(dart.is(other, _NativeJsSendPort)) && dart.notNull(dar
t.equals(this[_receivePort], dart.dload(other, '_receivePort'))); |
750 } | 788 } |
751 get hashCode() { | 789 get hashCode() { |
752 return this._receivePort._id; | 790 return this[_receivePort][_id]; |
753 } | 791 } |
754 } | 792 } |
755 class _WorkerSendPort extends _BaseSendPort { | 793 class _WorkerSendPort extends _BaseSendPort { |
756 _WorkerSendPort(_workerId, isolateId, _receivePortId) { | 794 _WorkerSendPort($_workerId, isolateId, $_receivePortId) { |
757 this._workerId = _workerId; | 795 this[_workerId] = $_workerId; |
758 this._receivePortId = _receivePortId; | 796 this[_receivePortId] = $_receivePortId; |
759 super._BaseSendPort(isolateId); | 797 super._BaseSendPort(isolateId); |
760 } | 798 } |
761 send(message) { | 799 send(message) { |
762 let workerMessage = _serializeMessage(dart.map({command: 'message', port:
this, msg: message})); | 800 let workerMessage = _serializeMessage(dart.map({command: 'message', port:
this, msg: message})); |
763 if (_isolate_helper._globalState.isWorker) { | 801 if (_isolate_helper._globalState.isWorker) { |
764 _isolate_helper._globalState.mainManager.postMessage(workerMessage); | 802 _isolate_helper._globalState.mainManager.postMessage(workerMessage); |
765 } else { | 803 } else { |
766 let manager = _isolate_helper._globalState.managers.get(this._workerId); | 804 let manager = _isolate_helper._globalState.managers.get(this[_workerId])
; |
767 if (manager !== null) { | 805 if (manager !== null) { |
768 manager.postMessage(workerMessage); | 806 manager.postMessage(workerMessage); |
769 } | 807 } |
770 } | 808 } |
771 } | 809 } |
772 ['=='](other) { | 810 ['=='](other) { |
773 return dart.notNull(dart.notNull(dart.notNull(dart.is(other, _WorkerSendPo
rt)) && dart.notNull(this._workerId === dart.dload(other, '_workerId'))) && dart
.notNull(this._isolateId === dart.dload(other, '_isolateId'))) && dart.notNull(t
his._receivePortId === dart.dload(other, '_receivePortId')); | 811 return dart.notNull(dart.notNull(dart.notNull(dart.is(other, _WorkerSendPo
rt)) && dart.notNull(this[_workerId] === dart.dload(other, '_workerId'))) && dar
t.notNull(this[_isolateId] === dart.dload(other, '_isolateId'))) && dart.notNull
(this[_receivePortId] === dart.dload(other, '_receivePortId')); |
774 } | 812 } |
775 get hashCode() { | 813 get hashCode() { |
776 return this._workerId << 16 ^ this._isolateId << 8 ^ this._receivePortId; | 814 return this[_workerId] << 16 ^ this[_isolateId] << 8 ^ this[_receivePortId
]; |
777 } | 815 } |
778 } | 816 } |
779 class RawReceivePortImpl extends dart.Object { | 817 class RawReceivePortImpl extends dart.Object { |
780 RawReceivePortImpl(_handler) { | 818 RawReceivePortImpl($_handler) { |
781 this._handler = _handler; | 819 this[_handler] = $_handler; |
782 this._id = _nextFreeId++; | 820 this[_id] = _nextFreeId++; |
783 this._isClosed = false; | 821 this[_isClosed] = false; |
784 _isolate_helper._globalState.currentContext.register(this._id, this); | 822 _isolate_helper._globalState.currentContext.register(this[_id], this); |
785 } | 823 } |
786 RawReceivePortImpl$weak(_handler) { | 824 RawReceivePortImpl$weak($_handler) { |
787 this._handler = _handler; | 825 this[_handler] = $_handler; |
788 this._id = _nextFreeId++; | 826 this[_id] = _nextFreeId++; |
789 this._isClosed = false; | 827 this[_isClosed] = false; |
790 _isolate_helper._globalState.currentContext.registerWeak(this._id, this); | 828 _isolate_helper._globalState.currentContext.registerWeak(this[_id], this); |
791 } | 829 } |
792 RawReceivePortImpl$_controlPort() { | 830 RawReceivePortImpl$_controlPort() { |
793 this._handler = null; | 831 this[_handler] = null; |
794 this._id = 0; | 832 this[_id] = 0; |
795 this._isClosed = false; | 833 this[_isClosed] = false; |
796 } | 834 } |
797 set handler(newHandler) { | 835 set handler(newHandler) { |
798 this._handler = newHandler; | 836 this[_handler] = newHandler; |
799 } | 837 } |
800 _close() { | 838 [_close]() { |
801 this._isClosed = true; | 839 this[_isClosed] = true; |
802 this._handler = null; | 840 this[_handler] = null; |
803 } | 841 } |
804 close() { | 842 close() { |
805 if (this._isClosed) | 843 if (this[_isClosed]) |
806 return; | 844 return; |
807 this._isClosed = true; | 845 this[_isClosed] = true; |
808 this._handler = null; | 846 this[_handler] = null; |
809 _isolate_helper._globalState.currentContext.unregister(this._id); | 847 _isolate_helper._globalState.currentContext.unregister(this[_id]); |
810 } | 848 } |
811 _add(dataEvent) { | 849 [_add](dataEvent) { |
812 if (this._isClosed) | 850 if (this[_isClosed]) |
813 return; | 851 return; |
814 dart.dinvokef(this._handler, dataEvent); | 852 dart.dinvokef(this[_handler], dataEvent); |
815 } | 853 } |
816 get sendPort() { | 854 get sendPort() { |
817 return new _NativeJsSendPort(this, _isolate_helper._globalState.currentCon
text.id); | 855 return new _NativeJsSendPort(this, _isolate_helper._globalState.currentCon
text.id); |
818 } | 856 } |
819 } | 857 } |
820 dart.defineNamedConstructor(RawReceivePortImpl, 'weak'); | 858 dart.defineNamedConstructor(RawReceivePortImpl, 'weak'); |
821 dart.defineNamedConstructor(RawReceivePortImpl, '_controlPort'); | 859 dart.defineNamedConstructor(RawReceivePortImpl, '_controlPort'); |
822 RawReceivePortImpl._nextFreeId = 1; | 860 RawReceivePortImpl._nextFreeId = 1; |
823 class ReceivePortImpl extends async.Stream { | 861 class ReceivePortImpl extends async.Stream { |
824 ReceivePortImpl() { | 862 ReceivePortImpl() { |
825 this.ReceivePortImpl$fromRawReceivePort(new RawReceivePortImpl(null)); | 863 this.ReceivePortImpl$fromRawReceivePort(new RawReceivePortImpl(null)); |
826 } | 864 } |
827 ReceivePortImpl$weak() { | 865 ReceivePortImpl$weak() { |
828 this.ReceivePortImpl$fromRawReceivePort(new RawReceivePortImpl.weak(null))
; | 866 this.ReceivePortImpl$fromRawReceivePort(new RawReceivePortImpl.weak(null))
; |
829 } | 867 } |
830 ReceivePortImpl$fromRawReceivePort(_rawPort) { | 868 ReceivePortImpl$fromRawReceivePort($_rawPort) { |
831 this._rawPort = _rawPort; | 869 this[_rawPort] = $_rawPort; |
832 this._controller = null; | 870 this[_controller] = null; |
833 super.Stream(); | 871 super.Stream(); |
834 this._controller = new async.StreamController({onCancel: this.close, sync:
true}); | 872 this[_controller] = new async.StreamController({onCancel: this.close, sync
: true}); |
835 this._rawPort.handler = this._controller.add; | 873 this[_rawPort].handler = this[_controller].add; |
836 } | 874 } |
837 listen(onData, opt$) { | 875 listen(onData, opt$) { |
838 let onError = opt$.onError === void 0 ? null : opt$.onError; | 876 let onError = opt$.onError === void 0 ? null : opt$.onError; |
839 let onDone = opt$.onDone === void 0 ? null : opt$.onDone; | 877 let onDone = opt$.onDone === void 0 ? null : opt$.onDone; |
840 let cancelOnError = opt$.cancelOnError === void 0 ? null : opt$.cancelOnEr
ror; | 878 let cancelOnError = opt$.cancelOnError === void 0 ? null : opt$.cancelOnEr
ror; |
841 return this._controller.stream.listen(onData, {onError: onError, onDone: o
nDone, cancelOnError: cancelOnError}); | 879 return this[_controller].stream.listen(onData, {onError: onError, onDone:
onDone, cancelOnError: cancelOnError}); |
842 } | 880 } |
843 close() { | 881 close() { |
844 this._rawPort.close(); | 882 this[_rawPort].close(); |
845 this._controller.close(); | 883 this[_controller].close(); |
846 } | 884 } |
847 get sendPort() { | 885 get sendPort() { |
848 return this._rawPort.sendPort; | 886 return this[_rawPort].sendPort; |
849 } | 887 } |
850 } | 888 } |
851 dart.defineNamedConstructor(ReceivePortImpl, 'weak'); | 889 dart.defineNamedConstructor(ReceivePortImpl, 'weak'); |
852 dart.defineNamedConstructor(ReceivePortImpl, 'fromRawReceivePort'); | 890 dart.defineNamedConstructor(ReceivePortImpl, 'fromRawReceivePort'); |
853 class TimerImpl extends dart.Object { | 891 class TimerImpl extends dart.Object { |
854 TimerImpl(milliseconds, callback) { | 892 TimerImpl(milliseconds, callback) { |
855 this._once = true; | 893 this[_once] = true; |
856 this._inEventLoop = false; | 894 this[_inEventLoop] = false; |
857 this._handle = dart.as(null, core.int); | 895 this[_handle] = dart.as(null, core.int); |
858 if (dart.notNull(milliseconds === 0) && dart.notNull(dart.notNull(!dart.no
tNull(hasTimer())) || dart.notNull(_isolate_helper._globalState.isWorker))) { | 896 if (dart.notNull(milliseconds === 0) && dart.notNull(dart.notNull(!dart.no
tNull(hasTimer())) || dart.notNull(_isolate_helper._globalState.isWorker))) { |
859 // Function internalCallback: () → void | 897 // Function internalCallback: () → void |
860 function internalCallback() { | 898 function internalCallback() { |
861 this._handle = dart.as(null, core.int); | 899 this[_handle] = dart.as(null, core.int); |
862 callback(); | 900 callback(); |
863 } | 901 } |
864 this._handle = 1; | 902 this[_handle] = 1; |
865 _isolate_helper._globalState.topEventLoop.enqueue(_isolate_helper._globa
lState.currentContext, internalCallback, 'timer'); | 903 _isolate_helper._globalState.topEventLoop.enqueue(_isolate_helper._globa
lState.currentContext, internalCallback, 'timer'); |
866 this._inEventLoop = true; | 904 this[_inEventLoop] = true; |
867 } else if (hasTimer()) { | 905 } else if (hasTimer()) { |
868 // Function internalCallback: () → void | 906 // Function internalCallback: () → void |
869 function internalCallback() { | 907 function internalCallback() { |
870 this._handle = dart.as(null, core.int); | 908 this[_handle] = dart.as(null, core.int); |
871 leaveJsAsync(); | 909 leaveJsAsync(); |
872 callback(); | 910 callback(); |
873 } | 911 } |
874 enterJsAsync(); | 912 enterJsAsync(); |
875 this._handle = self.setTimeout(_js_helper.convertDartClosureToJS(interna
lCallback, 0), milliseconds); | 913 this[_handle] = self.setTimeout(_js_helper.convertDartClosureToJS(intern
alCallback, 0), milliseconds); |
876 } else { | 914 } else { |
877 dart.assert(milliseconds > 0); | 915 dart.assert(milliseconds > 0); |
878 throw new core.UnsupportedError("Timer greater than 0."); | 916 throw new core.UnsupportedError("Timer greater than 0."); |
879 } | 917 } |
880 } | 918 } |
881 TimerImpl$periodic(milliseconds, callback) { | 919 TimerImpl$periodic(milliseconds, callback) { |
882 this._once = false; | 920 this[_once] = false; |
883 this._inEventLoop = false; | 921 this[_inEventLoop] = false; |
884 this._handle = dart.as(null, core.int); | 922 this[_handle] = dart.as(null, core.int); |
885 if (hasTimer()) { | 923 if (hasTimer()) { |
886 enterJsAsync(); | 924 enterJsAsync(); |
887 this._handle = self.setInterval(_js_helper.convertDartClosureToJS((() =>
{ | 925 this[_handle] = self.setInterval(_js_helper.convertDartClosureToJS((() =
> { |
888 callback(this); | 926 callback(this); |
889 }).bind(this), 0), milliseconds); | 927 }).bind(this), 0), milliseconds); |
890 } else { | 928 } else { |
891 throw new core.UnsupportedError("Periodic timer."); | 929 throw new core.UnsupportedError("Periodic timer."); |
892 } | 930 } |
893 } | 931 } |
894 cancel() { | 932 cancel() { |
895 if (hasTimer()) { | 933 if (hasTimer()) { |
896 if (this._inEventLoop) { | 934 if (this[_inEventLoop]) { |
897 throw new core.UnsupportedError("Timer in event loop cannot be cancele
d."); | 935 throw new core.UnsupportedError("Timer in event loop cannot be cancele
d."); |
898 } | 936 } |
899 if (this._handle === null) | 937 if (this[_handle] === null) |
900 return; | 938 return; |
901 leaveJsAsync(); | 939 leaveJsAsync(); |
902 if (this._once) { | 940 if (this[_once]) { |
903 self.clearTimeout(this._handle); | 941 self.clearTimeout(this[_handle]); |
904 } else { | 942 } else { |
905 self.clearInterval(this._handle); | 943 self.clearInterval(this[_handle]); |
906 } | 944 } |
907 this._handle = dart.as(null, core.int); | 945 this[_handle] = dart.as(null, core.int); |
908 } else { | 946 } else { |
909 throw new core.UnsupportedError("Canceling a timer."); | 947 throw new core.UnsupportedError("Canceling a timer."); |
910 } | 948 } |
911 } | 949 } |
912 get isActive() { | 950 get isActive() { |
913 return this._handle !== null; | 951 return this[_handle] !== null; |
914 } | 952 } |
915 } | 953 } |
916 dart.defineNamedConstructor(TimerImpl, 'periodic'); | 954 dart.defineNamedConstructor(TimerImpl, 'periodic'); |
917 // Function hasTimer: () → bool | 955 // Function hasTimer: () → bool |
918 function hasTimer() { | 956 function hasTimer() { |
919 _js_helper.requiresPreamble(); | 957 _js_helper.requiresPreamble(); |
920 return self.setTimeout !== null; | 958 return self.setTimeout !== null; |
921 } | 959 } |
922 class CapabilityImpl extends dart.Object { | 960 class CapabilityImpl extends dart.Object { |
923 CapabilityImpl() { | 961 CapabilityImpl() { |
924 this.CapabilityImpl$_internal(_js_helper.random64()); | 962 this.CapabilityImpl$_internal(_js_helper.random64()); |
925 } | 963 } |
926 CapabilityImpl$_internal(_id) { | 964 CapabilityImpl$_internal($_id) { |
927 this._id = _id; | 965 this[_id] = $_id; |
928 } | 966 } |
929 get hashCode() { | 967 get hashCode() { |
930 let hash = this._id; | 968 let hash = this[_id]; |
931 hash = hash >> 0 ^ (hash / 4294967296).truncate(); | 969 hash = hash >> 0 ^ (hash / 4294967296).truncate(); |
932 hash = ~hash + (hash << 15) & 4294967295; | 970 hash = ~hash + (hash << 15) & 4294967295; |
933 hash = hash >> 12; | 971 hash = hash >> 12; |
934 hash = hash * 5 & 4294967295; | 972 hash = hash * 5 & 4294967295; |
935 hash = hash >> 4; | 973 hash = hash >> 4; |
936 hash = hash * 2057 & 4294967295; | 974 hash = hash * 2057 & 4294967295; |
937 hash = hash >> 16; | 975 hash = hash >> 16; |
938 return hash; | 976 return hash; |
939 } | 977 } |
940 ['=='](other) { | 978 ['=='](other) { |
941 if (core.identical(other, this)) | 979 if (core.identical(other, this)) |
942 return true; | 980 return true; |
943 if (dart.is(other, CapabilityImpl)) { | 981 if (dart.is(other, CapabilityImpl)) { |
944 return core.identical(this._id, other._id); | 982 return core.identical(this[_id], other[_id]); |
945 } | 983 } |
946 return false; | 984 return false; |
947 } | 985 } |
948 } | 986 } |
949 dart.defineNamedConstructor(CapabilityImpl, '_internal'); | 987 dart.defineNamedConstructor(CapabilityImpl, '_internal'); |
950 // Function _serializeMessage: (dynamic) → dynamic | 988 // Function _serializeMessage: (dynamic) → dynamic |
951 function _serializeMessage(message) { | 989 function _serializeMessage(message) { |
952 return new _Serializer().serialize(message); | 990 return new _Serializer().serialize(message); |
953 } | 991 } |
954 // Function _deserializeMessage: (dynamic) → dynamic | 992 // Function _deserializeMessage: (dynamic) → dynamic |
955 function _deserializeMessage(message) { | 993 function _deserializeMessage(message) { |
956 return new _Deserializer().deserialize(message); | 994 return new _Deserializer().deserialize(message); |
957 } | 995 } |
958 // Function _clone: (dynamic) → dynamic | 996 // Function _clone: (dynamic) → dynamic |
959 function _clone(message) { | 997 function _clone(message) { |
960 let serializer = new _Serializer({serializeSendPorts: false}); | 998 let serializer = new _Serializer({serializeSendPorts: false}); |
961 let deserializer = new _Deserializer(); | 999 let deserializer = new _Deserializer(); |
962 return deserializer.deserialize(serializer.serialize(message)); | 1000 return deserializer.deserialize(serializer.serialize(message)); |
963 } | 1001 } |
964 class _Serializer extends dart.Object { | 1002 class _Serializer extends dart.Object { |
965 _Serializer(opt$) { | 1003 _Serializer(opt$) { |
966 let serializeSendPorts = opt$.serializeSendPorts === void 0 ? true : opt$.
serializeSendPorts; | 1004 let serializeSendPorts = opt$.serializeSendPorts === void 0 ? true : opt$.
serializeSendPorts; |
967 this.serializedObjectIds = new core.Map.identity(); | 1005 this.serializedObjectIds = new core.Map.identity(); |
968 this._serializeSendPorts = dart.as(serializeSendPorts, core.bool); | 1006 this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); |
969 } | 1007 } |
970 serialize(x) { | 1008 serialize(x) { |
971 if (this.isPrimitive(x)) | 1009 if (this.isPrimitive(x)) |
972 return this.serializePrimitive(x); | 1010 return this.serializePrimitive(x); |
973 let serializationId = this.serializedObjectIds.get(x); | 1011 let serializationId = this.serializedObjectIds.get(x); |
974 if (serializationId !== null) | 1012 if (serializationId !== null) |
975 return this.makeRef(serializationId); | 1013 return this.makeRef(serializationId); |
976 serializationId = this.serializedObjectIds.length; | 1014 serializationId = this.serializedObjectIds.length; |
977 this.serializedObjectIds.set(x, serializationId); | 1015 this.serializedObjectIds.set(x, serializationId); |
978 if (dart.is(x, _native_typed_data.NativeByteBuffer)) | 1016 if (dart.is(x, _native_typed_data.NativeByteBuffer)) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 } | 1096 } |
1059 let keys = dart.as(Object.keys(x), core.List); | 1097 let keys = dart.as(Object.keys(x), core.List); |
1060 let values = new List.from([]); | 1098 let values = new List.from([]); |
1061 values.length = keys.length; | 1099 values.length = keys.length; |
1062 for (let i = 0; i < keys.length; i++) { | 1100 for (let i = 0; i < keys.length; i++) { |
1063 values.set(i, this.serialize(x[keys.get(i)])); | 1101 values.set(i, this.serialize(x[keys.get(i)])); |
1064 } | 1102 } |
1065 return new List.from(['js-object', keys, values]); | 1103 return new List.from(['js-object', keys, values]); |
1066 } | 1104 } |
1067 serializeWorkerSendPort(x) { | 1105 serializeWorkerSendPort(x) { |
1068 if (this._serializeSendPorts) { | 1106 if (this[_serializeSendPorts]) { |
1069 return new List.from(['sendport', x._workerId, x._isolateId, x._receiveP
ortId]); | 1107 return new List.from(['sendport', x[_workerId], x[_isolateId], x[_receiv
ePortId]]); |
1070 } | 1108 } |
1071 return new List.from(['raw sendport', x]); | 1109 return new List.from(['raw sendport', x]); |
1072 } | 1110 } |
1073 serializeJsSendPort(x) { | 1111 serializeJsSendPort(x) { |
1074 if (this._serializeSendPorts) { | 1112 if (this[_serializeSendPorts]) { |
1075 let workerId = _isolate_helper._globalState.currentManagerId; | 1113 let workerId = _isolate_helper._globalState.currentManagerId; |
1076 return new List.from(['sendport', workerId, x._isolateId, x._receivePort
._id]); | 1114 return new List.from(['sendport', workerId, x[_isolateId], x[_receivePor
t][_id]]); |
1077 } | 1115 } |
1078 return new List.from(['raw sendport', x]); | 1116 return new List.from(['raw sendport', x]); |
1079 } | 1117 } |
1080 serializeCapability(x) { | 1118 serializeCapability(x) { |
1081 return new List.from(['capability', x._id]); | 1119 return new List.from(['capability', x[_id]]); |
1082 } | 1120 } |
1083 serializeClosure(x) { | 1121 serializeClosure(x) { |
1084 let name = IsolateNatives._getJSFunctionName(x); | 1122 let name = IsolateNatives._getJSFunctionName(x); |
1085 if (name === null) { | 1123 if (name === null) { |
1086 this.unsupported(x, "Closures can't be transmitted:"); | 1124 this.unsupported(x, "Closures can't be transmitted:"); |
1087 } | 1125 } |
1088 return new List.from(['function', name]); | 1126 return new List.from(['function', name]); |
1089 } | 1127 } |
1090 serializeDartObject(x) { | 1128 serializeDartObject(x) { |
1091 let classExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_em
bedded_names.CLASS_ID_EXTRACTOR, core.String)); | 1129 let classExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_em
bedded_names.CLASS_ID_EXTRACTOR, core.String)); |
1092 let fieldsExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_e
mbedded_names.CLASS_FIELDS_EXTRACTOR, core.String)); | 1130 let fieldsExtractor = _foreign_helper.JS_EMBEDDED_GLOBAL('', dart.as(_js_e
mbedded_names.CLASS_FIELDS_EXTRACTOR, core.String)); |
1093 let classId = classExtractor(x); | 1131 let classId = classExtractor(x); |
1094 let fields = dart.as(fieldsExtractor(x), core.List); | 1132 let fields = dart.as(fieldsExtractor(x), core.List); |
1095 return new List.from(['dart', classId, this.serializeArrayInPlace(dart.as(
fields, _interceptors.JSArray))]); | 1133 return new List.from(['dart', classId, this.serializeArrayInPlace(dart.as(
fields, _interceptors.JSArray))]); |
1096 } | 1134 } |
1097 } | 1135 } |
1098 class _Deserializer extends dart.Object { | 1136 class _Deserializer extends dart.Object { |
1099 _Deserializer(opt$) { | 1137 _Deserializer(opt$) { |
1100 let adjustSendPorts = opt$.adjustSendPorts === void 0 ? true : opt$.adjust
SendPorts; | 1138 let adjustSendPorts = opt$.adjustSendPorts === void 0 ? true : opt$.adjust
SendPorts; |
1101 this.deserializedObjects = new core.List(); | 1139 this.deserializedObjects = new core.List(); |
1102 this._adjustSendPorts = dart.as(adjustSendPorts, core.bool); | 1140 this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); |
1103 } | 1141 } |
1104 deserialize(x) { | 1142 deserialize(x) { |
1105 if (this.isPrimitive(x)) | 1143 if (this.isPrimitive(x)) |
1106 return this.deserializePrimitive(x); | 1144 return this.deserializePrimitive(x); |
1107 if (!dart.is(x, _interceptors.JSArray)) | 1145 if (!dart.is(x, _interceptors.JSArray)) |
1108 throw new core.ArgumentError(`Bad serialized message: ${x}`); | 1146 throw new core.ArgumentError(`Bad serialized message: ${x}`); |
1109 switch (dart.dload(x, 'first')) { | 1147 switch (dart.dload(x, 'first')) { |
1110 case "ref": | 1148 case "ref": |
1111 return this.deserializeRef(x); | 1149 return this.deserializeRef(x); |
1112 case "buffer": | 1150 case "buffer": |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 _isolate_helper.globalWindow = globalWindow; | 1304 _isolate_helper.globalWindow = globalWindow; |
1267 _isolate_helper.globalWorker = globalWorker; | 1305 _isolate_helper.globalWorker = globalWorker; |
1268 _isolate_helper.globalPostMessageDefined = globalPostMessageDefined; | 1306 _isolate_helper.globalPostMessageDefined = globalPostMessageDefined; |
1269 _isolate_helper.IsolateNatives = IsolateNatives; | 1307 _isolate_helper.IsolateNatives = IsolateNatives; |
1270 _isolate_helper.RawReceivePortImpl = RawReceivePortImpl; | 1308 _isolate_helper.RawReceivePortImpl = RawReceivePortImpl; |
1271 _isolate_helper.ReceivePortImpl = ReceivePortImpl; | 1309 _isolate_helper.ReceivePortImpl = ReceivePortImpl; |
1272 _isolate_helper.TimerImpl = TimerImpl; | 1310 _isolate_helper.TimerImpl = TimerImpl; |
1273 _isolate_helper.hasTimer = hasTimer; | 1311 _isolate_helper.hasTimer = hasTimer; |
1274 _isolate_helper.CapabilityImpl = CapabilityImpl; | 1312 _isolate_helper.CapabilityImpl = CapabilityImpl; |
1275 })(_isolate_helper || (_isolate_helper = {})); | 1313 })(_isolate_helper || (_isolate_helper = {})); |
OLD | NEW |