diff options
author | 2016-10-06 17:44:26 -0700 | |
---|---|---|
committer | 2016-10-12 09:49:49 -0700 | |
commit | 9d156d500801accee919b6d51e22d6ddcdcd4a05 (patch) | |
tree | 92129562c0ba1673c660297f26444a4a2ad31459 /runtime/mirror/class-inl.h | |
parent | 078483d4dfd049d5b3f192a99e2dfdc355e4754f (diff) |
Move Heap parameters to ObjPtr
Deleted some unused object dumping code.
Test: test-art-host
Bug: 31113334
Change-Id: I747220caafe6679591fd4b361d7f50383a046164
Diffstat (limited to 'runtime/mirror/class-inl.h')
-rw-r--r-- | runtime/mirror/class-inl.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index cc088b8aa8..98d383dac9 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -707,9 +707,13 @@ inline Object* Class::Alloc(Thread* self, gc::AllocatorType allocator_type) { 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 @@ inline Object* Class::Alloc(Thread* self, gc::AllocatorType allocator_type) { obj = nullptr; } } - return obj; + return obj.Ptr(); } inline Object* Class::AllocObject(Thread* self) { @@ -879,11 +883,11 @@ inline void Class::SetSlowPath(bool enabled) { 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. |