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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/optimize.dart

Issue 24680006: Fix list length optimization bug: do not inline a length access to a constant if the receiver can b… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « no previous file | tests/language/list_length_tracer_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/optimize.dart (revision 27940)
+++ sdk/lib/_internal/compiler/implementation/ssa/optimize.dart (working copy)
@@ -694,7 +694,17 @@
} else {
var type = receiver.instructionType.computeMask(compiler);
if (type.isContainer && type.length != null) {
- return graph.addConstantInt(type.length, compiler);
+ HInstruction constant = graph.addConstantInt(type.length, compiler);
+ if (type.isNullable) {
+ // If the container can be null, we update all uses of the
+ // length access to use the constant instead, but keep the
+ // length access in the graph, to ensure we still have a
+ // null check.
+ node.block.rewrite(node, constant);
+ return node;
+ } else {
+ return constant;
+ }
}
}
}
« no previous file with comments | « no previous file | tests/language/list_length_tracer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698