ART: Clean up includes.

Reduce dependencies to improve incremental build times.
Break up circular dependency involving class_linker-inl.h.

Change-Id: I4be742c5c2b5cd9855beea86630fd68aab76b0db
diff --git a/runtime/gc/accounting/bitmap.cc b/runtime/gc/accounting/bitmap.cc
index 20984fd..13fcdb3 100644
--- a/runtime/gc/accounting/bitmap.cc
+++ b/runtime/gc/accounting/bitmap.cc
@@ -35,6 +35,10 @@
   CHECK_NE(bitmap_size, 0U);
 }
 
+Bitmap::~Bitmap() {
+  // Destroys MemMap via std::unique_ptr<>.
+}
+
 MemMap* Bitmap::AllocateMemMap(const std::string& name, size_t num_bits) {
   const size_t bitmap_size = RoundUp(
       RoundUp(num_bits, kBitsPerBitmapWord) / kBitsPerBitmapWord * sizeof(uintptr_t), kPageSize);
diff --git a/runtime/gc/accounting/bitmap.h b/runtime/gc/accounting/bitmap.h
index cf2c293..b294d49 100644
--- a/runtime/gc/accounting/bitmap.h
+++ b/runtime/gc/accounting/bitmap.h
@@ -103,6 +103,7 @@
   static constexpr size_t kBitsPerBitmapWord = sizeof(uintptr_t) * kBitsPerByte;
 
   Bitmap(MemMap* mem_map, size_t bitmap_size);
+  ~Bitmap();
 
   // Allocate the mem-map for a bitmap based on how many bits are required.
   static MemMap* AllocateMemMap(const std::string& name, size_t num_bits);
diff --git a/runtime/gc/accounting/card_table-inl.h b/runtime/gc/accounting/card_table-inl.h
index 83ad33e..b936d93 100644
--- a/runtime/gc/accounting/card_table-inl.h
+++ b/runtime/gc/accounting/card_table-inl.h
@@ -20,6 +20,7 @@
 #include "atomic.h"
 #include "base/logging.h"
 #include "card_table.h"
+#include "mem_map.h"
 #include "space_bitmap.h"
 #include "utils.h"
 
@@ -223,6 +224,12 @@
   return card_addr;
 }
 
+inline bool CardTable::IsValidCard(const uint8_t* card_addr) const {
+  uint8_t* begin = mem_map_->Begin() + offset_;
+  uint8_t* end = mem_map_->End();
+  return card_addr >= begin && card_addr < end;
+}
+
 inline void CardTable::CheckCardValid(uint8_t* card) const {
   DCHECK(IsValidCard(card))
       << " card_addr: " << reinterpret_cast<const void*>(card)
diff --git a/runtime/gc/accounting/card_table.cc b/runtime/gc/accounting/card_table.cc
index ad1f192..7879632 100644
--- a/runtime/gc/accounting/card_table.cc
+++ b/runtime/gc/accounting/card_table.cc
@@ -21,6 +21,7 @@
 #include "gc/heap.h"
 #include "gc/space/space.h"
 #include "heap_bitmap.h"
+#include "mem_map.h"
 #include "runtime.h"
 #include "utils.h"
 
@@ -90,6 +91,10 @@
     : mem_map_(mem_map), biased_begin_(biased_begin), offset_(offset) {
 }
 
+CardTable::~CardTable() {
+  // Destroys MemMap via std::unique_ptr<>.
+}
+
 void CardTable::ClearSpaceCards(space::ContinuousSpace* space) {
   // TODO: clear just the range of the table that has been modified
   uint8_t* card_start = CardFromAddr(space->Begin());
diff --git a/runtime/gc/accounting/card_table.h b/runtime/gc/accounting/card_table.h
index 3ea7651..896cce5 100644
--- a/runtime/gc/accounting/card_table.h
+++ b/runtime/gc/accounting/card_table.h
@@ -21,10 +21,11 @@
 
 #include "base/mutex.h"
 #include "globals.h"
-#include "mem_map.h"
 
 namespace art {
 
+class MemMap;
+
 namespace mirror {
   class Object;
 }  // namespace mirror
@@ -52,6 +53,7 @@
   static constexpr uint8_t kCardDirty = 0x70;
 
   static CardTable* Create(const uint8_t* heap_begin, size_t heap_capacity);
+  ~CardTable();
 
   // Set the card associated with the given address to GC_CARD_DIRTY.
   ALWAYS_INLINE void MarkCard(const void *addr) {
@@ -130,11 +132,7 @@
   CardTable(MemMap* begin, uint8_t* biased_begin, size_t offset);
 
   // Returns true iff the card table address is within the bounds of the card table.
-  bool IsValidCard(const uint8_t* card_addr) const {
-    uint8_t* begin = mem_map_->Begin() + offset_;
-    uint8_t* end = mem_map_->End();
-    return card_addr >= begin && card_addr < end;
-  }
+  bool IsValidCard(const uint8_t* card_addr) const ALWAYS_INLINE;
 
   void CheckCardValid(uint8_t* card) const ALWAYS_INLINE;
 
diff --git a/runtime/gc/accounting/mod_union_table_test.cc b/runtime/gc/accounting/mod_union_table_test.cc
index 94bb3f5..043b558 100644
--- a/runtime/gc/accounting/mod_union_table_test.cc
+++ b/runtime/gc/accounting/mod_union_table_test.cc
@@ -16,6 +16,7 @@
 
 #include "mod_union_table-inl.h"
 
+#include "class_linker-inl.h"
 #include "common_runtime_test.h"
 #include "gc/space/space-inl.h"
 #include "mirror/array-inl.h"
diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc
index f64a4ff..515f124 100644
--- a/runtime/gc/allocator/rosalloc.cc
+++ b/runtime/gc/allocator/rosalloc.cc
@@ -18,6 +18,7 @@
 
 #include "base/mutex-inl.h"
 #include "gc/space/valgrind_settings.h"
+#include "mem_map.h"
 #include "mirror/class-inl.h"
 #include "mirror/object.h"
 #include "mirror/object-inl.h"
diff --git a/runtime/gc/allocator/rosalloc.h b/runtime/gc/allocator/rosalloc.h
index d1e7ad9..a54edcc 100644
--- a/runtime/gc/allocator/rosalloc.h
+++ b/runtime/gc/allocator/rosalloc.h
@@ -30,11 +30,13 @@
 #include "base/mutex.h"
 #include "base/logging.h"
 #include "globals.h"
-#include "mem_map.h"
 #include "thread.h"
 #include "utils.h"
 
 namespace art {
+
+class MemMap;
+
 namespace gc {
 namespace allocator {
 
diff --git a/runtime/gc/heap_test.cc b/runtime/gc/heap_test.cc
index 14d78d8..a3cefd9 100644
--- a/runtime/gc/heap_test.cc
+++ b/runtime/gc/heap_test.cc
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include "class_linker-inl.h"
 #include "common_runtime_test.h"
 #include "gc/accounting/card_table-inl.h"
 #include "gc/accounting/space_bitmap-inl.h"