Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 3094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3105 OnlyNegativeOrZero(left_range, right_range) ? 0 : result_max; | 3105 OnlyNegativeOrZero(left_range, right_range) ? 0 : result_max; |
| 3106 max = RangeBoundary::FromConstant(r_max); | 3106 max = RangeBoundary::FromConstant(r_max); |
| 3107 break; | 3107 break; |
| 3108 } | 3108 } |
| 3109 } | 3109 } |
| 3110 if (range_ == NULL) { | 3110 if (range_ == NULL) { |
| 3111 range_ = Range::Unknown(); | 3111 range_ = Range::Unknown(); |
| 3112 } | 3112 } |
| 3113 return; | 3113 return; |
| 3114 } | 3114 } |
| 3115 case Token::kSHL: { | |
| 3116 Range::Shl(left_range, right_range, &min, &max); | |
| 3117 break; | |
| 3118 } | |
| 3115 case Token::kBIT_AND: | 3119 case Token::kBIT_AND: |
| 3116 if (Range::ConstantMin(right_range).value() >= 0) { | 3120 if (Range::ConstantMin(right_range).value() >= 0) { |
| 3117 min = RangeBoundary::FromConstant(0); | 3121 min = RangeBoundary::FromConstant(0); |
| 3118 max = Range::ConstantMax(right_range); | 3122 max = Range::ConstantMax(right_range); |
| 3119 break; | 3123 break; |
| 3120 } | 3124 } |
| 3121 if (Range::ConstantMin(left_range).value() >= 0) { | 3125 if (Range::ConstantMin(left_range).value() >= 0) { |
| 3122 min = RangeBoundary::FromConstant(0); | 3126 min = RangeBoundary::FromConstant(0); |
| 3123 max = Range::ConstantMax(left_range); | 3127 max = Range::ConstantMax(left_range); |
| 3124 break; | 3128 break; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3229 return true; | 3233 return true; |
| 3230 } | 3234 } |
| 3231 // Symbol case: For example [v+1, v]. | 3235 // Symbol case: For example [v+1, v]. |
| 3232 if (DependOnSameSymbol(min(), max()) && min().offset() > max().offset()) { | 3236 if (DependOnSameSymbol(min(), max()) && min().offset() > max().offset()) { |
| 3233 return true; | 3237 return true; |
| 3234 } | 3238 } |
| 3235 return false; | 3239 return false; |
| 3236 } | 3240 } |
| 3237 | 3241 |
| 3238 | 3242 |
| 3243 void Range::Shl(Range* left, | |
| 3244 Range* right, | |
| 3245 RangeBoundary* result_min, | |
| 3246 RangeBoundary* result_max) { | |
| 3247 RangeBoundary left_max = Range::ConstantMax(left); | |
| 3248 RangeBoundary left_min = Range::ConstantMin(left); | |
| 3249 // Ignore negative values of shift count because shift by a negative shift | |
| 3250 // count does give a result. | |
| 3251 intptr_t right_max = Range::ConstantMax(right).value() > 0 | |
|
Vyacheslav Egorov (Google)
2014/06/12 14:59:00
Can be written as Max(Range::ConstantMax(right).va
Florian Schneider
2014/06/12 15:12:42
Done.
| |
| 3252 ? Range::ConstantMax(right).value() : 0; | |
| 3253 intptr_t right_min = Range::ConstantMin(right).value() > 0 | |
|
Vyacheslav Egorov (Google)
2014/06/12 14:59:00
ditto
Florian Schneider
2014/06/12 15:12:42
Done.
| |
| 3254 ? Range::ConstantMin(right).value() : 0; | |
| 3255 | |
| 3256 *result_min = RangeBoundary::Shl( | |
| 3257 left_min, | |
| 3258 left_min.value() > 0 ? right_min : right_max, | |
| 3259 left_min.value() > 0 | |
| 3260 ? RangeBoundary::PositiveInfinity() | |
| 3261 : RangeBoundary::NegativeInfinity()); | |
| 3262 | |
| 3263 *result_max = RangeBoundary::Shl( | |
| 3264 left_max, | |
| 3265 left_max.value() > 0 ? right_max : right_min, | |
| 3266 left_max.value() > 0 | |
| 3267 ? RangeBoundary::PositiveInfinity() | |
| 3268 : RangeBoundary::NegativeInfinity()); | |
| 3269 } | |
| 3270 | |
| 3271 | |
| 3239 bool CheckArrayBoundInstr::IsFixedLengthArrayType(intptr_t cid) { | 3272 bool CheckArrayBoundInstr::IsFixedLengthArrayType(intptr_t cid) { |
| 3240 return LoadFieldInstr::IsFixedLengthArrayCid(cid); | 3273 return LoadFieldInstr::IsFixedLengthArrayCid(cid); |
| 3241 } | 3274 } |
| 3242 | 3275 |
| 3243 | 3276 |
| 3244 bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) { | 3277 bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) { |
| 3245 Range* index_range = index()->definition()->range(); | 3278 Range* index_range = index()->definition()->range(); |
| 3246 | 3279 |
| 3247 // Range of the index is unknown can't decide if the check is redundant. | 3280 // Range of the index is unknown can't decide if the check is redundant. |
| 3248 if (index_range == NULL) { | 3281 if (index_range == NULL) { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3561 case Token::kTRUNCDIV: return 0; | 3594 case Token::kTRUNCDIV: return 0; |
| 3562 case Token::kMOD: return 1; | 3595 case Token::kMOD: return 1; |
| 3563 default: UNIMPLEMENTED(); return -1; | 3596 default: UNIMPLEMENTED(); return -1; |
| 3564 } | 3597 } |
| 3565 } | 3598 } |
| 3566 | 3599 |
| 3567 | 3600 |
| 3568 #undef __ | 3601 #undef __ |
| 3569 | 3602 |
| 3570 } // namespace dart | 3603 } // namespace dart |
| OLD | NEW |