Compiler: continuing refactoring
Moving the arena memory allocation mechanism into it's own class as
a prelude to cleaning up the MIR and LIR data structures.
Reworked bit vector as a class using placement new w/ the arena
allocator.
Reworked GrowableList as a class template using the new arena
allocator and renamed to GrowableArray.
Change-Id: I639c4c08abe068094cae2649e04f58c8addd0015
diff --git a/src/compiler/dex/frontend.cc b/src/compiler/dex/frontend.cc
index e99c196..6f4ee6c 100644
--- a/src/compiler/dex/frontend.cc
+++ b/src/compiler/dex/frontend.cc
@@ -27,6 +27,7 @@
#include "mirror/object.h"
#include "runtime.h"
#include "backend.h"
+#include "base/logging.h"
namespace {
#if !defined(ART_USE_PORTABLE_COMPILER)
@@ -118,10 +119,6 @@
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
UniquePtr<CompilationUnit> cu(new CompilationUnit);
- if (!HeapInit(cu.get())) {
- LOG(FATAL) << "Failed to initialize compiler heap";
- }
-
cu->compiler_driver = &compiler;
cu->class_linker = class_linker;
cu->instruction_set = compiler.GetInstructionSet();
@@ -171,7 +168,7 @@
(1 << kPromoteCompilerTemps));
}
- cu->mir_graph.reset(new MIRGraph(cu.get()));
+ cu->mir_graph.reset(new MIRGraph(cu.get(), &cu->arena));
/* Gathering opcode stats? */
if (kCompilerDebugFlags & (1 << kDebugCountOpcodes)) {
@@ -218,17 +215,18 @@
#if defined(ART_USE_PORTABLE_COMPILER)
if (compiler_backend == kPortable) {
- cu->cg.reset(PortableCodeGenerator(cu.get(), cu->mir_graph.get(), llvm_compilation_unit));
+ cu->cg.reset(PortableCodeGenerator(cu.get(), cu->mir_graph.get(), &cu->arena,
+ llvm_compilation_unit));
} else
#endif
{
switch (compiler.GetInstructionSet()) {
case kThumb2:
- cu->cg.reset(ArmCodeGenerator(cu.get(), cu->mir_graph.get())); break;
+ cu->cg.reset(ArmCodeGenerator(cu.get(), cu->mir_graph.get(), &cu->arena)); break;
case kMips:
- cu->cg.reset(MipsCodeGenerator(cu.get(), cu->mir_graph.get())); break;
+ cu->cg.reset(MipsCodeGenerator(cu.get(), cu->mir_graph.get(), &cu->arena)); break;
case kX86:
- cu->cg.reset(X86CodeGenerator(cu.get(), cu->mir_graph.get())); break;
+ cu->cg.reset(X86CodeGenerator(cu.get(), cu->mir_graph.get(), &cu->arena)); break;
default:
LOG(FATAL) << "Unexpected instruction set: " << compiler.GetInstructionSet();
}
@@ -244,13 +242,14 @@
VLOG(compiler) << "Deferred " << PrettyMethod(method_idx, dex_file);
}
-#ifdef WITH_MEMSTATS
if (cu->enable_debug & (1 << kDebugShowMemoryUsage)) {
- DumpMemStats(cu.get());
+ if (cu->arena.BytesAllocated() > (5 * 1024 *1024)) {
+ MemStats mem_stats(cu->arena);
+ LOG(INFO) << PrettyMethod(method_idx, dex_file) << " " << Dumpable<MemStats>(mem_stats);
+ }
}
-#endif
- ArenaReset(cu.get());
+ cu->arena.ArenaReset();
return result;
}