diff --git a/test/unittests/compiler/coalesced-live-ranges-unittest.cc b/test/unittests/compiler/coalesced-live-ranges-unittest.cc index e728c9ff64..fe8fac4bfe 100644 --- a/test/unittests/compiler/coalesced-live-ranges-unittest.cc +++ b/test/unittests/compiler/coalesced-live-ranges-unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "src/compiler/coalesced-live-ranges.h" +#include "test/unittests/compiler/live-range-builder.h" #include "test/unittests/test-utils.h" namespace v8 { @@ -10,50 +11,6 @@ namespace internal { namespace compiler { -// Utility offering shorthand syntax for building up a range by providing its ID -// and pairs (start, end) specifying intervals. Circumvents current incomplete -// support for C++ features such as instantiation lists, on OS X and Android. -class TestRangeBuilder { - public: - explicit TestRangeBuilder(Zone* zone) : id_(-1), pairs_(), zone_(zone) {} - - TestRangeBuilder& Id(int id) { - id_ = id; - return *this; - } - TestRangeBuilder& Add(int start, int end) { - pairs_.push_back({start, end}); - return *this; - } - - LiveRange* Build(int start, int end) { return Add(start, end).Build(); } - - LiveRange* Build() { - TopLevelLiveRange* range = - new (zone_) TopLevelLiveRange(id_, MachineType::kRepTagged); - // Traverse the provided interval specifications backwards, because that is - // what LiveRange expects. - for (int i = static_cast(pairs_.size()) - 1; i >= 0; --i) { - Interval pair = pairs_[i]; - LifetimePosition start = LifetimePosition::FromInt(pair.first); - LifetimePosition end = LifetimePosition::FromInt(pair.second); - CHECK(start < end); - range->AddUseInterval(start, end, zone_); - } - - pairs_.clear(); - return range; - } - - private: - typedef std::pair Interval; - typedef std::vector IntervalList; - int id_; - IntervalList pairs_; - Zone* zone_; -}; - - class CoalescedLiveRangesTest : public TestWithZone { public: CoalescedLiveRangesTest() : TestWithZone(), ranges_(zone()) {} diff --git a/test/unittests/compiler/live-range-builder.h b/test/unittests/compiler/live-range-builder.h new file mode 100644 index 0000000000..988716d8eb --- /dev/null +++ b/test/unittests/compiler/live-range-builder.h @@ -0,0 +1,63 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_LIVE_RANGE_BUILDER_H_ +#define V8_LIVE_RANGE_BUILDER_H_ + +#include "src/compiler/register-allocator.h" + +namespace v8 { +namespace internal { +namespace compiler { + + +// Utility offering shorthand syntax for building up a range by providing its ID +// and pairs (start, end) specifying intervals. Circumvents current incomplete +// support for C++ features such as instantiation lists, on OS X and Android. +class TestRangeBuilder { + public: + explicit TestRangeBuilder(Zone* zone) : id_(-1), pairs_(), zone_(zone) {} + + TestRangeBuilder& Id(int id) { + id_ = id; + return *this; + } + TestRangeBuilder& Add(int start, int end) { + pairs_.push_back({start, end}); + return *this; + } + + LiveRange* Build(int start, int end) { return Add(start, end).Build(); } + + LiveRange* Build() { + TopLevelLiveRange* range = + new (zone_) TopLevelLiveRange(id_, MachineType::kRepTagged); + // Traverse the provided interval specifications backwards, because that is + // what LiveRange expects. + for (int i = static_cast(pairs_.size()) - 1; i >= 0; --i) { + Interval pair = pairs_[i]; + LifetimePosition start = LifetimePosition::FromInt(pair.first); + LifetimePosition end = LifetimePosition::FromInt(pair.second); + CHECK(start < end); + range->AddUseInterval(start, end, zone_); + } + + pairs_.clear(); + return range; + } + + private: + typedef std::pair Interval; + typedef std::vector IntervalList; + int id_; + IntervalList pairs_; + Zone* zone_; +}; + + +} // namespace compiler +} // namespace internal +} // namespace v8 + +#endif // V8_LIVE_RANGE_BUILDER_H_