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

Side by Side Diff: test/unittests/compiler/live-range-builder.h

Issue 1305313008: [turbofan] Factored out the test live range builder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « test/unittests/compiler/coalesced-live-ranges-unittest.cc ('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
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_LIVE_RANGE_BUILDER_H_
6 #define V8_LIVE_RANGE_BUILDER_H_
7
8 #include "src/compiler/register-allocator.h"
9
10 namespace v8 {
11 namespace internal {
12 namespace compiler {
13
14
15 // Utility offering shorthand syntax for building up a range by providing its ID
16 // and pairs (start, end) specifying intervals. Circumvents current incomplete
17 // support for C++ features such as instantiation lists, on OS X and Android.
18 class TestRangeBuilder {
19 public:
20 explicit TestRangeBuilder(Zone* zone) : id_(-1), pairs_(), zone_(zone) {}
21
22 TestRangeBuilder& Id(int id) {
23 id_ = id;
24 return *this;
25 }
26 TestRangeBuilder& Add(int start, int end) {
27 pairs_.push_back({start, end});
28 return *this;
29 }
30
31 LiveRange* Build(int start, int end) { return Add(start, end).Build(); }
32
33 LiveRange* Build() {
34 TopLevelLiveRange* range =
35 new (zone_) TopLevelLiveRange(id_, MachineType::kRepTagged);
36 // Traverse the provided interval specifications backwards, because that is
37 // what LiveRange expects.
38 for (int i = static_cast<int>(pairs_.size()) - 1; i >= 0; --i) {
39 Interval pair = pairs_[i];
40 LifetimePosition start = LifetimePosition::FromInt(pair.first);
41 LifetimePosition end = LifetimePosition::FromInt(pair.second);
42 CHECK(start < end);
43 range->AddUseInterval(start, end, zone_);
44 }
45
46 pairs_.clear();
47 return range;
48 }
49
50 private:
51 typedef std::pair<int, int> Interval;
52 typedef std::vector<Interval> IntervalList;
53 int id_;
54 IntervalList pairs_;
55 Zone* zone_;
56 };
57
58
59 } // namespace compiler
60 } // namespace internal
61 } // namespace v8
62
63 #endif // V8_LIVE_RANGE_BUILDER_H_
OLDNEW
« no previous file with comments | « test/unittests/compiler/coalesced-live-ranges-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698