Move most mirror:: args to ObjPtr
Fixed possible moving GC bugs in ClinitImageUpdate class.
Bug: 31113334
Test: test-art-host
Change-Id: I0bf6578553d58b944aaa17665f1350bdf5ed15ec
diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h
index d18781a..3789081 100644
--- a/runtime/mirror/array-inl.h
+++ b/runtime/mirror/array-inl.h
@@ -150,8 +150,11 @@
};
template <bool kIsInstrumented, bool kFillUsable>
-inline Array* Array::Alloc(Thread* self, Class* array_class, int32_t component_count,
- size_t component_size_shift, gc::AllocatorType allocator_type) {
+inline Array* Array::Alloc(Thread* self,
+ ObjPtr<Class> array_class,
+ int32_t component_count,
+ size_t component_size_shift,
+ gc::AllocatorType allocator_type) {
DCHECK(allocator_type != gc::kAllocatorTypeLOS);
DCHECK(array_class != nullptr);
DCHECK(array_class->IsArrayClass());
@@ -204,7 +207,9 @@
template<typename T>
inline PrimitiveArray<T>* PrimitiveArray<T>::Alloc(Thread* self, size_t length) {
- Array* raw_array = Array::Alloc<true>(self, GetArrayClass(), length,
+ Array* raw_array = Array::Alloc<true>(self,
+ GetArrayClass(),
+ length,
ComponentSizeShiftWidth(sizeof(T)),
Runtime::Current()->GetHeap()->GetCurrentAllocator());
return down_cast<PrimitiveArray<T>*>(raw_array);
@@ -275,7 +280,9 @@
}
template<class T>
-inline void PrimitiveArray<T>::Memmove(int32_t dst_pos, PrimitiveArray<T>* src, int32_t src_pos,
+inline void PrimitiveArray<T>::Memmove(int32_t dst_pos,
+ ObjPtr<PrimitiveArray<T>> src,
+ int32_t src_pos,
int32_t count) {
if (UNLIKELY(count == 0)) {
return;
@@ -335,7 +342,9 @@
}
template<class T>
-inline void PrimitiveArray<T>::Memcpy(int32_t dst_pos, PrimitiveArray<T>* src, int32_t src_pos,
+inline void PrimitiveArray<T>::Memcpy(int32_t dst_pos,
+ ObjPtr<PrimitiveArray<T>> src,
+ int32_t src_pos,
int32_t count) {
if (UNLIKELY(count == 0)) {
return;
@@ -415,6 +424,13 @@
}
}
+template<typename T>
+inline void PrimitiveArray<T>::SetArrayClass(ObjPtr<Class> array_class) {
+ CHECK(array_class_.IsNull());
+ CHECK(array_class != nullptr);
+ array_class_ = GcRoot<Class>(array_class);
+}
+
} // namespace mirror
} // namespace art