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

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

Issue 1528673002: Constant-fold fields of constant objects. (Closed) Base URL: https://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 8b84164da0896717dcda1a727256fb4c7a793361..86333da6aefa5eb09a5014b6ed2849cf40533e98 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -3141,10 +3141,18 @@ class TypePropagationVisitor implements Visitor {
AbstractConstantValue object = getValue(node.object.definition);
if (object.isNothing || object.isNullConstant) {
setValue(node, nothing);
- } else {
- node.objectIsNotNull = object.isDefinitelyNotNull;
- setValue(node, lattice.fromMask(typeSystem.getFieldType(node.field)));
+ return;
+ }
+ node.objectIsNotNull = object.isDefinitelyNotNull;
+ if (object.isConstant && object.constant.isConstructedObject) {
+ ConstructedConstantValue constructedConstant = object.constant;
+ ConstantValue value = constructedConstant.fields[node.field];
+ if (value != null) {
+ setValue(node, constantValue(value));
+ return;
+ }
}
+ setValue(node, lattice.fromMask(typeSystem.getFieldType(node.field)));
}
void visitSetField(SetField 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