From 9b34b244ecddd8a35c922ed87bc3df0ca4db0282 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Mon, 9 Mar 2015 11:30:17 -0700 Subject: Trim arenas for JIT Moved arena pool into the runtime. Added arena trimming to arena pool. When called, this madvises the used memory. Changed the JIT compiler to trim arenas after compilation. Changed the arena mmap name to dalvik-LinearAlloc. Native PSS before: 80353 kB: Native 80775 kB: Native 78116 kB: Native After: 73357 kB: Native 70181 kB: Native 70306 kB: Native Bug: 17950037 Bug: 17643507 Bug: 19264997 Change-Id: I63e7a898fd6e909c2c677fa57b5917a7b1398930 --- compiler/jit/jit_compiler.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'compiler/jit/jit_compiler.cc') diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc index 04efa21f4e..a63e14a980 100644 --- a/compiler/jit/jit_compiler.cc +++ b/compiler/jit/jit_compiler.cc @@ -103,7 +103,7 @@ JitCompiler::~JitCompiler() { } bool JitCompiler::CompileMethod(Thread* self, mirror::ArtMethod* method) { - uint64_t start_time = NanoTime(); + const uint64_t start_time = NanoTime(); StackHandleScope<2> hs(self); self->AssertNoPendingException(); Runtime* runtime = Runtime::Current(); @@ -130,6 +130,8 @@ bool JitCompiler::CompileMethod(Thread* self, mirror::ArtMethod* method) { } } CompiledMethod* compiled_method(compiler_driver_->CompileMethod(self, h_method.Get())); + // Trim maps to reduce memory usage, TODO: measure how much this increases compile time. + runtime->GetArenaPool()->TrimMaps(); if (compiled_method == nullptr) { return false; } @@ -137,7 +139,7 @@ bool JitCompiler::CompileMethod(Thread* self, mirror::ArtMethod* method) { // Don't add the method if we are supposed to be deoptimized. bool result = false; if (!runtime->GetInstrumentation()->AreAllMethodsDeoptimized()) { - const void* code = Runtime::Current()->GetClassLinker()->GetOatMethodQuickCodeFor( + const void* code = runtime->GetClassLinker()->GetOatMethodQuickCodeFor( h_method.Get()); if (code != nullptr) { // Already have some compiled code, just use this instead of linking. -- cgit v1.2.3-59-g8ed1b