diff options
author | Sebastien Hertz <shertz@google.com> | 2013-10-02 17:07:20 +0200 |
---|---|---|
committer | Sebastien Hertz <shertz@google.com> | 2013-10-28 18:12:22 +0100 |
commit | d4beb6bc2b42b176c6d04fdd91d6c758e542c7c2 (patch) | |
tree | 083f8c75e44105e98688eff3e206e5a7fd188912 /runtime/entrypoints/portable/portable_invoke_entrypoints.cc | |
parent | 57e6d8a99058e5c74d5244b68a5f4d53526fa108 (diff) | |
download | art-d4beb6bc2b42b176c6d04fdd91d6c758e542c7c2.zip art-d4beb6bc2b42b176c6d04fdd91d6c758e542c7c2.tar.gz art-d4beb6bc2b42b176c6d04fdd91d6c758e542c7c2.tar.bz2 |
Inline field and method resolution.
According to profiling results, field and method resolutions are hot points
during interpreter execution. This CL attempts to speed up these resolutions.
Forces aggressive inlining of FindFieldFromCode and FindMethodFromCode. This
allows to reduce the overhead of access check code when the interpreter runs
without these checks. Templatize these functions to optimize inlining and their
callers.
Also spread the use of C++11 "nullptr" in place of "NULL" in field access and
invoke helpers.
Change-Id: Ic1a69834d8975b2cddcddaae32f08a7de146a951
Diffstat (limited to 'runtime/entrypoints/portable/portable_invoke_entrypoints.cc')
-rw-r--r-- | runtime/entrypoints/portable/portable_invoke_entrypoints.cc | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/runtime/entrypoints/portable/portable_invoke_entrypoints.cc b/runtime/entrypoints/portable/portable_invoke_entrypoints.cc index 14cbd84..e2a0cc2 100644 --- a/runtime/entrypoints/portable/portable_invoke_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_invoke_entrypoints.cc @@ -21,21 +21,13 @@ namespace art { -static mirror::ArtMethod* FindMethodHelper(uint32_t method_idx, - mirror::Object* this_object, - mirror::ArtMethod* caller_method, - bool access_check, - InvokeType type, - Thread* thread) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::ArtMethod* method = FindMethodFast(method_idx, - this_object, - caller_method, - access_check, - type); +template<InvokeType type, bool access_check> +static mirror::ArtMethod* FindMethodHelper(uint32_t method_idx, mirror::Object* this_object, + mirror::ArtMethod* caller_method, Thread* thread) { + mirror::ArtMethod* method = FindMethodFast(method_idx, this_object, caller_method, + access_check, type); if (UNLIKELY(method == NULL)) { - method = FindMethodFromCode(method_idx, this_object, caller_method, - thread, access_check, type); + method = FindMethodFromCode<type, access_check>(method_idx, this_object, caller_method, thread); if (UNLIKELY(method == NULL)) { CHECK(thread->IsExceptionPending()); return 0; // failure @@ -53,12 +45,32 @@ static mirror::ArtMethod* FindMethodHelper(uint32_t method_idx, return method; } +// Explicit template declarations of FindMethodHelper for all invoke types. +#define EXPLICIT_FIND_METHOD_HELPER_TEMPLATE_DECL(_type, _access_check) \ + template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) \ + static mirror::ArtMethod* FindMethodHelper<_type, _access_check>(uint32_t method_idx, \ + mirror::Object* this_object, \ + mirror::ArtMethod* caller_method, \ + Thread* thread) +#define EXPLICIT_FIND_METHOD_HELPER_TYPED_TEMPLATE_DECL(_type) \ + EXPLICIT_FIND_METHOD_HELPER_TEMPLATE_DECL(_type, false); \ + EXPLICIT_FIND_METHOD_HELPER_TEMPLATE_DECL(_type, true) + +EXPLICIT_FIND_METHOD_HELPER_TYPED_TEMPLATE_DECL(kStatic); +EXPLICIT_FIND_METHOD_HELPER_TYPED_TEMPLATE_DECL(kDirect); +EXPLICIT_FIND_METHOD_HELPER_TYPED_TEMPLATE_DECL(kVirtual); +EXPLICIT_FIND_METHOD_HELPER_TYPED_TEMPLATE_DECL(kSuper); +EXPLICIT_FIND_METHOD_HELPER_TYPED_TEMPLATE_DECL(kInterface); + +#undef EXPLICIT_FIND_METHOD_HELPER_TYPED_TEMPLATE_DECL +#undef EXPLICIT_FIND_METHOD_HELPER_TEMPLATE_DECL + extern "C" mirror::Object* art_portable_find_static_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return FindMethodHelper(method_idx, this_object, referrer, true, kStatic, thread); + return FindMethodHelper<kStatic, true>(method_idx, this_object, referrer, thread); } extern "C" mirror::Object* art_portable_find_direct_method_from_code_with_access_check(uint32_t method_idx, @@ -66,7 +78,7 @@ extern "C" mirror::Object* art_portable_find_direct_method_from_code_with_access mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return FindMethodHelper(method_idx, this_object, referrer, true, kDirect, thread); + return FindMethodHelper<kDirect, true>(method_idx, this_object, referrer, thread); } extern "C" mirror::Object* art_portable_find_virtual_method_from_code_with_access_check(uint32_t method_idx, @@ -74,7 +86,7 @@ extern "C" mirror::Object* art_portable_find_virtual_method_from_code_with_acces mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return FindMethodHelper(method_idx, this_object, referrer, true, kVirtual, thread); + return FindMethodHelper<kVirtual, true>(method_idx, this_object, referrer, thread); } extern "C" mirror::Object* art_portable_find_super_method_from_code_with_access_check(uint32_t method_idx, @@ -82,7 +94,7 @@ extern "C" mirror::Object* art_portable_find_super_method_from_code_with_access_ mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return FindMethodHelper(method_idx, this_object, referrer, true, kSuper, thread); + return FindMethodHelper<kSuper, true>(method_idx, this_object, referrer, thread); } extern "C" mirror::Object* art_portable_find_interface_method_from_code_with_access_check(uint32_t method_idx, @@ -90,7 +102,7 @@ extern "C" mirror::Object* art_portable_find_interface_method_from_code_with_acc mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return FindMethodHelper(method_idx, this_object, referrer, true, kInterface, thread); + return FindMethodHelper<kInterface, true>(method_idx, this_object, referrer, thread); } extern "C" mirror::Object* art_portable_find_interface_method_from_code(uint32_t method_idx, @@ -98,7 +110,7 @@ extern "C" mirror::Object* art_portable_find_interface_method_from_code(uint32_t mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return FindMethodHelper(method_idx, this_object, referrer, false, kInterface, thread); + return FindMethodHelper<kInterface, false>(method_idx, this_object, referrer, thread); } } // namespace art |