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

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

Issue 81623003: Use range information to omit checks in TRUNCDIV/MOD operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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') | 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/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_allocator.h" 10 #include "vm/flow_graph_allocator.h"
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 || !right_range->IsWithin(0, RangeBoundary::kPlusInfinity); 1107 || !right_range->IsWithin(0, RangeBoundary::kPlusInfinity);
1108 } 1108 }
1109 case Token::kSHL: { 1109 case Token::kSHL: {
1110 Range* right_range = this->right()->definition()->range(); 1110 Range* right_range = this->right()->definition()->range();
1111 if ((right_range != NULL) && is_truncating()) { 1111 if ((right_range != NULL) && is_truncating()) {
1112 // Can deoptimize if right can be negative. 1112 // Can deoptimize if right can be negative.
1113 return !right_range->IsWithin(0, RangeBoundary::kPlusInfinity); 1113 return !right_range->IsWithin(0, RangeBoundary::kPlusInfinity);
1114 } 1114 }
1115 return true; 1115 return true;
1116 } 1116 }
1117 case Token::kMOD: {
1118 Range* right_range = this->right()->definition()->range();
1119 return (right_range == NULL) || right_range->Overlaps(0, 0);
1120 }
1117 default: 1121 default:
1118 return overflow_; 1122 return overflow_;
1119 } 1123 }
1120 } 1124 }
1121 1125
1122 1126
1123 bool BinarySmiOpInstr::RightIsPowerOfTwoConstant() const { 1127 bool BinarySmiOpInstr::RightIsPowerOfTwoConstant() const {
1124 if (!right()->definition()->IsConstant()) return false; 1128 if (!right()->definition()->IsConstant()) return false;
1125 const Object& constant = right()->definition()->AsConstant()->value(); 1129 const Object& constant = right()->definition()->AsConstant()->value();
1126 if (!constant.IsSmi()) return false; 1130 if (!constant.IsSmi()) return false;
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 2683
2680 2684
2681 // Inclusive. 2685 // Inclusive.
2682 bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const { 2686 bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const {
2683 if (min().LowerBound().value() < min_int) return false; 2687 if (min().LowerBound().value() < min_int) return false;
2684 if (max().UpperBound().value() > max_int) return false; 2688 if (max().UpperBound().value() > max_int) return false;
2685 return true; 2689 return true;
2686 } 2690 }
2687 2691
2688 2692
2693 bool Range::Overlaps(intptr_t min_int, intptr_t max_int) const {
2694 const intptr_t this_min = min().LowerBound().value();
2695 const intptr_t this_max = max().UpperBound().value();
2696 if ((this_min <= min_int) && (min_int <= this_max)) return true;
2697 if ((this_min <= max_int) && (max_int <= this_max)) return true;
2698 if ((min_int < this_min) && (max_int > this_max)) return true;
2699 return false;
2700 }
2701
2702
2689 bool Range::IsUnsatisfiable() const { 2703 bool Range::IsUnsatisfiable() const {
2690 // Constant case: For example [0, -1]. 2704 // Constant case: For example [0, -1].
2691 if (Range::ConstantMin(this).value() > Range::ConstantMax(this).value()) { 2705 if (Range::ConstantMin(this).value() > Range::ConstantMax(this).value()) {
2692 return true; 2706 return true;
2693 } 2707 }
2694 // Symbol case: For example [v+1, v]. 2708 // Symbol case: For example [v+1, v].
2695 if (DependOnSameSymbol(min(), max()) && min().offset() > max().offset()) { 2709 if (DependOnSameSymbol(min(), max()) && min().offset() > max().offset()) {
2696 return true; 2710 return true;
2697 } 2711 }
2698 return false; 2712 return false;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2971 ASSERT((*inputs)[i] != NULL); 2985 ASSERT((*inputs)[i] != NULL);
2972 (*inputs)[i]->set_instruction(this); 2986 (*inputs)[i]->set_instruction(this);
2973 (*inputs)[i]->set_use_index(i); 2987 (*inputs)[i]->set_use_index(i);
2974 } 2988 }
2975 deopt_id_ = original_deopt_id; 2989 deopt_id_ = original_deopt_id;
2976 } 2990 }
2977 2991
2978 #undef __ 2992 #undef __
2979 2993
2980 } // namespace dart 2994 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698