Free Arenas from the ArenaStack before running codegen.

Since the ArenaStack is used only by the MIRGraph and not by
the memory hungry codegen, freeing the ArenaStack's Arenas
just before running the codegen should reduce the compiler's
peak memory usage.

Bug: 13564922
Change-Id: I1cb49d367e4e81d71a03cac89b3739ed61e4f966
diff --git a/compiler/utils/scoped_arena_allocator.cc b/compiler/utils/scoped_arena_allocator.cc
index ee3b07e..a78d287 100644
--- a/compiler/utils/scoped_arena_allocator.cc
+++ b/compiler/utils/scoped_arena_allocator.cc
@@ -34,9 +34,19 @@
 }
 
 ArenaStack::~ArenaStack() {
+  DebugStackRefCounter::CheckNoRefs();
   stats_and_pool_.pool->FreeArenaChain(bottom_arena_);
 }
 
+void ArenaStack::Reset() {
+  DebugStackRefCounter::CheckNoRefs();
+  stats_and_pool_.pool->FreeArenaChain(bottom_arena_);
+  bottom_arena_ = nullptr;
+  top_arena_  = nullptr;
+  top_ptr_ = nullptr;
+  top_end_ = nullptr;
+}
+
 MemStats ArenaStack::GetPeakStats() const {
   DebugStackRefCounter::CheckNoRefs();
   return MemStats("ArenaStack peak", static_cast<const TaggedStats<Peak>*>(&stats_and_pool_),