Remove mirror:: and ArtMethod deps in utils.{h,cc}

The latest chapter in the ongoing saga of attempting to dump a DEX
file without having to start a whole runtime instance.  This episode
finds us removing references to ArtMethod/ArtField/mirror.

One aspect of this change that I would like to call out specfically
is that the utils versions of the "Pretty*" functions all were written
to accept nullptr as an argument.  I have split these functions up as
follows:
1) an instance method, such as PrettyClass that obviously requires
this != nullptr.
2) a static method, that behaves the same way as the util method, but
calls the instance method if p != nullptr.
This requires using a full class qualifier for the static methods,
which isn't exactly beautiful.  I have tried to remove as many cases
as possible where it was clear p != nullptr.

Bug: 22322814
Test: test-art-host
Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h
index 8077c21..31811fb 100644
--- a/runtime/entrypoints/entrypoint_utils-inl.h
+++ b/runtime/entrypoints/entrypoint_utils-inl.h
@@ -148,12 +148,13 @@
   }
   if (kAccessCheck) {
     if (UNLIKELY(!klass->IsInstantiable())) {
-      self->ThrowNewException("Ljava/lang/InstantiationError;", PrettyDescriptor(klass).c_str());
+      self->ThrowNewException("Ljava/lang/InstantiationError;", klass->PrettyDescriptor().c_str());
       *slow_path = true;
       return nullptr;  // Failure
     }
     if (UNLIKELY(klass->IsClassClass())) {
-      ThrowIllegalAccessError(nullptr, "Class %s is inaccessible", PrettyDescriptor(klass).c_str());
+      ThrowIllegalAccessError(nullptr, "Class %s is inaccessible",
+                              klass->PrettyDescriptor().c_str());
       *slow_path = true;
       return nullptr;  // Failure
     }
@@ -293,7 +294,7 @@
       DCHECK(Thread::Current()->IsExceptionPending());
       return nullptr;  // Failure
     }
-    CHECK(klass->IsArrayClass()) << PrettyClass(klass);
+    CHECK(klass->IsArrayClass()) << klass->PrettyClass();
   }
   if (kAccessCheck) {
     mirror::Class* referrer = method->GetDeclaringClass();
@@ -433,7 +434,7 @@
                                  "Attempted read of %zd-bit %s on field '%s'",
                                  expected_size * (32 / sizeof(int32_t)),
                                  is_primitive ? "primitive" : "non-primitive",
-                                 PrettyField(resolved_field, true).c_str());
+                                 resolved_field->PrettyField(true).c_str());
         return nullptr;  // Failure.
       }
     }
@@ -549,7 +550,7 @@
                                resolved_method->GetName(), resolved_method->GetSignature());
         return nullptr;  // Failure.
       }
-      DCHECK(klass->HasVTable()) << PrettyClass(klass);
+      DCHECK(klass->HasVTable()) << klass->PrettyClass();
       return klass->GetVTableEntry(vtable_index, class_linker->GetImagePointerSize());
     }
     case kSuper: {
@@ -624,9 +625,10 @@
           mirror::Class* klass = (*this_object)->GetClass();
           ArtMethod* method = klass->FindVirtualMethodForInterface(
               resolved_method, class_linker->GetImagePointerSize());
-          CHECK_EQ(imt_method, method) << PrettyMethod(resolved_method) << " / " <<
-              PrettyMethod(imt_method) << " / " << PrettyMethod(method) << " / " <<
-              PrettyClass(klass);
+          CHECK_EQ(imt_method, method) << ArtMethod::PrettyMethod(resolved_method) << " / "
+                                       << imt_method->PrettyMethod() << " / "
+                                       << ArtMethod::PrettyMethod(method) << " / "
+                                       << klass->PrettyClass();
         }
         return imt_method;
       } else {
diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc
index f8deb8f..cbefbba 100644
--- a/runtime/entrypoints/entrypoint_utils.cc
+++ b/runtime/entrypoints/entrypoint_utils.cc
@@ -61,12 +61,12 @@
   if (UNLIKELY(klass->IsPrimitive() && !klass->IsPrimitiveInt())) {
     if (klass->IsPrimitiveLong() || klass->IsPrimitiveDouble()) {
       ThrowRuntimeException("Bad filled array request for type %s",
-                            PrettyDescriptor(klass).c_str());
+                            klass->PrettyDescriptor().c_str());
     } else {
       self->ThrowNewExceptionF(
           "Ljava/lang/InternalError;",
           "Found type %s; filled-new-array not implemented for anything but 'int'",
-          PrettyDescriptor(klass).c_str());
+          klass->PrettyDescriptor().c_str());
     }
     return nullptr;  // Failure
   }
@@ -77,7 +77,7 @@
       return nullptr;  // Failure
     }
   }
-  DCHECK(klass->IsArrayClass()) << PrettyClass(klass);
+  DCHECK(klass->IsArrayClass()) << klass->PrettyClass();
   return klass;
 }
 
@@ -131,8 +131,8 @@
   if (!o->InstanceOf(return_type)) {
     Runtime::Current()->GetJavaVM()->JniAbortF(nullptr,
                                                "attempt to return an instance of %s from %s",
-                                               PrettyTypeOf(o.Get()).c_str(),
-                                               PrettyMethod(method).c_str());
+                                               o->PrettyTypeOf().c_str(),
+                                               method->PrettyMethod().c_str());
   }
 }
 
diff --git a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc
index fec7373..aa547bf 100644
--- a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc
@@ -44,7 +44,7 @@
   bool interpreter_entry = (result == GetQuickToInterpreterBridge());
   instrumentation->PushInstrumentationStackFrame(self, method->IsStatic() ? nullptr : this_object,
                                                  method, lr, interpreter_entry);
-  CHECK(result != nullptr) << PrettyMethod(method);
+  CHECK(result != nullptr) << method->PrettyMethod();
   return result;
 }
 
diff --git a/runtime/entrypoints/quick/quick_jni_entrypoints.cc b/runtime/entrypoints/quick/quick_jni_entrypoints.cc
index 383cdd2..b25f447 100644
--- a/runtime/entrypoints/quick/quick_jni_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_jni_entrypoints.cc
@@ -47,7 +47,7 @@
 
   if (kIsDebugBuild) {
     ArtMethod* native_method = *self->GetManagedStack()->GetTopQuickFrame();
-    CHECK(native_method->IsAnnotatedWithFastNative()) << PrettyMethod(native_method);
+    CHECK(native_method->IsAnnotatedWithFastNative()) << native_method->PrettyMethod();
   }
 
   return saved_local_ref_cookie;
@@ -110,7 +110,7 @@
 
   if (kIsDebugBuild) {
     ArtMethod* native_method = *self->GetManagedStack()->GetTopQuickFrame();
-    CHECK(native_method->IsAnnotatedWithFastNative()) << PrettyMethod(native_method);
+    CHECK(native_method->IsAnnotatedWithFastNative()) << native_method->PrettyMethod();
   }
 
   if (UNLIKELY(self->TestAllFlags())) {
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 750efac..0bb6581 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -660,11 +660,11 @@
       StackedShadowFrameType::kDeoptimizationShadowFrame, false);
   ManagedStack fragment;
 
-  DCHECK(!method->IsNative()) << PrettyMethod(method);
+  DCHECK(!method->IsNative()) << method->PrettyMethod();
   uint32_t shorty_len = 0;
   ArtMethod* non_proxy_method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
   const DexFile::CodeItem* code_item = non_proxy_method->GetCodeItem();
-  DCHECK(code_item != nullptr) << PrettyMethod(method);
+  DCHECK(code_item != nullptr) << method->PrettyMethod();
   const char* shorty = non_proxy_method->GetShorty(&shorty_len);
 
   JValue result;
@@ -679,8 +679,8 @@
       while (linked->GetLink() != nullptr) {
         linked = linked->GetLink();
       }
-      CHECK_EQ(method, linked->GetMethod()) << PrettyMethod(method) << " "
-          << PrettyMethod(linked->GetMethod());
+      CHECK_EQ(method, linked->GetMethod()) << method->PrettyMethod() << " "
+          << ArtMethod::PrettyMethod(linked->GetMethod());
     }
 
     if (VLOG_IS_ON(deopt)) {
@@ -743,7 +743,8 @@
       StackHandleScope<1> hs(self);
       Handle<mirror::Class> h_class(hs.NewHandle(shadow_frame->GetMethod()->GetDeclaringClass()));
       if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(self, h_class, true, true)) {
-        DCHECK(Thread::Current()->IsExceptionPending()) << PrettyMethod(shadow_frame->GetMethod());
+        DCHECK(Thread::Current()->IsExceptionPending())
+            << shadow_frame->GetMethod()->PrettyMethod();
         self->PopManagedStackFragment(fragment);
         return 0;
       }
@@ -846,13 +847,13 @@
 extern "C" uint64_t artQuickProxyInvokeHandler(
     ArtMethod* proxy_method, mirror::Object* receiver, Thread* self, ArtMethod** sp)
     REQUIRES_SHARED(Locks::mutator_lock_) {
-  DCHECK(proxy_method->IsProxyMethod()) << PrettyMethod(proxy_method);
-  DCHECK(receiver->GetClass()->IsProxyClass()) << PrettyMethod(proxy_method);
+  DCHECK(proxy_method->IsProxyMethod()) << proxy_method->PrettyMethod();
+  DCHECK(receiver->GetClass()->IsProxyClass()) << proxy_method->PrettyMethod();
   // Ensure we don't get thread suspension until the object arguments are safely in jobjects.
   const char* old_cause =
       self->StartAssertNoThreadSuspension("Adding to IRT proxy object arguments");
   // Register the top of the managed stack, making stack crawlable.
-  DCHECK_EQ((*sp), proxy_method) << PrettyMethod(proxy_method);
+  DCHECK_EQ((*sp), proxy_method) << proxy_method->PrettyMethod();
   self->VerifyStack();
   // Start new JNI local reference state.
   JNIEnvExt* env = self->GetJniEnv();
@@ -863,21 +864,21 @@
 
   // Placing arguments into args vector and remove the receiver.
   ArtMethod* non_proxy_method = proxy_method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
-  CHECK(!non_proxy_method->IsStatic()) << PrettyMethod(proxy_method) << " "
-                                       << PrettyMethod(non_proxy_method);
+  CHECK(!non_proxy_method->IsStatic()) << proxy_method->PrettyMethod() << " "
+                                       << non_proxy_method->PrettyMethod();
   std::vector<jvalue> args;
   uint32_t shorty_len = 0;
   const char* shorty = non_proxy_method->GetShorty(&shorty_len);
   BuildQuickArgumentVisitor local_ref_visitor(sp, false, shorty, shorty_len, &soa, &args);
 
   local_ref_visitor.VisitArguments();
-  DCHECK_GT(args.size(), 0U) << PrettyMethod(proxy_method);
+  DCHECK_GT(args.size(), 0U) << proxy_method->PrettyMethod();
   args.erase(args.begin());
 
   // Convert proxy method into expected interface method.
   ArtMethod* interface_method = proxy_method->FindOverriddenMethod(kRuntimePointerSize);
-  DCHECK(interface_method != nullptr) << PrettyMethod(proxy_method);
-  DCHECK(!interface_method->IsProxyMethod()) << PrettyMethod(interface_method);
+  DCHECK(interface_method != nullptr) << proxy_method->PrettyMethod();
+  DCHECK(!interface_method->IsProxyMethod()) << interface_method->PrettyMethod();
   self->EndAssertNoThreadSuspension(old_cause);
   DCHECK_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize);
   DCHECK(!Runtime::Current()->IsActiveTransaction());
@@ -1034,7 +1035,7 @@
   if (LIKELY(!self->IsExceptionPending())) {
     // Incompatible class change should have been handled in resolve method.
     CHECK(!called->CheckIncompatibleClassChange(invoke_type))
-        << PrettyMethod(called) << " " << invoke_type;
+        << called->PrettyMethod() << " " << invoke_type;
     if (virtual_or_interface || invoke_type == kSuper) {
       // Refine called method based on receiver for kVirtual/kInterface, and
       // caller for kSuper.
@@ -1064,8 +1065,8 @@
         }
       }
 
-      CHECK(called != nullptr) << PrettyMethod(orig_called) << " "
-                               << PrettyTypeOf(receiver) << " "
+      CHECK(called != nullptr) << orig_called->PrettyMethod() << " "
+                               << mirror::Object::PrettyTypeOf(receiver) << " "
                                << invoke_type << " " << orig_called->GetVtableIndex();
 
       // We came here because of sharpening. Ensure the dex cache is up-to-date on the method index
@@ -1999,7 +2000,7 @@
 extern "C" TwoWordReturn artQuickGenericJniTrampoline(Thread* self, ArtMethod** sp)
     REQUIRES_SHARED(Locks::mutator_lock_) {
   ArtMethod* called = *sp;
-  DCHECK(called->IsNative()) << PrettyMethod(called, true);
+  DCHECK(called->IsNative()) << called->PrettyMethod(true);
   uint32_t shorty_len = 0;
   const char* shorty = called->GetShorty(&shorty_len);
   bool critical_native = called->IsAnnotatedWithCriticalNative();
@@ -2149,7 +2150,7 @@
   const void* code = method->GetEntryPointFromQuickCompiledCode();
 
   // When we return, the caller will branch to this address, so it had better not be 0!
-  DCHECK(code != nullptr) << "Code was null in method: " << PrettyMethod(method)
+  DCHECK(code != nullptr) << "Code was null in method: " << method->PrettyMethod()
                           << " location: "
                           << method->GetDexFile()->GetLocation();
 
@@ -2240,7 +2241,7 @@
 
   ArtMethod* interface_method = caller_method->GetDexCacheResolvedMethod(
       dex_method_idx, kRuntimePointerSize);
-  DCHECK(interface_method != nullptr) << dex_method_idx << " " << PrettyMethod(caller_method);
+  DCHECK(interface_method != nullptr) << dex_method_idx << " " << caller_method->PrettyMethod();
   ArtMethod* method = nullptr;
   ImTable* imt = cls->GetImt(kRuntimePointerSize);
 
@@ -2321,7 +2322,7 @@
   const void* code = method->GetEntryPointFromQuickCompiledCode();
 
   // When we return, the caller will branch to this address, so it had better not be 0!
-  DCHECK(code != nullptr) << "Code was null in method: " << PrettyMethod(method)
+  DCHECK(code != nullptr) << "Code was null in method: " << method->PrettyMethod()
                           << " location: " << method->GetDexFile()->GetLocation();
 
   return GetTwoWordSuccessValue(reinterpret_cast<uintptr_t>(code),