Refactor oat.h.

Move OatClassType and OatMethodOffsets to oat_file.h and
make all dependencies on oat.h explicit instead of relying
on transitive #includes. This reduces the number of files
that need to be rebuilt for oat version changes.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I89c8e397a4f423043d7a036a995cc33548b25051
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index dc0dd67..095f027 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -87,6 +87,7 @@
 #include "mirror/class_loader.h"
 #include "mirror/object-inl.h"
 #include "mirror/object_array-inl.h"
+#include "oat.h"
 #include "oat_file.h"
 #include "oat_file_assistant.h"
 #include "profile/profile_compilation_info.h"
diff --git a/dex2oat/linker/image_test.h b/dex2oat/linker/image_test.h
index fa08627..9ec6e56 100644
--- a/dex2oat/linker/image_test.h
+++ b/dex2oat/linker/image_test.h
@@ -48,6 +48,7 @@
 #include "linker/multi_oat_relative_patcher.h"
 #include "lock_word.h"
 #include "mirror/object-inl.h"
+#include "oat.h"
 #include "oat_writer.h"
 #include "scoped_thread_state_change-inl.h"
 #include "signal_catcher.h"
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index b3c8999..92de151 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -61,6 +61,7 @@
 #include "mirror/class_loader.h"
 #include "mirror/dex_cache-inl.h"
 #include "mirror/object-inl.h"
+#include "oat.h"
 #include "oat_quick_method_header.h"
 #include "profile/profile_compilation_info.h"
 #include "quicken_info.h"
diff --git a/dex2oat/linker/oat_writer.h b/dex2oat/linker/oat_writer.h
index fb263d9..19c0cfe 100644
--- a/dex2oat/linker/oat_writer.h
+++ b/dex2oat/linker/oat_writer.h
@@ -35,7 +35,6 @@
 #include "dex/type_reference.h"
 #include "linker/relative_patcher.h"  // For RelativePatcherTargetProvider.
 #include "mirror/class.h"
-#include "oat.h"
 
 namespace art {
 
@@ -44,6 +43,7 @@
 class CompilerDriver;
 class CompilerOptions;
 class DexContainer;
+class OatHeader;
 class OutputStream;
 class ProfileCompilationInfo;
 class TimingLogger;
diff --git a/dex2oat/linker/oat_writer_test.cc b/dex2oat/linker/oat_writer_test.cc
index 2eb4476..11600a8 100644
--- a/dex2oat/linker/oat_writer_test.cc
+++ b/dex2oat/linker/oat_writer_test.cc
@@ -41,6 +41,7 @@
 #include "mirror/class-inl.h"
 #include "mirror/object-inl.h"
 #include "mirror/object_array-inl.h"
+#include "oat.h"
 #include "oat_file-inl.h"
 #include "oat_writer.h"
 #include "profile/profile_compilation_info.h"
diff --git a/dex2oat/linker/relative_patcher_test.h b/dex2oat/linker/relative_patcher_test.h
index dc53ac4..f34e6eb 100644
--- a/dex2oat/linker/relative_patcher_test.h
+++ b/dex2oat/linker/relative_patcher_test.h
@@ -29,7 +29,6 @@
 #include "dex/string_reference.h"
 #include "driver/compiled_method_storage.h"
 #include "linker/relative_patcher.h"
-#include "oat.h"
 #include "oat_quick_method_header.h"
 #include "stream/vector_output_stream.h"
 
diff --git a/runtime/Android.bp b/runtime/Android.bp
index cfa16f8..0546c69 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -497,7 +497,7 @@
         "jdwp/jdwp_constants.h",
         "jni_id_type.h",
         "lock_word.h",
-        "oat.h",
+        "oat_file.h",
         "object_callbacks.h",
         "process_state.h",
         "reflective_value_visitor.h",
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h
index 3aec1c3..dfadc62 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -39,7 +39,6 @@
 #include "mirror/object-inl.h"
 #include "mirror/object_array.h"
 #include "mirror/string.h"
-#include "oat.h"
 #include "obj_ptr-inl.h"
 #include "quick/quick_method_frame_info.h"
 #include "read_barrier-inl.h"
diff --git a/runtime/dexopt_test.cc b/runtime/dexopt_test.cc
index fd3d20d..4f438e7 100644
--- a/runtime/dexopt_test.cc
+++ b/runtime/dexopt_test.cc
@@ -30,6 +30,7 @@
 #include "dexopt_test.h"
 #include "gc/space/image_space.h"
 #include "hidden_api.h"
+#include "oat.h"
 
 namespace art {
 void DexoptTest::SetUp() {
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 87ce674..6a52d24 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -48,6 +48,7 @@
 #include "mirror/object-inl.h"
 #include "mirror/object_array-inl.h"
 #include "mirror/var_handle.h"
+#include "oat.h"
 #include "oat_file.h"
 #include "oat_quick_method_header.h"
 #include "quick_exception_handler.h"
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 8b8ac18..31dffc8 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -54,6 +54,7 @@
 #include "mirror/executable-inl.h"
 #include "mirror/object-inl.h"
 #include "mirror/object-refvisitor-inl.h"
+#include "oat.h"
 #include "oat_file.h"
 #include "runtime.h"
 #include "space-inl.h"
diff --git a/runtime/oat.cc b/runtime/oat.cc
index db6cda5..3fceec9 100644
--- a/runtime/oat.cc
+++ b/runtime/oat.cc
@@ -411,9 +411,4 @@
   key_value_store_size_ = data_ptr - reinterpret_cast<char*>(&key_value_store_);
 }
 
-OatMethodOffsets::OatMethodOffsets(uint32_t code_offset) : code_offset_(code_offset) {
-}
-
-OatMethodOffsets::~OatMethodOffsets() {}
-
 }  // namespace art
diff --git a/runtime/oat.h b/runtime/oat.h
index 1ff21c1..352b9e8 100644
--- a/runtime/oat.h
+++ b/runtime/oat.h
@@ -134,31 +134,6 @@
   DISALLOW_COPY_AND_ASSIGN(OatHeader);
 };
 
-// OatMethodOffsets are currently 5x32-bits=160-bits long, so if we can
-// save even one OatMethodOffsets struct, the more complicated encoding
-// using a bitmap pays for itself since few classes will have 160
-// methods.
-enum OatClassType {
-  kOatClassAllCompiled = 0,   // OatClass is followed by an OatMethodOffsets for each method.
-  kOatClassSomeCompiled = 1,  // A bitmap of which OatMethodOffsets are present follows the OatClass.
-  kOatClassNoneCompiled = 2,  // All methods are interpreted so no OatMethodOffsets are necessary.
-  kOatClassMax = 3,
-};
-
-std::ostream& operator<<(std::ostream& os, const OatClassType& rhs);
-
-class PACKED(4) OatMethodOffsets {
- public:
-  explicit OatMethodOffsets(uint32_t code_offset = 0);
-
-  ~OatMethodOffsets();
-
-  OatMethodOffsets(const OatMethodOffsets&) = default;
-  OatMethodOffsets& operator=(const OatMethodOffsets&) = default;
-
-  uint32_t code_offset_;
-};
-
 }  // namespace art
 
 #endif  // ART_RUNTIME_OAT_H_
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index 69d5efd..70a9534 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -34,7 +34,6 @@
 #include "dex/utf.h"
 #include "index_bss_mapping.h"
 #include "mirror/object.h"
-#include "oat.h"
 #include "runtime.h"
 
 namespace art {
@@ -61,6 +60,31 @@
 }  // namespace collector
 }  // namespace gc
 
+// OatMethodOffsets are currently 5x32-bits=160-bits long, so if we can
+// save even one OatMethodOffsets struct, the more complicated encoding
+// using a bitmap pays for itself since few classes will have 160
+// methods.
+enum OatClassType {
+  kOatClassAllCompiled = 0,   // OatClass is followed by an OatMethodOffsets for each method.
+  kOatClassSomeCompiled = 1,  // A bitmap of OatMethodOffsets that are present follows the OatClass.
+  kOatClassNoneCompiled = 2,  // All methods are interpreted so no OatMethodOffsets are necessary.
+  kOatClassMax = 3,
+};
+
+std::ostream& operator<<(std::ostream& os, const OatClassType& rhs);
+
+class PACKED(4) OatMethodOffsets {
+ public:
+  explicit OatMethodOffsets(uint32_t code_offset = 0) : code_offset_(code_offset) {}
+
+  ~OatMethodOffsets() {}
+
+  OatMethodOffsets(const OatMethodOffsets&) = default;
+  OatMethodOffsets& operator=(const OatMethodOffsets&) = default;
+
+  uint32_t code_offset_;
+};
+
 // Runtime representation of the OAT file format which holds compiler output.
 // The class opens an OAT file from storage and maps it to memory, typically with
 // dlopen and provides access to its internal data structures (see OatWriter for
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index 9a5409f..0412ab5 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -34,6 +34,7 @@
 #include "common_runtime_test.h"
 #include "dexopt_test.h"
 #include "hidden_api.h"
+#include "oat.h"
 #include "oat_file.h"
 #include "oat_file_manager.h"
 #include "scoped_thread_state_change-inl.h"
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 691aa80..908a928 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -146,6 +146,7 @@
 #include "native_bridge_art_interface.h"
 #include "native_stack_dump.h"
 #include "nativehelper/scoped_local_ref.h"
+#include "oat.h"
 #include "oat_file.h"
 #include "oat_file_manager.h"
 #include "object_callbacks.h"
diff --git a/test/common/runtime_state.cc b/test/common/runtime_state.cc
index 5fa7e19..4ca5fe8 100644
--- a/test/common/runtime_state.cc
+++ b/test/common/runtime_state.cc
@@ -32,6 +32,7 @@
 #include "mirror/class-inl.h"
 #include "mirror/class.h"
 #include "nativehelper/ScopedUtfChars.h"
+#include "oat.h"
 #include "oat_file.h"
 #include "oat_quick_method_header.h"
 #include "profile/profile_compilation_info.h"