Create a scoped arena allocator and use that for LVN.
This saves more than 0.5s of boot.oat compilation time
on Nexus 5.
TODO: Move other stuff to the scoped allocator. This CL
alone increases the peak memory allocation. By reusing
the memory for other parts of the compilation we should
reduce this overhead.
Change-Id: Ifbc00aab4f3afd0000da818dfe68b96713824a08
diff --git a/compiler/dex/frontend.cc b/compiler/dex/frontend.cc
index b55b471..1c2d16f 100644
--- a/compiler/dex/frontend.cc
+++ b/compiler/dex/frontend.cc
@@ -98,6 +98,7 @@
num_regs(0),
compiler_flip_match(false),
arena(pool),
+ arena_stack(pool),
mir_graph(NULL),
cg(NULL),
timings("QuickCompiler", true, false) {
@@ -247,9 +248,12 @@
}
if (cu.enable_debug & (1 << kDebugShowMemoryUsage)) {
- if (cu.arena.BytesAllocated() > (5 * 1024 *1024)) {
- MemStats mem_stats(cu.arena);
- LOG(INFO) << PrettyMethod(method_idx, dex_file) << " " << Dumpable<MemStats>(mem_stats);
+ if (cu.arena.BytesAllocated() > (1 * 1024 *1024) ||
+ cu.arena_stack.PeakBytesAllocated() > 256 * 1024) {
+ MemStats mem_stats(cu.arena.GetMemStats());
+ MemStats peak_stats(cu.arena_stack.GetPeakStats());
+ LOG(INFO) << PrettyMethod(method_idx, dex_file) << " " << Dumpable<MemStats>(mem_stats)
+ << Dumpable<MemStats>(peak_stats);
}
}