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

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: Handle union type masks and rename 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/type_mask_system.dart ('k') | pkg/compiler/lib/src/js_backend/backend.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..e55f6e2ee84c3acd466ddac677244220141fad3e 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -2248,8 +2248,13 @@ class TypePropagationVisitor implements Visitor {
}
void visitApplyBuiltinMethod(ApplyBuiltinMethod node) {
- // TODO(asgerf): For pop(), use the container type from the TypeMask.
- setValue(node, nonConstant());
+ AbstractValue receiver = getValue(node.receiver.definition);
+ if (node.method == BuiltinMethod.Pop) {
+ setValue(node, nonConstant(
+ typeSystem.elementTypeOfIndexable(receiver.type)));
+ } else {
+ setValue(node, nonConstant());
+ }
}
void visitInvokeMethodDirectly(InvokeMethodDirectly node) {
@@ -2482,12 +2487,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.elementTypeOfIndexable(input.type)));
}
@override
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_mask_system.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698