Move mirror::ObjectArray to ObjPtr
Also reduce calls to ObjPtr::Ptr.
Bug: 31113334
Test: test-art-host -j32
Change-Id: I73e1b356972bb079b66332f00f7f07451601044e
diff --git a/runtime/mirror/object_array.h b/runtime/mirror/object_array.h
index 19b9d87..e4e954e 100644
--- a/runtime/mirror/object_array.h
+++ b/runtime/mirror/object_array.h
@@ -18,6 +18,7 @@
#define ART_RUNTIME_MIRROR_OBJECT_ARRAY_H_
#include "array.h"
+#include "obj_ptr.h"
namespace art {
namespace mirror {
@@ -30,11 +31,15 @@
return Array::ClassSize(pointer_size);
}
- static ObjectArray<T>* Alloc(Thread* self, Class* object_array_class, int32_t length,
+ static ObjectArray<T>* Alloc(Thread* self,
+ ObjPtr<Class> object_array_class,
+ int32_t length,
gc::AllocatorType allocator_type)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
- static ObjectArray<T>* Alloc(Thread* self, Class* object_array_class, int32_t length)
+ static ObjectArray<T>* Alloc(Thread* self,
+ ObjPtr<Class> object_array_class,
+ int32_t length)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
@@ -45,13 +50,13 @@
// an ArrayStoreException and returns false.
// TODO fix thread safety analysis: should be REQUIRES_SHARED(Locks::mutator_lock_).
template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
- bool CheckAssignable(T* object) NO_THREAD_SAFETY_ANALYSIS;
+ bool CheckAssignable(ObjPtr<T> object) NO_THREAD_SAFETY_ANALYSIS;
- ALWAYS_INLINE void Set(int32_t i, T* object) REQUIRES_SHARED(Locks::mutator_lock_);
+ ALWAYS_INLINE void Set(int32_t i, ObjPtr<T> object) REQUIRES_SHARED(Locks::mutator_lock_);
// TODO fix thread safety analysis: should be REQUIRES_SHARED(Locks::mutator_lock_).
template<bool kTransactionActive, bool kCheckTransaction = true,
VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
- ALWAYS_INLINE void Set(int32_t i, T* object) NO_THREAD_SAFETY_ANALYSIS;
+ ALWAYS_INLINE void Set(int32_t i, ObjPtr<T> object) NO_THREAD_SAFETY_ANALYSIS;
// Set element without bound and element type checks, to be used in limited
// circumstances, such as during boot image writing.
@@ -59,32 +64,42 @@
// REQUIRES_SHARED(Locks::mutator_lock_).
template<bool kTransactionActive, bool kCheckTransaction = true,
VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
- ALWAYS_INLINE void SetWithoutChecks(int32_t i, T* object) NO_THREAD_SAFETY_ANALYSIS;
+ ALWAYS_INLINE void SetWithoutChecks(int32_t i, ObjPtr<T> object) NO_THREAD_SAFETY_ANALYSIS;
// TODO fix thread safety analysis broken by the use of template. This should be
// REQUIRES_SHARED(Locks::mutator_lock_).
template<bool kTransactionActive, bool kCheckTransaction = true,
VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
- ALWAYS_INLINE void SetWithoutChecksAndWriteBarrier(int32_t i, T* object)
+ ALWAYS_INLINE void SetWithoutChecksAndWriteBarrier(int32_t i, ObjPtr<T> object)
NO_THREAD_SAFETY_ANALYSIS;
ALWAYS_INLINE T* GetWithoutChecks(int32_t i) REQUIRES_SHARED(Locks::mutator_lock_);
// Copy src into this array (dealing with overlaps as memmove does) without assignability checks.
- void AssignableMemmove(int32_t dst_pos, ObjectArray<T>* src, int32_t src_pos,
- int32_t count) REQUIRES_SHARED(Locks::mutator_lock_);
+ void AssignableMemmove(int32_t dst_pos,
+ ObjPtr<ObjectArray<T>> src,
+ int32_t src_pos,
+ int32_t count)
+ REQUIRES_SHARED(Locks::mutator_lock_);
// Copy src into this array assuming no overlap and without assignability checks.
- void AssignableMemcpy(int32_t dst_pos, ObjectArray<T>* src, int32_t src_pos,
- int32_t count) REQUIRES_SHARED(Locks::mutator_lock_);
+ void AssignableMemcpy(int32_t dst_pos,
+ ObjPtr<ObjectArray<T>> src,
+ int32_t src_pos,
+ int32_t count)
+ REQUIRES_SHARED(Locks::mutator_lock_);
// Copy src into this array with assignability checks.
template<bool kTransactionActive>
- void AssignableCheckingMemcpy(int32_t dst_pos, ObjectArray<T>* src, int32_t src_pos,
- int32_t count, bool throw_exception)
+ void AssignableCheckingMemcpy(int32_t dst_pos,
+ ObjPtr<ObjectArray<T>> src,
+ int32_t src_pos,
+ int32_t count,
+ bool throw_exception)
REQUIRES_SHARED(Locks::mutator_lock_);
ObjectArray<T>* CopyOf(Thread* self, int32_t new_length)
- REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
+ REQUIRES_SHARED(Locks::mutator_lock_)
+ REQUIRES(!Roles::uninterruptible_);
static MemberOffset OffsetOfElement(int32_t i);