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

Side by Side Diff: runtime/vm/flow_graph_range_analysis.h

Issue 516013003: Address review comments for r39595. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/flow_graph_range_analysis.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) 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 VM_FLOW_GRAPH_RANGE_ANALYSIS_H_ 5 #ifndef VM_FLOW_GRAPH_RANGE_ANALYSIS_H_
6 #define VM_FLOW_GRAPH_RANGE_ANALYSIS_H_ 6 #define 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 Range Intersect(const Range* other) const { 418 Range Intersect(const Range* other) const {
419 return Range(RangeBoundary::IntersectionMin(min(), other->min()), 419 return Range(RangeBoundary::IntersectionMin(min(), other->min()),
420 RangeBoundary::IntersectionMax(max(), other->max())); 420 RangeBoundary::IntersectionMax(max(), other->max()));
421 } 421 }
422 422
423 bool Fits(RangeBoundary::RangeSize size) const { 423 bool Fits(RangeBoundary::RangeSize size) const {
424 return !min().LowerBound().Overflowed(size) && 424 return !min().LowerBound().Overflowed(size) &&
425 !max().UpperBound().Overflowed(size); 425 !max().UpperBound().Overflowed(size);
426 } 426 }
427 427
428 static bool Fits(Range* range, RangeBoundary::RangeSize size) {
429 return !IsUnknown(range) && range->Fits(size);
430 }
431
432 // Clamp this to be within size. 428 // Clamp this to be within size.
433 void Clamp(RangeBoundary::RangeSize size); 429 void Clamp(RangeBoundary::RangeSize size);
434 430
435 static void Add(const Range* left_range, 431 static void Add(const Range* left_range,
436 const Range* right_range, 432 const Range* right_range,
437 RangeBoundary* min, 433 RangeBoundary* min,
438 RangeBoundary* max, 434 RangeBoundary* max,
439 Definition* left_defn); 435 Definition* left_defn);
440 436
441 static void Sub(const Range* left_range, 437 static void Sub(const Range* left_range,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 const Range* right_range, 474 const Range* right_range,
479 Definition* left_defn, 475 Definition* left_defn,
480 Range* result); 476 Range* result);
481 477
482 private: 478 private:
483 RangeBoundary min_; 479 RangeBoundary min_;
484 RangeBoundary max_; 480 RangeBoundary max_;
485 }; 481 };
486 482
487 483
484 class RangeUtils : public AllStatic {
485 public:
486 static bool Fits(Range* range, RangeBoundary::RangeSize size) {
487 return !Range::IsUnknown(range) && range->Fits(size);
488 }
489
490 static bool IsWithin(Range* range, int64_t min, int64_t max) {
491 return !Range::IsUnknown(range) && range->IsWithin(min, max);
492 }
493 };
494
495
488 // Range analysis for integer values. 496 // Range analysis for integer values.
489 class RangeAnalysis : public ValueObject { 497 class RangeAnalysis : public ValueObject {
490 public: 498 public:
491 explicit RangeAnalysis(FlowGraph* flow_graph) 499 explicit RangeAnalysis(FlowGraph* flow_graph)
492 : flow_graph_(flow_graph), 500 : flow_graph_(flow_graph),
493 smi_range_(Range::Full(RangeBoundary::kRangeBoundarySmi)) { } 501 smi_range_(Range::Full(RangeBoundary::kRangeBoundarySmi)) { }
494 502
495 // Infer ranges for all values and remove overflow checks from binary smi 503 // Infer ranges for all values and remove overflow checks from binary smi
496 // operations when proven redundant. 504 // operations when proven redundant.
497 void Analyze(); 505 void Analyze();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 BitVector* selected_uint32_defs_; 630 BitVector* selected_uint32_defs_;
623 631
624 FlowGraph* flow_graph_; 632 FlowGraph* flow_graph_;
625 Isolate* isolate_; 633 Isolate* isolate_;
626 }; 634 };
627 635
628 636
629 } // namespace dart 637 } // namespace dart
630 638
631 #endif // VM_FLOW_GRAPH_RANGE_ANALYSIS_H_ 639 #endif // VM_FLOW_GRAPH_RANGE_ANALYSIS_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/flow_graph_range_analysis.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698