diff options
Diffstat (limited to 'runtime/entrypoints/entrypoint_utils-inl.h')
-rw-r--r-- | runtime/entrypoints/entrypoint_utils-inl.h | 97 |
1 files changed, 46 insertions, 51 deletions
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h index 9292cff88e..a4dd55cebe 100644 --- a/runtime/entrypoints/entrypoint_utils-inl.h +++ b/runtime/entrypoints/entrypoint_utils-inl.h @@ -19,6 +19,7 @@ #include "entrypoint_utils.h" +#include "art_method.h" #include "class_linker-inl.h" #include "common_throws.h" #include "dex_file.h" @@ -27,7 +28,6 @@ #include "indirect_reference_table.h" #include "invoke_type.h" #include "jni_internal.h" -#include "mirror/art_method.h" #include "mirror/array.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" @@ -38,15 +38,15 @@ namespace art { -inline mirror::ArtMethod* GetCalleeSaveMethodCaller(Thread* self, Runtime::CalleeSaveType type) +inline ArtMethod* GetCalleeSaveMethodCaller(Thread* self, Runtime::CalleeSaveType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - auto* refs_only_sp = self->GetManagedStack()->GetTopQuickFrame(); - DCHECK_EQ(refs_only_sp->AsMirrorPtr(), Runtime::Current()->GetCalleeSaveMethod(type)); + auto** refs_only_sp = self->GetManagedStack()->GetTopQuickFrame(); + DCHECK_EQ(*refs_only_sp, Runtime::Current()->GetCalleeSaveMethod(type)); const size_t callee_frame_size = GetCalleeSaveFrameSize(kRuntimeISA, type); - auto* caller_sp = reinterpret_cast<StackReference<mirror::ArtMethod>*>( - reinterpret_cast<uintptr_t>(refs_only_sp) + callee_frame_size); - auto* caller = caller_sp->AsMirrorPtr(); + auto** caller_sp = reinterpret_cast<ArtMethod**>( + reinterpret_cast<uintptr_t>(refs_only_sp) + callee_frame_size); + auto* caller = *caller_sp; if (kIsDebugBuild) { NthCallerVisitor visitor(self, 1, true); @@ -60,7 +60,7 @@ inline mirror::ArtMethod* GetCalleeSaveMethodCaller(Thread* self, Runtime::Calle template <const bool kAccessCheck> ALWAYS_INLINE inline mirror::Class* CheckObjectAlloc(uint32_t type_idx, - mirror::ArtMethod* method, + ArtMethod* method, Thread* self, bool* slow_path) { mirror::Class* klass = method->GetDexCacheResolvedType<false>(type_idx); if (UNLIKELY(klass == nullptr)) { @@ -141,7 +141,7 @@ inline mirror::Class* CheckClassInitializedForObjectAlloc(mirror::Class* klass, template <bool kAccessCheck, bool kInstrumented> ALWAYS_INLINE inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, - mirror::ArtMethod* method, + ArtMethod* method, Thread* self, gc::AllocatorType allocator_type) { bool slow_path = false; @@ -193,7 +193,7 @@ template <bool kAccessCheck> ALWAYS_INLINE inline mirror::Class* CheckArrayAlloc(uint32_t type_idx, int32_t component_count, - mirror::ArtMethod* method, + ArtMethod* method, bool* slow_path) { if (UNLIKELY(component_count < 0)) { ThrowNegativeArraySizeException(component_count); @@ -229,7 +229,7 @@ template <bool kAccessCheck, bool kInstrumented> ALWAYS_INLINE inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, int32_t component_count, - mirror::ArtMethod* method, + ArtMethod* method, Thread* self, gc::AllocatorType allocator_type) { bool slow_path = false; @@ -252,7 +252,7 @@ template <bool kAccessCheck, bool kInstrumented> ALWAYS_INLINE inline mirror::Array* AllocArrayFromCodeResolved(mirror::Class* klass, int32_t component_count, - mirror::ArtMethod* method, + ArtMethod* method, Thread* self, gc::AllocatorType allocator_type) { DCHECK(klass != nullptr); @@ -274,7 +274,7 @@ inline mirror::Array* AllocArrayFromCodeResolved(mirror::Class* klass, } template<FindFieldType type, bool access_check> -inline ArtField* FindFieldFromCode(uint32_t field_idx, mirror::ArtMethod* referrer, +inline ArtField* FindFieldFromCode(uint32_t field_idx, ArtMethod* referrer, Thread* self, size_t expected_size) { bool is_primitive; bool is_set; @@ -347,8 +347,8 @@ inline ArtField* FindFieldFromCode(uint32_t field_idx, mirror::ArtMethod* referr #define EXPLICIT_FIND_FIELD_FROM_CODE_TEMPLATE_DECL(_type, _access_check) \ template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE \ ArtField* FindFieldFromCode<_type, _access_check>(uint32_t field_idx, \ - mirror::ArtMethod* referrer, \ - Thread* self, size_t expected_size) \ + ArtMethod* referrer, \ + Thread* self, size_t expected_size) \ #define EXPLICIT_FIND_FIELD_FROM_CODE_TYPED_TEMPLATE_DECL(_type) \ EXPLICIT_FIND_FIELD_FROM_CODE_TEMPLATE_DECL(_type, false); \ @@ -367,17 +367,16 @@ EXPLICIT_FIND_FIELD_FROM_CODE_TYPED_TEMPLATE_DECL(StaticPrimitiveWrite); #undef EXPLICIT_FIND_FIELD_FROM_CODE_TEMPLATE_DECL template<InvokeType type, bool access_check> -inline mirror::ArtMethod* FindMethodFromCode(uint32_t method_idx, - mirror::Object** this_object, - mirror::ArtMethod** referrer, Thread* self) { +inline ArtMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object** this_object, + ArtMethod** referrer, Thread* self) { ClassLinker* const class_linker = Runtime::Current()->GetClassLinker(); - mirror::ArtMethod* resolved_method = class_linker->GetResolvedMethod(method_idx, *referrer); + ArtMethod* resolved_method = class_linker->GetResolvedMethod(method_idx, *referrer); if (resolved_method == nullptr) { StackHandleScope<1> hs(self); mirror::Object* null_this = nullptr; HandleWrapper<mirror::Object> h_this( hs.NewHandleWrapper(type == kStatic ? &null_this : this_object)); - resolved_method = class_linker->ResolveMethod(self, method_idx, referrer, type); + resolved_method = class_linker->ResolveMethod(self, method_idx, *referrer, type); } if (UNLIKELY(resolved_method == nullptr)) { DCHECK(self->IsExceptionPending()); // Throw exception and unwind. @@ -420,7 +419,7 @@ inline mirror::ArtMethod* FindMethodFromCode(uint32_t method_idx, return nullptr; // Failure. } DCHECK(klass->HasVTable()) << PrettyClass(klass); - return klass->GetVTableEntry(vtable_index); + return klass->GetVTableEntry(vtable_index, class_linker->GetImagePointerSize()); } case kSuper: { mirror::Class* super_class = (*referrer)->GetDeclaringClass()->GetSuperClass(); @@ -439,23 +438,25 @@ inline mirror::ArtMethod* FindMethodFromCode(uint32_t method_idx, DCHECK(super_class != nullptr); } DCHECK(super_class->HasVTable()); - return super_class->GetVTableEntry(vtable_index); + return super_class->GetVTableEntry(vtable_index, class_linker->GetImagePointerSize()); } case kInterface: { uint32_t imt_index = resolved_method->GetDexMethodIndex() % mirror::Class::kImtSize; - mirror::ArtMethod* imt_method = (*this_object)->GetClass()->GetEmbeddedImTableEntry(imt_index); + ArtMethod* imt_method = (*this_object)->GetClass()->GetEmbeddedImTableEntry( + imt_index, class_linker->GetImagePointerSize()); if (!imt_method->IsImtConflictMethod() && !imt_method->IsImtUnimplementedMethod()) { if (kIsDebugBuild) { mirror::Class* klass = (*this_object)->GetClass(); - mirror::ArtMethod* method = klass->FindVirtualMethodForInterface(resolved_method); + ArtMethod* method = klass->FindVirtualMethodForInterface( + resolved_method, class_linker->GetImagePointerSize()); CHECK_EQ(imt_method, method) << PrettyMethod(resolved_method) << " / " << PrettyMethod(imt_method) << " / " << PrettyMethod(method) << " / " << PrettyClass(klass); } return imt_method; } else { - mirror::ArtMethod* interface_method = - (*this_object)->GetClass()->FindVirtualMethodForInterface(resolved_method); + ArtMethod* interface_method = (*this_object)->GetClass()->FindVirtualMethodForInterface( + resolved_method, class_linker->GetImagePointerSize()); if (UNLIKELY(interface_method == nullptr)) { ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(resolved_method, *this_object, *referrer); @@ -473,10 +474,10 @@ inline mirror::ArtMethod* FindMethodFromCode(uint32_t method_idx, // Explicit template declarations of FindMethodFromCode for all invoke types. #define EXPLICIT_FIND_METHOD_FROM_CODE_TEMPLATE_DECL(_type, _access_check) \ template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE \ - mirror::ArtMethod* FindMethodFromCode<_type, _access_check>(uint32_t method_idx, \ - mirror::Object** this_object, \ - mirror::ArtMethod** referrer, \ - Thread* self) + ArtMethod* FindMethodFromCode<_type, _access_check>(uint32_t method_idx, \ + mirror::Object** this_object, \ + ArtMethod** referrer, \ + Thread* self) #define EXPLICIT_FIND_METHOD_FROM_CODE_TYPED_TEMPLATE_DECL(_type) \ EXPLICIT_FIND_METHOD_FROM_CODE_TEMPLATE_DECL(_type, false); \ EXPLICIT_FIND_METHOD_FROM_CODE_TEMPLATE_DECL(_type, true) @@ -491,9 +492,8 @@ EXPLICIT_FIND_METHOD_FROM_CODE_TYPED_TEMPLATE_DECL(kInterface); #undef EXPLICIT_FIND_METHOD_FROM_CODE_TEMPLATE_DECL // Fast path field resolution that can't initialize classes or throw exceptions. -inline ArtField* FindFieldFast(uint32_t field_idx, - mirror::ArtMethod* referrer, - FindFieldType type, size_t expected_size) { +inline ArtField* FindFieldFast(uint32_t field_idx, ArtMethod* referrer, FindFieldType type, + size_t expected_size) { ArtField* resolved_field = referrer->GetDeclaringClass()->GetDexCache()->GetResolvedField(field_idx, sizeof(void*)); if (UNLIKELY(resolved_field == nullptr)) { @@ -530,8 +530,7 @@ inline ArtField* FindFieldFast(uint32_t field_idx, } mirror::Class* referring_class = referrer->GetDeclaringClass(); if (UNLIKELY(!referring_class->CanAccess(fields_class) || - !referring_class->CanAccessMember(fields_class, - resolved_field->GetAccessFlags()) || + !referring_class->CanAccessMember(fields_class, resolved_field->GetAccessFlags()) || (is_set && resolved_field->IsFinal() && (fields_class != referring_class)))) { // Illegal access. return nullptr; @@ -544,15 +543,13 @@ inline ArtField* FindFieldFast(uint32_t field_idx, } // Fast path method resolution that can't throw exceptions. -inline mirror::ArtMethod* FindMethodFast(uint32_t method_idx, - mirror::Object* this_object, - mirror::ArtMethod* referrer, - bool access_check, InvokeType type) { +inline ArtMethod* FindMethodFast(uint32_t method_idx, mirror::Object* this_object, + ArtMethod* referrer, bool access_check, InvokeType type) { if (UNLIKELY(this_object == nullptr && type != kStatic)) { return nullptr; } - mirror::ArtMethod* resolved_method = - referrer->GetDeclaringClass()->GetDexCache()->GetResolvedMethod(method_idx); + ArtMethod* resolved_method = + referrer->GetDeclaringClass()->GetDexCache()->GetResolvedMethod(method_idx, sizeof(void*)); if (UNLIKELY(resolved_method == nullptr)) { return nullptr; } @@ -572,22 +569,21 @@ inline mirror::ArtMethod* FindMethodFast(uint32_t method_idx, } } if (type == kInterface) { // Most common form of slow path dispatch. - return this_object->GetClass()->FindVirtualMethodForInterface(resolved_method); + return this_object->GetClass()->FindVirtualMethodForInterface(resolved_method, sizeof(void*)); } else if (type == kStatic || type == kDirect) { return resolved_method; } else if (type == kSuper) { - return referrer->GetDeclaringClass()->GetSuperClass() - ->GetVTableEntry(resolved_method->GetMethodIndex()); + return referrer->GetDeclaringClass()->GetSuperClass()->GetVTableEntry( + resolved_method->GetMethodIndex(), sizeof(void*)); } else { DCHECK(type == kVirtual); - return this_object->GetClass()->GetVTableEntry(resolved_method->GetMethodIndex()); + return this_object->GetClass()->GetVTableEntry( + resolved_method->GetMethodIndex(), sizeof(void*)); } } -inline mirror::Class* ResolveVerifyAndClinit(uint32_t type_idx, - mirror::ArtMethod* referrer, - Thread* self, bool can_run_clinit, - bool verify_access) { +inline mirror::Class* ResolveVerifyAndClinit(uint32_t type_idx, ArtMethod* referrer, Thread* self, + bool can_run_clinit, bool verify_access) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); mirror::Class* klass = class_linker->ResolveType(type_idx, referrer); if (UNLIKELY(klass == nullptr)) { @@ -620,8 +616,7 @@ inline mirror::Class* ResolveVerifyAndClinit(uint32_t type_idx, return h_class.Get(); } -inline mirror::String* ResolveStringFromCode(mirror::ArtMethod* referrer, - uint32_t string_idx) { +inline mirror::String* ResolveStringFromCode(ArtMethod* referrer, uint32_t string_idx) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); return class_linker->ResolveString(string_idx, referrer); } |