Move most of runtime/base to libartbase/base

Enforce the layering that code in runtime/base should not depend on
runtime by separating it into libartbase.  Some of the code in
runtime/base depends on the Runtime class, so it cannot be moved yet.
Also, some of the tests depend on CommonRuntimeTest, which itself needs
to be factored (in a subsequent CL).

Bug: 22322814
Test: make -j 50 checkbuild
      make -j 50 test-art-host

Change-Id: I8b096c1e2542f829eb456b4b057c71421b77d7e2
diff --git a/runtime/mirror/array.cc b/runtime/mirror/array.cc
index 25283bc..ea202e7 100644
--- a/runtime/mirror/array.cc
+++ b/runtime/mirror/array.cc
@@ -16,6 +16,7 @@
 
 #include "array-inl.h"
 
+#include "base/utils.h"
 #include "class-inl.h"
 #include "class.h"
 #include "class_linker-inl.h"
@@ -26,7 +27,6 @@
 #include "object-inl.h"
 #include "object_array-inl.h"
 #include "thread.h"
-#include "utils.h"
 
 namespace art {
 namespace mirror {
diff --git a/runtime/mirror/call_site.h b/runtime/mirror/call_site.h
index db244a5..93f2748 100644
--- a/runtime/mirror/call_site.h
+++ b/runtime/mirror/call_site.h
@@ -17,8 +17,8 @@
 #ifndef ART_RUNTIME_MIRROR_CALL_SITE_H_
 #define ART_RUNTIME_MIRROR_CALL_SITE_H_
 
+#include "base/utils.h"
 #include "mirror/method_handle_impl.h"
-#include "utils.h"
 
 namespace art {
 
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 86d538e..ee7d217 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -23,6 +23,7 @@
 #include "art_method.h"
 #include "base/array_slice.h"
 #include "base/length_prefixed_array.h"
+#include "base/utils.h"
 #include "class_linker.h"
 #include "class_loader.h"
 #include "common_throws.h"
@@ -39,7 +40,6 @@
 #include "reference-inl.h"
 #include "runtime.h"
 #include "string.h"
-#include "utils.h"
 
 namespace art {
 namespace mirror {
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index 7a09391..3f4e841 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -21,6 +21,7 @@
 #include "art_field-inl.h"
 #include "art_method-inl.h"
 #include "base/logging.h"  // For VLOG.
+#include "base/utils.h"
 #include "class-inl.h"
 #include "class_ext.h"
 #include "class_linker-inl.h"
@@ -40,7 +41,6 @@
 #include "runtime.h"
 #include "thread.h"
 #include "throwable.h"
-#include "utils.h"
 #include "well_known_classes.h"
 
 namespace art {
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index 6000317..ea06567 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -21,6 +21,8 @@
 #include "base/casts.h"
 #include "base/enums.h"
 #include "base/iteration_range.h"
+#include "base/stride_iterator.h"
+#include "base/utils.h"
 #include "class_flags.h"
 #include "class_status.h"
 #include "dex/dex_file.h"
@@ -33,9 +35,7 @@
 #include "object.h"
 #include "object_array.h"
 #include "read_barrier_option.h"
-#include "stride_iterator.h"
 #include "thread.h"
-#include "utils.h"
 
 namespace art {
 
diff --git a/runtime/mirror/class_ext.cc b/runtime/mirror/class_ext.cc
index c18b219..0819579 100644
--- a/runtime/mirror/class_ext.cc
+++ b/runtime/mirror/class_ext.cc
@@ -19,13 +19,13 @@
 #include "art_method-inl.h"
 #include "base/casts.h"
 #include "base/enums.h"
+#include "base/utils.h"
 #include "class-inl.h"
 #include "dex/dex_file-inl.h"
 #include "gc/accounting/card_table-inl.h"
 #include "object-inl.h"
 #include "object_array.h"
 #include "stack_trace_element.h"
-#include "utils.h"
 #include "well_known_classes.h"
 
 namespace art {
diff --git a/runtime/mirror/emulated_stack_frame.h b/runtime/mirror/emulated_stack_frame.h
index 9bfa4d6..23626f4 100644
--- a/runtime/mirror/emulated_stack_frame.h
+++ b/runtime/mirror/emulated_stack_frame.h
@@ -17,12 +17,12 @@
 #ifndef ART_RUNTIME_MIRROR_EMULATED_STACK_FRAME_H_
 #define ART_RUNTIME_MIRROR_EMULATED_STACK_FRAME_H_
 
+#include "base/utils.h"
 #include "dex/dex_instruction.h"
 #include "method_type.h"
 #include "object.h"
 #include "stack.h"
 #include "string.h"
-#include "utils.h"
 
 namespace art {
 
diff --git a/runtime/mirror/method_handles_lookup.h b/runtime/mirror/method_handles_lookup.h
index dd8d45e..fefcb2e 100644
--- a/runtime/mirror/method_handles_lookup.h
+++ b/runtime/mirror/method_handles_lookup.h
@@ -17,11 +17,11 @@
 #ifndef ART_RUNTIME_MIRROR_METHOD_HANDLES_LOOKUP_H_
 #define ART_RUNTIME_MIRROR_METHOD_HANDLES_LOOKUP_H_
 
+#include "base/utils.h"
 #include "gc_root.h"
 #include "handle.h"
 #include "obj_ptr.h"
 #include "object.h"
-#include "utils.h"
 
 namespace art {
 
diff --git a/runtime/mirror/method_type.h b/runtime/mirror/method_type.h
index edd9910..3627214 100644
--- a/runtime/mirror/method_type.h
+++ b/runtime/mirror/method_type.h
@@ -17,10 +17,10 @@
 #ifndef ART_RUNTIME_MIRROR_METHOD_TYPE_H_
 #define ART_RUNTIME_MIRROR_METHOD_TYPE_H_
 
+#include "base/utils.h"
 #include "object_array.h"
 #include "object.h"
 #include "string.h"
-#include "utils.h"
 
 namespace art {
 
diff --git a/runtime/mirror/object-inl.h b/runtime/mirror/object-inl.h
index 7fdaa32..55dd514 100644
--- a/runtime/mirror/object-inl.h
+++ b/runtime/mirror/object-inl.h
@@ -22,7 +22,7 @@
 #include "array-inl.h"
 #include "art_field.h"
 #include "art_method.h"
-#include "atomic.h"
+#include "base/atomic.h"
 #include "class-inl.h"
 #include "class_flags.h"
 #include "class_linker.h"
diff --git a/runtime/mirror/object-readbarrier-inl.h b/runtime/mirror/object-readbarrier-inl.h
index 126cb04..aeaa850 100644
--- a/runtime/mirror/object-readbarrier-inl.h
+++ b/runtime/mirror/object-readbarrier-inl.h
@@ -19,7 +19,7 @@
 
 #include "object.h"
 
-#include "atomic.h"
+#include "base/atomic.h"
 #include "heap_poisoning.h"
 #include "lock_word-inl.h"
 #include "object_reference-inl.h"
diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h
index 816ac69..95f82cb 100644
--- a/runtime/mirror/object.h
+++ b/runtime/mirror/object.h
@@ -17,7 +17,7 @@
 #ifndef ART_RUNTIME_MIRROR_OBJECT_H_
 #define ART_RUNTIME_MIRROR_OBJECT_H_
 
-#include "atomic.h"
+#include "base/atomic.h"
 #include "base/casts.h"
 #include "base/enums.h"
 #include "globals.h"
diff --git a/runtime/mirror/object_array-inl.h b/runtime/mirror/object_array-inl.h
index 5cfc987..086d2f4 100644
--- a/runtime/mirror/object_array-inl.h
+++ b/runtime/mirror/object_array-inl.h
@@ -24,6 +24,7 @@
 #include "android-base/stringprintf.h"
 
 #include "array-inl.h"
+#include "base/utils.h"
 #include "class.h"
 #include "gc/heap.h"
 #include "handle_scope-inl.h"
@@ -31,7 +32,6 @@
 #include "object-inl.h"
 #include "runtime.h"
 #include "thread.h"
-#include "utils.h"
 
 namespace art {
 namespace mirror {
diff --git a/runtime/mirror/object_reference.h b/runtime/mirror/object_reference.h
index 7fd9c71..cf1f85d 100644
--- a/runtime/mirror/object_reference.h
+++ b/runtime/mirror/object_reference.h
@@ -17,7 +17,7 @@
 #ifndef ART_RUNTIME_MIRROR_OBJECT_REFERENCE_H_
 #define ART_RUNTIME_MIRROR_OBJECT_REFERENCE_H_
 
-#include "atomic.h"
+#include "base/atomic.h"
 #include "base/mutex.h"  // For Locks::mutator_lock_.
 #include "globals.h"
 #include "heap_poisoning.h"
diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc
index 32a99eb..5306eac 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -787,5 +787,23 @@
   }
 }
 
+TEST_F(ObjectTest, PrettyTypeOf) {
+  ScopedObjectAccess soa(Thread::Current());
+  EXPECT_EQ("null", mirror::Object::PrettyTypeOf(nullptr));
+
+  StackHandleScope<2> hs(soa.Self());
+  Handle<mirror::String> s(hs.NewHandle(mirror::String::AllocFromModifiedUtf8(soa.Self(), "")));
+  EXPECT_EQ("java.lang.String", mirror::Object::PrettyTypeOf(s.Get()));
+
+  Handle<mirror::ShortArray> a(hs.NewHandle(mirror::ShortArray::Alloc(soa.Self(), 2)));
+  EXPECT_EQ("short[]", mirror::Object::PrettyTypeOf(a.Get()));
+
+  mirror::Class* c = class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/String;");
+  ASSERT_TRUE(c != nullptr);
+  mirror::Object* o = mirror::ObjectArray<mirror::String>::Alloc(soa.Self(), c, 0);
+  EXPECT_EQ("java.lang.String[]", mirror::Object::PrettyTypeOf(o));
+  EXPECT_EQ("java.lang.Class<java.lang.String[]>", mirror::Object::PrettyTypeOf(o->GetClass()));
+}
+
 }  // namespace mirror
 }  // namespace art
diff --git a/runtime/mirror/string-inl.h b/runtime/mirror/string-inl.h
index 8c2a49c..a60861c 100644
--- a/runtime/mirror/string-inl.h
+++ b/runtime/mirror/string-inl.h
@@ -22,14 +22,14 @@
 
 #include "array.h"
 #include "base/bit_utils.h"
+#include "base/globals.h"
+#include "base/utils.h"
 #include "class.h"
 #include "common_throws.h"
 #include "dex/utf.h"
 #include "gc/heap-inl.h"
-#include "globals.h"
 #include "runtime.h"
 #include "thread.h"
-#include "utils.h"
 
 namespace art {
 namespace mirror {
diff --git a/runtime/mirror/throwable.cc b/runtime/mirror/throwable.cc
index a7a6d08..b6173d4 100644
--- a/runtime/mirror/throwable.cc
+++ b/runtime/mirror/throwable.cc
@@ -20,6 +20,7 @@
 
 #include "art_method-inl.h"
 #include "base/enums.h"
+#include "base/utils.h"
 #include "class-inl.h"
 #include "dex/dex_file-inl.h"
 #include "gc/accounting/card_table-inl.h"
@@ -28,7 +29,6 @@
 #include "object_array.h"
 #include "stack_trace_element.h"
 #include "string.h"
-#include "utils.h"
 #include "well_known_classes.h"
 
 namespace art {