diff options
| author | 2014-01-27 16:50:29 -0800 | |
|---|---|---|
| committer | 2014-01-27 16:50:29 -0800 | |
| commit | bb8f0ab736b61db8f543e433859272e83f96ee9b (patch) | |
| tree | 7b7bac5c0e7d0ac9aba91a40e0fbf761cfacb412 /runtime/entrypoints/entrypoint_utils.h | |
| parent | 6e65720d99bd3387b72d528a46291f1ed8184ede (diff) | |
Embed array class pointers at array allocation sites.
Following https://android-review.googlesource.com/#/c/79302, embed
array class pointers at array allocation sites in the compiled code.
Change-Id: I67a1292466dfbb7f48e746e5060e992dd93525c5
Diffstat (limited to 'runtime/entrypoints/entrypoint_utils.h')
| -rw-r--r-- | runtime/entrypoints/entrypoint_utils.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/runtime/entrypoints/entrypoint_utils.h b/runtime/entrypoints/entrypoint_utils.h index 5ee750fa7f..f6e8ca3d64 100644 --- a/runtime/entrypoints/entrypoint_utils.h +++ b/runtime/entrypoints/entrypoint_utils.h @@ -232,6 +232,30 @@ ALWAYS_INLINE static inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, return mirror::Array::Alloc<kInstrumented>(self, klass, component_count, allocator_type); } +template <bool kAccessCheck, bool kInstrumented> +ALWAYS_INLINE static inline mirror::Array* AllocArrayFromCodeResolved(mirror::Class* klass, + mirror::ArtMethod* method, + int32_t component_count, + Thread* self, + gc::AllocatorType allocator_type) + NO_THREAD_SAFETY_ANALYSIS { + DCHECK(klass != nullptr); + if (UNLIKELY(component_count < 0)) { + ThrowNegativeArraySizeException(component_count); + return nullptr; // Failure + } + if (kAccessCheck) { + mirror::Class* referrer = method->GetDeclaringClass(); + if (UNLIKELY(!referrer->CanAccess(klass))) { + ThrowIllegalAccessErrorClass(referrer, klass); + return nullptr; // Failure + } + } + // No need to retry a slow-path allocation as the above code won't + // cause a GC or thread suspension. + return mirror::Array::Alloc<kInstrumented>(self, klass, component_count, allocator_type); +} + extern mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, bool access_check, |