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

Side by Side Diff: runtime/vm/flow_graph_range_analysis.cc

Issue 1434213005: VM: Fix imprecision in array bounds check elimination. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/compiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_range_analysis.h" 5 #include "vm/flow_graph_range_analysis.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/il_printer.h" 8 #include "vm/il_printer.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 3108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3119 ASSERT(!Range::IsUnknown(&range)); 3119 ASSERT(!Range::IsUnknown(&range));
3120 index()->definition()->set_range(range); 3120 index()->definition()->set_range(range);
3121 index_range = index()->definition()->range(); 3121 index_range = index()->definition()->range();
3122 } 3122 }
3123 3123
3124 // Range of the index is not positive. Check can't be redundant. 3124 // Range of the index is not positive. Check can't be redundant.
3125 if (Range::ConstantMinSmi(index_range).ConstantValue() < 0) { 3125 if (Range::ConstantMinSmi(index_range).ConstantValue() < 0) {
3126 return false; 3126 return false;
3127 } 3127 }
3128 3128
3129 RangeBoundary max = CanonicalizeBoundary( 3129 RangeBoundary max = RangeBoundary::FromDefinition(index()->definition());
3130 RangeBoundary::FromDefinition(index()->definition()),
3131 RangeBoundary::PositiveInfinity());
3132
3133 if (max.OverflowedSmi()) {
3134 return false;
3135 }
3136
3137 3130
3138 RangeBoundary max_upper = max.UpperBound(); 3131 RangeBoundary max_upper = max.UpperBound();
3139 RangeBoundary length_lower = length.LowerBound(); 3132 RangeBoundary length_lower = length.LowerBound();
3140 3133
3141 if (max_upper.OverflowedSmi() || length_lower.OverflowedSmi()) { 3134 if (max_upper.OverflowedSmi() || length_lower.OverflowedSmi()) {
3142 return false; 3135 return false;
3143 } 3136 }
3144 3137
3145 // Try to compare constant boundaries. 3138 // Try to compare constant boundaries.
3146 if (max_upper.ConstantValue() < length_lower.ConstantValue()) { 3139 if (max_upper.ConstantValue() < length_lower.ConstantValue()) {
(...skipping 13 matching lines...) Expand all
3160 } 3153 }
3161 } while (CanonicalizeMaxBoundary(&max) || 3154 } while (CanonicalizeMaxBoundary(&max) ||
3162 CanonicalizeMinBoundary(&canonical_length)); 3155 CanonicalizeMinBoundary(&canonical_length));
3163 3156
3164 // Failed to prove that maximum is bounded with array length. 3157 // Failed to prove that maximum is bounded with array length.
3165 return false; 3158 return false;
3166 } 3159 }
3167 3160
3168 3161
3169 } // namespace dart 3162 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698