From eead0711984ee20a3bba7c2e2415593a520e40b3 Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Fri, 18 Sep 2015 14:58:57 +0100 Subject: ART: Optimize catch phi creation to save memory. Catch phis are eagerly created for all vregs and then removed as throwing instructions with undefined locals are encountered. This can be optimized since rougly one third of vregs is already undefined with the first throwing instruction. Change-Id: Ia4e66f19ea03f9a129b4b64d4193d262fff45224 --- compiler/optimizing/ssa_builder.h | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'compiler/optimizing/ssa_builder.h') diff --git a/compiler/optimizing/ssa_builder.h b/compiler/optimizing/ssa_builder.h index 804296f7ba..79f1a28ac8 100644 --- a/compiler/optimizing/ssa_builder.h +++ b/compiler/optimizing/ssa_builder.h @@ -61,28 +61,9 @@ class SsaBuilder : public HGraphVisitor { void BuildSsa(); - ArenaVector* GetLocalsFor(HBasicBlock* block) { - DCHECK_LT(block->GetBlockId(), locals_for_.size()); - ArenaVector* locals = &locals_for_[block->GetBlockId()]; - if (locals->empty() && GetGraph()->GetNumberOfVRegs() != 0u) { - const size_t vregs = GetGraph()->GetNumberOfVRegs(); - locals->resize(vregs, nullptr); - - if (block->IsCatchBlock()) { - // We record incoming inputs of catch phis at throwing instructions and - // must therefore eagerly create the phis. Unused phis will be removed - // in the dead phi analysis. - ArenaAllocator* arena = GetGraph()->GetArena(); - for (size_t i = 0; i < vregs; ++i) { - HPhi* phi = new (arena) HPhi(arena, i, 0, Primitive::kPrimVoid); - block->AddPhi(phi); - (*locals)[i] = phi; - } - } - } - return locals; - } - + // Returns locals vector for `block`. If it is a catch block, the vector will be + // prepopulated with catch phis for vregs which are defined in `current_locals_`. + ArenaVector* GetLocalsFor(HBasicBlock* block); HInstruction* ValueOfLocal(HBasicBlock* block, size_t local); void VisitBasicBlock(HBasicBlock* block); -- cgit v1.2.3-59-g8ed1b