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

Unified Diff: pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart

Issue 1519513002: dart2js cps: Retain refinement nodes and update refinements after GVN. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Undo removed passes 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 | « pkg/compiler/lib/src/js_backend/codegen/task.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
diff --git a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
index 84c5200515ff58d2f8c9d1082a5874ac7c05177c..0f686a6c285d012f17bf5ef464ea6fd595e9f0fc 100644
--- a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
+++ b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
@@ -98,6 +98,7 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
/// Obtains the variable representing the given primitive. Returns null for
/// primitives that have no reference and do not need a variable.
Variable getVariable(cps_ir.Primitive primitive) {
+ primitive = primitive.effectiveDefinition;
return primitive2variable.putIfAbsent(primitive,
() => new Variable(currentElement, primitive.hint));
}
@@ -107,7 +108,8 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
/// This increments the reference count for the given variable, so the
/// returned expression must be used in the tree.
Expression getVariableUse(cps_ir.Reference<cps_ir.Primitive> reference) {
- if (thisParameter != null && reference.definition == thisParameter) {
+ if (thisParameter != null &&
+ reference.definition.effectiveDefinition == thisParameter) {
return new This();
}
return new VariableUse(getVariable(reference.definition));
@@ -452,7 +454,7 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
Expression visitGetField(cps_ir.GetField node) {
return new GetField(getVariableUse(node.object), node.field,
- objectIsNotNull: node.objectIsNotNull);
+ objectIsNotNull: !node.object.definition.type.isNullable);
sra1 2015/12/11 02:44:15 Explain why the refined type is not appropriate
asgerf 2015/12/11 10:18:18 It is the refined type.
}
Expression visitCreateBox(cps_ir.CreateBox node) {
@@ -553,7 +555,7 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
return new ApplyBuiltinMethod(node.method,
getVariableUse(node.receiver),
translateArguments(node.arguments),
- receiverIsNotNull: node.receiverIsNotNull);
+ receiverIsNotNull: !node.receiver.definition.type.isNullable);
}
Expression visitGetLength(cps_ir.GetLength node) {
@@ -584,7 +586,15 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
node.mask,
translateArguments(node.arguments),
node.sourceInformation);
- invoke.receiverIsNotNull = node.receiverIsNotNull;
+ // Sometimes we know the Dart receiver is non-null because it has been
+ // refined, which implies that the JS receiver also can not be null at the
+ // use-site. Interceptors are not refined, so this information is not
+ // always available on the JS receiver.
+ // Also check the JS receiver's type, however, because sometimes we know an
+ // interceptor is non-null because it intercepts JSNull.
+ invoke.receiverIsNotNull =
+ !node.dartReceiver.type.isNullable ||
+ !node.receiver.definition.type.isNullable;
return invoke;
}
@@ -662,8 +672,8 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ {
}
@override
- Expression visitRefinement(cps_ir.Refinement node) {
- throw 'Unexpected Refinement node in tree builder';
+ visitRefinement(cps_ir.Refinement node) {
+ return (Statement next) => next; // Compile to nothing.
}
/********** UNUSED VISIT METHODS *************/
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/task.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698