Move mirror::Object setters to ObjPtr
Bug: 31113334
Test: test-art-host
Change-Id: I2c4c84645e194c3c435a4a6fd670176b0e98671f
diff --git a/runtime/mirror/object_reference.h b/runtime/mirror/object_reference.h
index f4a3580..573cb30 100644
--- a/runtime/mirror/object_reference.h
+++ b/runtime/mirror/object_reference.h
@@ -19,6 +19,7 @@
#include "base/mutex.h" // For Locks::mutator_lock_.
#include "globals.h"
+#include "obj_ptr.h"
namespace art {
namespace mirror {
@@ -86,11 +87,18 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
return HeapReference<MirrorType>(mirror_ptr);
}
+
+ static HeapReference<MirrorType> FromObjPtr(ObjPtr<MirrorType> ptr)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
private:
explicit HeapReference(MirrorType* mirror_ptr) REQUIRES_SHARED(Locks::mutator_lock_)
: ObjectReference<kPoisonHeapReferences, MirrorType>(mirror_ptr) {}
};
+static_assert(sizeof(mirror::HeapReference<mirror::Object>) == kHeapReferenceSize,
+ "heap reference size does not match");
+
// Standard compressed reference used in the runtime. Used for StackReference and GC roots.
template<class MirrorType>
class MANAGED CompressedReference : public mirror::ObjectReference<false, MirrorType> {