From 2aaa4b5532d30c4e65d8892b556400bb61f9dc8c Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 17 Sep 2015 17:03:26 +0100 Subject: Optimizing: Tag more arena allocations. Replace GrowableArray with ArenaVector and tag arena allocations with new allocation types. As part of this, make the register allocator a bit more efficient, doing bulk insert/erase. Some loops are now O(n) instead of O(n^2). Change-Id: Ifac0871ffb34b121cc0447801a2d07eefd308c14 --- compiler/optimizing/locations.h | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'compiler/optimizing/locations.h') diff --git a/compiler/optimizing/locations.h b/compiler/optimizing/locations.h index 2162ab928b..2eeba18a4d 100644 --- a/compiler/optimizing/locations.h +++ b/compiler/optimizing/locations.h @@ -17,6 +17,7 @@ #ifndef ART_COMPILER_OPTIMIZING_LOCATIONS_H_ #define ART_COMPILER_OPTIMIZING_LOCATIONS_H_ +#include "base/arena_containers.h" #include "base/arena_object.h" #include "base/bit_field.h" #include "base/bit_vector.h" @@ -481,15 +482,17 @@ class LocationSummary : public ArenaObject { bool intrinsified = false); void SetInAt(uint32_t at, Location location) { - inputs_.Put(at, location); + DCHECK_LT(at, GetInputCount()); + inputs_[at] = location; } Location InAt(uint32_t at) const { - return inputs_.Get(at); + DCHECK_LT(at, GetInputCount()); + return inputs_[at]; } size_t GetInputCount() const { - return inputs_.Size(); + return inputs_.size(); } void SetOut(Location location, Location::OutputOverlap overlaps = Location::kOutputOverlap) { @@ -508,23 +511,25 @@ class LocationSummary : public ArenaObject { } void AddTemp(Location location) { - temps_.Add(location); + temps_.push_back(location); } Location GetTemp(uint32_t at) const { - return temps_.Get(at); + DCHECK_LT(at, GetTempCount()); + return temps_[at]; } void SetTempAt(uint32_t at, Location location) { - DCHECK(temps_.Get(at).IsUnallocated() || temps_.Get(at).IsInvalid()); - temps_.Put(at, location); + DCHECK_LT(at, GetTempCount()); + DCHECK(temps_[at].IsUnallocated() || temps_[at].IsInvalid()); + temps_[at] = location; } size_t GetTempCount() const { - return temps_.Size(); + return temps_.size(); } - bool HasTemps() const { return !temps_.IsEmpty(); } + bool HasTemps() const { return !temps_.empty(); } Location Out() const { return output_; } @@ -576,7 +581,7 @@ class LocationSummary : public ArenaObject { } bool IsFixedInput(uint32_t input_index) const { - Location input = inputs_.Get(input_index); + Location input = inputs_[input_index]; return input.IsRegister() || input.IsFpuRegister() || input.IsPair() @@ -593,8 +598,8 @@ class LocationSummary : public ArenaObject { } private: - GrowableArray inputs_; - GrowableArray temps_; + ArenaVector inputs_; + ArenaVector temps_; // Whether the output overlaps with any of the inputs. If it overlaps, then it cannot // share the same register as the inputs. Location::OutputOverlap output_overlaps_; -- cgit v1.2.3-59-g8ed1b