| OLD | NEW |
| 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 #ifndef RUNTIME_VM_FLOW_GRAPH_RANGE_ANALYSIS_H_ | 5 #ifndef RUNTIME_VM_FLOW_GRAPH_RANGE_ANALYSIS_H_ |
| 6 #define RUNTIME_VM_FLOW_GRAPH_RANGE_ANALYSIS_H_ | 6 #define RUNTIME_VM_FLOW_GRAPH_RANGE_ANALYSIS_H_ |
| 7 | 7 |
| 8 #include "vm/flow_graph.h" | 8 #include "vm/flow_graph.h" |
| 9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 | 10 |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 } | 389 } |
| 390 | 390 |
| 391 bool Fits(RangeBoundary::RangeSize size) const { | 391 bool Fits(RangeBoundary::RangeSize size) const { |
| 392 return !min().LowerBound().Overflowed(size) && | 392 return !min().LowerBound().Overflowed(size) && |
| 393 !max().UpperBound().Overflowed(size); | 393 !max().UpperBound().Overflowed(size); |
| 394 } | 394 } |
| 395 | 395 |
| 396 // Clamp this to be within size. | 396 // Clamp this to be within size. |
| 397 void Clamp(RangeBoundary::RangeSize size); | 397 void Clamp(RangeBoundary::RangeSize size); |
| 398 | 398 |
| 399 // Clamp this to be within size and eliminate symbols. |
| 400 void ClampToConstant(RangeBoundary::RangeSize size); |
| 401 |
| 399 static void Add(const Range* left_range, | 402 static void Add(const Range* left_range, |
| 400 const Range* right_range, | 403 const Range* right_range, |
| 401 RangeBoundary* min, | 404 RangeBoundary* min, |
| 402 RangeBoundary* max, | 405 RangeBoundary* max, |
| 403 Definition* left_defn); | 406 Definition* left_defn); |
| 404 | 407 |
| 405 static void Sub(const Range* left_range, | 408 static void Sub(const Range* left_range, |
| 406 const Range* right_range, | 409 const Range* right_range, |
| 407 RangeBoundary* min, | 410 RangeBoundary* min, |
| 408 RangeBoundary* max, | 411 RangeBoundary* max, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 return !Range::IsUnknown(range) && range->Fits(size); | 465 return !Range::IsUnknown(range) && range->Fits(size); |
| 463 } | 466 } |
| 464 | 467 |
| 465 static bool IsWithin(Range* range, int64_t min, int64_t max) { | 468 static bool IsWithin(Range* range, int64_t min, int64_t max) { |
| 466 return !Range::IsUnknown(range) && range->IsWithin(min, max); | 469 return !Range::IsUnknown(range) && range->IsWithin(min, max); |
| 467 } | 470 } |
| 468 | 471 |
| 469 static bool IsPositive(Range* range) { | 472 static bool IsPositive(Range* range) { |
| 470 return !Range::IsUnknown(range) && range->IsPositive(); | 473 return !Range::IsUnknown(range) && range->IsPositive(); |
| 471 } | 474 } |
| 475 |
| 476 static bool Overlaps(Range* range, intptr_t min, intptr_t max) { |
| 477 return Range::IsUnknown(range) || range->Overlaps(min, max); |
| 478 } |
| 479 |
| 480 static bool CanBeZero(Range* range) { return Overlaps(range, 0, 0); } |
| 481 |
| 482 static bool OnlyLessThanOrEqualTo(Range* range, intptr_t value) { |
| 483 return !Range::IsUnknown(range) && range->OnlyLessThanOrEqualTo(value); |
| 484 } |
| 472 }; | 485 }; |
| 473 | 486 |
| 474 | 487 |
| 475 // Range analysis for integer values. | 488 // Range analysis for integer values. |
| 476 class RangeAnalysis : public ValueObject { | 489 class RangeAnalysis : public ValueObject { |
| 477 public: | 490 public: |
| 478 explicit RangeAnalysis(FlowGraph* flow_graph) | 491 explicit RangeAnalysis(FlowGraph* flow_graph) |
| 479 : flow_graph_(flow_graph), | 492 : flow_graph_(flow_graph), |
| 480 smi_range_(Range::Full(RangeBoundary::kRangeBoundarySmi)), | 493 smi_range_(Range::Full(RangeBoundary::kRangeBoundarySmi)), |
| 481 int64_range_(Range::Full(RangeBoundary::kRangeBoundaryInt64)) {} | 494 int64_range_(Range::Full(RangeBoundary::kRangeBoundaryInt64)) {} |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 BitVector* selected_uint32_defs_; | 634 BitVector* selected_uint32_defs_; |
| 622 | 635 |
| 623 FlowGraph* flow_graph_; | 636 FlowGraph* flow_graph_; |
| 624 Zone* zone_; | 637 Zone* zone_; |
| 625 }; | 638 }; |
| 626 | 639 |
| 627 | 640 |
| 628 } // namespace dart | 641 } // namespace dart |
| 629 | 642 |
| 630 #endif // RUNTIME_VM_FLOW_GRAPH_RANGE_ANALYSIS_H_ | 643 #endif // RUNTIME_VM_FLOW_GRAPH_RANGE_ANALYSIS_H_ |
| OLD | NEW |