| OLD | NEW |
| 1 var _isolate_helper; | 1 var _isolate_helper; |
| 2 (function(exports) { | 2 (function(exports) { |
| 3 'use strict'; | 3 'use strict'; |
| 4 // Function _serializeMessage: (dynamic) → dynamic | 4 // Function _serializeMessage: (dynamic) → dynamic |
| 5 function _serializeMessage(message) { | 5 function _serializeMessage(message) { |
| 6 return new _Serializer().serialize(message); | 6 return new _Serializer().serialize(message); |
| 7 } | 7 } |
| 8 // Function _deserializeMessage: (dynamic) → dynamic | 8 // Function _deserializeMessage: (dynamic) → dynamic |
| 9 function _deserializeMessage(message) { | 9 function _deserializeMessage(message) { |
| 10 return new _Deserializer().deserialize(message); | 10 return new _Deserializer().deserialize(message); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } | 351 } |
| 352 // Function _callInIsolate: (_IsolateContext, Function) → dynamic | 352 // Function _callInIsolate: (_IsolateContext, Function) → dynamic |
| 353 function _callInIsolate(isolate, function$0) { | 353 function _callInIsolate(isolate, function$0) { |
| 354 let result = isolate.eval(function$0); | 354 let result = isolate.eval(function$0); |
| 355 exports._globalState.topEventLoop.run(); | 355 exports._globalState.topEventLoop.run(); |
| 356 return result; | 356 return result; |
| 357 } | 357 } |
| 358 let _activeJsAsyncCount = Symbol('_activeJsAsyncCount'); | 358 let _activeJsAsyncCount = Symbol('_activeJsAsyncCount'); |
| 359 // Function enterJsAsync: () → dynamic | 359 // Function enterJsAsync: () → dynamic |
| 360 function enterJsAsync() { | 360 function enterJsAsync() { |
| 361 exports._globalState.topEventLoop[_activeJsAsyncCount] = dart.notNull(export
s._globalState.topEventLoop[_activeJsAsyncCount]) + 1; | 361 let o$ = exports._globalState.topEventLoop; |
| 362 o$[_activeJsAsyncCount] = dart.notNull(o$[_activeJsAsyncCount]) + 1; |
| 362 } | 363 } |
| 363 // Function leaveJsAsync: () → dynamic | 364 // Function leaveJsAsync: () → dynamic |
| 364 function leaveJsAsync() { | 365 function leaveJsAsync() { |
| 365 exports._globalState.topEventLoop[_activeJsAsyncCount] = dart.notNull(export
s._globalState.topEventLoop[_activeJsAsyncCount]) - 1; | 366 let o$ = exports._globalState.topEventLoop; |
| 367 o$[_activeJsAsyncCount] = dart.notNull(o$[_activeJsAsyncCount]) - 1; |
| 366 dart.assert(dart.notNull(exports._globalState.topEventLoop[_activeJsAsyncCou
nt]) >= 0); | 368 dart.assert(dart.notNull(exports._globalState.topEventLoop[_activeJsAsyncCou
nt]) >= 0); |
| 367 } | 369 } |
| 368 // Function isWorker: () → bool | 370 // Function isWorker: () → bool |
| 369 function isWorker() { | 371 function isWorker() { |
| 370 return exports._globalState.isWorker; | 372 return exports._globalState.isWorker; |
| 371 } | 373 } |
| 372 // Function _currentIsolate: () → _IsolateContext | 374 // Function _currentIsolate: () → _IsolateContext |
| 373 function _currentIsolate() { | 375 function _currentIsolate() { |
| 374 return exports._globalState.currentContext; | 376 return exports._globalState.currentContext; |
| 375 } | 377 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 } | 476 } |
| 475 let _controlPort = Symbol('_controlPort'); | 477 let _controlPort = Symbol('_controlPort'); |
| 476 let _scheduledControlEvents = Symbol('_scheduledControlEvents'); | 478 let _scheduledControlEvents = Symbol('_scheduledControlEvents'); |
| 477 let _isExecutingEvent = Symbol('_isExecutingEvent'); | 479 let _isExecutingEvent = Symbol('_isExecutingEvent'); |
| 478 let _updateGlobalState = Symbol('_updateGlobalState'); | 480 let _updateGlobalState = Symbol('_updateGlobalState'); |
| 479 let _setGlobals = Symbol('_setGlobals'); | 481 let _setGlobals = Symbol('_setGlobals'); |
| 480 let _addRegistration = Symbol('_addRegistration'); | 482 let _addRegistration = Symbol('_addRegistration'); |
| 481 let _close = Symbol('_close'); | 483 let _close = Symbol('_close'); |
| 482 class _IsolateContext extends core.Object { | 484 class _IsolateContext extends core.Object { |
| 483 _IsolateContext() { | 485 _IsolateContext() { |
| 484 this.id = ((x$) => exports._globalState.nextIsolateId = dart.notNull(x$) +
1, x$)(exports._globalState.nextIsolateId); | 486 this.id = ((o$, x$) => { |
| 487 o$ = exports._globalState; |
| 488 x$ = o$.nextIsolateId; |
| 489 o$.nextIsolateId = dart.notNull(x$) + 1; |
| 490 return x$; |
| 491 })(); |
| 485 this.ports = new (core.Map$(core.int, RawReceivePortImpl))(); | 492 this.ports = new (core.Map$(core.int, RawReceivePortImpl))(); |
| 486 this.weakPorts = new (core.Set$(core.int))(); | 493 this.weakPorts = new (core.Set$(core.int))(); |
| 487 this.isolateStatics = _foreign_helper.JS_CREATE_ISOLATE(); | 494 this.isolateStatics = _foreign_helper.JS_CREATE_ISOLATE(); |
| 488 this.controlPort = new RawReceivePortImpl[_controlPort](); | 495 this.controlPort = new RawReceivePortImpl[_controlPort](); |
| 489 this.pauseCapability = new isolate.Capability(); | 496 this.pauseCapability = new isolate.Capability(); |
| 490 this.terminateCapability = new isolate.Capability(); | 497 this.terminateCapability = new isolate.Capability(); |
| 491 this.delayedEvents = dart.as(new core.List.from([]), core.List$(_IsolateEv
ent)); | 498 this.delayedEvents = dart.as(new core.List.from([]), core.List$(_IsolateEv
ent)); |
| 492 this.pauseTokens = dart.as(new core.Set(), core.Set$(isolate.Capability)); | 499 this.pauseTokens = dart.as(new core.Set(), core.Set$(isolate.Capability)); |
| 493 this.errorPorts = dart.as(new core.Set(), core.Set$(isolate.SendPort)); | 500 this.errorPorts = dart.as(new core.Set(), core.Set$(isolate.SendPort)); |
| 494 this.initialized = false; | 501 this.initialized = false; |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 let isSpawnUri = false; | 1005 let isSpawnUri = false; |
| 999 return IsolateNatives.spawn(name, null, null, message, isLight, isSpawnUri
, startPaused); | 1006 return IsolateNatives.spawn(name, null, null, message, isLight, isSpawnUri
, startPaused); |
| 1000 } | 1007 } |
| 1001 static spawnUri(uri, args, message, startPaused) { | 1008 static spawnUri(uri, args, message, startPaused) { |
| 1002 IsolateNatives.enableSpawnWorker = true; | 1009 IsolateNatives.enableSpawnWorker = true; |
| 1003 let isLight = false; | 1010 let isLight = false; |
| 1004 let isSpawnUri = true; | 1011 let isSpawnUri = true; |
| 1005 return IsolateNatives.spawn(null, uri.toString(), args, message, isLight,
isSpawnUri, startPaused); | 1012 return IsolateNatives.spawn(null, uri.toString(), args, message, isLight,
isSpawnUri, startPaused); |
| 1006 } | 1013 } |
| 1007 static spawn(functionName, uri, args, message, isLight, isSpawnUri, startPau
sed) { | 1014 static spawn(functionName, uri, args, message, isLight, isSpawnUri, startPau
sed) { |
| 1008 if (dart.notNull(uri != null) && dart.notNull(uri.endsWith(".dart"))) | 1015 if (dart.notNull(uri != null) && dart.notNull(uri.endsWith(".dart"))) { |
| 1009 uri = ".js"; | 1016 uri = core.String['+'](uri, ".js"); |
| 1017 } |
| 1010 let port = new isolate.ReceivePort(); | 1018 let port = new isolate.ReceivePort(); |
| 1011 let completer = dart.as(new async.Completer(), async.Completer$(core.List)
); | 1019 let completer = dart.as(new async.Completer(), async.Completer$(core.List)
); |
| 1012 port.first.then((msg) => { | 1020 port.first.then((msg) => { |
| 1013 if (dart.equals(dart.dindex(msg, 0), _SPAWNED_SIGNAL)) { | 1021 if (dart.equals(dart.dindex(msg, 0), _SPAWNED_SIGNAL)) { |
| 1014 completer.complete(msg); | 1022 completer.complete(msg); |
| 1015 } else { | 1023 } else { |
| 1016 dart.assert(dart.equals(dart.dindex(msg, 0), _SPAWN_FAILED_SIGNAL)); | 1024 dart.assert(dart.equals(dart.dindex(msg, 0), _SPAWN_FAILED_SIGNAL)); |
| 1017 completer.completeError(dart.dindex(msg, 1)); | 1025 completer.completeError(dart.dindex(msg, 1)); |
| 1018 } | 1026 } |
| 1019 }); | 1027 }); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 }; | 1092 }; |
| 1085 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives.workerOnError), uri, o
nError); | 1093 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives.workerOnError), uri, o
nError); |
| 1086 worker.onerror = onerrorTrampoline; | 1094 worker.onerror = onerrorTrampoline; |
| 1087 let processWorkerMessageTrampoline = function(f, a) { | 1095 let processWorkerMessageTrampoline = function(f, a) { |
| 1088 return function(e) { | 1096 return function(e) { |
| 1089 e.onerror = null; | 1097 e.onerror = null; |
| 1090 return f(a, e); | 1098 return f(a, e); |
| 1091 }; | 1099 }; |
| 1092 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives[_processWorkerMessage]
), worker); | 1100 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives[_processWorkerMessage]
), worker); |
| 1093 worker.onmessage = processWorkerMessageTrampoline; | 1101 worker.onmessage = processWorkerMessageTrampoline; |
| 1094 let workerId = ((x$) => exports._globalState.nextManagerId = dart.notNull(
x$) + 1, x$)(exports._globalState.nextManagerId); | 1102 let o$ = exports._globalState; |
| 1103 let workerId = o$.nextManagerId; |
| 1104 o$.nextManagerId = dart.notNull(workerId) + 1; |
| 1095 IsolateNatives.workerIds.set(worker, workerId); | 1105 IsolateNatives.workerIds.set(worker, workerId); |
| 1096 exports._globalState.managers.set(workerId, worker); | 1106 exports._globalState.managers.set(workerId, worker); |
| 1097 worker.postMessage(_serializeMessage(dart.map({command: 'start', id: worke
rId, replyTo: _serializeMessage(replyPort), args: args, msg: _serializeMessage(m
essage), isSpawnUri: isSpawnUri, startPaused: startPaused, functionName: functio
nName}))); | 1107 worker.postMessage(_serializeMessage(dart.map({command: 'start', id: worke
rId, replyTo: _serializeMessage(replyPort), args: args, msg: _serializeMessage(m
essage), isSpawnUri: isSpawnUri, startPaused: startPaused, functionName: functio
nName}))); |
| 1098 } | 1108 } |
| 1099 static workerOnError(event, uri, onError) { | 1109 static workerOnError(event, uri, onError) { |
| 1100 event.preventDefault(); | 1110 event.preventDefault(); |
| 1101 let message = dart.as(event.message, core.String); | 1111 let message = dart.as(event.message, core.String); |
| 1102 if (message == null) { | 1112 if (message == null) { |
| 1103 message = `Error spawning worker for ${uri}`; | 1113 message = `Error spawning worker for ${uri}`; |
| 1104 } else { | 1114 } else { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 get hashCode() { | 1195 get hashCode() { |
| 1186 return dart.notNull(this[_workerId]) << 16 ^ dart.notNull(this[_isolateId]
) << 8 ^ dart.notNull(this[_receivePortId]); | 1196 return dart.notNull(this[_workerId]) << 16 ^ dart.notNull(this[_isolateId]
) << 8 ^ dart.notNull(this[_receivePortId]); |
| 1187 } | 1197 } |
| 1188 } | 1198 } |
| 1189 _WorkerSendPort[dart.implements] = () => [isolate.SendPort]; | 1199 _WorkerSendPort[dart.implements] = () => [isolate.SendPort]; |
| 1190 let _handler = Symbol('_handler'); | 1200 let _handler = Symbol('_handler'); |
| 1191 let _nextFreeId = Symbol('_nextFreeId'); | 1201 let _nextFreeId = Symbol('_nextFreeId'); |
| 1192 class RawReceivePortImpl extends core.Object { | 1202 class RawReceivePortImpl extends core.Object { |
| 1193 RawReceivePortImpl(handler) { | 1203 RawReceivePortImpl(handler) { |
| 1194 this[_handler] = handler; | 1204 this[_handler] = handler; |
| 1195 this[_id] = ((x$) => RawReceivePortImpl[_nextFreeId] = dart.notNull(x$) +
1, x$)(RawReceivePortImpl[_nextFreeId]); | 1205 this[_id] = ((x$) => (x$ = RawReceivePortImpl[_nextFreeId], RawReceivePort
Impl[_nextFreeId] = dart.notNull(x$) + 1, x$))(); |
| 1196 this[_isClosed] = false; | 1206 this[_isClosed] = false; |
| 1197 exports._globalState.currentContext.register(this[_id], this); | 1207 exports._globalState.currentContext.register(this[_id], this); |
| 1198 } | 1208 } |
| 1199 weak(handler) { | 1209 weak(handler) { |
| 1200 this[_handler] = handler; | 1210 this[_handler] = handler; |
| 1201 this[_id] = ((x$) => RawReceivePortImpl[_nextFreeId] = dart.notNull(x$) +
1, x$)(RawReceivePortImpl[_nextFreeId]); | 1211 this[_id] = ((x$) => (x$ = RawReceivePortImpl[_nextFreeId], RawReceivePort
Impl[_nextFreeId] = dart.notNull(x$) + 1, x$))(); |
| 1202 this[_isClosed] = false; | 1212 this[_isClosed] = false; |
| 1203 exports._globalState.currentContext.registerWeak(this[_id], this); | 1213 exports._globalState.currentContext.registerWeak(this[_id], this); |
| 1204 } | 1214 } |
| 1205 [_controlPort]() { | 1215 [_controlPort]() { |
| 1206 this[_handler] = null; | 1216 this[_handler] = null; |
| 1207 this[_id] = 0; | 1217 this[_id] = 0; |
| 1208 this[_isClosed] = false; | 1218 this[_isClosed] = false; |
| 1209 } | 1219 } |
| 1210 set handler(newHandler) { | 1220 set handler(newHandler) { |
| 1211 this[_handler] = newHandler; | 1221 this[_handler] = newHandler; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1345 CapabilityImpl() { | 1355 CapabilityImpl() { |
| 1346 this[_internal](_js_helper.random64()); | 1356 this[_internal](_js_helper.random64()); |
| 1347 } | 1357 } |
| 1348 [_internal](id) { | 1358 [_internal](id) { |
| 1349 this[_id] = id; | 1359 this[_id] = id; |
| 1350 } | 1360 } |
| 1351 get hashCode() { | 1361 get hashCode() { |
| 1352 let hash = this[_id]; | 1362 let hash = this[_id]; |
| 1353 hash = dart.notNull(hash) >> 0 ^ (dart.notNull(hash) / 4294967296).truncat
e(); | 1363 hash = dart.notNull(hash) >> 0 ^ (dart.notNull(hash) / 4294967296).truncat
e(); |
| 1354 hash = ~dart.notNull(hash) + (dart.notNull(hash) << 15) & 4294967295; | 1364 hash = ~dart.notNull(hash) + (dart.notNull(hash) << 15) & 4294967295; |
| 1355 hash = dart.notNull(hash) >> 12; | 1365 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 12; |
| 1356 hash = dart.notNull(hash) * 5 & 4294967295; | 1366 hash = dart.notNull(hash) * 5 & 4294967295; |
| 1357 hash = dart.notNull(hash) >> 4; | 1367 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 4; |
| 1358 hash = dart.notNull(hash) * 2057 & 4294967295; | 1368 hash = dart.notNull(hash) * 2057 & 4294967295; |
| 1359 hash = dart.notNull(hash) >> 16; | 1369 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 16; |
| 1360 return hash; | 1370 return hash; |
| 1361 } | 1371 } |
| 1362 ['=='](other) { | 1372 ['=='](other) { |
| 1363 if (core.identical(other, this)) | 1373 if (core.identical(other, this)) |
| 1364 return true; | 1374 return true; |
| 1365 if (dart.is(other, CapabilityImpl)) { | 1375 if (dart.is(other, CapabilityImpl)) { |
| 1366 return core.identical(this[_id], other[_id]); | 1376 return core.identical(this[_id], other[_id]); |
| 1367 } | 1377 } |
| 1368 return false; | 1378 return false; |
| 1369 } | 1379 } |
| 1370 } | 1380 } |
| 1371 CapabilityImpl[dart.implements] = () => [isolate.Capability]; | 1381 CapabilityImpl[dart.implements] = () => [isolate.Capability]; |
| 1372 dart.defineNamedConstructor(CapabilityImpl, _internal); | 1382 dart.defineNamedConstructor(CapabilityImpl, _internal); |
| 1373 // Exports: | 1383 // Exports: |
| 1374 exports.enterJsAsync = enterJsAsync; | 1384 exports.enterJsAsync = enterJsAsync; |
| 1375 exports.leaveJsAsync = leaveJsAsync; | 1385 exports.leaveJsAsync = leaveJsAsync; |
| 1376 exports.isWorker = isWorker; | 1386 exports.isWorker = isWorker; |
| 1377 exports.startRootIsolate = startRootIsolate; | 1387 exports.startRootIsolate = startRootIsolate; |
| 1378 exports.IsolateNatives = IsolateNatives; | 1388 exports.IsolateNatives = IsolateNatives; |
| 1379 exports.RawReceivePortImpl = RawReceivePortImpl; | 1389 exports.RawReceivePortImpl = RawReceivePortImpl; |
| 1380 exports.ReceivePortImpl = ReceivePortImpl; | 1390 exports.ReceivePortImpl = ReceivePortImpl; |
| 1381 exports.TimerImpl = TimerImpl; | 1391 exports.TimerImpl = TimerImpl; |
| 1382 exports.hasTimer = hasTimer; | 1392 exports.hasTimer = hasTimer; |
| 1383 exports.CapabilityImpl = CapabilityImpl; | 1393 exports.CapabilityImpl = CapabilityImpl; |
| 1384 })(_isolate_helper || (_isolate_helper = {})); | 1394 })(_isolate_helper || (_isolate_helper = {})); |
| OLD | NEW |