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/jdwp/object_registry.cc b/runtime/jdwp/object_registry.cc
index 9ba62c9..dc3bf16 100644
--- a/runtime/jdwp/object_registry.cc
+++ b/runtime/jdwp/object_registry.cc
@@ -19,6 +19,7 @@
 #include "handle_scope-inl.h"
 #include "jni_internal.h"
 #include "mirror/class.h"
+#include "obj_ptr-inl.h"
 #include "scoped_thread_state_change-inl.h"
 
 namespace art {
@@ -35,7 +36,7 @@
     : lock_("ObjectRegistry lock", kJdwpObjectRegistryLock), next_id_(1) {
 }
 
-JDWP::RefTypeId ObjectRegistry::AddRefType(mirror::Class* c) {
+JDWP::RefTypeId ObjectRegistry::AddRefType(ObjPtr<mirror::Class> c) {
   return Add(c);
 }
 
@@ -43,7 +44,7 @@
   return Add(c_h);
 }
 
-JDWP::ObjectId ObjectRegistry::Add(mirror::Object* o) {
+JDWP::ObjectId ObjectRegistry::Add(ObjPtr<mirror::Object> o) {
   if (o == nullptr) {
     return 0;
   }
@@ -118,7 +119,9 @@
   return entry->id;
 }
 
-bool ObjectRegistry::ContainsLocked(Thread* self, mirror::Object* o, int32_t identity_hash_code,
+bool ObjectRegistry::ContainsLocked(Thread* self,
+                                    ObjPtr<mirror::Object> o,
+                                    int32_t identity_hash_code,
                                     ObjectRegistryEntry** out_entry) {
   DCHECK(o != nullptr);
   for (auto it = object_to_entry_.lower_bound(identity_hash_code), end = object_to_entry_.end();
diff --git a/runtime/jdwp/object_registry.h b/runtime/jdwp/object_registry.h
index 7fa57c6..9cacc66 100644
--- a/runtime/jdwp/object_registry.h
+++ b/runtime/jdwp/object_registry.h
@@ -25,6 +25,7 @@
 #include "base/casts.h"
 #include "handle.h"
 #include "jdwp/jdwp.h"
+#include "obj_ptr.h"
 #include "safe_map.h"
 
 namespace art {
@@ -62,11 +63,11 @@
  public:
   ObjectRegistry();
 
-  JDWP::ObjectId Add(mirror::Object* o)
+  JDWP::ObjectId Add(ObjPtr<mirror::Object> o)
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_, !lock_);
 
-  JDWP::RefTypeId AddRefType(mirror::Class* c)
+  JDWP::RefTypeId AddRefType(ObjPtr<mirror::Class> c)
       REQUIRES_SHARED(Locks::mutator_lock_)
       REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_, !lock_);
 
@@ -121,7 +122,9 @@
   void Promote(ObjectRegistryEntry& entry)
       REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(lock_);
 
-  bool ContainsLocked(Thread* self, mirror::Object* o, int32_t identity_hash_code,
+  bool ContainsLocked(Thread* self,
+                      ObjPtr<mirror::Object> o,
+                      int32_t identity_hash_code,
                       ObjectRegistryEntry** out_entry)
       REQUIRES(lock_) REQUIRES_SHARED(Locks::mutator_lock_);