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

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

Issue 1340093002: dart2js cps: Use more precise type inference for direct index access. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove unused field 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
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..5175406317e0c9032dbd71510739852b2deb51ce 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -2482,12 +2482,21 @@ class TypePropagationVisitor implements Visitor {
@override
void visitGetLength(GetLength node) {
- setValue(node, nonConstant(typeSystem.intType));
+ AbstractValue input = getValue(node.object.definition);
+ int length = typeSystem.getContainerLength(input.type);
+ if (length != null) {
+ // TODO(asgerf): Constant-folding the length might degrade the VM's
+ // own bounds-check elimination?
+ setValue(node, constantValue(new IntConstantValue(length)));
+ } else {
+ setValue(node, nonConstant(typeSystem.intType));
+ }
}
@override
void visitGetIndex(GetIndex node) {
- setValue(node, nonConstant());
+ AbstractValue input = getValue(node.object.definition);
+ setValue(node, nonConstant(typeSystem.getIndexType(input.type)));
}
@override

Powered by Google App Engine
This is Rietveld 408576698