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/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 926575e..73afbad 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -46,12 +46,15 @@
 #include "base/file_utils.h"
 #include "base/leb128.h"
 #include "base/macros.h"
+#include "base/mutex.h"
+#include "base/os.h"
 #include "base/scoped_flock.h"
 #include "base/stl_util.h"
 #include "base/stringpiece.h"
 #include "base/time_utils.h"
 #include "base/timing_logger.h"
 #include "base/unix_file/fd_file.h"
+#include "base/utils.h"
 #include "class_linker.h"
 #include "class_loader_context.h"
 #include "cmdline_parser.h"
@@ -89,11 +92,9 @@
 #include "mirror/object_array-inl.h"
 #include "oat_file.h"
 #include "oat_file_assistant.h"
-#include "os.h"
 #include "runtime.h"
 #include "runtime_options.h"
 #include "scoped_thread_state_change-inl.h"
-#include "utils.h"
 #include "vdex_file.h"
 #include "verifier/verifier_deps.h"
 #include "well_known_classes.h"
@@ -1164,6 +1165,7 @@
     original_argc = argc;
     original_argv = argv;
 
+    Locks::Init();
     InitLogging(argv, Runtime::Abort);
 
     compiler_options_.reset(new CompilerOptions());
diff --git a/dex2oat/dex2oat_image_test.cc b/dex2oat/dex2oat_image_test.cc
index 05592f1..49b84bb 100644
--- a/dex2oat/dex2oat_image_test.cc
+++ b/dex2oat/dex2oat_image_test.cc
@@ -29,13 +29,13 @@
 #include "base/file_utils.h"
 #include "base/macros.h"
 #include "base/unix_file/fd_file.h"
+#include "base/utils.h"
 #include "dex/art_dex_file_loader.h"
 #include "dex/dex_file-inl.h"
 #include "dex/dex_file_loader.h"
 #include "jit/profile_compilation_info.h"
 #include "method_reference.h"
 #include "runtime.h"
-#include "utils.h"
 
 namespace art {
 
@@ -129,9 +129,9 @@
     std::string art_file = scratch.GetFilename() + ".art";
     std::string oat_file = scratch.GetFilename() + ".oat";
     std::string vdex_file = scratch.GetFilename() + ".vdex";
-    ret.art_size = GetFileSizeBytes(art_file);
-    ret.oat_size = GetFileSizeBytes(oat_file);
-    ret.vdex_size = GetFileSizeBytes(vdex_file);
+    ret.art_size = OS::GetFileSizeBytes(art_file.c_str());
+    ret.oat_size = OS::GetFileSizeBytes(oat_file.c_str());
+    ret.vdex_size = OS::GetFileSizeBytes(vdex_file.c_str());
     CHECK_GT(ret.art_size, 0u) << art_file;
     CHECK_GT(ret.oat_size, 0u) << oat_file;
     CHECK_GT(ret.vdex_size, 0u) << vdex_file;
diff --git a/dex2oat/dex2oat_options.h b/dex2oat/dex2oat_options.h
index ccc85c8..cc124c1 100644
--- a/dex2oat/dex2oat_options.h
+++ b/dex2oat/dex2oat_options.h
@@ -21,6 +21,7 @@
 #include <string>
 #include <vector>
 
+#include "arch/instruction_set.h"
 #include "base/variant_map.h"
 #include "cmdline_types.h"  // TODO: don't need to include this file here
 #include "compiler.h"
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 6b75595..96dd319 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -29,6 +29,7 @@
 
 #include "base/macros.h"
 #include "base/mutex-inl.h"
+#include "base/utils.h"
 #include "bytecode_utils.h"
 #include "dex/art_dex_file_loader.h"
 #include "dex/base64_test_util.h"
@@ -40,7 +41,6 @@
 #include "jit/profile_compilation_info.h"
 #include "oat.h"
 #include "oat_file.h"
-#include "utils.h"
 #include "vdex_file.h"
 #include "ziparchive/zip_writer.h"
 
diff --git a/dex2oat/linker/elf_writer.h b/dex2oat/linker/elf_writer.h
index 7c47740..bcf2cd7 100644
--- a/dex2oat/linker/elf_writer.h
+++ b/dex2oat/linker/elf_writer.h
@@ -25,8 +25,8 @@
 #include "base/array_ref.h"
 #include "base/macros.h"
 #include "base/mutex.h"
+#include "base/os.h"
 #include "debug/debug_info.h"
-#include "os.h"
 
 namespace art {
 
diff --git a/dex2oat/linker/elf_writer_quick.cc b/dex2oat/linker/elf_writer_quick.cc
index d2e863c..07b02f1 100644
--- a/dex2oat/linker/elf_writer_quick.cc
+++ b/dex2oat/linker/elf_writer_quick.cc
@@ -24,6 +24,7 @@
 
 #include "base/casts.h"
 #include "base/leb128.h"
+#include "base/utils.h"
 #include "compiled_method.h"
 #include "debug/elf_debug_writer.h"
 #include "debug/method_debug_info.h"
@@ -36,7 +37,6 @@
 #include "linker/file_output_stream.h"
 #include "thread-current-inl.h"
 #include "thread_pool.h"
-#include "utils.h"
 
 namespace art {
 namespace linker {
diff --git a/dex2oat/linker/elf_writer_quick.h b/dex2oat/linker/elf_writer_quick.h
index e20957c..274d18b 100644
--- a/dex2oat/linker/elf_writer_quick.h
+++ b/dex2oat/linker/elf_writer_quick.h
@@ -20,8 +20,8 @@
 #include <memory>
 
 #include "arch/instruction_set.h"
+#include "base/os.h"
 #include "elf_writer.h"
-#include "os.h"
 
 namespace art {
 
diff --git a/dex2oat/linker/elf_writer_test.cc b/dex2oat/linker/elf_writer_test.cc
index 8427e7b..b2be003 100644
--- a/dex2oat/linker/elf_writer_test.cc
+++ b/dex2oat/linker/elf_writer_test.cc
@@ -18,13 +18,13 @@
 
 #include "base/file_utils.h"
 #include "base/unix_file/fd_file.h"
+#include "base/utils.h"
 #include "common_compiler_test.h"
 #include "elf_file.h"
 #include "elf_file_impl.h"
 #include "elf_writer_quick.h"
 #include "linker/elf_builder.h"
 #include "oat.h"
-#include "utils.h"
 
 namespace art {
 namespace linker {
diff --git a/dex2oat/linker/image_test.h b/dex2oat/linker/image_test.h
index c6ce951..319c5fb 100644
--- a/dex2oat/linker/image_test.h
+++ b/dex2oat/linker/image_test.h
@@ -28,6 +28,7 @@
 #include "art_method-inl.h"
 #include "base/file_utils.h"
 #include "base/unix_file/fd_file.h"
+#include "base/utils.h"
 #include "class_linker-inl.h"
 #include "common_compiler_test.h"
 #include "compiler_callbacks.h"
@@ -46,7 +47,6 @@
 #include "oat_writer.h"
 #include "scoped_thread_state_change-inl.h"
 #include "signal_catcher.h"
-#include "utils.h"
 
 namespace art {
 namespace linker {
diff --git a/dex2oat/linker/image_writer.h b/dex2oat/linker/image_writer.h
index 856edfb..36bbb47 100644
--- a/dex2oat/linker/image_writer.h
+++ b/dex2oat/linker/image_writer.h
@@ -33,7 +33,9 @@
 #include "base/enums.h"
 #include "base/length_prefixed_array.h"
 #include "base/macros.h"
+#include "base/os.h"
 #include "base/safe_map.h"
+#include "base/utils.h"
 #include "class_table.h"
 #include "driver/compiler_driver.h"
 #include "image.h"
@@ -43,8 +45,6 @@
 #include "mirror/dex_cache.h"
 #include "oat_file.h"
 #include "obj_ptr.h"
-#include "os.h"
-#include "utils.h"
 
 namespace art {
 namespace gc {
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index 2feb14a..c72beea 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -27,6 +27,7 @@
 #include "base/enums.h"
 #include "base/file_magic.h"
 #include "base/logging.h"  // For VLOG
+#include "base/os.h"
 #include "base/safe_map.h"
 #include "base/stl_util.h"
 #include "base/unix_file/fd_file.h"
@@ -60,7 +61,6 @@
 #include "mirror/dex_cache-inl.h"
 #include "mirror/object-inl.h"
 #include "oat_quick_method_header.h"
-#include "os.h"
 #include "quicken_info.h"
 #include "scoped_thread_state_change-inl.h"
 #include "type_lookup_table.h"
diff --git a/dex2oat/linker/oat_writer.h b/dex2oat/linker/oat_writer.h
index d67e4de..0cb0ef2 100644
--- a/dex2oat/linker/oat_writer.h
+++ b/dex2oat/linker/oat_writer.h
@@ -24,6 +24,7 @@
 
 #include "base/array_ref.h"
 #include "base/dchecked_vector.h"
+#include "base/os.h"
 #include "base/safe_map.h"
 #include "compiler.h"
 #include "dex/compact_dex_level.h"
@@ -33,7 +34,6 @@
 #include "method_reference.h"
 #include "mirror/class.h"
 #include "oat.h"
-#include "os.h"
 #include "string_reference.h"
 #include "type_reference.h"