Move Heap parameters to ObjPtr
Deleted some unused object dumping code.
Test: test-art-host
Bug: 31113334
Change-Id: I747220caafe6679591fd4b361d7f50383a046164
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index cc088b8..98d383d 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -707,9 +707,13 @@
if (!kCheckAddFinalizer) {
DCHECK(!IsFinalizable());
}
- mirror::Object* obj =
- heap->AllocObjectWithAllocator<kIsInstrumented, false>(self, this, this->object_size_,
- allocator_type, VoidFunctor());
+ // Note that the this pointer may be invalidated after the allocation.
+ ObjPtr<mirror::Object> obj =
+ heap->AllocObjectWithAllocator<kIsInstrumented, false>(self,
+ this,
+ this->object_size_,
+ allocator_type,
+ VoidFunctor());
if (add_finalizer && LIKELY(obj != nullptr)) {
heap->AddFinalizerReference(self, &obj);
if (UNLIKELY(self->IsExceptionPending())) {
@@ -717,7 +721,7 @@
obj = nullptr;
}
}
- return obj;
+ return obj.Ptr();
}
inline Object* Class::AllocObject(Thread* self) {
@@ -879,11 +883,11 @@
SetFieldBoolean<false, false>(GetSlowPathFlagOffset(), enabled);
}
-inline void Class::InitializeClassVisitor::operator()(
- mirror::Object* obj, size_t usable_size) const {
+inline void Class::InitializeClassVisitor::operator()(ObjPtr<mirror::Object> obj,
+ size_t usable_size) const {
DCHECK_LE(class_size_, usable_size);
// Avoid AsClass as object is not yet in live bitmap or allocation stack.
- mirror::Class* klass = down_cast<mirror::Class*>(obj);
+ ObjPtr<mirror::Class> klass = ObjPtr<mirror::Class>::DownCast(obj);
// DCHECK(klass->IsClass());
klass->SetClassSize(class_size_);
klass->SetPrimitiveType(Primitive::kPrimNot); // Default to not being primitive.