Write out image bitmap inside of image file.

We now create the image bitmap when we generate the image. The image
bitmap is written after the image inside of the image file. This
speeds up dex2oat by making walking the image during heap creation
unnecessary. This should also help memory pressure by enabling the
image bitmap to be swappable.

Bug: 10432288

Change-Id: Idebf459ed15edbb41a7d9b9b353934155bce2f19
diff --git a/compiler/image_writer.h b/compiler/image_writer.h
index 6a126b8..0d85f36 100644
--- a/compiler/image_writer.h
+++ b/compiler/image_writer.h
@@ -58,7 +58,10 @@
  private:
   bool AllocMemory();
 
-  // we use the lock word to store the offset of the object in the image
+  // Mark the objects defined in this space in the given live bitmap.
+  void RecordImageAllocations() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
+  // We use the lock word to store the offset of the object in the image.
   void AssignImageOffset(mirror::Object* object)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
     DCHECK(object != NULL);
@@ -194,6 +197,9 @@
   // Beginning target oat address for the pointers from the output image to its oat file.
   const byte* oat_data_begin_;
 
+  // Image bitmap which lets us know where the objects inside of the image reside.
+  UniquePtr<gc::accounting::SpaceBitmap> image_bitmap_;
+
   // Offset from oat_data_begin_ to the stubs.
   uint32_t interpreter_to_interpreter_bridge_offset_;
   uint32_t interpreter_to_compiled_code_bridge_offset_;