Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Side by Side Diff: lib/runtime/dart/_isolate_helper.js

Issue 1633003002: Add --modules=node support (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: reverted let->const parasite change Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 dart_library.library('dart/_isolate_helper', null, /* Imports */[ 1 dart_library.library('dart/_isolate_helper', null, /* Imports */[
2 'dart/_runtime', 2 'dart/_runtime',
3 'dart/core', 3 'dart/core',
4 'dart/_interceptors', 4 'dart/_interceptors',
5 'dart/_js_helper', 5 'dart/_js_helper',
6 'dart/isolate', 6 'dart/isolate',
7 'dart/_foreign_helper', 7 'dart/_foreign_helper',
8 'dart/collection', 8 'dart/collection',
9 'dart/async' 9 'dart/async'
10 ], /* Lazy imports */[ 10 ], /* Lazy imports */[
11 'dart/_native_typed_data', 11 'dart/_native_typed_data',
12 'dart/_js_embedded_names' 12 'dart/_js_embedded_names'
13 ], function(exports, dart, core, _interceptors, _js_helper, isolate, _foreign_he lper, collection, async, _native_typed_data, _js_embedded_names) { 13 ], function(exports, dart, core, _interceptors, _js_helper, isolate, _foreign_he lper, collection, $async, _native_typed_data, _js_embedded_names) {
14 'use strict'; 14 'use strict';
15 let dartx = dart.dartx; 15 let dartx = dart.dartx;
16 function _serializeMessage(message) { 16 function _serializeMessage(message) {
17 return new _Serializer().serialize(message); 17 return new _Serializer().serialize(message);
18 } 18 }
19 dart.fn(_serializeMessage); 19 dart.fn(_serializeMessage);
20 function _deserializeMessage(message) { 20 function _deserializeMessage(message) {
21 return new _Deserializer().deserialize(message); 21 return new _Deserializer().deserialize(message);
22 } 22 }
23 dart.fn(_deserializeMessage); 23 dart.fn(_deserializeMessage);
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 exports._globalState.maybeCloseWorker(); 823 exports._globalState.maybeCloseWorker();
824 return false; 824 return false;
825 } 825 }
826 event.process(); 826 event.process();
827 return true; 827 return true;
828 } 828 }
829 [_runHelper]() { 829 [_runHelper]() {
830 if (exports.globalWindow != null) { 830 if (exports.globalWindow != null) {
831 const next = (function() { 831 const next = (function() {
832 if (!dart.notNull(this.runIteration())) return; 832 if (!dart.notNull(this.runIteration())) return;
833 async.Timer.run(next); 833 $async.Timer.run(next);
834 }).bind(this); 834 }).bind(this);
835 dart.fn(next); 835 dart.fn(next);
836 next(); 836 next();
837 } else { 837 } else {
838 while (dart.notNull(this.runIteration())) { 838 while (dart.notNull(this.runIteration())) {
839 } 839 }
840 } 840 }
841 } 841 }
842 run() { 842 run() {
843 if (!dart.notNull(exports._globalState.isWorker)) { 843 if (!dart.notNull(exports._globalState.isWorker)) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 IsolateNatives.enableSpawnWorker = true; 1062 IsolateNatives.enableSpawnWorker = true;
1063 let isLight = false; 1063 let isLight = false;
1064 let isSpawnUri = true; 1064 let isSpawnUri = true;
1065 return IsolateNatives.spawn(null, dart.toString(uri), args, message, isLig ht, isSpawnUri, startPaused); 1065 return IsolateNatives.spawn(null, dart.toString(uri), args, message, isLig ht, isSpawnUri, startPaused);
1066 } 1066 }
1067 static spawn(functionName, uri, args, message, isLight, isSpawnUri, startPau sed) { 1067 static spawn(functionName, uri, args, message, isLight, isSpawnUri, startPau sed) {
1068 if (uri != null && dart.notNull(uri[dartx.endsWith](".dart"))) { 1068 if (uri != null && dart.notNull(uri[dartx.endsWith](".dart"))) {
1069 uri = dart.notNull(uri) + ".js"; 1069 uri = dart.notNull(uri) + ".js";
1070 } 1070 }
1071 let port = isolate.ReceivePort.new(); 1071 let port = isolate.ReceivePort.new();
1072 let completer = async.Completer$(core.List).new(); 1072 let completer = $async.Completer$(core.List).new();
1073 port.first.then(dart.fn(msg => { 1073 port.first.then(dart.fn(msg => {
1074 if (dart.equals(dart.dindex(msg, 0), _SPAWNED_SIGNAL)) { 1074 if (dart.equals(dart.dindex(msg, 0), _SPAWNED_SIGNAL)) {
1075 completer.complete(msg); 1075 completer.complete(msg);
1076 } else { 1076 } else {
1077 dart.assert(dart.equals(dart.dindex(msg, 0), _SPAWN_FAILED_SIGNAL)); 1077 dart.assert(dart.equals(dart.dindex(msg, 0), _SPAWN_FAILED_SIGNAL));
1078 completer.completeError(dart.dindex(msg, 1)); 1078 completer.completeError(dart.dindex(msg, 1));
1079 } 1079 }
1080 })); 1080 }));
1081 let signalReply = port.sendPort; 1081 let signalReply = port.sendPort;
1082 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight )) { 1082 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight )) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 computeThisScriptD8: [core.String, []], 1175 computeThisScriptD8: [core.String, []],
1176 computeThisScriptFromTrace: [core.String, []], 1176 computeThisScriptFromTrace: [core.String, []],
1177 _getEventData: [dart.dynamic, [dart.dynamic]], 1177 _getEventData: [dart.dynamic, [dart.dynamic]],
1178 _processWorkerMessage: [dart.void, [dart.dynamic, dart.dynamic]], 1178 _processWorkerMessage: [dart.void, [dart.dynamic, dart.dynamic]],
1179 handleSpawnWorkerRequest: [dart.dynamic, [dart.dynamic]], 1179 handleSpawnWorkerRequest: [dart.dynamic, [dart.dynamic]],
1180 _log: [dart.dynamic, [dart.dynamic]], 1180 _log: [dart.dynamic, [dart.dynamic]],
1181 _consoleLog: [dart.void, [dart.dynamic]], 1181 _consoleLog: [dart.void, [dart.dynamic]],
1182 _getJSFunctionFromName: [dart.dynamic, [core.String]], 1182 _getJSFunctionFromName: [dart.dynamic, [core.String]],
1183 _getJSFunctionName: [core.String, [core.Function]], 1183 _getJSFunctionName: [core.String, [core.Function]],
1184 _allocate: [dart.dynamic, [dart.dynamic]], 1184 _allocate: [dart.dynamic, [dart.dynamic]],
1185 spawnFunction: [async.Future$(core.List), [dart.functionType(dart.void, [d art.dynamic]), dart.dynamic, core.bool]], 1185 spawnFunction: [$async.Future$(core.List), [dart.functionType(dart.void, [ dart.dynamic]), dart.dynamic, core.bool]],
1186 spawnUri: [async.Future$(core.List), [core.Uri, core.List$(core.String), d art.dynamic, core.bool]], 1186 spawnUri: [$async.Future$(core.List), [core.Uri, core.List$(core.String), dart.dynamic, core.bool]],
1187 spawn: [async.Future$(core.List), [core.String, core.String, core.List$(co re.String), dart.dynamic, core.bool, core.bool, core.bool]], 1187 spawn: [$async.Future$(core.List), [core.String, core.String, core.List$(c ore.String), dart.dynamic, core.bool, core.bool, core.bool]],
1188 _startWorker: [dart.void, [core.String, core.String, core.List$(core.Strin g), dart.dynamic, core.bool, core.bool, isolate.SendPort, dart.functionType(dart .void, [core.String])]], 1188 _startWorker: [dart.void, [core.String, core.String, core.List$(core.Strin g), dart.dynamic, core.bool, core.bool, isolate.SendPort, dart.functionType(dart .void, [core.String])]],
1189 _startNonWorker: [dart.void, [core.String, core.String, core.List$(core.St ring), dart.dynamic, core.bool, core.bool, isolate.SendPort]], 1189 _startNonWorker: [dart.void, [core.String, core.String, core.List$(core.St ring), dart.dynamic, core.bool, core.bool, isolate.SendPort]],
1190 _startIsolate: [dart.void, [core.Function, core.List$(core.String), dart.d ynamic, core.bool, core.bool, isolate.SendPort]], 1190 _startIsolate: [dart.void, [core.Function, core.List$(core.String), dart.d ynamic, core.bool, core.bool, isolate.SendPort]],
1191 _spawnWorker: [dart.void, [dart.dynamic, core.String, core.List$(core.Stri ng), dart.dynamic, core.bool, core.bool, isolate.SendPort, dart.functionType(dar t.void, [core.String])]], 1191 _spawnWorker: [dart.void, [dart.dynamic, core.String, core.List$(core.Stri ng), dart.dynamic, core.bool, core.bool, isolate.SendPort, dart.functionType(dar t.void, [core.String])]],
1192 workerOnError: [core.bool, [dart.dynamic, core.String, dart.functionType(d art.void, [core.String])]] 1192 workerOnError: [core.bool, [dart.dynamic, core.String, dart.functionType(d art.void, [core.String])]]
1193 }), 1193 }),
1194 names: ['computeThisScript', 'computeThisScriptJsshell', 'computeThisScriptD 8', 'computeThisScriptFromTrace', '_getEventData', '_processWorkerMessage', 'han dleSpawnWorkerRequest', '_log', '_consoleLog', '_getJSFunctionFromName', '_getJS FunctionName', '_allocate', 'spawnFunction', 'spawnUri', 'spawn', '_startWorker' , '_startNonWorker', '_startIsolate', '_spawnWorker', 'workerOnError'] 1194 names: ['computeThisScript', 'computeThisScriptJsshell', 'computeThisScriptD 8', 'computeThisScriptFromTrace', '_getEventData', '_processWorkerMessage', 'han dleSpawnWorkerRequest', '_log', '_consoleLog', '_getJSFunctionFromName', '_getJS FunctionName', '_allocate', 'spawnFunction', 'spawnUri', 'spawn', '_startWorker' , '_startNonWorker', '_startIsolate', '_spawnWorker', 'workerOnError']
1195 }); 1195 });
1196 IsolateNatives.enableSpawnWorker = null; 1196 IsolateNatives.enableSpawnWorker = null;
1197 dart.defineLazyProperties(IsolateNatives, { 1197 dart.defineLazyProperties(IsolateNatives, {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 }), 1341 }),
1342 methods: () => ({ 1342 methods: () => ({
1343 [_close]: [dart.void, []], 1343 [_close]: [dart.void, []],
1344 close: [dart.void, []], 1344 close: [dart.void, []],
1345 [_add]: [dart.void, [dart.dynamic]] 1345 [_add]: [dart.void, [dart.dynamic]]
1346 }) 1346 })
1347 }); 1347 });
1348 RawReceivePortImpl._nextFreeId = 1; 1348 RawReceivePortImpl._nextFreeId = 1;
1349 const _rawPort = Symbol('_rawPort'); 1349 const _rawPort = Symbol('_rawPort');
1350 const _controller = Symbol('_controller'); 1350 const _controller = Symbol('_controller');
1351 class ReceivePortImpl extends async.Stream { 1351 class ReceivePortImpl extends $async.Stream {
1352 ReceivePortImpl() { 1352 ReceivePortImpl() {
1353 this.fromRawReceivePort(new RawReceivePortImpl(null)); 1353 this.fromRawReceivePort(new RawReceivePortImpl(null));
1354 } 1354 }
1355 weak() { 1355 weak() {
1356 this.fromRawReceivePort(new RawReceivePortImpl.weak(null)); 1356 this.fromRawReceivePort(new RawReceivePortImpl.weak(null));
1357 } 1357 }
1358 fromRawReceivePort(rawPort) { 1358 fromRawReceivePort(rawPort) {
1359 this[_rawPort] = rawPort; 1359 this[_rawPort] = rawPort;
1360 this[_controller] = null; 1360 this[_controller] = null;
1361 super.Stream(); 1361 super.Stream();
1362 this[_controller] = async.StreamController.new({onCancel: dart.bind(this, 'close'), sync: true}); 1362 this[_controller] = $async.StreamController.new({onCancel: dart.bind(this, 'close'), sync: true});
1363 this[_rawPort].handler = dart.bind(this[_controller], 'add'); 1363 this[_rawPort].handler = dart.bind(this[_controller], 'add');
1364 } 1364 }
1365 listen(onData, opts) { 1365 listen(onData, opts) {
1366 let onError = opts && 'onError' in opts ? opts.onError : null; 1366 let onError = opts && 'onError' in opts ? opts.onError : null;
1367 let onDone = opts && 'onDone' in opts ? opts.onDone : null; 1367 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
1368 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null; 1368 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
1369 return this[_controller].stream.listen(onData, {onError: onError, onDone: onDone, cancelOnError: cancelOnError}); 1369 return this[_controller].stream.listen(onData, {onError: onError, onDone: onDone, cancelOnError: cancelOnError});
1370 } 1370 }
1371 close() { 1371 close() {
1372 this[_rawPort].close(); 1372 this[_rawPort].close();
1373 this[_controller].close(); 1373 this[_controller].close();
1374 } 1374 }
1375 get sendPort() { 1375 get sendPort() {
1376 return this[_rawPort].sendPort; 1376 return this[_rawPort].sendPort;
1377 } 1377 }
1378 } 1378 }
1379 ReceivePortImpl[dart.implements] = () => [isolate.ReceivePort]; 1379 ReceivePortImpl[dart.implements] = () => [isolate.ReceivePort];
1380 dart.defineNamedConstructor(ReceivePortImpl, 'weak'); 1380 dart.defineNamedConstructor(ReceivePortImpl, 'weak');
1381 dart.defineNamedConstructor(ReceivePortImpl, 'fromRawReceivePort'); 1381 dart.defineNamedConstructor(ReceivePortImpl, 'fromRawReceivePort');
1382 dart.setSignature(ReceivePortImpl, { 1382 dart.setSignature(ReceivePortImpl, {
1383 constructors: () => ({ 1383 constructors: () => ({
1384 ReceivePortImpl: [ReceivePortImpl, []], 1384 ReceivePortImpl: [ReceivePortImpl, []],
1385 weak: [ReceivePortImpl, []], 1385 weak: [ReceivePortImpl, []],
1386 fromRawReceivePort: [ReceivePortImpl, [isolate.RawReceivePort]] 1386 fromRawReceivePort: [ReceivePortImpl, [isolate.RawReceivePort]]
1387 }), 1387 }),
1388 methods: () => ({ 1388 methods: () => ({
1389 listen: [async.StreamSubscription, [dart.functionType(dart.void, [dart.dyn amic])], {onError: core.Function, onDone: dart.functionType(dart.void, []), canc elOnError: core.bool}], 1389 listen: [$async.StreamSubscription, [dart.functionType(dart.void, [dart.dy namic])], {onError: core.Function, onDone: dart.functionType(dart.void, []), can celOnError: core.bool}],
1390 close: [dart.void, []] 1390 close: [dart.void, []]
1391 }) 1391 })
1392 }); 1392 });
1393 const _once = Symbol('_once'); 1393 const _once = Symbol('_once');
1394 const _inEventLoop = Symbol('_inEventLoop'); 1394 const _inEventLoop = Symbol('_inEventLoop');
1395 const _handle = Symbol('_handle'); 1395 const _handle = Symbol('_handle');
1396 class TimerImpl extends core.Object { 1396 class TimerImpl extends core.Object {
1397 TimerImpl(milliseconds, callback) { 1397 TimerImpl(milliseconds, callback) {
1398 this[_once] = true; 1398 this[_once] = true;
1399 this[_inEventLoop] = false; 1399 this[_inEventLoop] = false;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 } 1448 }
1449 this[_handle] = null; 1449 this[_handle] = null;
1450 } else { 1450 } else {
1451 dart.throw(new core.UnsupportedError("Canceling a timer.")); 1451 dart.throw(new core.UnsupportedError("Canceling a timer."));
1452 } 1452 }
1453 } 1453 }
1454 get isActive() { 1454 get isActive() {
1455 return this[_handle] != null; 1455 return this[_handle] != null;
1456 } 1456 }
1457 } 1457 }
1458 TimerImpl[dart.implements] = () => [async.Timer]; 1458 TimerImpl[dart.implements] = () => [$async.Timer];
1459 dart.defineNamedConstructor(TimerImpl, 'periodic'); 1459 dart.defineNamedConstructor(TimerImpl, 'periodic');
1460 dart.setSignature(TimerImpl, { 1460 dart.setSignature(TimerImpl, {
1461 constructors: () => ({ 1461 constructors: () => ({
1462 TimerImpl: [TimerImpl, [core.int, dart.functionType(dart.void, [])]], 1462 TimerImpl: [TimerImpl, [core.int, dart.functionType(dart.void, [])]],
1463 periodic: [TimerImpl, [core.int, dart.functionType(dart.void, [async.Timer ])]] 1463 periodic: [TimerImpl, [core.int, dart.functionType(dart.void, [$async.Time r])]]
1464 }), 1464 }),
1465 methods: () => ({cancel: [dart.void, []]}) 1465 methods: () => ({cancel: [dart.void, []]})
1466 }); 1466 });
1467 function hasTimer() { 1467 function hasTimer() {
1468 return self.setTimeout != null; 1468 return self.setTimeout != null;
1469 } 1469 }
1470 dart.fn(hasTimer, core.bool, []); 1470 dart.fn(hasTimer, core.bool, []);
1471 class CapabilityImpl extends core.Object { 1471 class CapabilityImpl extends core.Object {
1472 CapabilityImpl() { 1472 CapabilityImpl() {
1473 this._internal(_js_helper.random64()); 1473 this._internal(_js_helper.random64());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 exports.leaveJsAsync = leaveJsAsync; 1508 exports.leaveJsAsync = leaveJsAsync;
1509 exports.isWorker = isWorker; 1509 exports.isWorker = isWorker;
1510 exports.startRootIsolate = startRootIsolate; 1510 exports.startRootIsolate = startRootIsolate;
1511 exports.IsolateNatives = IsolateNatives; 1511 exports.IsolateNatives = IsolateNatives;
1512 exports.RawReceivePortImpl = RawReceivePortImpl; 1512 exports.RawReceivePortImpl = RawReceivePortImpl;
1513 exports.ReceivePortImpl = ReceivePortImpl; 1513 exports.ReceivePortImpl = ReceivePortImpl;
1514 exports.TimerImpl = TimerImpl; 1514 exports.TimerImpl = TimerImpl;
1515 exports.hasTimer = hasTimer; 1515 exports.hasTimer = hasTimer;
1516 exports.CapabilityImpl = CapabilityImpl; 1516 exports.CapabilityImpl = CapabilityImpl;
1517 }); 1517 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698