From 9ed88f17899169df19d09d0e73968d7c599b0624 Mon Sep 17 00:00:00 2001 From: mstarzinger Date: Fri, 5 Dec 2014 05:04:29 -0800 Subject: [PATCH] Switch two ZoneLists to ZoneVector in register allocator. R=dcarney@chromium.org Review URL: https://codereview.chromium.org/778093003 Cr-Commit-Position: refs/heads/master@{#25682} --- src/compiler/register-allocator.cc | 21 +++++++++------------ src/compiler/register-allocator.h | 6 +++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/compiler/register-allocator.cc b/src/compiler/register-allocator.cc index 6c67ff4..88732f9 100644 --- a/src/compiler/register-allocator.cc +++ b/src/compiler/register-allocator.cc @@ -567,9 +567,7 @@ RegisterAllocator::RegisterAllocator(const RegisterConfiguration* config, void RegisterAllocator::InitializeLivenessAnalysis() { // Initialize the live_in sets for each block to NULL. - int block_count = code()->InstructionBlockCount(); - live_in_sets_.Initialize(block_count, local_zone()); - live_in_sets_.AddBlock(NULL, block_count, local_zone()); + std::fill(live_in_sets_.begin(), live_in_sets_.end(), nullptr); } @@ -583,7 +581,7 @@ BitVector* RegisterAllocator::ComputeLiveOut(const InstructionBlock* block) { for (auto succ : block->successors()) { // Add values live on entry to the successor. Note the successor's // live_in will not be computed yet for backwards edges. - BitVector* live_in = live_in_sets_[static_cast(succ.ToSize())]; + BitVector* live_in = live_in_sets_[succ.ToSize()]; if (live_in != NULL) live_out->Union(*live_in); // All phi input operands corresponding to this successor edge are live @@ -683,9 +681,8 @@ LiveRange* RegisterAllocator::FixedDoubleLiveRangeFor(int index) { LiveRange* RegisterAllocator::LiveRangeFor(int index) { - if (index >= live_ranges_.length()) { - live_ranges_.AddBlock(NULL, index - live_ranges_.length() + 1, - local_zone()); + if (index >= static_cast(live_ranges_.size())) { + live_ranges_.resize(index + 1, NULL); } LiveRange* result = live_ranges_[index]; if (result == NULL) { @@ -1328,7 +1325,7 @@ const InstructionBlock* RegisterAllocator::GetInstructionBlock( void RegisterAllocator::ConnectRanges() { - for (int i = 0; i < live_ranges().length(); ++i) { + for (size_t i = 0; i < live_ranges().size(); ++i) { LiveRange* first_range = live_ranges().at(i); if (first_range == NULL || first_range->parent() != NULL) continue; @@ -1474,7 +1471,7 @@ class LiveRangeFinder { public: explicit LiveRangeFinder(const RegisterAllocator& allocator) : allocator_(allocator), - bounds_length_(allocator.live_ranges().length()), + bounds_length_(static_cast(allocator.live_ranges().size())), bounds_(allocator.local_zone()->NewArray( bounds_length_)) { for (int i = 0; i < bounds_length_; ++i) { @@ -1645,7 +1642,7 @@ void RegisterAllocator::BuildLiveRanges() { } } - for (int i = 0; i < live_ranges_.length(); ++i) { + for (size_t i = 0; i < live_ranges_.size(); ++i) { if (live_ranges_[i] != NULL) { live_ranges_[i]->kind_ = RequiredRegisterKind(live_ranges_[i]->id()); @@ -1715,7 +1712,7 @@ void RegisterAllocator::PopulatePointerMaps() { int last_range_start = 0; const PointerMapDeque* pointer_maps = code()->pointer_maps(); PointerMapDeque::const_iterator first_it = pointer_maps->begin(); - for (int range_idx = 0; range_idx < live_ranges().length(); ++range_idx) { + for (size_t range_idx = 0; range_idx < live_ranges().size(); ++range_idx) { LiveRange* range = live_ranges().at(range_idx); if (range == NULL) continue; // Iterate over the first parts of multi-part live ranges. @@ -1806,7 +1803,7 @@ void RegisterAllocator::AllocateDoubleRegisters() { void RegisterAllocator::AllocateRegisters() { DCHECK(unhandled_live_ranges_.is_empty()); - for (int i = 0; i < live_ranges_.length(); ++i) { + for (size_t i = 0; i < live_ranges_.size(); ++i) { if (live_ranges_[i] != NULL) { if (live_ranges_[i]->Kind() == mode_) { AddToUnhandledUnsorted(live_ranges_[i]); diff --git a/src/compiler/register-allocator.h b/src/compiler/register-allocator.h index fe5aa73..504cdb2 100644 --- a/src/compiler/register-allocator.h +++ b/src/compiler/register-allocator.h @@ -357,7 +357,7 @@ class RegisterAllocator FINAL : public ZoneObject { bool AllocationOk() { return allocation_ok_; } - const ZoneList& live_ranges() const { return live_ranges_; } + const ZoneVector& live_ranges() const { return live_ranges_; } const ZoneVector& fixed_live_ranges() const { return fixed_live_ranges_; } @@ -555,10 +555,10 @@ class RegisterAllocator FINAL : public ZoneObject { // During liveness analysis keep a mapping from block id to live_in sets // for blocks already analyzed. - ZoneList live_in_sets_; + ZoneVector live_in_sets_; // Liveness analysis results. - ZoneList live_ranges_; + ZoneVector live_ranges_; // Lists of live ranges ZoneVector fixed_live_ranges_; -- 2.7.4