diff options
author | 2015-09-02 14:05:49 +0100 | |
---|---|---|
committer | 2015-09-02 20:16:58 +0100 | |
commit | f9f6441c665b5ff9004d3ed55014f46d416fb1bb (patch) | |
tree | 3d66a0b44e1ac927156eec6e6488de5fd52b982b /compiler/optimizing/nodes.h | |
parent | fe3879e6011f629d0dd6b04fab00b9496bd4ea08 (diff) |
Optimizing: Tag Arena allocations with their source.
This adds the ability to track where we allocate memory
when the kArenaAllocatorCountAllocations flag is turned on.
Also move some allocations from native heap to the Arena
and remove some unnecessary utilities.
Bug: 23736311
Change-Id: I1aaef3fd405d1de444fe9e618b1ce7ecef07ade3
Diffstat (limited to 'compiler/optimizing/nodes.h')
-rw-r--r-- | compiler/optimizing/nodes.h | 93 |
1 files changed, 38 insertions, 55 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 2ed2d9ab20..ee82fda6c8 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -17,6 +17,7 @@ #ifndef ART_COMPILER_OPTIMIZING_NODES_H_ #define ART_COMPILER_OPTIMIZING_NODES_H_ +#include <array> #include <type_traits> #include "base/arena_containers.h" @@ -81,7 +82,7 @@ enum IfCondition { kCondGE, }; -class HInstructionList { +class HInstructionList : public ValueObject { public: HInstructionList() : first_instruction_(nullptr), last_instruction_(nullptr) {} @@ -127,7 +128,7 @@ class HInstructionList { }; // Control-flow graph of a method. Contains a list of basic blocks. -class HGraph : public ArenaObject<kArenaAllocMisc> { +class HGraph : public ArenaObject<kArenaAllocGraph> { public: HGraph(ArenaAllocator* arena, const DexFile& dex_file, @@ -464,7 +465,7 @@ class HGraph : public ArenaObject<kArenaAllocMisc> { DISALLOW_COPY_AND_ASSIGN(HGraph); }; -class HLoopInformation : public ArenaObject<kArenaAllocMisc> { +class HLoopInformation : public ArenaObject<kArenaAllocLoopInfo> { public: HLoopInformation(HBasicBlock* header, HGraph* graph) : header_(header), @@ -562,7 +563,7 @@ class HLoopInformation : public ArenaObject<kArenaAllocMisc> { // Stores try/catch information for basic blocks. // Note that HGraph is constructed so that catch blocks cannot simultaneously // be try blocks. -class TryCatchInformation : public ArenaObject<kArenaAllocMisc> { +class TryCatchInformation : public ArenaObject<kArenaAllocTryCatchInfo> { public: // Try block information constructor. explicit TryCatchInformation(const HTryBoundary& try_entry) @@ -619,7 +620,7 @@ static constexpr uint32_t kNoDexPc = -1; // as a double linked list. Each block knows its predecessors and // successors. -class HBasicBlock : public ArenaObject<kArenaAllocMisc> { +class HBasicBlock : public ArenaObject<kArenaAllocBasicBlock> { public: explicit HBasicBlock(HGraph* graph, uint32_t dex_pc = kNoDexPc) : graph_(graph), @@ -1107,7 +1108,7 @@ FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) template <typename T> class HUseList; template <typename T> -class HUseListNode : public ArenaObject<kArenaAllocMisc> { +class HUseListNode : public ArenaObject<kArenaAllocUseListNode> { public: HUseListNode* GetPrevious() const { return prev_; } HUseListNode* GetNext() const { return next_; } @@ -1492,7 +1493,7 @@ class SideEffects : public ValueObject { }; // A HEnvironment object contains the values of virtual registers at a given location. -class HEnvironment : public ArenaObject<kArenaAllocMisc> { +class HEnvironment : public ArenaObject<kArenaAllocEnvironment> { public: HEnvironment(ArenaAllocator* arena, size_t number_of_vregs, @@ -1682,7 +1683,7 @@ class ReferenceTypeInfo : ValueObject { std::ostream& operator<<(std::ostream& os, const ReferenceTypeInfo& rhs); -class HInstruction : public ArenaObject<kArenaAllocMisc> { +class HInstruction : public ArenaObject<kArenaAllocInstruction> { public: explicit HInstruction(SideEffects side_effects) : previous_(nullptr), @@ -2038,72 +2039,54 @@ class HBackwardInstructionIterator : public ValueObject { DISALLOW_COPY_AND_ASSIGN(HBackwardInstructionIterator); }; -// An embedded container with N elements of type T. Used (with partial -// specialization for N=0) because embedded arrays cannot have size 0. -template<typename T, intptr_t N> -class EmbeddedArray { +template<size_t N> +class HTemplateInstruction: public HInstruction { public: - EmbeddedArray() : elements_() {} - - intptr_t GetLength() const { return N; } - - const T& operator[](intptr_t i) const { - DCHECK_LT(i, GetLength()); - return elements_[i]; - } + HTemplateInstruction<N>(SideEffects side_effects) + : HInstruction(side_effects), inputs_() {} + virtual ~HTemplateInstruction() {} - T& operator[](intptr_t i) { - DCHECK_LT(i, GetLength()); - return elements_[i]; - } + size_t InputCount() const OVERRIDE { return N; } - const T& At(intptr_t i) const { - return (*this)[i]; + protected: + const HUserRecord<HInstruction*> InputRecordAt(size_t i) const OVERRIDE { + DCHECK_LT(i, N); + return inputs_[i]; } - void SetAt(intptr_t i, const T& val) { - (*this)[i] = val; + void SetRawInputRecordAt(size_t i, const HUserRecord<HInstruction*>& input) OVERRIDE { + DCHECK_LT(i, N); + inputs_[i] = input; } private: - T elements_[N]; -}; + std::array<HUserRecord<HInstruction*>, N> inputs_; -template<typename T> -class EmbeddedArray<T, 0> { - public: - intptr_t length() const { return 0; } - const T& operator[](intptr_t i) const { - UNUSED(i); - LOG(FATAL) << "Unreachable"; - UNREACHABLE(); - } - T& operator[](intptr_t i) { - UNUSED(i); - LOG(FATAL) << "Unreachable"; - UNREACHABLE(); - } + friend class SsaBuilder; }; -template<intptr_t N> -class HTemplateInstruction: public HInstruction { +// HTemplateInstruction specialization for N=0. +template<> +class HTemplateInstruction<0>: public HInstruction { public: - HTemplateInstruction<N>(SideEffects side_effects) - : HInstruction(side_effects), inputs_() {} + explicit HTemplateInstruction(SideEffects side_effects) : HInstruction(side_effects) {} virtual ~HTemplateInstruction() {} - size_t InputCount() const OVERRIDE { return N; } + size_t InputCount() const OVERRIDE { return 0; } protected: - const HUserRecord<HInstruction*> InputRecordAt(size_t i) const OVERRIDE { return inputs_[i]; } + const HUserRecord<HInstruction*> InputRecordAt(size_t i ATTRIBUTE_UNUSED) const OVERRIDE { + LOG(FATAL) << "Unreachable"; + UNREACHABLE(); + } - void SetRawInputRecordAt(size_t i, const HUserRecord<HInstruction*>& input) OVERRIDE { - inputs_[i] = input; + void SetRawInputRecordAt(size_t i ATTRIBUTE_UNUSED, + const HUserRecord<HInstruction*>& input ATTRIBUTE_UNUSED) OVERRIDE { + LOG(FATAL) << "Unreachable"; + UNREACHABLE(); } private: - EmbeddedArray<HUserRecord<HInstruction*>, N> inputs_; - friend class SsaBuilder; }; @@ -4833,7 +4816,7 @@ class HFakeString : public HTemplateInstruction<0> { DISALLOW_COPY_AND_ASSIGN(HFakeString); }; -class MoveOperands : public ArenaObject<kArenaAllocMisc> { +class MoveOperands : public ArenaObject<kArenaAllocMoveOperands> { public: MoveOperands(Location source, Location destination, |