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

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

Issue 14566020: - Correctly handle negative constant indices when (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 2293 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 2304
2305 bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) { 2305 bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) {
2306 // Check that array has an immutable length. 2306 // Check that array has an immutable length.
2307 if (!IsFixedLengthArrayType(array_type())) { 2307 if (!IsFixedLengthArrayType(array_type())) {
2308 return false; 2308 return false;
2309 } 2309 }
2310 2310
2311 Range* index_range = index()->definition()->range(); 2311 Range* index_range = index()->definition()->range();
2312 2312
2313 // Range of the index is unknown can't decide if the check is redundant. 2313 // Range of the index is unknown can't decide if the check is redundant.
2314 if (index_range == NULL) return false; 2314 if (index_range == NULL) {
2315 return false;
2316 }
2315 2317
2316 // Range of the index is not positive. Check can't be redundant. 2318 // Range of the index is not positive. Check can't be redundant.
2317 if (Range::ConstantMin(index_range).value() < 0) return false; 2319 if (Range::ConstantMin(index_range).value() < 0) {
2320 return false;
2321 }
2318 2322
2319 RangeBoundary max = CanonicalizeBoundary(index_range->max(), 2323 RangeBoundary max = CanonicalizeBoundary(index_range->max(),
2320 RangeBoundary::OverflowedMaxSmi()); 2324 RangeBoundary::OverflowedMaxSmi());
2321 2325
2322 if (max.Overflowed()) return false; 2326 if (max.Overflowed()) {
2327 return false;
2328 }
2323 2329
2324 // Try to compare constant boundaries. 2330 // Try to compare constant boundaries.
2325 if (max.UpperBound().value() < length.LowerBound().value()) { 2331 if (max.UpperBound().value() < length.LowerBound().value()) {
2326 return true; 2332 return true;
2327 } 2333 }
2328 2334
2329 length = CanonicalizeBoundary(length, RangeBoundary::OverflowedMaxSmi()); 2335 length = CanonicalizeBoundary(length, RangeBoundary::OverflowedMaxSmi());
2330 if (length.Overflowed()) return false; 2336 if (length.Overflowed()) {
2337 return false;
2338 }
2331 2339
2332 // Try symbolic comparison. 2340 // Try symbolic comparison.
2333 do { 2341 do {
2334 if (DependOnSameSymbol(max, length)) return max.offset() < length.offset(); 2342 if (DependOnSameSymbol(max, length)) return max.offset() < length.offset();
2335 } while (CanonicalizeMaxBoundary(&max) || CanonicalizeMinBoundary(&length)); 2343 } while (CanonicalizeMaxBoundary(&max) || CanonicalizeMinBoundary(&length));
2336 2344
2337 // Failed to prove that maximum is bounded with array length. 2345 // Failed to prove that maximum is bounded with array length.
2338 return false; 2346 return false;
2339 } 2347 }
2340 2348
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 default: 2459 default:
2452 UNREACHABLE(); 2460 UNREACHABLE();
2453 } 2461 }
2454 return kPowRuntimeEntry; 2462 return kPowRuntimeEntry;
2455 } 2463 }
2456 2464
2457 2465
2458 #undef __ 2466 #undef __
2459 2467
2460 } // namespace dart 2468 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698