diff options
Diffstat (limited to 'runtime/mirror/object_reference.h')
-rw-r--r-- | runtime/mirror/object_reference.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/mirror/object_reference.h b/runtime/mirror/object_reference.h index b63d13d602..5edda8b346 100644 --- a/runtime/mirror/object_reference.h +++ b/runtime/mirror/object_reference.h @@ -43,6 +43,11 @@ class MANAGED ObjectReference { void Clear() { reference_ = 0; + DCHECK(IsNull()); + } + + bool IsNull() const { + return reference_ == 0; } uint32_t AsVRegValue() const { @@ -86,6 +91,23 @@ class MANAGED HeapReference : public ObjectReference<kPoisonHeapReferences, Mirr : ObjectReference<kPoisonHeapReferences, MirrorType>(mirror_ptr) {} }; +// Standard compressed reference used in the runtime. Used for StackRefernce and GC roots. +template<class MirrorType> +class MANAGED CompressedReference : public mirror::ObjectReference<false, MirrorType> { + public: + CompressedReference<MirrorType>() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) + : mirror::ObjectReference<false, MirrorType>(nullptr) {} + + static CompressedReference<MirrorType> FromMirrorPtr(MirrorType* p) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + return CompressedReference<MirrorType>(p); + } + + private: + CompressedReference<MirrorType>(MirrorType* p) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) + : mirror::ObjectReference<false, MirrorType>(p) {} +}; + } // namespace mirror } // namespace art |