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

Unified Diff: pkg/compiler/lib/src/cps_ir/type_propagation.dart

Issue 1335933004: dart2js cps: Set a flag on InvokeMethod when the receiver is intercepted (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Also use getDartReceiver, getDartArgument in constant folding Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/unsugar.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
index 48581f00ae8d348eb4587c46bda506febe4db747..6f19c26f684f3fbb620d3b08ea4355af1f7fc930 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -719,10 +719,8 @@ class TransformingVisitor extends LeafVisitor {
}
if (node.selector.isOperator && node.arguments.length == 2) {
- // The operators we specialize are are intercepted calls, so the operands
- // are in the argument list.
- Primitive leftArg = node.arguments[0].definition;
- Primitive rightArg = node.arguments[1].definition;
+ Primitive leftArg = getDartReceiver(node);
+ Primitive rightArg = getDartArgument(node, 0);
AbstractValue left = getValue(leftArg);
AbstractValue right = getValue(rightArg);
@@ -794,7 +792,7 @@ class TransformingVisitor extends LeafVisitor {
}
Primitive getDartReceiver(InvokeMethod node) {
- if (isInterceptedSelector(node.selector)) {
+ if (node.receiverIsIntercepted) {
return node.arguments[0].definition;
} else {
return node.receiver.definition;
@@ -1475,7 +1473,7 @@ class TransformingVisitor extends LeafVisitor {
AbstractValue receiver = getValue(node.receiver.definition);
node.receiverIsNotNull = receiver.isDefinitelyNotNull;
- if (isInterceptedSelector(node.selector) &&
+ if (node.receiverIsIntercepted &&
node.receiver.definition.sameValue(node.arguments[0].definition)) {
// The receiver and first argument are the same; that means we already
// determined in visitInterceptor that we are targeting a non-interceptor.
@@ -1498,6 +1496,7 @@ class TransformingVisitor extends LeafVisitor {
insertLetPrim(node, dummy);
node.arguments[0].unlink();
node.arguments[0] = new Reference<Primitive>(dummy);
+ node.receiverIsIntercepted = false;
}
}
}
@@ -1994,6 +1993,26 @@ class TypePropagationVisitor implements Visitor {
defWorklist.add(node);
}
+ bool isInterceptedSelector(Selector selector) {
+ return backend.isInterceptedSelector(selector);
+ }
+
+ Primitive getDartReceiver(InvokeMethod node) {
+ if (node.receiverIsIntercepted) {
+ return node.arguments[0].definition;
+ } else {
+ return node.receiver.definition;
+ }
+ }
+
+ Primitive getDartArgument(InvokeMethod node, int n) {
+ if (isInterceptedSelector(node.selector)) {
+ return node.arguments[n+1].definition;
+ } else {
+ return node.arguments[n].definition;
+ }
+ }
+
// -------------------------- Visitor overrides ------------------------------
void visit(Node node) { node.accept(this); }
@@ -2128,11 +2147,10 @@ class TypePropagationVisitor implements Visitor {
}
// Calculate the resulting constant if possible.
- // Operators are intercepted, so the operands are in the argument list.
AbstractValue result;
String opname = node.selector.name;
if (node.arguments.length == 1) {
- AbstractValue argument = getValue(node.arguments[0].definition);
+ AbstractValue argument = getValue(getDartReceiver(node));
// Unary operator.
if (opname == "unary-") {
opname = "-";
@@ -2141,8 +2159,8 @@ class TypePropagationVisitor implements Visitor {
result = lattice.unaryOp(operator, argument);
} else if (node.arguments.length == 2) {
// Binary operator.
- AbstractValue left = getValue(node.arguments[0].definition);
- AbstractValue right = getValue(node.arguments[1].definition);
+ AbstractValue left = getValue(getDartReceiver(node));
+ AbstractValue right = getValue(getDartArgument(node, 0));
BinaryOperator operator = BinaryOperator.parse(opname);
result = lattice.binaryOp(operator, left, right);
}
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/unsugar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698