Move ArtField to ObjPtr
Added EXPECT_OBJ_PTR_EQ and variants to gtests.
Fixed moving GC bugs in:
ClassLinker::CreatePathClassLoader
ClassLinkerTest: StaticFields
ObjPtr Decode call sites: 186 -> 181.
Some tests fail due to ResolvedFieldAccessTest, will fix in follow
up CL.
Bug: 31113334
Test: test-art-host CC baker
Change-Id: I8b266ad00f3c20c8cbe7cfdf280d175083df0b88
diff --git a/runtime/gc_root-inl.h b/runtime/gc_root-inl.h
index ae8a38f..11ccd33 100644
--- a/runtime/gc_root-inl.h
+++ b/runtime/gc_root-inl.h
@@ -21,6 +21,7 @@
#include <sstream>
+#include "obj_ptr-inl.h"
#include "read_barrier-inl.h"
namespace art {
@@ -31,10 +32,15 @@
return down_cast<MirrorType*>(
ReadBarrier::BarrierForRoot<mirror::Object, kReadBarrierOption>(&root_, gc_root_source));
}
+
template<class MirrorType>
inline GcRoot<MirrorType>::GcRoot(MirrorType* ref)
: root_(mirror::CompressedReference<mirror::Object>::FromMirrorPtr(ref)) { }
+template<class MirrorType>
+inline GcRoot<MirrorType>::GcRoot(ObjPtr<MirrorType, kIsDebugBuild> ref)
+ : GcRoot(ref.Decode()) { }
+
inline std::string RootInfo::ToString() const {
std::ostringstream oss;
Describe(oss);