Chromium Code Reviews| Index: test/codegen/expect/_isolate_helper/_isolate_helper.js |
| diff --git a/test/codegen/expect/_isolate_helper/_isolate_helper.js b/test/codegen/expect/_isolate_helper/_isolate_helper.js |
| index a16ca27c7b409dd94e618b573a9a1eda877f599e..ef2073899d88df25c247f38a26004fa80045fa33 100644 |
| --- a/test/codegen/expect/_isolate_helper/_isolate_helper.js |
| +++ b/test/codegen/expect/_isolate_helper/_isolate_helper.js |
| @@ -1,6 +1,44 @@ |
| var _isolate_helper; |
| (function(exports) { |
| 'use strict'; |
| + let _activeJsAsyncCount = Symbol('_activeJsAsyncCount'); |
| + let _nativeDetectEnvironment = Symbol('_nativeDetectEnvironment'); |
| + let _nativeInitWorkerMessageHandler = Symbol('_nativeInitWorkerMessageHandler'); |
| + let _processWorkerMessage = Symbol('_processWorkerMessage'); |
| + let _serializePrintMessage = Symbol('_serializePrintMessage'); |
| + let _scheduledControlEvents = Symbol('_scheduledControlEvents'); |
| + let _isExecutingEvent = Symbol('_isExecutingEvent'); |
| + let _id = Symbol('_id'); |
| + let _updateGlobalState = Symbol('_updateGlobalState'); |
| + let _setGlobals = Symbol('_setGlobals'); |
| + let _addRegistration = Symbol('_addRegistration'); |
| + let _runHelper = Symbol('_runHelper'); |
| + let _getEventData = Symbol('_getEventData'); |
| + let _log = Symbol('_log'); |
| + let _consoleLog = Symbol('_consoleLog'); |
| + let _getJSFunctionFromName = Symbol('_getJSFunctionFromName'); |
| + let _getJSFunctionName = Symbol('_getJSFunctionName'); |
| + let _allocate = Symbol('_allocate'); |
| + let _startWorker = Symbol('_startWorker'); |
| + let _startNonWorker = Symbol('_startNonWorker'); |
| + let _startIsolate = Symbol('_startIsolate'); |
| + let _spawnWorker = Symbol('_spawnWorker'); |
| + let _isolateId = Symbol('_isolateId'); |
| + let _checkReplyTo = Symbol('_checkReplyTo'); |
| + let _receivePort = Symbol('_receivePort'); |
| + let _isClosed = Symbol('_isClosed'); |
| + let _workerId = Symbol('_workerId'); |
| + let _receivePortId = Symbol('_receivePortId'); |
| + let _handler = Symbol('_handler'); |
| + let _close = Symbol('_close'); |
| + let _add = Symbol('_add'); |
| + let _rawPort = Symbol('_rawPort'); |
| + let _controller = Symbol('_controller'); |
| + let _once = Symbol('_once'); |
| + let _inEventLoop = Symbol('_inEventLoop'); |
| + let _handle = Symbol('_handle'); |
| + let _serializeSendPorts = Symbol('_serializeSendPorts'); |
| + let _adjustSendPorts = Symbol('_adjustSendPorts'); |
| // Function _callInIsolate: (_IsolateContext, Function) → dynamic |
| function _callInIsolate(isolate, function) { |
| let result = isolate.eval(function); |
| @@ -9,12 +47,21 @@ var _isolate_helper; |
| } |
| // Function enterJsAsync: () → dynamic |
| function enterJsAsync() { |
| +<<<<<<< HEAD |
|
vsm
2015/03/02 21:17:01
Resolve this? :-)
|
| + _isolate_helper._globalState.topEventLoop[_activeJsAsyncCount]++; |
| + } |
| + // Function leaveJsAsync: () → dynamic |
| + function leaveJsAsync() { |
| + _isolate_helper._globalState.topEventLoop[_activeJsAsyncCount]--; |
| + dart.assert(_isolate_helper._globalState.topEventLoop[_activeJsAsyncCount] >= 0); |
| +======= |
| exports._globalState.topEventLoop._activeJsAsyncCount++; |
| } |
| // Function leaveJsAsync: () → dynamic |
| function leaveJsAsync() { |
| exports._globalState.topEventLoop._activeJsAsyncCount--; |
| dart.assert(exports._globalState.topEventLoop._activeJsAsyncCount >= 0); |
| +>>>>>>> origin/master |
| } |
| // Function isWorker: () → bool |
| function isWorker() { |
| @@ -77,28 +124,35 @@ var _isolate_helper; |
| this.isolates = null; |
| this.mainManager = null; |
| this.managers = null; |
| - this._nativeDetectEnvironment(); |
| + this[_nativeDetectEnvironment](); |
| this.topEventLoop = new _EventLoop(); |
| this.isolates = new core.Map(); |
| this.managers = new core.Map(); |
| if (this.isWorker) { |
| this.mainManager = new _MainManagerStub(); |
| - this._nativeInitWorkerMessageHandler(); |
| + this[_nativeInitWorkerMessageHandler](); |
| } |
| } |
| +<<<<<<< HEAD |
|
vsm
2015/03/02 21:17:01
Ditto
|
| + [_nativeDetectEnvironment]() { |
| + let isWindowDefined = _isolate_helper.globalWindow !== null; |
| + let isWorkerDefined = _isolate_helper.globalWorker !== null; |
| + this.isWorker = dart.notNull(!dart.notNull(isWindowDefined)) && dart.notNull(_isolate_helper.globalPostMessageDefined); |
| +======= |
| _nativeDetectEnvironment() { |
| let isWindowDefined = exports.globalWindow !== null; |
| let isWorkerDefined = exports.globalWorker !== null; |
| this.isWorker = dart.notNull(!dart.notNull(isWindowDefined)) && dart.notNull(exports.globalPostMessageDefined); |
| +>>>>>>> origin/master |
| this.supportsWorkers = dart.notNull(this.isWorker) || dart.notNull(dart.notNull(isWorkerDefined) && dart.notNull(IsolateNatives.thisScript !== null)); |
| this.fromCommandLine = dart.notNull(!dart.notNull(isWindowDefined)) && dart.notNull(!dart.notNull(this.isWorker)); |
| } |
| - _nativeInitWorkerMessageHandler() { |
| + [_nativeInitWorkerMessageHandler]() { |
| let function = function(f, a) { |
| return function(e) { |
| f(a, e); |
| }; |
| - }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives._processWorkerMessage), this.mainManager); |
| + }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives[_processWorkerMessage]), this.mainManager); |
| self.onmessage = function; |
| self.dartPrint = self.dartPrint || function(serialize) { |
| return function(object) { |
| @@ -110,11 +164,11 @@ var _isolate_helper; |
| }; |
| }(_foreign_helper.DART_CLOSURE_TO_JS(_serializePrintMessage)); |
| } |
| - static _serializePrintMessage(object) { |
| + static [_serializePrintMessage](object) { |
| return _serializeMessage(dart.map({command: "print", msg: object})); |
| } |
| maybeCloseWorker() { |
| - if (dart.notNull(dart.notNull(this.isWorker) && dart.notNull(this.isolates.isEmpty)) && dart.notNull(this.topEventLoop._activeJsAsyncCount === 0)) { |
| + if (dart.notNull(dart.notNull(this.isWorker) && dart.notNull(this.isolates.isEmpty)) && dart.notNull(this.topEventLoop[_activeJsAsyncCount] === 0)) { |
| this.mainManager.postMessage(_serializeMessage(dart.map({command: 'close'}))); |
| } |
| } |
| @@ -134,10 +188,10 @@ var _isolate_helper; |
| this.initialized = false; |
| this.isPaused = false; |
| this.doneHandlers = null; |
| - this._scheduledControlEvents = null; |
| - this._isExecutingEvent = false; |
| + this[_scheduledControlEvents] = null; |
| + this[_isExecutingEvent] = false; |
| this.errorsAreFatal = true; |
| - this.registerWeak(this.controlPort._id, this.controlPort); |
| + this.registerWeak(this.controlPort[_id], this.controlPort); |
| } |
| addPause(authentification, resume) { |
| if (!dart.equals(this.pauseCapability, authentification)) |
| @@ -145,7 +199,7 @@ var _isolate_helper; |
| if (dart.notNull(this.pauseTokens.add(resume)) && dart.notNull(!dart.notNull(this.isPaused))) { |
| this.isPaused = true; |
| } |
| - this._updateGlobalState(); |
| + this[_updateGlobalState](); |
| } |
| removePause(resume) { |
| if (!dart.notNull(this.isPaused)) |
| @@ -158,7 +212,7 @@ var _isolate_helper; |
| } |
| this.isPaused = false; |
| } |
| - this._updateGlobalState(); |
| + this[_updateGlobalState](); |
| } |
| addDoneListener(responsePort) { |
| if (this.doneHandlers === null) { |
| @@ -179,7 +233,7 @@ var _isolate_helper; |
| this.errorsAreFatal = errorsAreFatal; |
| } |
| handlePing(responsePort, pingType) { |
| - if (dart.notNull(pingType === isolate.Isolate.IMMEDIATE) || dart.notNull(dart.notNull(pingType === isolate.Isolate.BEFORE_NEXT_EVENT) && dart.notNull(!dart.notNull(this._isExecutingEvent)))) { |
| + if (dart.notNull(pingType === isolate.Isolate.IMMEDIATE) || dart.notNull(dart.notNull(pingType === isolate.Isolate.BEFORE_NEXT_EVENT) && dart.notNull(!dart.notNull(this[_isExecutingEvent])))) { |
| responsePort.send(null); |
| return; |
| } |
| @@ -192,15 +246,15 @@ var _isolate_helper; |
| return; |
| } |
| dart.assert(pingType === isolate.Isolate.BEFORE_NEXT_EVENT); |
| - if (this._scheduledControlEvents === null) { |
| - this._scheduledControlEvents = new collection.Queue(); |
| + if (this[_scheduledControlEvents] === null) { |
| + this[_scheduledControlEvents] = new collection.Queue(); |
| } |
| - dart.dinvoke(this._scheduledControlEvents, 'addLast', respond); |
| + dart.dinvoke(this[_scheduledControlEvents], 'addLast', respond); |
| } |
| handleKill(authentification, priority) { |
| if (!dart.equals(this.terminateCapability, authentification)) |
| return; |
| - if (dart.notNull(priority === isolate.Isolate.IMMEDIATE) || dart.notNull(dart.notNull(priority === isolate.Isolate.BEFORE_NEXT_EVENT) && dart.notNull(!dart.notNull(this._isExecutingEvent)))) { |
| + if (dart.notNull(priority === isolate.Isolate.IMMEDIATE) || dart.notNull(dart.notNull(priority === isolate.Isolate.BEFORE_NEXT_EVENT) && dart.notNull(!dart.notNull(this[_isExecutingEvent])))) { |
| this.kill(); |
| return; |
| } |
| @@ -209,10 +263,10 @@ var _isolate_helper; |
| return; |
| } |
| dart.assert(priority === isolate.Isolate.BEFORE_NEXT_EVENT); |
| - if (this._scheduledControlEvents === null) { |
| - this._scheduledControlEvents = new collection.Queue(); |
| + if (this[_scheduledControlEvents] === null) { |
| + this[_scheduledControlEvents] = new collection.Queue(); |
| } |
| - dart.dinvoke(this._scheduledControlEvents, 'addLast', this.kill); |
| + dart.dinvoke(this[_scheduledControlEvents], 'addLast', this.kill); |
| } |
| addErrorListener(port) { |
| this.errorPorts.add(port); |
| @@ -245,7 +299,7 @@ var _isolate_helper; |
| exports._globalState.currentContext = this; |
| this._setGlobals(); |
| let result = null; |
| - this._isExecutingEvent = true; |
| + this[_isExecutingEvent] = true; |
| try { |
| result = dart.dinvokef(code); |
| } catch (e) { |
| @@ -259,19 +313,24 @@ var _isolate_helper; |
| } |
| } |
| finally { |
| +<<<<<<< HEAD |
|
vsm
2015/03/02 21:17:01
ditto ... and a few more below
|
| + this[_isExecutingEvent] = false; |
| + _isolate_helper._globalState.currentContext = old; |
| +======= |
| this._isExecutingEvent = false; |
| exports._globalState.currentContext = old; |
| +>>>>>>> origin/master |
| if (old !== null) |
| old._setGlobals(); |
| - if (this._scheduledControlEvents !== null) { |
| - while (dart.dload(this._scheduledControlEvents, 'isNotEmpty')) { |
| - dart.dinvokef(dart.dinvoke(this._scheduledControlEvents, 'removeFirst')); |
| + if (this[_scheduledControlEvents] !== null) { |
| + while (dart.dload(this[_scheduledControlEvents], 'isNotEmpty')) { |
| + dart.dinvokef(dart.dinvoke(this[_scheduledControlEvents], 'removeFirst')); |
| } |
| } |
| } |
| return result; |
| } |
| - _setGlobals() { |
| + [_setGlobals]() { |
| _foreign_helper.JS_SET_CURRENT_ISOLATE(this.isolateStatics); |
| } |
| handleControlMessage(message) { |
| @@ -309,21 +368,21 @@ var _isolate_helper; |
| lookup(portId) { |
| return this.ports.get(portId); |
| } |
| - _addRegistration(portId, port) { |
| + [_addRegistration](portId, port) { |
| if (this.ports.containsKey(portId)) { |
| throw new core.Exception("Registry: ports must be registered only once."); |
| } |
| this.ports.set(portId, port); |
| } |
| register(portId, port) { |
| - this._addRegistration(portId, port); |
| - this._updateGlobalState(); |
| + this[_addRegistration](portId, port); |
| + this[_updateGlobalState](); |
| } |
| registerWeak(portId, port) { |
| this.weakPorts.add(portId); |
| - this._addRegistration(portId, port); |
| + this[_addRegistration](portId, port); |
| } |
| - _updateGlobalState() { |
| + [_updateGlobalState]() { |
| if (dart.notNull(dart.notNull(this.ports.length - this.weakPorts.length > 0) || dart.notNull(this.isPaused)) || dart.notNull(!dart.notNull(this.initialized))) { |
| exports._globalState.isolates.set(this.id, this); |
| } else { |
| @@ -331,8 +390,8 @@ var _isolate_helper; |
| } |
| } |
| kill() { |
| - if (this._scheduledControlEvents !== null) { |
| - dart.dinvoke(this._scheduledControlEvents, 'clear'); |
| + if (this[_scheduledControlEvents] !== null) { |
| + dart.dinvoke(this[_scheduledControlEvents], 'clear'); |
| } |
| for (let port of this.ports.values) { |
| dart.dinvoke(port, '_close'); |
| @@ -351,13 +410,13 @@ var _isolate_helper; |
| unregister(portId) { |
| this.ports.remove(portId); |
| this.weakPorts.remove(portId); |
| - this._updateGlobalState(); |
| + this[_updateGlobalState](); |
| } |
| } |
| class _EventLoop extends dart.Object { |
| _EventLoop() { |
| this.events = new collection.Queue(); |
| - this._activeJsAsyncCount = 0; |
| + this[_activeJsAsyncCount] = 0; |
| } |
| enqueue(isolate, fn, msg) { |
| this.events.addLast(new _IsolateEvent(dart.as(isolate, _IsolateContext), dart.as(fn, core.Function), dart.as(msg, core.String))); |
| @@ -385,8 +444,13 @@ var _isolate_helper; |
| event.process(); |
| return true; |
| } |
| +<<<<<<< HEAD |
| + [_runHelper]() { |
| + if (_isolate_helper.globalWindow !== null) { |
| +======= |
| _runHelper() { |
| if (exports.globalWindow !== null) { |
| +>>>>>>> origin/master |
| // Function next: () → void |
| function next() { |
| if (!dart.notNull(this.runIteration())) |
| @@ -400,11 +464,16 @@ var _isolate_helper; |
| } |
| } |
| run() { |
| +<<<<<<< HEAD |
| + if (!dart.notNull(_isolate_helper._globalState.isWorker)) { |
| + this[_runHelper](); |
| +======= |
| if (!dart.notNull(exports._globalState.isWorker)) { |
| this._runHelper(); |
| +>>>>>>> origin/master |
| } else { |
| try { |
| - this._runHelper(); |
| + this[_runHelper](); |
| } catch (e) { |
| let trace = dart.stackTrace(e); |
| exports._globalState.mainManager.postMessage(_serializeMessage(dart.map({command: 'error', msg: `${e}\n${trace}`}))); |
| @@ -494,10 +563,10 @@ var _isolate_helper; |
| return matches[1]; |
| throw new core.UnsupportedError(`Cannot extract URI from "${stack}"`); |
| } |
| - static _getEventData(e) { |
| + static [_getEventData](e) { |
| return e.data; |
| } |
| - static _processWorkerMessage(sender, e) { |
| + static [_processWorkerMessage](sender, e) { |
| let msg = _deserializeMessage(_getEventData(e)); |
| switch (dart.dindex(msg, 'command')) { |
| case 'start': |
| @@ -556,9 +625,15 @@ var _isolate_helper; |
| } |
| }); |
| } |
| +<<<<<<< HEAD |
| + static [_log](msg) { |
| + if (_isolate_helper._globalState.isWorker) { |
| + _isolate_helper._globalState.mainManager.postMessage(_serializeMessage(dart.map({command: 'log', msg: msg}))); |
| +======= |
| static _log(msg) { |
| if (exports._globalState.isWorker) { |
| exports._globalState.mainManager.postMessage(_serializeMessage(dart.map({command: 'log', msg: msg}))); |
| +>>>>>>> origin/master |
| } else { |
| try { |
| _consoleLog(msg); |
| @@ -569,18 +644,18 @@ var _isolate_helper; |
| } |
| } |
| - static _consoleLog(msg) { |
| + static [_consoleLog](msg) { |
| _js_helper.requiresPreamble(); |
| self.console.log(msg); |
| } |
| - static _getJSFunctionFromName(functionName) { |
| + static [_getJSFunctionFromName](functionName) { |
| let globalFunctionsContainer = _foreign_helper.JS_EMBEDDED_GLOBAL("", dart.as(_js_embedded_names.GLOBAL_FUNCTIONS, core.String)); |
| return globalFunctionsContainer[functionName](); |
| } |
| - static _getJSFunctionName(f) { |
| + static [_getJSFunctionName](f) { |
| return dart.as(dart.is(f, _js_helper.Closure) ? f.$name : null, core.String); |
| } |
| - static _allocate(ctor) { |
| + static [_allocate](ctor) { |
| return new ctor(); |
| } |
| static spawnFunction(topLevelFunction, message, startPaused) { |
| @@ -620,7 +695,7 @@ var _isolate_helper; |
| } |
| return completer.future; |
| } |
| - static _startWorker(functionName, uri, args, message, isSpawnUri, startPaused, replyPort, onError) { |
| + static [_startWorker](functionName, uri, args, message, isSpawnUri, startPaused, replyPort, onError) { |
| if (args !== null) |
| args = new core.List.from(args); |
| if (exports._globalState.isWorker) { |
| @@ -629,7 +704,7 @@ var _isolate_helper; |
| _spawnWorker(functionName, uri, args, message, isSpawnUri, startPaused, replyPort, onError); |
| } |
| } |
| - static _startNonWorker(functionName, uri, args, message, isSpawnUri, startPaused, replyPort) { |
| + static [_startNonWorker](functionName, uri, args, message, isSpawnUri, startPaused, replyPort) { |
| if (uri !== null) { |
| throw new core.UnsupportedError("Currently spawnUri is not supported without web workers."); |
| } |
| @@ -645,7 +720,7 @@ var _isolate_helper; |
| let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _IsolateContext); |
| return new isolate.Isolate(context.controlPort.sendPort, {pauseCapability: context.pauseCapability, terminateCapability: context.terminateCapability}); |
| } |
| - static _startIsolate(topLevel, args, message, isSpawnUri, startPaused, replyTo) { |
| + static [_startIsolate](topLevel, args, message, isSpawnUri, startPaused, replyTo) { |
| let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _IsolateContext); |
| _js_helper.Primitives.initializeStatics(context.id); |
| replyTo.send(new List.from([_SPAWNED_SIGNAL, context.controlPort.sendPort, context.pauseCapability, context.terminateCapability])); |
| @@ -669,7 +744,7 @@ var _isolate_helper; |
| runStartFunction(); |
| } |
| } |
| - static _spawnWorker(functionName, uri, args, message, isSpawnUri, startPaused, replyPort, onError) { |
| + static [_spawnWorker](functionName, uri, args, message, isSpawnUri, startPaused, replyPort, onError) { |
| if (uri === null) |
| uri = thisScript; |
| let worker = new Worker(uri); |
| @@ -714,48 +789,58 @@ var _isolate_helper; |
| } |
| }); |
| class _BaseSendPort extends dart.Object { |
| - _BaseSendPort(_isolateId) { |
| - this._isolateId = _isolateId; |
| + _BaseSendPort($_isolateId) { |
| + this[_isolateId] = $_isolateId; |
| } |
| - _checkReplyTo(replyTo) { |
| + [_checkReplyTo](replyTo) { |
| if (dart.notNull(dart.notNull(replyTo !== null) && dart.notNull(!dart.is(replyTo, _NativeJsSendPort))) && dart.notNull(!dart.is(replyTo, _WorkerSendPort))) { |
| throw new core.Exception("SendPort.send: Illegal replyTo port type"); |
| } |
| } |
| } |
| class _NativeJsSendPort extends _BaseSendPort { |
| - _NativeJsSendPort(_receivePort, isolateId) { |
| - this._receivePort = _receivePort; |
| + _NativeJsSendPort($_receivePort, isolateId) { |
| + this[_receivePort] = $_receivePort; |
| super._BaseSendPort(isolateId); |
| } |
| send(message) { |
| +<<<<<<< HEAD |
| + let isolate = _isolate_helper._globalState.isolates.get(this[_isolateId]); |
| +======= |
| let isolate = exports._globalState.isolates.get(this._isolateId); |
| +>>>>>>> origin/master |
| if (isolate === null) |
| return; |
| - if (this._receivePort._isClosed) |
| + if (this[_receivePort][_isClosed]) |
| return; |
| let msg = _clone(message); |
| - if (dart.equals(isolate.controlPort, this._receivePort)) { |
| + if (dart.equals(isolate.controlPort, this[_receivePort])) { |
| isolate.handleControlMessage(msg); |
| return; |
| } |
| +<<<<<<< HEAD |
| + _isolate_helper._globalState.topEventLoop.enqueue(isolate, (() => { |
| + if (!dart.notNull(this[_receivePort][_isClosed])) { |
| + this[_receivePort]._add(msg); |
| +======= |
| exports._globalState.topEventLoop.enqueue(isolate, (() => { |
| if (!dart.notNull(this._receivePort._isClosed)) { |
| this._receivePort._add(msg); |
| +>>>>>>> origin/master |
| } |
| }).bind(this), `receive ${message}`); |
| } |
| ['=='](other) { |
| - return dart.notNull(dart.is(other, _NativeJsSendPort)) && dart.notNull(dart.equals(this._receivePort, dart.dload(other, '_receivePort'))); |
| + return dart.notNull(dart.is(other, _NativeJsSendPort)) && dart.notNull(dart.equals(this[_receivePort], dart.dload(other, '_receivePort'))); |
| } |
| get hashCode() { |
| - return this._receivePort._id; |
| + return this[_receivePort][_id]; |
| } |
| } |
| class _WorkerSendPort extends _BaseSendPort { |
| - _WorkerSendPort(_workerId, isolateId, _receivePortId) { |
| - this._workerId = _workerId; |
| - this._receivePortId = _receivePortId; |
| + _WorkerSendPort($_workerId, isolateId, $_receivePortId) { |
| + this[_workerId] = $_workerId; |
| + this[_receivePortId] = $_receivePortId; |
| super._BaseSendPort(isolateId); |
| } |
| send(message) { |
| @@ -763,20 +848,37 @@ var _isolate_helper; |
| if (exports._globalState.isWorker) { |
| exports._globalState.mainManager.postMessage(workerMessage); |
| } else { |
| +<<<<<<< HEAD |
| + let manager = _isolate_helper._globalState.managers.get(this[_workerId]); |
| +======= |
| let manager = exports._globalState.managers.get(this._workerId); |
| +>>>>>>> origin/master |
| if (manager !== null) { |
| manager.postMessage(workerMessage); |
| } |
| } |
| } |
| ['=='](other) { |
| - return dart.notNull(dart.notNull(dart.notNull(dart.is(other, _WorkerSendPort)) && dart.notNull(this._workerId === dart.dload(other, '_workerId'))) && dart.notNull(this._isolateId === dart.dload(other, '_isolateId'))) && dart.notNull(this._receivePortId === dart.dload(other, '_receivePortId')); |
| + return dart.notNull(dart.notNull(dart.notNull(dart.is(other, _WorkerSendPort)) && dart.notNull(this[_workerId] === dart.dload(other, '_workerId'))) && dart.notNull(this[_isolateId] === dart.dload(other, '_isolateId'))) && dart.notNull(this[_receivePortId] === dart.dload(other, '_receivePortId')); |
| } |
| get hashCode() { |
| - return this._workerId << 16 ^ this._isolateId << 8 ^ this._receivePortId; |
| + return this[_workerId] << 16 ^ this[_isolateId] << 8 ^ this[_receivePortId]; |
| } |
| } |
| class RawReceivePortImpl extends dart.Object { |
| +<<<<<<< HEAD |
| + RawReceivePortImpl($_handler) { |
| + this[_handler] = $_handler; |
| + this[_id] = _nextFreeId++; |
| + this[_isClosed] = false; |
| + _isolate_helper._globalState.currentContext.register(this[_id], this); |
| + } |
| + RawReceivePortImpl$weak($_handler) { |
| + this[_handler] = $_handler; |
| + this[_id] = _nextFreeId++; |
| + this[_isClosed] = false; |
| + _isolate_helper._globalState.currentContext.registerWeak(this[_id], this); |
| +======= |
| RawReceivePortImpl(_handler) { |
| this._handler = _handler; |
| this._id = _nextFreeId++; |
| @@ -788,30 +890,37 @@ var _isolate_helper; |
| this._id = _nextFreeId++; |
| this._isClosed = false; |
| exports._globalState.currentContext.registerWeak(this._id, this); |
| +>>>>>>> origin/master |
| } |
| RawReceivePortImpl$_controlPort() { |
| - this._handler = null; |
| - this._id = 0; |
| - this._isClosed = false; |
| + this[_handler] = null; |
| + this[_id] = 0; |
| + this[_isClosed] = false; |
| } |
| set handler(newHandler) { |
| - this._handler = newHandler; |
| + this[_handler] = newHandler; |
| } |
| - _close() { |
| - this._isClosed = true; |
| - this._handler = null; |
| + [_close]() { |
| + this[_isClosed] = true; |
| + this[_handler] = null; |
| } |
| close() { |
| - if (this._isClosed) |
| + if (this[_isClosed]) |
| return; |
| +<<<<<<< HEAD |
| + this[_isClosed] = true; |
| + this[_handler] = null; |
| + _isolate_helper._globalState.currentContext.unregister(this[_id]); |
| +======= |
| this._isClosed = true; |
| this._handler = null; |
| exports._globalState.currentContext.unregister(this._id); |
| +>>>>>>> origin/master |
| } |
| - _add(dataEvent) { |
| - if (this._isClosed) |
| + [_add](dataEvent) { |
| + if (this[_isClosed]) |
| return; |
| - dart.dinvokef(this._handler, dataEvent); |
| + dart.dinvokef(this[_handler], dataEvent); |
| } |
| get sendPort() { |
| return new _NativeJsSendPort(this, exports._globalState.currentContext.id); |
| @@ -827,64 +936,77 @@ var _isolate_helper; |
| ReceivePortImpl$weak() { |
| this.ReceivePortImpl$fromRawReceivePort(new RawReceivePortImpl.weak(null)); |
| } |
| - ReceivePortImpl$fromRawReceivePort(_rawPort) { |
| - this._rawPort = _rawPort; |
| - this._controller = null; |
| + ReceivePortImpl$fromRawReceivePort($_rawPort) { |
| + this[_rawPort] = $_rawPort; |
| + this[_controller] = null; |
| super.Stream(); |
| - this._controller = new async.StreamController({onCancel: this.close, sync: true}); |
| - this._rawPort.handler = this._controller.add; |
| + this[_controller] = new async.StreamController({onCancel: this.close, sync: true}); |
| + this[_rawPort].handler = this[_controller].add; |
| } |
| listen(onData, opt$) { |
| let onError = opt$.onError === void 0 ? null : opt$.onError; |
| let onDone = opt$.onDone === void 0 ? null : opt$.onDone; |
| let cancelOnError = opt$.cancelOnError === void 0 ? null : opt$.cancelOnError; |
| - return this._controller.stream.listen(onData, {onError: onError, onDone: onDone, cancelOnError: cancelOnError}); |
| + return this[_controller].stream.listen(onData, {onError: onError, onDone: onDone, cancelOnError: cancelOnError}); |
| } |
| close() { |
| - this._rawPort.close(); |
| - this._controller.close(); |
| + this[_rawPort].close(); |
| + this[_controller].close(); |
| } |
| get sendPort() { |
| - return this._rawPort.sendPort; |
| + return this[_rawPort].sendPort; |
| } |
| } |
| dart.defineNamedConstructor(ReceivePortImpl, 'weak'); |
| dart.defineNamedConstructor(ReceivePortImpl, 'fromRawReceivePort'); |
| class TimerImpl extends dart.Object { |
| TimerImpl(milliseconds, callback) { |
| +<<<<<<< HEAD |
| + this[_once] = true; |
| + this[_inEventLoop] = false; |
| + this[_handle] = dart.as(null, core.int); |
| + if (dart.notNull(milliseconds === 0) && dart.notNull(dart.notNull(!dart.notNull(hasTimer())) || dart.notNull(_isolate_helper._globalState.isWorker))) { |
| +======= |
| this._once = true; |
| this._inEventLoop = false; |
| this._handle = dart.as(null, core.int); |
| if (dart.notNull(milliseconds === 0) && dart.notNull(dart.notNull(!dart.notNull(hasTimer())) || dart.notNull(exports._globalState.isWorker))) { |
| +>>>>>>> origin/master |
| // Function internalCallback: () → void |
| function internalCallback() { |
| - this._handle = dart.as(null, core.int); |
| + this[_handle] = dart.as(null, core.int); |
| callback(); |
| } |
| +<<<<<<< HEAD |
| + this[_handle] = 1; |
| + _isolate_helper._globalState.topEventLoop.enqueue(_isolate_helper._globalState.currentContext, internalCallback, 'timer'); |
| + this[_inEventLoop] = true; |
| +======= |
| this._handle = 1; |
| exports._globalState.topEventLoop.enqueue(exports._globalState.currentContext, internalCallback, 'timer'); |
| this._inEventLoop = true; |
| +>>>>>>> origin/master |
| } else if (hasTimer()) { |
| // Function internalCallback: () → void |
| function internalCallback() { |
| - this._handle = dart.as(null, core.int); |
| + this[_handle] = dart.as(null, core.int); |
| leaveJsAsync(); |
| callback(); |
| } |
| enterJsAsync(); |
| - this._handle = self.setTimeout(_js_helper.convertDartClosureToJS(internalCallback, 0), milliseconds); |
| + this[_handle] = self.setTimeout(_js_helper.convertDartClosureToJS(internalCallback, 0), milliseconds); |
| } else { |
| dart.assert(milliseconds > 0); |
| throw new core.UnsupportedError("Timer greater than 0."); |
| } |
| } |
| TimerImpl$periodic(milliseconds, callback) { |
| - this._once = false; |
| - this._inEventLoop = false; |
| - this._handle = dart.as(null, core.int); |
| + this[_once] = false; |
| + this[_inEventLoop] = false; |
| + this[_handle] = dart.as(null, core.int); |
| if (hasTimer()) { |
| enterJsAsync(); |
| - this._handle = self.setInterval(_js_helper.convertDartClosureToJS((() => { |
| + this[_handle] = self.setInterval(_js_helper.convertDartClosureToJS((() => { |
| callback(this); |
| }).bind(this), 0), milliseconds); |
| } else { |
| @@ -893,24 +1015,24 @@ var _isolate_helper; |
| } |
| cancel() { |
| if (hasTimer()) { |
| - if (this._inEventLoop) { |
| + if (this[_inEventLoop]) { |
| throw new core.UnsupportedError("Timer in event loop cannot be canceled."); |
| } |
| - if (this._handle === null) |
| + if (this[_handle] === null) |
| return; |
| leaveJsAsync(); |
| - if (this._once) { |
| - self.clearTimeout(this._handle); |
| + if (this[_once]) { |
| + self.clearTimeout(this[_handle]); |
| } else { |
| - self.clearInterval(this._handle); |
| + self.clearInterval(this[_handle]); |
| } |
| - this._handle = dart.as(null, core.int); |
| + this[_handle] = dart.as(null, core.int); |
| } else { |
| throw new core.UnsupportedError("Canceling a timer."); |
| } |
| } |
| get isActive() { |
| - return this._handle !== null; |
| + return this[_handle] !== null; |
| } |
| } |
| dart.defineNamedConstructor(TimerImpl, 'periodic'); |
| @@ -923,11 +1045,11 @@ var _isolate_helper; |
| CapabilityImpl() { |
| this.CapabilityImpl$_internal(_js_helper.random64()); |
| } |
| - CapabilityImpl$_internal(_id) { |
| - this._id = _id; |
| + CapabilityImpl$_internal($_id) { |
| + this[_id] = $_id; |
| } |
| get hashCode() { |
| - let hash = this._id; |
| + let hash = this[_id]; |
| hash = hash >> 0 ^ (hash / 4294967296).truncate(); |
| hash = ~hash + (hash << 15) & 4294967295; |
| hash = hash >> 12; |
| @@ -941,7 +1063,7 @@ var _isolate_helper; |
| if (core.identical(other, this)) |
| return true; |
| if (dart.is(other, CapabilityImpl)) { |
| - return core.identical(this._id, other._id); |
| + return core.identical(this[_id], other[_id]); |
| } |
| return false; |
| } |
| @@ -965,7 +1087,7 @@ var _isolate_helper; |
| _Serializer(opt$) { |
| let serializeSendPorts = opt$.serializeSendPorts === void 0 ? true : opt$.serializeSendPorts; |
| this.serializedObjectIds = new core.Map.identity(); |
| - this._serializeSendPorts = dart.as(serializeSendPorts, core.bool); |
| + this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); |
| } |
| serialize(x) { |
| if (this.isPrimitive(x)) |
| @@ -1065,20 +1187,26 @@ var _isolate_helper; |
| return new List.from(['js-object', keys, values]); |
| } |
| serializeWorkerSendPort(x) { |
| - if (this._serializeSendPorts) { |
| - return new List.from(['sendport', x._workerId, x._isolateId, x._receivePortId]); |
| + if (this[_serializeSendPorts]) { |
| + return new List.from(['sendport', x[_workerId], x[_isolateId], x[_receivePortId]]); |
| } |
| return new List.from(['raw sendport', x]); |
| } |
| serializeJsSendPort(x) { |
| +<<<<<<< HEAD |
| + if (this[_serializeSendPorts]) { |
| + let workerId = _isolate_helper._globalState.currentManagerId; |
| + return new List.from(['sendport', workerId, x[_isolateId], x[_receivePort][_id]]); |
| +======= |
| if (this._serializeSendPorts) { |
| let workerId = exports._globalState.currentManagerId; |
| return new List.from(['sendport', workerId, x._isolateId, x._receivePort._id]); |
| +>>>>>>> origin/master |
| } |
| return new List.from(['raw sendport', x]); |
| } |
| serializeCapability(x) { |
| - return new List.from(['capability', x._id]); |
| + return new List.from(['capability', x[_id]]); |
| } |
| serializeClosure(x) { |
| let name = IsolateNatives._getJSFunctionName(x); |
| @@ -1099,7 +1227,7 @@ var _isolate_helper; |
| _Deserializer(opt$) { |
| let adjustSendPorts = opt$.adjustSendPorts === void 0 ? true : opt$.adjustSendPorts; |
| this.deserializedObjects = new core.List(); |
| - this._adjustSendPorts = dart.as(adjustSendPorts, core.bool); |
| + this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); |
| } |
| deserialize(x) { |
| if (this.isPrimitive(x)) |