ObjPtr<>-ify mirror::Field and mirror::Executable.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 31113334
Change-Id: Ib536df95543cb7240a5816bef019391bb90e6369
diff --git a/runtime/mirror/executable-inl.h b/runtime/mirror/executable-inl.h
new file mode 100644
index 0000000..6d4b46a
--- /dev/null
+++ b/runtime/mirror/executable-inl.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_RUNTIME_MIRROR_EXECUTABLE_INL_H_
+#define ART_RUNTIME_MIRROR_EXECUTABLE_INL_H_
+
+#include "executable.h"
+
+#include "object-inl.h"
+
+namespace art {
+namespace mirror {
+
+template <bool kTransactionActive,
+          bool kCheckTransaction,
+          VerifyObjectFlags kVerifyFlags>
+inline void Executable::SetArtMethod(ArtMethod* method) {
+  SetField64<kTransactionActive, kCheckTransaction, kVerifyFlags>(
+      ArtMethodOffset(), reinterpret_cast64<uint64_t>(method));
+}
+
+inline ObjPtr<mirror::Class> Executable::GetDeclaringClass() {
+  return GetFieldObject<mirror::Class>(DeclaringClassOffset());
+}
+
+}  // namespace mirror
+}  // namespace art
+
+#endif  // ART_RUNTIME_MIRROR_EXECUTABLE_INL_H_
diff --git a/runtime/mirror/executable.cc b/runtime/mirror/executable.cc
index 24e2047..d2a2ec5 100644
--- a/runtime/mirror/executable.cc
+++ b/runtime/mirror/executable.cc
@@ -14,9 +14,10 @@
  * limitations under the License.
  */
 
-#include "executable.h"
+#include "executable-inl.h"
 
 #include "art_method-inl.h"
+#include "object-inl.h"
 
 namespace art {
 namespace mirror {
@@ -38,9 +39,5 @@
 template bool Executable::CreateFromArtMethod<PointerSize::k64, false>(ArtMethod* method);
 template bool Executable::CreateFromArtMethod<PointerSize::k64, true>(ArtMethod* method);
 
-mirror::Class* Executable::GetDeclaringClass() {
-  return GetFieldObject<mirror::Class>(DeclaringClassOffset());
-}
-
 }  // namespace mirror
 }  // namespace art
diff --git a/runtime/mirror/executable.h b/runtime/mirror/executable.h
index 14c9d4c..a99c3ec 100644
--- a/runtime/mirror/executable.h
+++ b/runtime/mirror/executable.h
@@ -18,7 +18,7 @@
 #define ART_RUNTIME_MIRROR_EXECUTABLE_H_
 
 #include "accessible_object.h"
-#include "object-inl.h"
+#include "object.h"
 #include "read_barrier_option.h"
 
 namespace art {
@@ -44,12 +44,9 @@
   template <bool kTransactionActive = false,
             bool kCheckTransaction = true,
             VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
-  void SetArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) {
-    SetField64<kTransactionActive, kCheckTransaction, kVerifyFlags>(
-        ArtMethodOffset(), reinterpret_cast64<uint64_t>(method));
-  }
+  void SetArtMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
 
-  mirror::Class* GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_);
+  ObjPtr<mirror::Class> GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_);
 
   static MemberOffset ArtMethodOffset() {
     return MemberOffset(OFFSETOF_MEMBER(Executable, art_method_));
diff --git a/runtime/mirror/field-inl.h b/runtime/mirror/field-inl.h
index 803b880..ac11be1 100644
--- a/runtime/mirror/field-inl.h
+++ b/runtime/mirror/field-inl.h
@@ -23,13 +23,28 @@
 #include "class-alloc-inl.h"
 #include "class_root.h"
 #include "dex_cache-inl.h"
+#include "object-inl.h"
 
 namespace art {
 
 namespace mirror {
 
+inline ObjPtr<mirror::Class> Field::GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_) {
+  return GetFieldObject<Class>(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_));
+}
+
+inline Primitive::Type Field::GetTypeAsPrimitiveType() {
+  return GetType()->GetPrimitiveType();
+}
+
+inline ObjPtr<mirror::Class> Field::GetType() {
+  return GetFieldObject<mirror::Class>(OFFSET_OF_OBJECT_MEMBER(Field, type_));
+}
+
 template <PointerSize kPointerSize, bool kTransactionActive>
-inline mirror::Field* Field::CreateFromArtField(Thread* self, ArtField* field, bool force_resolve) {
+inline ObjPtr<mirror::Field> Field::CreateFromArtField(Thread* self,
+                                                       ArtField* field,
+                                                       bool force_resolve) {
   StackHandleScope<2> hs(self);
   // Try to resolve type before allocating since this is a thread suspension point.
   Handle<mirror::Class> type = hs.NewHandle(field->ResolveType());
@@ -89,10 +104,6 @@
   SetFieldObject<kTransactionActive>(OFFSET_OF_OBJECT_MEMBER(Field, type_), type);
 }
 
-inline Primitive::Type Field::GetTypeAsPrimitiveType() {
-  return GetType()->GetPrimitiveType();
-}
-
 }  // namespace mirror
 }  // namespace art
 
diff --git a/runtime/mirror/field.cc b/runtime/mirror/field.cc
index 1af0778..e885d41 100644
--- a/runtime/mirror/field.cc
+++ b/runtime/mirror/field.cc
@@ -25,7 +25,7 @@
 namespace mirror {
 
 ArtField* Field::GetArtField() {
-  mirror::Class* declaring_class = GetDeclaringClass();
+  ObjPtr<mirror::Class> declaring_class = GetDeclaringClass();
   if (UNLIKELY(declaring_class->IsProxyClass())) {
     DCHECK(IsStatic());
     DCHECK_EQ(declaring_class->NumStaticFields(), 2U);
diff --git a/runtime/mirror/field.h b/runtime/mirror/field.h
index 3501e71..6ba8dc6 100644
--- a/runtime/mirror/field.h
+++ b/runtime/mirror/field.h
@@ -42,9 +42,7 @@
     return GetField32(OFFSET_OF_OBJECT_MEMBER(Field, dex_field_index_));
   }
 
-  mirror::Class* GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_) {
-    return GetFieldObject<Class>(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_));
-  }
+  ObjPtr<mirror::Class> GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_);
 
   uint32_t GetAccessFlags() REQUIRES_SHARED(Locks::mutator_lock_) {
     return GetField32(OFFSET_OF_OBJECT_MEMBER(Field, access_flags_));
@@ -64,9 +62,7 @@
 
   ALWAYS_INLINE Primitive::Type GetTypeAsPrimitiveType() REQUIRES_SHARED(Locks::mutator_lock_);
 
-  mirror::Class* GetType() REQUIRES_SHARED(Locks::mutator_lock_) {
-    return GetFieldObject<mirror::Class>(OFFSET_OF_OBJECT_MEMBER(Field, type_));
-  }
+  ObjPtr<mirror::Class> GetType() REQUIRES_SHARED(Locks::mutator_lock_);
 
   int32_t GetOffset() REQUIRES_SHARED(Locks::mutator_lock_) {
     return GetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_));
@@ -76,8 +72,9 @@
   ArtField* GetArtField() REQUIRES_SHARED(Locks::mutator_lock_);
 
   template <PointerSize kPointerSize, bool kTransactionActive = false>
-  static mirror::Field* CreateFromArtField(Thread* self, ArtField* field,
-                                           bool force_resolve)
+  static ObjPtr<mirror::Field> CreateFromArtField(Thread* self,
+                                                  ArtField* field,
+                                                  bool force_resolve)
       REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
 
  private: