From 009d166842195711eca4d5768c59a8f7404e6875 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 10 Oct 2017 13:21:15 +0100 Subject: Use ScopedArenaAllocator in BCE, DCE, LSE, ... ... ReferenceTypePropagation and GraphChecker. Define and use a new allocation kind for LoadStoreAnalysis. Memory needed to compile the two most expensive methods for aosp_angler-userdebug boot image: BatteryStats.dumpCheckinLocked() : 19.7MiB -> 19.6MiB (-79KiB) BatteryStats.dumpLocked(): 39.4MiB -> 39.3MiB (-120KiB) Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 64312607 Change-Id: Ib0cf074ac21ab67d8f8f2efabbdfb84cce9cae8e --- compiler/optimizing/graph_checker.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'compiler/optimizing/graph_checker.cc') diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc index 1c7d1a0b69..b1ac027a68 100644 --- a/compiler/optimizing/graph_checker.cc +++ b/compiler/optimizing/graph_checker.cc @@ -22,8 +22,9 @@ #include "android-base/stringprintf.h" -#include "base/arena_containers.h" #include "base/bit_vector-inl.h" +#include "base/scoped_arena_allocator.h" +#include "base/scoped_arena_containers.h" namespace art { @@ -47,10 +48,13 @@ static bool IsExitTryBoundaryIntoExitBlock(HBasicBlock* block) { void GraphChecker::VisitBasicBlock(HBasicBlock* block) { current_block_ = block; + // Use local allocator for allocating memory. + ScopedArenaAllocator allocator(GetGraph()->GetArenaStack()); + // Check consistency with respect to predecessors of `block`. // Note: Counting duplicates with a sorted vector uses up to 6x less memory // than ArenaSafeMap and also allows storage reuse. - ArenaVector& sorted_predecessors = blocks_storage_; + ScopedArenaVector sorted_predecessors(allocator.Adapter(kArenaAllocGraphChecker)); sorted_predecessors.assign(block->GetPredecessors().begin(), block->GetPredecessors().end()); std::sort(sorted_predecessors.begin(), sorted_predecessors.end()); for (auto it = sorted_predecessors.begin(), end = sorted_predecessors.end(); it != end; ) { @@ -73,7 +77,7 @@ void GraphChecker::VisitBasicBlock(HBasicBlock* block) { // Check consistency with respect to successors of `block`. // Note: Counting duplicates with a sorted vector uses up to 6x less memory // than ArenaSafeMap and also allows storage reuse. - ArenaVector& sorted_successors = blocks_storage_; + ScopedArenaVector sorted_successors(allocator.Adapter(kArenaAllocGraphChecker)); sorted_successors.assign(block->GetSuccessors().begin(), block->GetSuccessors().end()); std::sort(sorted_successors.begin(), sorted_successors.end()); for (auto it = sorted_successors.begin(), end = sorted_successors.end(); it != end; ) { @@ -829,10 +833,14 @@ void GraphChecker::VisitPhi(HPhi* phi) { phi->GetRegNumber(), type_str.str().c_str())); } else { + // Use local allocator for allocating memory. + ScopedArenaAllocator allocator(GetGraph()->GetArenaStack()); // If we get here, make sure we allocate all the necessary storage at once // because the BitVector reallocation strategy has very bad worst-case behavior. - ArenaBitVector& visited = visited_storage_; - visited.SetBit(GetGraph()->GetCurrentInstructionId()); + ArenaBitVector visited(&allocator, + GetGraph()->GetCurrentInstructionId(), + /* expandable */ false, + kArenaAllocGraphChecker); visited.ClearAllBits(); if (!IsConstantEquivalent(phi, other_phi, &visited)) { AddError(StringPrintf("Two phis (%d and %d) found for VReg %d but they " -- cgit v1.2.3-59-g8ed1b