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

Side by Side Diff: frog/leg/emitter.dart

Issue 9706054: Fix wrong assumptions I had on the isolate library. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | frog/leg/ssa/builder.dart » ('j') | frog/leg/ssa/builder.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * A function element that represents a closure call. The signature is copied 6 * A function element that represents a closure call. The signature is copied
7 * from the given element. 7 * from the given element.
8 */ 8 */
9 class ClosureInvocationElement extends FunctionElement { 9 class ClosureInvocationElement extends FunctionElement {
10 ClosureInvocationElement(SourceString name, 10 ClosureInvocationElement(SourceString name,
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 generateMethod('get ${getterName.slowToString()}', jsName, 599 generateMethod('get ${getterName.slowToString()}', jsName,
600 Selector.GETTER); 600 Selector.GETTER);
601 }); 601 });
602 602
603 compiler.universe.invokedSetters.forEach((SourceString setterName) { 603 compiler.universe.invokedSetters.forEach((SourceString setterName) {
604 String jsName = namer.setterName(setterName); 604 String jsName = namer.setterName(setterName);
605 generateMethod('set ${setterName.slowToString()}', jsName, 605 generateMethod('set ${setterName.slowToString()}', jsName,
606 Selector.SETTER); 606 Selector.SETTER);
607 }); 607 });
608 } 608 }
609 609
610 String buildIsolateSetup(Element appMain, Element isolateMain) { 610 String buildIsolateSetup(Element appMain, Element isolateMain) {
611 String mainAccess = "${namer.isolateAccess(appMain)}"; 611 String mainAccess = "${namer.isolateAccess(appMain)}";
612 String currentIsolate = "${namer.CURRENT_ISOLATE}"; 612 String currentIsolate = "${namer.CURRENT_ISOLATE}";
613 String mainEnsureGetter = ''; 613 String mainEnsureGetter = '';
614 // Since we pass the closurized version of the main method to 614 // Since we pass the closurized version of the main method to
615 // the isolate method, we must make sure that it exists. 615 // the isolate method, we must make sure that it exists.
616 if (!compiler.universe.staticFunctionsNeedingGetter.contains(appMain)) { 616 if (!compiler.universe.staticFunctionsNeedingGetter.contains(appMain)) {
617 String invocationName = 617 String invocationName =
618 "${namer.closureInvocationName(Selector.INVOCATION_0)}"; 618 "${namer.closureInvocationName(Selector.INVOCATION_0)}";
619 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; 619 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess";
620 } 620 }
621 621
622 // TODO(ngeoffray): These globals are currently required by the isolate 622 // TODO(ngeoffray): These globals are currently required by the isolate
623 // library, but since leg already generates code on an Isolate object, they 623 // library, but since leg already generates code on an Isolate object, they
624 // are not really needed. We should remove them once Leg replaces Frog. 624 // are not really needed. We should remove them once Leg replaces Frog.
625 return """ 625 return """
626 var \$globalThis = $currentIsolate; 626 var \$globalThis = $currentIsolate;
627 var \$globalState = $currentIsolate; 627 var \$globalState;
628 var \$globals = $currentIsolate; 628 var \$globals;
629 function \$static_init(){}; 629 function \$static_init(){};
630 630
631 function \$initGlobals(context) { 631 function \$initGlobals(context) {
632 context.isolateStatics = new ${namer.ISOLATE}(); 632 context.isolateStatics = new ${namer.ISOLATE}();
633 } 633 }
634 function \$setGlobals(context) { 634 function \$setGlobals(context) {
635 \$globals = context.isolateStatics; 635 $currentIsolate = context.isolateStatics;
636 \$globalThis = $currentIsolate;
636 } 637 }
637 $mainEnsureGetter 638 $mainEnsureGetter
638 ${namer.isolateAccess(isolateMain)}($mainAccess);"""; 639 ${namer.isolateAccess(isolateMain)}($mainAccess);""";
639 } 640 }
640 641
641 String assembleProgram() { 642 String assembleProgram() {
642 measure(() { 643 measure(() {
643 StringBuffer buffer = new StringBuffer(); 644 StringBuffer buffer = new StringBuffer();
644 buffer.add('function ${namer.ISOLATE}() {'); 645 buffer.add('function ${namer.ISOLATE}() {');
645 emitStaticNonFinalFieldInitializations(buffer); 646 emitStaticNonFinalFieldInitializations(buffer);
(...skipping 11 matching lines...) Expand all
657 compiler.isolateLibrary.find(Compiler.START_ROOT_ISOLATE); 658 compiler.isolateLibrary.find(Compiler.START_ROOT_ISOLATE);
658 buffer.add(buildIsolateSetup(main, isolateMain)); 659 buffer.add(buildIsolateSetup(main, isolateMain));
659 } else { 660 } else {
660 buffer.add('${namer.isolateAccess(main)}();\n'); 661 buffer.add('${namer.isolateAccess(main)}();\n');
661 } 662 }
662 compiler.assembledCode = buffer.toString(); 663 compiler.assembledCode = buffer.toString();
663 }); 664 });
664 return compiler.assembledCode; 665 return compiler.assembledCode;
665 } 666 }
666 } 667 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/ssa/builder.dart » ('j') | frog/leg/ssa/builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698