From 69d310e0317e2fce97bf8c9c133c5c2c0332e61d Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Mon, 9 Oct 2017 14:12:23 +0100 Subject: Use ScopedArenaAllocator for building HGraph. Memory needed to compile the two most expensive methods for aosp_angler-userdebug boot image: BatteryStats.dumpCheckinLocked() : 21.1MiB -> 20.2MiB BatteryStats.dumpLocked(): 42.0MiB -> 40.3MiB This is because all the memory previously used by the graph builder is reused by later passes. And finish the "arena"->"allocator" renaming; make renamed allocator pointers that are members of classes const when appropriate (and make a few more members around them const). Test: m test-art-host-gtest Test: testrunner.py --host Bug: 64312607 Change-Id: Ia50aafc80c05941ae5b96984ba4f31ed4c78255e --- compiler/optimizing/ssa_builder.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'compiler/optimizing/ssa_builder.cc') diff --git a/compiler/optimizing/ssa_builder.cc b/compiler/optimizing/ssa_builder.cc index f4a8a17131..e4edbfdc24 100644 --- a/compiler/optimizing/ssa_builder.cc +++ b/compiler/optimizing/ssa_builder.cc @@ -105,7 +105,7 @@ void SsaBuilder::FixEnvironmentPhis() { } static void AddDependentInstructionsToWorklist(HInstruction* instruction, - ArenaVector* worklist) { + ScopedArenaVector* worklist) { // If `instruction` is a dead phi, type conflict was just identified. All its // live phi users, and transitively users of those users, therefore need to be // marked dead/conflicting too, so we add them to the worklist. Otherwise we @@ -167,7 +167,7 @@ static bool TypePhiFromInputs(HPhi* phi) { } // Replace inputs of `phi` to match its type. Return false if conflict is identified. -bool SsaBuilder::TypeInputsOfPhi(HPhi* phi, ArenaVector* worklist) { +bool SsaBuilder::TypeInputsOfPhi(HPhi* phi, ScopedArenaVector* worklist) { DataType::Type common_type = phi->GetType(); if (DataType::IsIntegralType(common_type)) { // We do not need to retype ambiguous inputs because they are always constructed @@ -213,7 +213,7 @@ bool SsaBuilder::TypeInputsOfPhi(HPhi* phi, ArenaVector* worklist) { // Attempt to set the primitive type of `phi` to match its inputs. Return whether // it was changed by the algorithm or not. -bool SsaBuilder::UpdatePrimitiveType(HPhi* phi, ArenaVector* worklist) { +bool SsaBuilder::UpdatePrimitiveType(HPhi* phi, ScopedArenaVector* worklist) { DCHECK(phi->IsLive()); DataType::Type original_type = phi->GetType(); @@ -233,7 +233,7 @@ bool SsaBuilder::UpdatePrimitiveType(HPhi* phi, ArenaVector* worklist) { } void SsaBuilder::RunPrimitiveTypePropagation() { - ArenaVector worklist(graph_->GetAllocator()->Adapter(kArenaAllocGraphBuilder)); + ScopedArenaVector worklist(local_allocator_->Adapter(kArenaAllocGraphBuilder)); for (HBasicBlock* block : graph_->GetReversePostOrder()) { if (block->IsLoopHeader()) { @@ -262,7 +262,7 @@ void SsaBuilder::RunPrimitiveTypePropagation() { EquivalentPhisCleanup(); } -void SsaBuilder::ProcessPrimitiveTypePropagationWorklist(ArenaVector* worklist) { +void SsaBuilder::ProcessPrimitiveTypePropagationWorklist(ScopedArenaVector* worklist) { // Process worklist while (!worklist->empty()) { HPhi* phi = worklist->back(); @@ -319,7 +319,7 @@ bool SsaBuilder::FixAmbiguousArrayOps() { // uses (because they are untyped) and environment uses (if --debuggable). // After resolving all ambiguous ArrayGets, we will re-run primitive type // propagation on the Phis which need to be updated. - ArenaVector worklist(graph_->GetAllocator()->Adapter(kArenaAllocGraphBuilder)); + ScopedArenaVector worklist(local_allocator_->Adapter(kArenaAllocGraphBuilder)); { ScopedObjectAccess soa(Thread::Current()); @@ -623,8 +623,7 @@ HPhi* SsaBuilder::GetFloatDoubleOrReferenceEquivalentOfPhi(HPhi* phi, DataType:: || (next->GetType() != type)) { ArenaAllocator* allocator = graph_->GetAllocator(); HInputsRef inputs = phi->GetInputs(); - HPhi* new_phi = - new (allocator) HPhi(allocator, phi->GetRegNumber(), inputs.size(), type); + HPhi* new_phi = new (allocator) HPhi(allocator, phi->GetRegNumber(), inputs.size(), type); // Copy the inputs. Note that the graph may not be correctly typed // by doing this copy, but the type propagation phase will fix it. ArrayRef> new_input_records = new_phi->GetInputRecords(); -- cgit v1.2.3-59-g8ed1b