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