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

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

Issue 1132113003: fixes #177, FunctionDeclarationStatement and closing over `this` (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | lib/runtime/dart/_js_helper.js » ('j') | lib/src/codegen/js_codegen.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var _isolate_helper = dart.defineLibrary(_isolate_helper, {}); 1 var _isolate_helper = dart.defineLibrary(_isolate_helper, {});
2 var core = dart.import(core); 2 var core = dart.import(core);
3 var _native_typed_data = dart.import(_native_typed_data); 3 var _native_typed_data = dart.import(_native_typed_data);
4 var _interceptors = dart.lazyImport(_interceptors); 4 var _interceptors = dart.lazyImport(_interceptors);
5 var _js_helper = dart.lazyImport(_js_helper); 5 var _js_helper = dart.lazyImport(_js_helper);
6 var isolate = dart.import(isolate); 6 var isolate = dart.import(isolate);
7 var _foreign_helper = dart.import(_foreign_helper); 7 var _foreign_helper = dart.import(_foreign_helper);
8 var _js_embedded_names = dart.import(_js_embedded_names); 8 var _js_embedded_names = dart.import(_js_embedded_names);
9 var collection = dart.import(collection); 9 var collection = dart.import(collection);
10 var async = dart.import(async); 10 var async = dart.import(async);
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 if (!dart.equals(this.terminateCapability, authentification)) 548 if (!dart.equals(this.terminateCapability, authentification))
549 return; 549 return;
550 this.errorsAreFatal = errorsAreFatal; 550 this.errorsAreFatal = errorsAreFatal;
551 } 551 }
552 handlePing(responsePort, pingType) { 552 handlePing(responsePort, pingType) {
553 if (pingType == isolate.Isolate.IMMEDIATE || pingType == isolate.Isolate.B EFORE_NEXT_EVENT && !dart.notNull(this[_isExecutingEvent])) { 553 if (pingType == isolate.Isolate.IMMEDIATE || pingType == isolate.Isolate.B EFORE_NEXT_EVENT && !dart.notNull(this[_isExecutingEvent])) {
554 responsePort.send(null); 554 responsePort.send(null);
555 return; 555 return;
556 } 556 }
557 // Function respond: () → void 557 // Function respond: () → void
558 function respond() { 558 let respond = () => {
559 responsePort.send(null); 559 responsePort.send(null);
560 } 560 };
561 if (pingType == isolate.Isolate.AS_EVENT) { 561 if (pingType == isolate.Isolate.AS_EVENT) {
562 exports._globalState.topEventLoop.enqueue(this, respond, "ping"); 562 exports._globalState.topEventLoop.enqueue(this, respond, "ping");
563 return; 563 return;
564 } 564 }
565 dart.assert(pingType == isolate.Isolate.BEFORE_NEXT_EVENT); 565 dart.assert(pingType == isolate.Isolate.BEFORE_NEXT_EVENT);
566 if (this[_scheduledControlEvents] == null) { 566 if (this[_scheduledControlEvents] == null) {
567 this[_scheduledControlEvents] = new collection.Queue(); 567 this[_scheduledControlEvents] = new collection.Queue();
568 } 568 }
569 dart.dsend(this[_scheduledControlEvents], 'addLast', respond); 569 dart.dsend(this[_scheduledControlEvents], 'addLast', respond);
570 } 570 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 this.checkOpenReceivePortsFromCommandLine(); 772 this.checkOpenReceivePortsFromCommandLine();
773 exports._globalState.maybeCloseWorker(); 773 exports._globalState.maybeCloseWorker();
774 return false; 774 return false;
775 } 775 }
776 event.process(); 776 event.process();
777 return true; 777 return true;
778 } 778 }
779 [_runHelper]() { 779 [_runHelper]() {
780 if (exports.globalWindow != null) { 780 if (exports.globalWindow != null) {
781 // Function next: () → void 781 // Function next: () → void
782 function next() { 782 let next = (() => {
783 if (!dart.notNull(this.runIteration())) 783 if (!dart.notNull(this.runIteration()))
784 return; 784 return;
785 async.Timer.run(next); 785 async.Timer.run(next);
786 } 786 }).bind(this);
787 next(); 787 next();
788 } else { 788 } else {
789 while (this.runIteration()) { 789 while (this.runIteration()) {
790 } 790 }
791 } 791 }
792 } 792 }
793 run() { 793 run() {
794 if (!dart.notNull(exports._globalState.isWorker)) { 794 if (!dart.notNull(exports._globalState.isWorker)) {
795 this[_runHelper](); 795 this[_runHelper]();
796 } else { 796 } else {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 } 1052 }
1053 static get currentIsolate() { 1053 static get currentIsolate() {
1054 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola teContext); 1054 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola teContext);
1055 return new isolate.Isolate(context.controlPort.sendPort, {pauseCapability: context.pauseCapability, terminateCapability: context.terminateCapability}); 1055 return new isolate.Isolate(context.controlPort.sendPort, {pauseCapability: context.pauseCapability, terminateCapability: context.terminateCapability});
1056 } 1056 }
1057 static _startIsolate(topLevel, args, message, isSpawnUri, startPaused, reply To) { 1057 static _startIsolate(topLevel, args, message, isSpawnUri, startPaused, reply To) {
1058 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola teContext); 1058 let context = dart.as(_foreign_helper.JS_CURRENT_ISOLATE_CONTEXT(), _Isola teContext);
1059 _js_helper.Primitives.initializeStatics(context.id); 1059 _js_helper.Primitives.initializeStatics(context.id);
1060 replyTo.send([_SPAWNED_SIGNAL, context.controlPort.sendPort, context.pause Capability, context.terminateCapability]); 1060 replyTo.send([_SPAWNED_SIGNAL, context.controlPort.sendPort, context.pause Capability, context.terminateCapability]);
1061 // Function runStartFunction: () → void 1061 // Function runStartFunction: () → void
1062 function runStartFunction() { 1062 let runStartFunction = () => {
1063 context.initialized = true; 1063 context.initialized = true;
1064 if (!dart.notNull(isSpawnUri)) { 1064 if (!dart.notNull(isSpawnUri)) {
1065 dart.dcall(topLevel, message); 1065 dart.dcall(topLevel, message);
1066 } else if (dart.is(topLevel, _MainFunctionArgsMessage)) { 1066 } else if (dart.is(topLevel, _MainFunctionArgsMessage)) {
1067 dart.dcall(topLevel, args, message); 1067 dart.dcall(topLevel, args, message);
1068 } else if (dart.is(topLevel, _MainFunctionArgs)) { 1068 } else if (dart.is(topLevel, _MainFunctionArgs)) {
1069 dart.dcall(topLevel, args); 1069 dart.dcall(topLevel, args);
1070 } else { 1070 } else {
1071 dart.dcall(topLevel); 1071 dart.dcall(topLevel);
1072 } 1072 }
1073 } 1073 };
1074 if (startPaused) { 1074 if (startPaused) {
1075 context.addPause(context.pauseCapability, context.pauseCapability); 1075 context.addPause(context.pauseCapability, context.pauseCapability);
1076 exports._globalState.topEventLoop.enqueue(context, runStartFunction, 'st art isolate'); 1076 exports._globalState.topEventLoop.enqueue(context, runStartFunction, 'st art isolate');
1077 } else { 1077 } else {
1078 runStartFunction(); 1078 runStartFunction();
1079 } 1079 }
1080 } 1080 }
1081 static _spawnWorker(functionName, uri, args, message, isSpawnUri, startPause d, replyPort, onError) { 1081 static _spawnWorker(functionName, uri, args, message, isSpawnUri, startPause d, replyPort, onError) {
1082 if (uri == null) 1082 if (uri == null)
1083 uri = IsolateNatives.thisScript; 1083 uri = IsolateNatives.thisScript;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 let _once = Symbol('_once'); 1283 let _once = Symbol('_once');
1284 let _inEventLoop = Symbol('_inEventLoop'); 1284 let _inEventLoop = Symbol('_inEventLoop');
1285 let _handle = Symbol('_handle'); 1285 let _handle = Symbol('_handle');
1286 class TimerImpl extends core.Object { 1286 class TimerImpl extends core.Object {
1287 TimerImpl(milliseconds, callback) { 1287 TimerImpl(milliseconds, callback) {
1288 this[_once] = true; 1288 this[_once] = true;
1289 this[_inEventLoop] = false; 1289 this[_inEventLoop] = false;
1290 this[_handle] = null; 1290 this[_handle] = null;
1291 if (milliseconds == 0 && (!dart.notNull(hasTimer()) || dart.notNull(export s._globalState.isWorker))) { 1291 if (milliseconds == 0 && (!dart.notNull(hasTimer()) || dart.notNull(export s._globalState.isWorker))) {
1292 // Function internalCallback: () → void 1292 // Function internalCallback: () → void
1293 function internalCallback() { 1293 let internalCallback = (() => {
1294 this[_handle] = null; 1294 this[_handle] = null;
1295 callback(); 1295 callback();
1296 } 1296 }).bind(this);
1297 this[_handle] = 1; 1297 this[_handle] = 1;
1298 exports._globalState.topEventLoop.enqueue(exports._globalState.currentCo ntext, internalCallback, 'timer'); 1298 exports._globalState.topEventLoop.enqueue(exports._globalState.currentCo ntext, internalCallback, 'timer');
1299 this[_inEventLoop] = true; 1299 this[_inEventLoop] = true;
1300 } else if (hasTimer()) { 1300 } else if (hasTimer()) {
1301 // Function internalCallback: () → void 1301 // Function internalCallback: () → void
1302 function internalCallback() { 1302 let internalCallback = (() => {
1303 this[_handle] = null; 1303 this[_handle] = null;
1304 leaveJsAsync(); 1304 leaveJsAsync();
1305 callback(); 1305 callback();
1306 } 1306 }).bind(this);
1307 enterJsAsync(); 1307 enterJsAsync();
1308 this[_handle] = self.setTimeout(_js_helper.convertDartClosureToJS(intern alCallback, 0), milliseconds); 1308 this[_handle] = self.setTimeout(_js_helper.convertDartClosureToJS(intern alCallback, 0), milliseconds);
1309 } else { 1309 } else {
1310 dart.assert(dart.notNull(milliseconds) > 0); 1310 dart.assert(dart.notNull(milliseconds) > 0);
1311 throw new core.UnsupportedError("Timer greater than 0."); 1311 throw new core.UnsupportedError("Timer greater than 0.");
1312 } 1312 }
1313 } 1313 }
1314 periodic(milliseconds, callback) { 1314 periodic(milliseconds, callback) {
1315 this[_once] = false; 1315 this[_once] = false;
1316 this[_inEventLoop] = false; 1316 this[_inEventLoop] = false;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 exports.leaveJsAsync = leaveJsAsync; 1387 exports.leaveJsAsync = leaveJsAsync;
1388 exports.isWorker = isWorker; 1388 exports.isWorker = isWorker;
1389 exports.startRootIsolate = startRootIsolate; 1389 exports.startRootIsolate = startRootIsolate;
1390 exports.IsolateNatives = IsolateNatives; 1390 exports.IsolateNatives = IsolateNatives;
1391 exports.RawReceivePortImpl = RawReceivePortImpl; 1391 exports.RawReceivePortImpl = RawReceivePortImpl;
1392 exports.ReceivePortImpl = ReceivePortImpl; 1392 exports.ReceivePortImpl = ReceivePortImpl;
1393 exports.TimerImpl = TimerImpl; 1393 exports.TimerImpl = TimerImpl;
1394 exports.hasTimer = hasTimer; 1394 exports.hasTimer = hasTimer;
1395 exports.CapabilityImpl = CapabilityImpl; 1395 exports.CapabilityImpl = CapabilityImpl;
1396 })(_isolate_helper, core, _native_typed_data, _interceptors, _js_helper, isolate , _foreign_helper, _js_embedded_names, collection, async); 1396 })(_isolate_helper, core, _native_typed_data, _interceptors, _js_helper, isolate , _foreign_helper, _js_embedded_names, collection, async);
OLDNEW
« no previous file with comments | « no previous file | lib/runtime/dart/_js_helper.js » ('j') | lib/src/codegen/js_codegen.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698