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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart

Issue 735253003: Add CPS IR transformation to make the JavaScript backend specific semantics explicit in the tree. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // IrNodes are kept in a separate library to have precise control over their 5 // IrNodes are kept in a separate library to have precise control over their
6 // dependencies on other parts of the system. 6 // dependencies on other parts of the system.
7 library dart2js.ir_nodes; 7 library dart2js.ir_nodes;
8 8
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../constants/values.dart' as values show ConstantValue; 10 import '../constants/values.dart' as values show ConstantValue;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 if (next != null) next.previous = previous; 105 if (next != null) next.previous = previous;
106 } 106 }
107 } 107 }
108 108
109 /// Binding a value (primitive or constant): 'let val x = V in E'. The bound 109 /// Binding a value (primitive or constant): 'let val x = V in E'. The bound
110 /// value is in scope in the body. 110 /// value is in scope in the body.
111 /// During one-pass construction a LetVal with an empty body is used to 111 /// During one-pass construction a LetVal with an empty body is used to
112 /// represent one-level context 'let val x = V in []'. 112 /// represent one-level context 'let val x = V in []'.
113 class LetPrim extends Expression implements InteriorNode { 113 class LetPrim extends Expression implements InteriorNode {
114 final Primitive primitive; 114 final Primitive primitive;
115 Expression body = null; 115 Expression body;
116 116
117 LetPrim(this.primitive); 117 LetPrim(this.primitive, [this.body = null]);
118 118
119 Expression plug(Expression expr) { 119 Expression plug(Expression expr) {
120 assert(body == null); 120 assert(body == null);
121 return body = expr; 121 return body = expr;
122 } 122 }
123 123
124 accept(Visitor visitor) => visitor.visitLetPrim(this); 124 accept(Visitor visitor) => visitor.visitLetPrim(this);
125 } 125 }
126 126
127 127
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 final Reference<Continuation> trueContinuation; 444 final Reference<Continuation> trueContinuation;
445 final Reference<Continuation> falseContinuation; 445 final Reference<Continuation> falseContinuation;
446 446
447 Branch(this.condition, Continuation trueCont, Continuation falseCont) 447 Branch(this.condition, Continuation trueCont, Continuation falseCont)
448 : trueContinuation = new Reference<Continuation>(trueCont), 448 : trueContinuation = new Reference<Continuation>(trueCont),
449 falseContinuation = new Reference<Continuation>(falseCont); 449 falseContinuation = new Reference<Continuation>(falseCont);
450 450
451 accept(Visitor visitor) => visitor.visitBranch(this); 451 accept(Visitor visitor) => visitor.visitBranch(this);
452 } 452 }
453 453
454 class Identical extends Primitive {
455 final Reference<Primitive> left;
456 final Reference<Primitive> right;
457 Identical(Primitive a, Primitive b)
Kevin Millikin (Google) 2014/11/25 14:27:23 I do prefer a ==> left and b ==> right in paramete
karlklose 2014/11/25 14:38:46 Done.
458 : left = new Reference<Primitive>(a),
459 right = new Reference<Primitive>(b);
460 accept(Visitor visitor) => visitor.visitIdentical(this);
461 }
462
454 class Constant extends Primitive { 463 class Constant extends Primitive {
455 final ConstantExpression expression; 464 final ConstantExpression expression;
456 465
457 Constant(this.expression); 466 Constant(this.expression);
458 467
459 values.ConstantValue get value => expression.value; 468 values.ConstantValue get value => expression.value;
460 469
461 accept(Visitor visitor) => visitor.visitConstant(this); 470 accept(Visitor visitor) => visitor.visitConstant(this);
462 } 471 }
463 472
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 T visitConstant(Constant node) => visitPrimitive(node); 622 T visitConstant(Constant node) => visitPrimitive(node);
614 T visitThis(This node) => visitPrimitive(node); 623 T visitThis(This node) => visitPrimitive(node);
615 T visitReifyTypeVar(ReifyTypeVar node) => visitPrimitive(node); 624 T visitReifyTypeVar(ReifyTypeVar node) => visitPrimitive(node);
616 T visitCreateFunction(CreateFunction node) => visitPrimitive(node); 625 T visitCreateFunction(CreateFunction node) => visitPrimitive(node);
617 T visitGetClosureVariable(GetClosureVariable node) => visitPrimitive(node); 626 T visitGetClosureVariable(GetClosureVariable node) => visitPrimitive(node);
618 T visitParameter(Parameter node) => visitPrimitive(node); 627 T visitParameter(Parameter node) => visitPrimitive(node);
619 T visitContinuation(Continuation node) => visitDefinition(node); 628 T visitContinuation(Continuation node) => visitDefinition(node);
620 629
621 // Conditions. 630 // Conditions.
622 T visitIsTrue(IsTrue node) => visitCondition(node); 631 T visitIsTrue(IsTrue node) => visitCondition(node);
632
633 // JavaScript specific nodes.
634 T visitIdentical(Identical node) => visitPrimitive(node);
623 } 635 }
624 636
625 /// Recursively visits the entire CPS term, and calls abstract `process*` 637 /// Recursively visits the entire CPS term, and calls abstract `process*`
626 /// (i.e. `processLetPrim`) functions in pre-order. 638 /// (i.e. `processLetPrim`) functions in pre-order.
627 abstract class RecursiveVisitor extends Visitor { 639 abstract class RecursiveVisitor extends Visitor {
628 const RecursiveVisitor(); 640 const RecursiveVisitor();
629 641
630 // Ensures that RecursiveVisitor contains overrides for all relevant nodes. 642 // Ensures that RecursiveVisitor contains overrides for all relevant nodes.
631 // As a rule of thumb, nodes with structure to traverse should be overridden 643 // As a rule of thumb, nodes with structure to traverse should be overridden
632 // with the appropriate visits in this class (for example, visitLetCont), 644 // with the appropriate visits in this class (for example, visitLetCont),
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 visit(node.body); 791 visit(node.body);
780 } 792 }
781 793
782 // Conditions. 794 // Conditions.
783 795
784 processIsTrue(IsTrue node) {} 796 processIsTrue(IsTrue node) {}
785 visitIsTrue(IsTrue node) { 797 visitIsTrue(IsTrue node) {
786 processIsTrue(node); 798 processIsTrue(node);
787 processReference(node.value); 799 processReference(node.value);
788 } 800 }
801
802 // JavaScript specific nodes.
803 processIdentical(Identical node) {}
804 visitIdentical(Identical node) {
805 processIdentical(node);
806 processReference(node.left);
807 processReference(node.right);
808 }
789 } 809 }
790 810
791 /// Keeps track of currently unused register indices. 811 /// Keeps track of currently unused register indices.
792 class RegisterArray { 812 class RegisterArray {
793 int nextIndex = 0; 813 int nextIndex = 0;
794 final List<int> freeStack = <int>[]; 814 final List<int> freeStack = <int>[];
795 815
796 /// Returns an index that is currently unused. 816 /// Returns an index that is currently unused.
797 int makeIndex() { 817 int makeIndex() {
798 if (freeStack.isEmpty) { 818 if (freeStack.isEmpty) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 // transferred without intermediate assignments. 967 // transferred without intermediate assignments.
948 for (int i = node.parameters.length - 1; i >= 0; --i) { 968 for (int i = node.parameters.length - 1; i >= 0; --i) {
949 release(node.parameters[i]); 969 release(node.parameters[i]);
950 } 970 }
951 } 971 }
952 972
953 void visitIsTrue(IsTrue node) { 973 void visitIsTrue(IsTrue node) {
954 visitReference(node.value); 974 visitReference(node.value);
955 } 975 }
956 976
977 // JavaScript specific nodes.
978
979 void visitIdentical(Identical node) {
980 visitReference(node.left);
981 visitReference(node.right);
982 }
957 } 983 }
958 984
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698