diff options
author | 2017-04-20 19:50:32 +0100 | |
---|---|---|
committer | 2017-04-21 10:52:53 +0100 | |
commit | b1d0ee1e02e6c461e2291d8d00b21fd847e88adf (patch) | |
tree | 9a28e23dbfc180437123bb35c2f416a95317b643 /compiler/optimizing | |
parent | 38870a8a2717ccf1bcd3faddc53b1999985bb29f (diff) |
Reuse DexCache and ClassLoader handles in inliner.
Measured memory usage with heaptrack for a large app:
Before:
bytes allocated in total (ignoring deallocations): 3.14GB
calls to allocation functions: 8130596
After:
bytes allocated in total (ignoring deallocations): 3.12GB
calls to allocation functions: 7750377
Test: testrunner.py --host
Bug: 34053922
Change-Id: I1ad7aaffccc6527cd4f409ca8fca75bab8d7439a
Diffstat (limited to 'compiler/optimizing')
-rw-r--r-- | compiler/optimizing/inliner.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index 66948ebf8c..4af2539812 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -1539,6 +1539,14 @@ HInstanceFieldSet* HInliner::CreateInstanceFieldSet(uint32_t field_index, return iput; } +template <typename T> +static inline Handle<T> NewHandleIfDifferent(T* object, + Handle<T> hint, + VariableSizedHandleScope* handles) + REQUIRES_SHARED(Locks::mutator_lock_) { + return (object != hint.Get()) ? handles->NewHandle(object) : hint; +} + bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, ArtMethod* resolved_method, ReferenceTypeInfo receiver_type, @@ -1550,9 +1558,13 @@ bool HInliner::TryBuildAndInlineHelper(HInvoke* invoke_instruction, const DexFile& callee_dex_file = *resolved_method->GetDexFile(); uint32_t method_index = resolved_method->GetDexMethodIndex(); ClassLinker* class_linker = caller_compilation_unit_.GetClassLinker(); - Handle<mirror::DexCache> dex_cache(handles_->NewHandle(resolved_method->GetDexCache())); - Handle<mirror::ClassLoader> class_loader(handles_->NewHandle( - resolved_method->GetDeclaringClass()->GetClassLoader())); + Handle<mirror::DexCache> dex_cache = NewHandleIfDifferent(resolved_method->GetDexCache(), + caller_compilation_unit_.GetDexCache(), + handles_); + Handle<mirror::ClassLoader> class_loader = + NewHandleIfDifferent(resolved_method->GetDeclaringClass()->GetClassLoader(), + caller_compilation_unit_.GetClassLoader(), + handles_); DexCompilationUnit dex_compilation_unit( class_loader, |