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

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

Issue 11665005: Support scalar lists in array bounds check elimination. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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/intermediate_language.h ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 2493
2494 void LoadFieldInstr::InferRange() { 2494 void LoadFieldInstr::InferRange() {
2495 if ((range_ == NULL) && 2495 if ((range_ == NULL) &&
2496 ((recognized_kind() == MethodRecognizer::kObjectArrayLength) || 2496 ((recognized_kind() == MethodRecognizer::kObjectArrayLength) ||
2497 (recognized_kind() == MethodRecognizer::kImmutableArrayLength))) { 2497 (recognized_kind() == MethodRecognizer::kImmutableArrayLength))) {
2498 range_ = new Range(RangeBoundary::FromConstant(0), 2498 range_ = new Range(RangeBoundary::FromConstant(0),
2499 RangeBoundary::FromConstant(Array::kMaxElements)); 2499 RangeBoundary::FromConstant(Array::kMaxElements));
2500 return; 2500 return;
2501 } 2501 }
2502 if ((range_ == NULL) && 2502 if ((range_ == NULL) &&
2503 (recognized_kind() == MethodRecognizer::kByteArrayBaseLength)) {
2504 range_ = new Range(RangeBoundary::FromConstant(0), RangeBoundary::MaxSmi());
2505 return;
2506 }
2507 if ((range_ == NULL) &&
2503 (recognized_kind() == MethodRecognizer::kStringBaseLength)) { 2508 (recognized_kind() == MethodRecognizer::kStringBaseLength)) {
2504 range_ = new Range(RangeBoundary::FromConstant(0), 2509 range_ = new Range(RangeBoundary::FromConstant(0),
2505 RangeBoundary::FromConstant(String::kMaxElements)); 2510 RangeBoundary::FromConstant(String::kMaxElements));
2506 return; 2511 return;
2507 } 2512 }
2508 Definition::InferRange(); 2513 Definition::InferRange();
2509 } 2514 }
2510 2515
2511 2516
2512 2517
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 2712
2708 2713
2709 // Inclusive. 2714 // Inclusive.
2710 bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const { 2715 bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const {
2711 if (min().LowerBound().value() < min_int) return false; 2716 if (min().LowerBound().value() < min_int) return false;
2712 if (max().UpperBound().value() > max_int) return false; 2717 if (max().UpperBound().value() > max_int) return false;
2713 return true; 2718 return true;
2714 } 2719 }
2715 2720
2716 2721
2722 bool CheckArrayBoundInstr::IsFixedLengthArrayType(intptr_t cid) {
2723 switch (cid) {
2724 case kArrayCid:
2725 case kImmutableArrayCid:
2726 case kInt8ArrayCid:
2727 case kUint8ArrayCid:
2728 case kInt16ArrayCid:
2729 case kUint16ArrayCid:
2730 case kInt32ArrayCid:
2731 case kUint32ArrayCid:
2732 case kInt64ArrayCid:
2733 case kUint64ArrayCid:
2734 case kFloat32ArrayCid:
2735 case kFloat64ArrayCid:
Vyacheslav Egorov (Google) 2013/01/07 11:47:09 Make sure that LengthOffsetFor can return offset f
Florian Schneider 2013/01/07 14:24:49 Done. Changed LengthOffsetFor to handle the same a
2736 return true;
2737 default:
2738 return false;
2739 }
2740 }
2741
2742
2717 bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) { 2743 bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) {
2718 // Check that array has an immutable length. 2744 // Check that array has an immutable length.
2719 if ((array_type() != kArrayCid) && (array_type() != kImmutableArrayCid)) { 2745 if (!IsFixedLengthArrayType(array_type())) {
2720 return false; 2746 return false;
2721 } 2747 }
2722 2748
2723 Range* index_range = index()->definition()->range(); 2749 Range* index_range = index()->definition()->range();
2724 2750
2725 // Range of the index is unknown can't decide if the check is redundant. 2751 // Range of the index is unknown can't decide if the check is redundant.
2726 if (index_range == NULL) return false; 2752 if (index_range == NULL) return false;
2727 2753
2728 // Range of the index is not positive. Check can't be redundant. 2754 // Range of the index is not positive. Check can't be redundant.
2729 if (Range::ConstantMin(index_range).value() < 0) return false; 2755 if (Range::ConstantMin(index_range).value() < 0) return false;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 default: 2798 default:
2773 UNREACHABLE(); 2799 UNREACHABLE();
2774 return -1; 2800 return -1;
2775 } 2801 }
2776 } 2802 }
2777 2803
2778 2804
2779 #undef __ 2805 #undef __
2780 2806
2781 } // namespace dart 2807 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698