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

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

Issue 806103003: cps-ir: Add support for intercepted calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Bailout on special selectors. 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 /// Invoke a method, operator, getter, setter, or index getter/setter. 187 /// Invoke a method, operator, getter, setter, or index getter/setter.
188 /// Converting a method to a function object is treated as a getter invocation. 188 /// Converting a method to a function object is treated as a getter invocation.
189 class InvokeMethod extends Expression implements Invoke { 189 class InvokeMethod extends Expression implements Invoke {
190 final Reference<Primitive> receiver; 190 final Reference<Primitive> receiver;
191 final Selector selector; 191 final Selector selector;
192 final Reference<Continuation> continuation; 192 final Reference<Continuation> continuation;
193 final List<Reference<Primitive>> arguments; 193 final List<Reference<Primitive>> arguments;
194 194
195 InvokeMethod(Primitive receiver, 195 InvokeMethod(Primitive receiver,
196 this.selector, 196 Selector selector,
197 Continuation cont, 197 Continuation cont,
198 List<Primitive> args) 198 List<Primitive> args)
199 : receiver = new Reference<Primitive>(receiver), 199 : this.internal(new Reference<Primitive>(receiver),
200 continuation = new Reference<Continuation>(cont), 200 selector,
201 arguments = _referenceList(args) { 201 new Reference<Continuation>(cont),
202 _referenceList(args));
203
204 InvokeMethod.internal(this.receiver,
205 this.selector,
206 this.continuation,
207 this.arguments) {
202 assert(selector != null); 208 assert(selector != null);
203 assert(selector.kind == SelectorKind.CALL || 209 assert(selector.kind == SelectorKind.CALL ||
204 selector.kind == SelectorKind.OPERATOR || 210 selector.kind == SelectorKind.OPERATOR ||
205 (selector.kind == SelectorKind.GETTER && arguments.isEmpty) || 211 (selector.kind == SelectorKind.GETTER && arguments.isEmpty) ||
206 (selector.kind == SelectorKind.SETTER && arguments.length == 1) || 212 (selector.kind == SelectorKind.SETTER && arguments.length == 1) ||
207 (selector.kind == SelectorKind.INDEX && arguments.length == 1) || 213 (selector.kind == SelectorKind.INDEX && arguments.length == 1) ||
208 (selector.kind == SelectorKind.INDEX && arguments.length == 2)); 214 (selector.kind == SelectorKind.INDEX && arguments.length == 2));
209 } 215 }
210 216
217 bool get isIntercepted => receiver.definition is Interceptor;
218
211 accept(Visitor visitor) => visitor.visitInvokeMethod(this); 219 accept(Visitor visitor) => visitor.visitInvokeMethod(this);
212 } 220 }
213 221
214 /// Invoke a method, operator, getter, setter, or index getter/setter from the 222 /// Invoke a method, operator, getter, setter, or index getter/setter from the
215 /// super class in tail position. 223 /// super class in tail position.
216 class InvokeSuperMethod extends Expression implements Invoke { 224 class InvokeSuperMethod extends Expression implements Invoke {
217 final Selector selector; 225 final Selector selector;
218 final Reference<Continuation> continuation; 226 final Reference<Continuation> continuation;
219 final List<Reference<Primitive>> arguments; 227 final List<Reference<Primitive>> arguments;
220 228
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 456
449 class Identical extends Primitive { 457 class Identical extends Primitive {
450 final Reference<Primitive> left; 458 final Reference<Primitive> left;
451 final Reference<Primitive> right; 459 final Reference<Primitive> right;
452 Identical(Primitive left, Primitive right) 460 Identical(Primitive left, Primitive right)
453 : left = new Reference<Primitive>(left), 461 : left = new Reference<Primitive>(left),
454 right = new Reference<Primitive>(right); 462 right = new Reference<Primitive>(right);
455 accept(Visitor visitor) => visitor.visitIdentical(this); 463 accept(Visitor visitor) => visitor.visitIdentical(this);
456 } 464 }
457 465
466 class Interceptor extends Primitive {
467 final Reference<Primitive> input;
468 final Set<ClassElement> interceptedClasses;
469 Interceptor(Primitive input, this.interceptedClasses)
470 : this.input = new Reference<Primitive>(input);
471 accept(Visitor visitor) => visitor.visitInterceptor(this);
472 }
473
458 class Constant extends Primitive { 474 class Constant extends Primitive {
459 final ConstantExpression expression; 475 final ConstantExpression expression;
460 476
461 Constant(this.expression); 477 Constant(this.expression);
462 478
463 values.ConstantValue get value => expression.value; 479 values.ConstantValue get value => expression.value;
464 480
465 accept(Visitor visitor) => visitor.visitConstant(this); 481 accept(Visitor visitor) => visitor.visitConstant(this);
466 } 482 }
467 483
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 T visitGetClosureVariable(GetClosureVariable node) => visitPrimitive(node); 699 T visitGetClosureVariable(GetClosureVariable node) => visitPrimitive(node);
684 T visitParameter(Parameter node) => visitPrimitive(node); 700 T visitParameter(Parameter node) => visitPrimitive(node);
685 T visitContinuation(Continuation node) => visitDefinition(node); 701 T visitContinuation(Continuation node) => visitDefinition(node);
686 T visitClosureVariable(ClosureVariable node) => visitDefinition(node); 702 T visitClosureVariable(ClosureVariable node) => visitDefinition(node);
687 703
688 // Conditions. 704 // Conditions.
689 T visitIsTrue(IsTrue node) => visitCondition(node); 705 T visitIsTrue(IsTrue node) => visitCondition(node);
690 706
691 // JavaScript specific nodes. 707 // JavaScript specific nodes.
692 T visitIdentical(Identical node) => visitPrimitive(node); 708 T visitIdentical(Identical node) => visitPrimitive(node);
709 T visitInterceptor(Interceptor node) => visitPrimitive(node);
693 } 710 }
694 711
695 /// Recursively visits the entire CPS term, and calls abstract `process*` 712 /// Recursively visits the entire CPS term, and calls abstract `process*`
696 /// (i.e. `processLetPrim`) functions in pre-order. 713 /// (i.e. `processLetPrim`) functions in pre-order.
697 abstract class RecursiveVisitor extends Visitor { 714 abstract class RecursiveVisitor extends Visitor {
698 const RecursiveVisitor(); 715 const RecursiveVisitor();
699 716
700 // Ensures that RecursiveVisitor contains overrides for all relevant nodes. 717 // Ensures that RecursiveVisitor contains overrides for all relevant nodes.
701 // As a rule of thumb, nodes with structure to traverse should be overridden 718 // As a rule of thumb, nodes with structure to traverse should be overridden
702 // with the appropriate visits in this class (for example, visitLetCont), 719 // with the appropriate visits in this class (for example, visitLetCont),
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 processReference(node.value); 889 processReference(node.value);
873 } 890 }
874 891
875 // JavaScript specific nodes. 892 // JavaScript specific nodes.
876 processIdentical(Identical node) {} 893 processIdentical(Identical node) {}
877 visitIdentical(Identical node) { 894 visitIdentical(Identical node) {
878 processIdentical(node); 895 processIdentical(node);
879 processReference(node.left); 896 processReference(node.left);
880 processReference(node.right); 897 processReference(node.right);
881 } 898 }
899
900 processInterceptor(Interceptor node) {}
901 visitInterceptor(Interceptor node) {
902 processInterceptor(node);
903 processReference(node.input);
904 }
882 } 905 }
883 906
884 /// Keeps track of currently unused register indices. 907 /// Keeps track of currently unused register indices.
885 class RegisterArray { 908 class RegisterArray {
886 int nextIndex = 0; 909 int nextIndex = 0;
887 final List<int> freeStack = <int>[]; 910 final List<int> freeStack = <int>[];
888 911
889 /// Returns an index that is currently unused. 912 /// Returns an index that is currently unused.
890 int makeIndex() { 913 int makeIndex() {
891 if (freeStack.isEmpty) { 914 if (freeStack.isEmpty) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 void visitIsTrue(IsTrue node) { 1079 void visitIsTrue(IsTrue node) {
1057 visitReference(node.value); 1080 visitReference(node.value);
1058 } 1081 }
1059 1082
1060 // JavaScript specific nodes. 1083 // JavaScript specific nodes.
1061 1084
1062 void visitIdentical(Identical node) { 1085 void visitIdentical(Identical node) {
1063 visitReference(node.left); 1086 visitReference(node.left);
1064 visitReference(node.right); 1087 visitReference(node.right);
1065 } 1088 }
1089
1090 void visitInterceptor(Interceptor node) {
1091 visitReference(node.input);
1092 }
1066 } 1093 }
1067
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart » ('j') | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698