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

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

Issue 1515833003: dart2js: Do not eliminate calls whose receiver can be null. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | 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 f558d756a785c5aa8beff40962ed29cb35233c34..f716f05e023f7479bd72b9f731accc4b9f2a9dcb 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -2643,16 +2643,15 @@ class TypePropagationVisitor implements Visitor {
AbstractConstantValue receiver = getValue(node.receiver.definition);
node.receiverIsNotNull = receiver.isDefinitelyNotNull;
if (receiver.isNothing) {
- setResult(node, lattice.nothing);
- return; // And come back later.
+ return setResult(node, lattice.nothing);
}
- void finish(AbstractConstantValue result) {
+ void finish(AbstractConstantValue result, {bool canReplace: false}) {
if (result == null) {
- setResult(node, lattice.getInvokeReturnType(node.selector, node.mask));
- } else {
- setResult(node, result, canReplace: true);
+ canReplace = false;
+ result = lattice.getInvokeReturnType(node.selector, node.mask);
}
+ setResult(node, result, canReplace: canReplace);
}
if (node.selector.isGetter) {
@@ -2661,42 +2660,34 @@ class TypePropagationVisitor implements Visitor {
AbstractConstantValue object = getValue(node.dartReceiver);
if (typeSystem.isDefinitelyIndexable(object.type, allowNull: true)) {
AbstractConstantValue length = lattice.lengthSpecial(object);
- if (length != null) {
- setResult(node, length, canReplace: !object.isNullable);
- return;
- }
+ return finish(length, canReplace: !object.isNullable);
}
}
- finish(null);
- return;
+ return finish(null);
}
if (node.selector.isCall) {
- AbstractConstantValue result;
if (node.selector == Selectors.codeUnitAt) {
AbstractConstantValue object = getValue(node.dartReceiver);
AbstractConstantValue right = getValue(node.dartArgument(0));
- result = lattice.codeUnitAtSpecial(object, right);
+ AbstractConstantValue result = lattice.codeUnitAtSpecial(object, right);
+ return finish(result, canReplace: !object.isNullable);
}
- finish(result);
- return;
+ return finish(null);
}
if (node.selector == Selectors.index) {
AbstractConstantValue object = getValue(node.dartReceiver);
AbstractConstantValue right = getValue(node.dartArgument(0));
AbstractConstantValue result = lattice.indexSpecial(object, right);
- finish(result);
- return;
+ return finish(result, canReplace: !object.isNullable);
}
if (!node.selector.isOperator) {
- finish(null);
- return;
+ return finish(null);
}
// Calculate the resulting constant if possible.
- AbstractConstantValue result;
String opname = node.selector.name;
if (node.arguments.length == 1) {
AbstractConstantValue argument = getValue(node.dartReceiver);
@@ -2705,15 +2696,17 @@ class TypePropagationVisitor implements Visitor {
opname = "-";
}
UnaryOperator operator = UnaryOperator.parse(opname);
- result = lattice.unaryOp(operator, argument);
+ AbstractConstantValue result = lattice.unaryOp(operator, argument);
+ return finish(result, canReplace: !argument.isNullable);
} else if (node.arguments.length == 2) {
// Binary operator.
AbstractConstantValue left = getValue(node.dartReceiver);
AbstractConstantValue right = getValue(node.dartArgument(0));
BinaryOperator operator = BinaryOperator.parse(opname);
- result = lattice.binaryOp(operator, left, right);
+ AbstractConstantValue result = lattice.binaryOp(operator, left, right);
+ return finish(result, canReplace: !left.isNullable);
}
- finish(result);
+ return finish(null);
}
void visitApplyBuiltinOperator(ApplyBuiltinOperator node) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698