diff options
author | 2015-04-22 13:56:20 -0700 | |
---|---|---|
committer | 2015-05-29 18:45:49 -0700 | |
commit | e401d146407d61eeb99f8d6176b2ac13c4df1e33 (patch) | |
tree | 17927f9bfe7d2041b5942c89832d55f9dedb24c5 /runtime/entrypoints/entrypoint_utils.cc | |
parent | 2006b7b9b8e32722bd0d640c62549d8a0ac624b6 (diff) |
Move mirror::ArtMethod to native
Optimizing + quick tests are passing, devices boot.
TODO: Test and fix bugs in mips64.
Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS.
Some of the savings are from removal of virtual methods and direct
methods object arrays.
Bug: 19264997
Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
Diffstat (limited to 'runtime/entrypoints/entrypoint_utils.cc')
-rw-r--r-- | runtime/entrypoints/entrypoint_utils.cc | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc index ce5673923f..fc7f8b782a 100644 --- a/runtime/entrypoints/entrypoint_utils.cc +++ b/runtime/entrypoints/entrypoint_utils.cc @@ -17,11 +17,11 @@ #include "entrypoints/entrypoint_utils.h" #include "art_field-inl.h" +#include "art_method-inl.h" #include "base/mutex.h" #include "class_linker-inl.h" #include "dex_file-inl.h" #include "gc/accounting/card_table-inl.h" -#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/method.h" #include "mirror/object-inl.h" @@ -35,7 +35,7 @@ namespace art { static inline mirror::Class* CheckFilledNewArrayAlloc(uint32_t type_idx, int32_t component_count, - mirror::ArtMethod* referrer, + ArtMethod* referrer, Thread* self, bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -76,7 +76,7 @@ static inline mirror::Class* CheckFilledNewArrayAlloc(uint32_t type_idx, // Helper function to allocate array for FILLED_NEW_ARRAY. mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, int32_t component_count, - mirror::ArtMethod* referrer, Thread* self, + ArtMethod* referrer, Thread* self, bool access_check, gc::AllocatorType /* allocator_type */) { mirror::Class* klass = CheckFilledNewArrayAlloc(type_idx, component_count, referrer, self, @@ -96,7 +96,7 @@ mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, int32_t component_c // Helper function to allocate array for FILLED_NEW_ARRAY. mirror::Array* CheckAndAllocArrayFromCodeInstrumented(uint32_t type_idx, int32_t component_count, - mirror::ArtMethod* referrer, + ArtMethod* referrer, Thread* self, bool access_check, gc::AllocatorType /* allocator_type */) { @@ -294,22 +294,19 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessAlreadyRunnable& soa, cons mirror::Object* rcvr = soa.Decode<mirror::Object*>(rcvr_jobj); mirror::Class* proxy_class = rcvr->GetClass(); mirror::Method* interface_method = soa.Decode<mirror::Method*>(interface_method_jobj); - mirror::ArtMethod* proxy_method = - rcvr->GetClass()->FindVirtualMethodForInterface(interface_method->GetArtMethod()); - int throws_index = -1; - size_t num_virt_methods = proxy_class->NumVirtualMethods(); - for (size_t i = 0; i < num_virt_methods; i++) { - if (proxy_class->GetVirtualMethod(i) == proxy_method) { - throws_index = i; - break; - } - } - CHECK_NE(throws_index, -1); + ArtMethod* proxy_method = rcvr->GetClass()->FindVirtualMethodForInterface( + interface_method->GetArtMethod(), sizeof(void*)); + auto* virtual_methods = proxy_class->GetVirtualMethodsPtr(); + size_t num_virtuals = proxy_class->NumVirtualMethods(); + size_t method_size = ArtMethod::ObjectSize(sizeof(void*)); + int throws_index = (reinterpret_cast<uintptr_t>(proxy_method) - + reinterpret_cast<uintptr_t>(virtual_methods)) / method_size; + CHECK_LT(throws_index, static_cast<int>(num_virtuals)); mirror::ObjectArray<mirror::Class>* declared_exceptions = proxy_class->GetThrows()->Get(throws_index); mirror::Class* exception_class = exception->GetClass(); bool declares_exception = false; - for (int i = 0; i < declared_exceptions->GetLength() && !declares_exception; i++) { + for (int32_t i = 0; i < declared_exceptions->GetLength() && !declares_exception; i++) { mirror::Class* declared_exception = declared_exceptions->Get(i); declares_exception = declared_exception->IsAssignableFrom(exception_class); } |