diff options
author | 2016-11-17 15:21:22 -0800 | |
---|---|---|
committer | 2016-11-21 10:57:00 -0800 | |
commit | a5b09a67034e57a6e10231dd4bd92f4cb50b824c (patch) | |
tree | 304be738f4fa528b7ad2676103eecc84c79eaeeb /runtime/entrypoints | |
parent | dac7ad17c78387d15d7aefae0f852dddf5f37e34 (diff) |
ART: Add dex::TypeIndex
Add abstraction for uint16_t type index.
Test: m test-art-host
Change-Id: I47708741c7c579cbbe59ab723c1e31c5fe71f83a
Diffstat (limited to 'runtime/entrypoints')
-rw-r--r-- | runtime/entrypoints/entrypoint_utils-inl.h | 20 | ||||
-rw-r--r-- | runtime/entrypoints/entrypoint_utils.cc | 23 | ||||
-rw-r--r-- | runtime/entrypoints/entrypoint_utils.h | 33 | ||||
-rw-r--r-- | runtime/entrypoints/quick/quick_alloc_entrypoints.cc | 52 | ||||
-rw-r--r-- | runtime/entrypoints/quick/quick_dexcache_entrypoints.cc | 7 |
5 files changed, 90 insertions, 45 deletions
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h index ed60f598d1..ac52f4e287 100644 --- a/runtime/entrypoints/entrypoint_utils-inl.h +++ b/runtime/entrypoints/entrypoint_utils-inl.h @@ -129,7 +129,7 @@ inline ArtMethod* GetCalleeSaveMethodCaller(Thread* self, Runtime::CalleeSaveTyp template <const bool kAccessCheck> ALWAYS_INLINE -inline mirror::Class* CheckObjectAlloc(uint32_t type_idx, +inline mirror::Class* CheckObjectAlloc(dex::TypeIndex type_idx, ArtMethod* method, Thread* self, bool* slow_path) { @@ -219,7 +219,7 @@ inline mirror::Class* CheckClassInitializedForObjectAlloc(mirror::Class* klass, // check. template <bool kAccessCheck, bool kInstrumented> ALWAYS_INLINE -inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, +inline mirror::Object* AllocObjectFromCode(dex::TypeIndex type_idx, ArtMethod* method, Thread* self, gc::AllocatorType allocator_type) { @@ -275,7 +275,7 @@ inline mirror::Object* AllocObjectFromCodeInitialized(mirror::Class* klass, template <bool kAccessCheck> ALWAYS_INLINE -inline mirror::Class* CheckArrayAlloc(uint32_t type_idx, +inline mirror::Class* CheckArrayAlloc(dex::TypeIndex type_idx, int32_t component_count, ArtMethod* method, bool* slow_path) { @@ -313,7 +313,7 @@ inline mirror::Class* CheckArrayAlloc(uint32_t type_idx, // check. template <bool kAccessCheck, bool kInstrumented> ALWAYS_INLINE -inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, +inline mirror::Array* AllocArrayFromCode(dex::TypeIndex type_idx, int32_t component_count, ArtMethod* method, Thread* self, @@ -562,7 +562,7 @@ inline ArtMethod* FindMethodFromCode(uint32_t method_idx, StackHandleScope<2> hs2(self); HandleWrapperObjPtr<mirror::Object> h_this(hs2.NewHandleWrapper(this_object)); Handle<mirror::Class> h_referring_class(hs2.NewHandle(referrer->GetDeclaringClass())); - const uint16_t method_type_idx = + const dex::TypeIndex method_type_idx = h_referring_class->GetDexFile().GetMethodId(method_idx).class_idx_; mirror::Class* method_reference_class = class_linker->ResolveType(method_type_idx, referrer); if (UNLIKELY(method_reference_class == nullptr)) { @@ -758,7 +758,8 @@ inline ArtMethod* FindMethodFast(uint32_t method_idx, return resolved_method; } else if (type == kSuper) { // TODO This lookup is rather slow. - uint16_t method_type_idx = referring_class->GetDexFile().GetMethodId(method_idx).class_idx_; + dex::TypeIndex method_type_idx = + referring_class->GetDexFile().GetMethodId(method_idx).class_idx_; mirror::Class* method_reference_class = referring_class->GetDexCache()->GetResolvedType(method_type_idx); if (method_reference_class == nullptr) { @@ -788,8 +789,11 @@ inline ArtMethod* FindMethodFast(uint32_t method_idx, } } -inline mirror::Class* ResolveVerifyAndClinit(uint32_t type_idx, ArtMethod* referrer, Thread* self, - bool can_run_clinit, bool verify_access) { +inline mirror::Class* ResolveVerifyAndClinit(dex::TypeIndex 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)) { diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc index 1ccb4b004c..5390165ecd 100644 --- a/runtime/entrypoints/entrypoint_utils.cc +++ b/runtime/entrypoints/entrypoint_utils.cc @@ -38,7 +38,7 @@ namespace art { -static inline mirror::Class* CheckFilledNewArrayAlloc(uint32_t type_idx, +static inline mirror::Class* CheckFilledNewArrayAlloc(dex::TypeIndex type_idx, int32_t component_count, ArtMethod* referrer, Thread* self, @@ -82,10 +82,12 @@ 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, - ArtMethod* referrer, Thread* self, +mirror::Array* CheckAndAllocArrayFromCode(dex::TypeIndex type_idx, + int32_t component_count, + ArtMethod* referrer, + Thread* self, bool access_check, - gc::AllocatorType /* allocator_type */) { + gc::AllocatorType allocator_type ATTRIBUTE_UNUSED) { mirror::Class* klass = CheckFilledNewArrayAlloc(type_idx, component_count, referrer, self, access_check); if (UNLIKELY(klass == nullptr)) { @@ -101,12 +103,13 @@ 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, - ArtMethod* referrer, - Thread* self, - bool access_check, - gc::AllocatorType /* allocator_type */) { +mirror::Array* CheckAndAllocArrayFromCodeInstrumented( + dex::TypeIndex type_idx, + int32_t component_count, + ArtMethod* referrer, + Thread* self, + bool access_check, + gc::AllocatorType allocator_type ATTRIBUTE_UNUSED) { mirror::Class* klass = CheckFilledNewArrayAlloc(type_idx, component_count, referrer, self, access_check); if (UNLIKELY(klass == nullptr)) { diff --git a/runtime/entrypoints/entrypoint_utils.h b/runtime/entrypoints/entrypoint_utils.h index bcddfb0508..d87dc674bc 100644 --- a/runtime/entrypoints/entrypoint_utils.h +++ b/runtime/entrypoints/entrypoint_utils.h @@ -23,6 +23,7 @@ #include "base/macros.h" #include "base/mutex.h" #include "dex_instruction.h" +#include "dex_file_types.h" #include "gc/allocator_type.h" #include "handle.h" #include "invoke_type.h" @@ -45,7 +46,7 @@ class ScopedObjectAccessAlreadyRunnable; class Thread; template <const bool kAccessCheck> -ALWAYS_INLINE inline mirror::Class* CheckObjectAlloc(uint32_t type_idx, +ALWAYS_INLINE inline mirror::Class* CheckObjectAlloc(dex::TypeIndex type_idx, ArtMethod* method, Thread* self, bool* slow_path) @@ -63,7 +64,7 @@ ALWAYS_INLINE inline mirror::Class* CheckClassInitializedForObjectAlloc(mirror:: // When verification/compiler hasn't been able to verify access, optionally perform an access // check. template <bool kAccessCheck, bool kInstrumented> -ALWAYS_INLINE inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, +ALWAYS_INLINE inline mirror::Object* AllocObjectFromCode(dex::TypeIndex type_idx, ArtMethod* method, Thread* self, gc::AllocatorType allocator_type) @@ -89,7 +90,7 @@ ALWAYS_INLINE inline mirror::Object* AllocObjectFromCodeInitialized( template <bool kAccessCheck> -ALWAYS_INLINE inline mirror::Class* CheckArrayAlloc(uint32_t type_idx, +ALWAYS_INLINE inline mirror::Class* CheckArrayAlloc(dex::TypeIndex type_idx, int32_t component_count, ArtMethod* method, bool* slow_path) @@ -101,7 +102,7 @@ ALWAYS_INLINE inline mirror::Class* CheckArrayAlloc(uint32_t type_idx, // When verification/compiler hasn't been able to verify access, optionally perform an access // check. template <bool kAccessCheck, bool kInstrumented> -ALWAYS_INLINE inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, +ALWAYS_INLINE inline mirror::Array* AllocArrayFromCode(dex::TypeIndex type_idx, int32_t component_count, ArtMethod* method, Thread* self, @@ -118,19 +119,21 @@ ALWAYS_INLINE inline mirror::Array* AllocArrayFromCodeResolved(mirror::Class* kl REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); -extern mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, int32_t component_count, - ArtMethod* method, Thread* self, - bool access_check, - gc::AllocatorType allocator_type) +mirror::Array* CheckAndAllocArrayFromCode(dex::TypeIndex type_idx, + int32_t component_count, + ArtMethod* method, + Thread* self, + bool access_check, + gc::AllocatorType allocator_type) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); -extern mirror::Array* CheckAndAllocArrayFromCodeInstrumented(uint32_t type_idx, - int32_t component_count, - ArtMethod* method, - Thread* self, - bool access_check, - gc::AllocatorType allocator_type) +mirror::Array* CheckAndAllocArrayFromCodeInstrumented(dex::TypeIndex type_idx, + int32_t component_count, + ArtMethod* method, + Thread* self, + bool access_check, + gc::AllocatorType allocator_type) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); @@ -177,7 +180,7 @@ inline ArtMethod* FindMethodFast(uint32_t method_idx, InvokeType type) REQUIRES_SHARED(Locks::mutator_lock_); -inline mirror::Class* ResolveVerifyAndClinit(uint32_t type_idx, +inline mirror::Class* ResolveVerifyAndClinit(dex::TypeIndex type_idx, ArtMethod* referrer, Thread* self, bool can_run_clinit, diff --git a/runtime/entrypoints/quick/quick_alloc_entrypoints.cc b/runtime/entrypoints/quick/quick_alloc_entrypoints.cc index 515fcbf6e6..397655a895 100644 --- a/runtime/entrypoints/quick/quick_alloc_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_alloc_entrypoints.cc @@ -19,6 +19,7 @@ #include "art_method-inl.h" #include "base/enums.h" #include "callee_save_frame.h" +#include "dex_file_types.h" #include "entrypoints/entrypoint_utils-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" @@ -34,7 +35,8 @@ extern "C" mirror::Object* artAllocObjectFromCode ##suffix##suffix2( \ REQUIRES_SHARED(Locks::mutator_lock_) { \ ScopedQuickEntrypointChecks sqec(self); \ if (kUseTlabFastPath && !(instrumented_bool) && (allocator_type) == gc::kAllocatorTypeTLAB) { \ - mirror::Class* klass = method->GetDexCacheResolvedType<false>(type_idx, kRuntimePointerSize); \ + mirror::Class* klass = method->GetDexCacheResolvedType<false>(dex::TypeIndex(type_idx), \ + kRuntimePointerSize); \ if (LIKELY(klass != nullptr && klass->IsInitialized() && !klass->IsFinalizable())) { \ size_t byte_count = klass->GetObjectSize(); \ byte_count = RoundUp(byte_count, gc::space::BumpPointerSpace::kAlignment); \ @@ -51,7 +53,10 @@ extern "C" mirror::Object* artAllocObjectFromCode ##suffix##suffix2( \ } \ } \ } \ - return AllocObjectFromCode<false, instrumented_bool>(type_idx, method, self, allocator_type); \ + return AllocObjectFromCode<false, instrumented_bool>(dex::TypeIndex(type_idx), \ + method, \ + self, \ + allocator_type); \ } \ extern "C" mirror::Object* artAllocObjectFromCodeResolved##suffix##suffix2( \ mirror::Class* klass, ArtMethod* method ATTRIBUTE_UNUSED, Thread* self) \ @@ -101,13 +106,19 @@ extern "C" mirror::Object* artAllocObjectFromCodeWithAccessCheck##suffix##suffix uint32_t type_idx, ArtMethod* method, Thread* self) \ REQUIRES_SHARED(Locks::mutator_lock_) { \ ScopedQuickEntrypointChecks sqec(self); \ - return AllocObjectFromCode<true, instrumented_bool>(type_idx, method, self, allocator_type); \ + return AllocObjectFromCode<true, instrumented_bool>(dex::TypeIndex(type_idx), \ + method, \ + self, \ + allocator_type); \ } \ extern "C" mirror::Array* artAllocArrayFromCode##suffix##suffix2( \ uint32_t type_idx, int32_t component_count, ArtMethod* method, Thread* self) \ REQUIRES_SHARED(Locks::mutator_lock_) { \ ScopedQuickEntrypointChecks sqec(self); \ - return AllocArrayFromCode<false, instrumented_bool>(type_idx, component_count, method, self, \ + return AllocArrayFromCode<false, instrumented_bool>(dex::TypeIndex(type_idx), \ + component_count, \ + method, \ + self, \ allocator_type); \ } \ extern "C" mirror::Array* artAllocArrayFromCodeResolved##suffix##suffix2( \ @@ -121,7 +132,10 @@ extern "C" mirror::Array* artAllocArrayFromCodeWithAccessCheck##suffix##suffix2( uint32_t type_idx, int32_t component_count, ArtMethod* method, Thread* self) \ REQUIRES_SHARED(Locks::mutator_lock_) { \ ScopedQuickEntrypointChecks sqec(self); \ - return AllocArrayFromCode<true, instrumented_bool>(type_idx, component_count, method, self, \ + return AllocArrayFromCode<true, instrumented_bool>(dex::TypeIndex(type_idx), \ + component_count, \ + method, \ + self, \ allocator_type); \ } \ extern "C" mirror::Array* artCheckAndAllocArrayFromCode##suffix##suffix2( \ @@ -129,9 +143,19 @@ extern "C" mirror::Array* artCheckAndAllocArrayFromCode##suffix##suffix2( \ REQUIRES_SHARED(Locks::mutator_lock_) { \ ScopedQuickEntrypointChecks sqec(self); \ if (!(instrumented_bool)) { \ - return CheckAndAllocArrayFromCode(type_idx, component_count, method, self, false, allocator_type); \ + return CheckAndAllocArrayFromCode(dex::TypeIndex(type_idx), \ + component_count, \ + method, \ + self, \ + false, \ + allocator_type); \ } else { \ - return CheckAndAllocArrayFromCodeInstrumented(type_idx, component_count, method, self, false, allocator_type); \ + return CheckAndAllocArrayFromCodeInstrumented(dex::TypeIndex(type_idx), \ + component_count, \ + method, \ + self, \ + false, \ + allocator_type); \ } \ } \ extern "C" mirror::Array* artCheckAndAllocArrayFromCodeWithAccessCheck##suffix##suffix2( \ @@ -139,9 +163,19 @@ extern "C" mirror::Array* artCheckAndAllocArrayFromCodeWithAccessCheck##suffix## REQUIRES_SHARED(Locks::mutator_lock_) { \ ScopedQuickEntrypointChecks sqec(self); \ if (!(instrumented_bool)) { \ - return CheckAndAllocArrayFromCode(type_idx, component_count, method, self, true, allocator_type); \ + return CheckAndAllocArrayFromCode(dex::TypeIndex(type_idx), \ + component_count, \ + method, \ + self, \ + true, \ + allocator_type); \ } else { \ - return CheckAndAllocArrayFromCodeInstrumented(type_idx, component_count, method, self, true, allocator_type); \ + return CheckAndAllocArrayFromCodeInstrumented(dex::TypeIndex(type_idx), \ + component_count, \ + method, \ + self, \ + true, \ + allocator_type); \ } \ } \ extern "C" mirror::String* artAllocStringFromBytesFromCode##suffix##suffix2( \ diff --git a/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc b/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc index d4384182b2..b1259e1b8d 100644 --- a/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc @@ -20,6 +20,7 @@ #include "class_linker-inl.h" #include "class_table-inl.h" #include "dex_file-inl.h" +#include "dex_file_types.h" #include "gc/heap.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" @@ -37,7 +38,7 @@ extern "C" mirror::Class* artInitializeStaticStorageFromCode(uint32_t type_idx, // given by inheritance. ScopedQuickEntrypointChecks sqec(self); auto* caller = GetCalleeSaveMethodCaller(self, Runtime::kSaveRefsOnly); - return ResolveVerifyAndClinit(type_idx, caller, self, true, false); + return ResolveVerifyAndClinit(dex::TypeIndex(type_idx), caller, self, true, false); } extern "C" mirror::Class* artInitializeTypeFromCode(uint32_t type_idx, Thread* self) @@ -45,7 +46,7 @@ extern "C" mirror::Class* artInitializeTypeFromCode(uint32_t type_idx, Thread* s // Called when method->dex_cache_resolved_types_[] misses. ScopedQuickEntrypointChecks sqec(self); auto* caller = GetCalleeSaveMethodCaller(self, Runtime::kSaveRefsOnly); - return ResolveVerifyAndClinit(type_idx, caller, self, false, false); + return ResolveVerifyAndClinit(dex::TypeIndex(type_idx), caller, self, false, false); } extern "C" mirror::Class* artInitializeTypeAndVerifyAccessFromCode(uint32_t type_idx, Thread* self) @@ -54,7 +55,7 @@ extern "C" mirror::Class* artInitializeTypeAndVerifyAccessFromCode(uint32_t type // unpopulated. ScopedQuickEntrypointChecks sqec(self); auto* caller = GetCalleeSaveMethodCaller(self, Runtime::kSaveRefsOnly); - return ResolveVerifyAndClinit(type_idx, caller, self, false, true); + return ResolveVerifyAndClinit(dex::TypeIndex(type_idx), caller, self, false, true); } extern "C" mirror::String* artResolveStringFromCode(int32_t string_idx, Thread* self) |