Move profile dependent modules to libartbase

Move mem_map and zip_archive to libartbase.  This should be the last two
remaining modules that profile_compilation_info is dependent upon.

Bug: 22322814
Test: make -j 50 checkbuild
      make and boot a device

Change-Id: I136ee23e426aa8ec7441e3d3f1978f1bebf4b562
diff --git a/compiler/jni/jni_compiler_test.cc b/compiler/jni/jni_compiler_test.cc
index 451a909..730a1a6 100644
--- a/compiler/jni/jni_compiler_test.cc
+++ b/compiler/jni/jni_compiler_test.cc
@@ -21,6 +21,7 @@
 
 #include "art_method-inl.h"
 #include "base/bit_utils.h"
+#include "base/mem_map.h"
 #include "class_linker.h"
 #include "common_compiler_test.h"
 #include "compiler.h"
@@ -29,7 +30,6 @@
 #include "indirect_reference_table.h"
 #include "java_vm_ext.h"
 #include "jni_internal.h"
-#include "mem_map.h"
 #include "mirror/class-inl.h"
 #include "mirror/class_loader.h"
 #include "mirror/object-inl.h"
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index e217769..fa71174 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -55,6 +55,7 @@
 #include "base/timing_logger.h"
 #include "base/unix_file/fd_file.h"
 #include "base/utils.h"
+#include "base/zip_archive.h"
 #include "class_linker.h"
 #include "class_loader_context.h"
 #include "cmdline_parser.h"
@@ -98,7 +99,6 @@
 #include "vdex_file.h"
 #include "verifier/verifier_deps.h"
 #include "well_known_classes.h"
-#include "zip_archive.h"
 
 namespace art {
 
diff --git a/dex2oat/linker/image_writer.h b/dex2oat/linker/image_writer.h
index c67835b..9a82fd0 100644
--- a/dex2oat/linker/image_writer.h
+++ b/dex2oat/linker/image_writer.h
@@ -33,6 +33,7 @@
 #include "base/enums.h"
 #include "base/length_prefixed_array.h"
 #include "base/macros.h"
+#include "base/mem_map.h"
 #include "base/os.h"
 #include "base/safe_map.h"
 #include "base/utils.h"
@@ -41,7 +42,6 @@
 #include "image.h"
 #include "intern_table.h"
 #include "lock_word.h"
-#include "mem_map.h"
 #include "mirror/dex_cache.h"
 #include "oat_file.h"
 #include "obj_ptr.h"
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index bcc5909..6552e95 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -31,6 +31,7 @@
 #include "base/safe_map.h"
 #include "base/stl_util.h"
 #include "base/unix_file/fd_file.h"
+#include "base/zip_archive.h"
 #include "class_linker.h"
 #include "class_table-inl.h"
 #include "compiled_method-inl.h"
@@ -67,7 +68,6 @@
 #include "utils/dex_cache_arrays_layout-inl.h"
 #include "vdex_file.h"
 #include "verifier/verifier_deps.h"
-#include "zip_archive.h"
 
 namespace art {
 namespace linker {
@@ -3398,7 +3398,7 @@
         break;
       }
       ZipEntry* entry = oat_dex_file.source_.GetZipEntry();
-      if (!entry->IsUncompressed() || !entry->IsAlignedToDexHeader()) {
+      if (!entry->IsUncompressed() || !entry->IsAlignedTo(alignof(DexFile::Header))) {
         extract_dex_files_into_vdex_ = true;
         break;
       }
diff --git a/dex2oat/linker/oat_writer.h b/dex2oat/linker/oat_writer.h
index 7b7bd13..619743e 100644
--- a/dex2oat/linker/oat_writer.h
+++ b/dex2oat/linker/oat_writer.h
@@ -25,6 +25,7 @@
 #include "base/array_ref.h"
 #include "base/dchecked_vector.h"
 #include "base/os.h"
+#include "base/mem_map.h"
 #include "base/safe_map.h"
 #include "compiler.h"
 #include "debug/debug_info.h"
@@ -33,7 +34,6 @@
 #include "dex/string_reference.h"
 #include "dex/type_reference.h"
 #include "linker/relative_patcher.h"  // For RelativePatcherTargetProvider.
-#include "mem_map.h"
 #include "mirror/class.h"
 #include "oat.h"
 
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index ec0cbe6..7a8c31b 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -34,6 +34,7 @@
 #include "android-base/stringprintf.h"
 
 #include "base/logging.h"  // For VLOG_IS_ON.
+#include "base/mem_map.h"
 #include "base/os.h"
 #include "base/utils.h"
 #include "dex/art_dex_file_loader.h"
@@ -49,7 +50,6 @@
 #include "dex_visualize.h"
 #include "dex_writer.h"
 #include "jit/profile_compilation_info.h"
-#include "mem_map.h"
 
 namespace art {
 
diff --git a/dexlayout/dexlayout_main.cc b/dexlayout/dexlayout_main.cc
index f30cfee..f81d16c 100644
--- a/dexlayout/dexlayout_main.cc
+++ b/dexlayout/dexlayout_main.cc
@@ -32,8 +32,8 @@
 #include <android-base/logging.h>
 
 #include "base/logging.h"  // For InitLogging.
+#include "base/mem_map.h"
 #include "jit/profile_compilation_info.h"
-#include "mem_map.h"
 #include "runtime.h"
 
 namespace art {
diff --git a/libartbase/Android.bp b/libartbase/Android.bp
index 62157e1..6d76122 100644
--- a/libartbase/Android.bp
+++ b/libartbase/Android.bp
@@ -28,6 +28,7 @@
         "base/logging.cc",
         "base/malloc_arena_pool.cc",
         "base/memory_region.cc",
+        "base/mem_map.cc",
         "base/os_linux.cc",
         "base/runtime_debug.cc",
         "base/safe_copy.cc",
@@ -37,13 +38,36 @@
         "base/unix_file/fd_file.cc",
         "base/unix_file/random_access_file_utils.cc",
         "base/utils.cc",
+        "base/zip_archive.cc",
     ],
+    target: {
+        android: {
+            static_libs: [
+                // ZipArchive support, the order matters here to get all symbols.
+                "libziparchive",
+                "libz",
+            ],
+	    shared_libs: [
+	        // For android::FileMap used by libziparchive.
+                "libutils",
+	    ],
+        },
+        host: {
+            shared_libs: [
+                "libziparchive",
+                "libz",
+            ],
+        },
+    },
     generated_sources: ["art_libartbase_operator_srcs"],
     cflags: ["-DBUILDING_LIBART=1"],
     shared_libs: [
+        "libbacktrace",
+        "liblog",
+	// For ashmem.
+        "libcutils",
         // For common macros.
         "libbase",
-        "liblog",
     ],
     export_include_dirs: ["."],
     // ART's macros.h depends on libbase's macros.h.
@@ -72,7 +96,10 @@
     strip: {
         keep_symbols: true,
     },
-    shared_libs: ["libbase"],
+    shared_libs: [
+        "libbase",
+        "libziparchive",
+    ],
     export_shared_lib_headers: ["libbase"],
 }
 
@@ -82,7 +109,10 @@
         "art_debug_defaults",
         "libartbase_defaults",
     ],
-    shared_libs: ["libbase"],
+    shared_libs: [
+        "libbase",
+        "libziparchive",
+    ],
     export_shared_lib_headers: ["libbase"],
 }
 
@@ -107,6 +137,7 @@
         "base/leb128_test.cc",
         "base/logging_test.cc",
         "base/memory_region_test.cc",
+        "base/mem_map_test.cc",
         "base/safe_copy_test.cc",
         "base/scoped_flock_test.cc",
         "base/time_utils_test.cc",
@@ -115,6 +146,7 @@
         "base/unix_file/fd_file_test.cc",
         "base/utils_test.cc",
         "base/variant_map_test.cc",
+        "base/zip_archive_test.cc",
     ],
     shared_libs: [
         "libbase",
diff --git a/libartbase/base/logging.cc b/libartbase/base/logging.cc
index 37b1f82..fd2cc20 100644
--- a/libartbase/base/logging.cc
+++ b/libartbase/base/logging.cc
@@ -21,6 +21,8 @@
 #include <sstream>
 
 #include "aborting.h"
+#include "base/os.h"
+#include "base/unix_file/fd_file.h"
 
 // Headers for LogMessage::LogLine.
 #ifdef ART_TARGET_ANDROID
@@ -140,4 +142,57 @@
 #endif  // ART_TARGET_ANDROID
 }
 
+bool PrintFileToLog(const std::string& file_name, android::base::LogSeverity level) {
+  File file(file_name, O_RDONLY, false);
+  if (!file.IsOpened()) {
+    return false;
+  }
+
+  constexpr size_t kBufSize = 256;  // Small buffer. Avoid stack overflow and stack size warnings.
+  char buf[kBufSize + 1];           // +1 for terminator.
+  size_t filled_to = 0;
+  while (true) {
+    DCHECK_LT(filled_to, kBufSize);
+    int64_t n = TEMP_FAILURE_RETRY(read(file.Fd(), &buf[filled_to], kBufSize - filled_to));
+    if (n <= 0) {
+      // Print the rest of the buffer, if it exists.
+      if (filled_to > 0) {
+        buf[filled_to] = 0;
+        LOG(level) << buf;
+      }
+      return n == 0;
+    }
+    // Scan for '\n'.
+    size_t i = filled_to;
+    bool found_newline = false;
+    for (; i < filled_to + n; ++i) {
+      if (buf[i] == '\n') {
+        // Found a line break, that's something to print now.
+        buf[i] = 0;
+        LOG(level) << buf;
+        // Copy the rest to the front.
+        if (i + 1 < filled_to + n) {
+          memmove(&buf[0], &buf[i + 1], filled_to + n - i - 1);
+          filled_to = filled_to + n - i - 1;
+        } else {
+          filled_to = 0;
+        }
+        found_newline = true;
+        break;
+      }
+    }
+    if (found_newline) {
+      continue;
+    } else {
+      filled_to += n;
+      // Check if we must flush now.
+      if (filled_to == kBufSize) {
+        buf[kBufSize] = 0;
+        LOG(level) << buf;
+        filled_to = 0;
+      }
+    }
+  }
+}
+
 }  // namespace art
diff --git a/libartbase/base/logging.h b/libartbase/base/logging.h
index fd5fc74..986704e 100644
--- a/libartbase/base/logging.h
+++ b/libartbase/base/logging.h
@@ -98,6 +98,9 @@
   DISALLOW_COPY_AND_ASSIGN(LogHelper);
 };
 
+// Copy the contents of file_name to the log stream for level.
+bool PrintFileToLog(const std::string& file_name, android::base::LogSeverity level);
+
 // Is verbose logging enabled for the given module? Where the module is defined in LogVerbosity.
 #define VLOG_IS_ON(module) UNLIKELY(::art::gLogVerbosity.module)
 
diff --git a/runtime/mem_map.cc b/libartbase/base/mem_map.cc
similarity index 99%
rename from runtime/mem_map.cc
rename to libartbase/base/mem_map.cc
index b9d51c1..21634f8 100644
--- a/runtime/mem_map.cc
+++ b/libartbase/base/mem_map.cc
@@ -34,7 +34,6 @@
 
 #include "base/allocator.h"
 #include "base/bit_utils.h"
-#include "base/file_utils.h"
 #include "base/globals.h"
 #include "base/logging.h"  // For VLOG_IS_ON.
 #include "base/memory_tool.h"
@@ -207,7 +206,8 @@
       *error_msg = StringPrintf("Requested region 0x%08" PRIxPTR "-0x%08" PRIxPTR " overlaps with "
                                 "existing map 0x%08" PRIxPTR "-0x%08" PRIxPTR " (%s)\n%s",
                                 begin, end,
-                                static_cast<uintptr_t>(entry->start), static_cast<uintptr_t>(entry->end),
+                                static_cast<uintptr_t>(entry->start),
+                                static_cast<uintptr_t>(entry->end),
                                 entry->name.c_str(),
                                 map_info.str().c_str());
       return false;
diff --git a/runtime/mem_map.h b/libartbase/base/mem_map.h
similarity index 98%
rename from runtime/mem_map.h
rename to libartbase/base/mem_map.h
index 0ecb414..b7beb08 100644
--- a/runtime/mem_map.h
+++ b/libartbase/base/mem_map.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef ART_RUNTIME_MEM_MAP_H_
-#define ART_RUNTIME_MEM_MAP_H_
+#ifndef ART_LIBARTBASE_BASE_MEM_MAP_H_
+#define ART_LIBARTBASE_BASE_MEM_MAP_H_
 
 #include <stddef.h>
 #include <sys/types.h>
@@ -25,6 +25,7 @@
 #include <string>
 
 #include "android-base/thread_annotations.h"
+#include "base/macros.h"
 
 namespace art {
 
@@ -297,4 +298,4 @@
 
 }  // namespace art
 
-#endif  // ART_RUNTIME_MEM_MAP_H_
+#endif  // ART_LIBARTBASE_BASE_MEM_MAP_H_
diff --git a/runtime/mem_map_test.cc b/libartbase/base/mem_map_test.cc
similarity index 100%
rename from runtime/mem_map_test.cc
rename to libartbase/base/mem_map_test.cc
diff --git a/runtime/zip_archive.cc b/libartbase/base/zip_archive.cc
similarity index 97%
rename from runtime/zip_archive.cc
rename to libartbase/base/zip_archive.cc
index 5b3cab4..4185c22 100644
--- a/runtime/zip_archive.cc
+++ b/libartbase/base/zip_archive.cc
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "zip_archive.h"
+#include "base/zip_archive.h"
 
 #include <fcntl.h>
 #include <stdio.h>
@@ -29,7 +29,6 @@
 
 #include "base/bit_utils.h"
 #include "base/unix_file/fd_file.h"
-#include "dex/dex_file.h"
 
 namespace art {
 
@@ -55,10 +54,6 @@
   return IsAlignedParam(zip_entry_->offset, static_cast<int>(alignment));
 }
 
-bool ZipEntry::IsAlignedToDexHeader() const {
-  return IsAlignedTo(alignof(DexFile::Header));
-}
-
 ZipEntry::~ZipEntry() {
   delete zip_entry_;
 }
diff --git a/runtime/zip_archive.h b/libartbase/base/zip_archive.h
similarity index 94%
rename from runtime/zip_archive.h
rename to libartbase/base/zip_archive.h
index aa54018..39c8168 100644
--- a/runtime/zip_archive.h
+++ b/libartbase/base/zip_archive.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef ART_RUNTIME_ZIP_ARCHIVE_H_
-#define ART_RUNTIME_ZIP_ARCHIVE_H_
+#ifndef ART_LIBARTBASE_BASE_ZIP_ARCHIVE_H_
+#define ART_LIBARTBASE_BASE_ZIP_ARCHIVE_H_
 
 #include <stdint.h>
 #include <memory>
@@ -24,10 +24,10 @@
 #include <android-base/logging.h>
 
 #include "base/os.h"
+#include "base/mem_map.h"
 #include "base/safe_map.h"
 #include "base/unix_file/random_access_file.h"
 #include "globals.h"
-#include "mem_map.h"
 
 // system/core/zip_archive definitions.
 struct ZipEntry;
@@ -64,7 +64,6 @@
 
   bool IsUncompressed();
   bool IsAlignedTo(size_t alignment) const;
-  bool IsAlignedToDexHeader() const;
 
  private:
   ZipEntry(ZipArchiveHandle handle,
@@ -102,4 +101,4 @@
 
 }  // namespace art
 
-#endif  // ART_RUNTIME_ZIP_ARCHIVE_H_
+#endif  // ART_LIBARTBASE_BASE_ZIP_ARCHIVE_H_
diff --git a/runtime/zip_archive_test.cc b/libartbase/base/zip_archive_test.cc
similarity index 98%
rename from runtime/zip_archive_test.cc
rename to libartbase/base/zip_archive_test.cc
index 48ee94c..03f4cd4 100644
--- a/runtime/zip_archive_test.cc
+++ b/libartbase/base/zip_archive_test.cc
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "zip_archive.h"
+#include "base/zip_archive.h"
 
 #include <fcntl.h>
 #include <sys/stat.h>
diff --git a/openjdkjvmti/ti_class_definition.h b/openjdkjvmti/ti_class_definition.h
index 31c3611..f888a74 100644
--- a/openjdkjvmti/ti_class_definition.h
+++ b/openjdkjvmti/ti_class_definition.h
@@ -39,7 +39,7 @@
 #include "art_jvmti.h"
 
 #include "base/array_ref.h"
-#include "mem_map.h"
+#include "base/mem_map.h"
 
 namespace openjdkjvmti {
 
diff --git a/openjdkjvmti/ti_class_loader.h b/openjdkjvmti/ti_class_loader.h
index 5c9497b..dbe30da 100644
--- a/openjdkjvmti/ti_class_loader.h
+++ b/openjdkjvmti/ti_class_loader.h
@@ -39,6 +39,7 @@
 #include "art_jvmti.h"
 #include "art_method.h"
 #include "base/array_slice.h"
+#include "base/mem_map.h"
 #include "class_linker.h"
 #include "dex/dex_file.h"
 #include "dex/utf.h"
@@ -47,7 +48,6 @@
 #include "jni_env_ext-inl.h"
 #include "jvmti.h"
 #include "linear_alloc.h"
-#include "mem_map.h"
 #include "mirror/array-inl.h"
 #include "mirror/array.h"
 #include "mirror/class-inl.h"
diff --git a/openjdkjvmti/ti_redefine.h b/openjdkjvmti/ti_redefine.h
index 778f87e..a8877f8 100644
--- a/openjdkjvmti/ti_redefine.h
+++ b/openjdkjvmti/ti_redefine.h
@@ -39,6 +39,7 @@
 #include "art_jvmti.h"
 #include "art_method.h"
 #include "base/array_ref.h"
+#include "base/mem_map.h"
 #include "class_linker.h"
 #include "dex/dex_file.h"
 #include "dex/utf.h"
@@ -47,7 +48,6 @@
 #include "jni_env_ext-inl.h"
 #include "jvmti.h"
 #include "linear_alloc.h"
-#include "mem_map.h"
 #include "mirror/array-inl.h"
 #include "mirror/array.h"
 #include "mirror/class-inl.h"
diff --git a/openjdkjvmti/transform.cc b/openjdkjvmti/transform.cc
index 43b8fe9..e88ecef 100644
--- a/openjdkjvmti/transform.cc
+++ b/openjdkjvmti/transform.cc
@@ -39,6 +39,7 @@
 
 #include "art_method.h"
 #include "base/array_ref.h"
+#include "base/mem_map.h"
 #include "class_linker.h"
 #include "dex/dex_file.h"
 #include "dex/dex_file_types.h"
@@ -51,7 +52,6 @@
 #include "jvalue.h"
 #include "jvmti.h"
 #include "linear_alloc.h"
-#include "mem_map.h"
 #include "mirror/array.h"
 #include "mirror/class-inl.h"
 #include "mirror/class_ext.h"
diff --git a/profman/profman.cc b/profman/profman.cc
index 90e342d..4e1ea23 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -40,6 +40,7 @@
 #include "base/time_utils.h"
 #include "base/unix_file/fd_file.h"
 #include "base/utils.h"
+#include "base/zip_archive.h"
 #include "boot_image_profile.h"
 #include "dex/art_dex_file_loader.h"
 #include "dex/bytecode_utils.h"
@@ -51,7 +52,6 @@
 #include "jit/profile_compilation_info.h"
 #include "profile_assistant.h"
 #include "runtime.h"
-#include "zip_archive.h"
 
 namespace art {
 
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 00d4a60..ec4c272 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -119,7 +119,6 @@
         "jobject_comparator.cc",
         "linear_alloc.cc",
         "managed_stack.cc",
-        "mem_map.cc",
         "method_handles.cc",
         "mirror/array.cc",
         "mirror/call_site.cc",
@@ -209,7 +208,6 @@
         "verifier/verifier_deps.cc",
         "verify_object.cc",
         "well_known_classes.cc",
-        "zip_archive.cc",
 
         "arch/context.cc",
         "arch/instruction_set.cc",
@@ -580,7 +578,6 @@
         "jdwp/jdwp_options_test.cc",
         "java_vm_ext_test.cc",
         "jit/profile_compilation_info_test.cc",
-        "mem_map_test.cc",
         "method_handles_test.cc",
         "mirror/dex_cache_test.cc",
         "mirror/method_type_test.cc",
@@ -602,7 +599,6 @@
         "vdex_file_test.cc",
         "verifier/method_verifier_test.cc",
         "verifier/reg_type_test.cc",
-        "zip_archive_test.cc",
     ],
     shared_libs: [
         "libbacktrace",
diff --git a/runtime/base/file_utils.cc b/runtime/base/file_utils.cc
index 2b3e360..7b0796c 100644
--- a/runtime/base/file_utils.cc
+++ b/runtime/base/file_utils.cc
@@ -83,59 +83,6 @@
   }
 }
 
-bool PrintFileToLog(const std::string& file_name, android::base::LogSeverity level) {
-  File file(file_name, O_RDONLY, false);
-  if (!file.IsOpened()) {
-    return false;
-  }
-
-  constexpr size_t kBufSize = 256;  // Small buffer. Avoid stack overflow and stack size warnings.
-  char buf[kBufSize + 1];           // +1 for terminator.
-  size_t filled_to = 0;
-  while (true) {
-    DCHECK_LT(filled_to, kBufSize);
-    int64_t n = TEMP_FAILURE_RETRY(read(file.Fd(), &buf[filled_to], kBufSize - filled_to));
-    if (n <= 0) {
-      // Print the rest of the buffer, if it exists.
-      if (filled_to > 0) {
-        buf[filled_to] = 0;
-        LOG(level) << buf;
-      }
-      return n == 0;
-    }
-    // Scan for '\n'.
-    size_t i = filled_to;
-    bool found_newline = false;
-    for (; i < filled_to + n; ++i) {
-      if (buf[i] == '\n') {
-        // Found a line break, that's something to print now.
-        buf[i] = 0;
-        LOG(level) << buf;
-        // Copy the rest to the front.
-        if (i + 1 < filled_to + n) {
-          memmove(&buf[0], &buf[i + 1], filled_to + n - i - 1);
-          filled_to = filled_to + n - i - 1;
-        } else {
-          filled_to = 0;
-        }
-        found_newline = true;
-        break;
-      }
-    }
-    if (found_newline) {
-      continue;
-    } else {
-      filled_to += n;
-      // Check if we must flush now.
-      if (filled_to == kBufSize) {
-        buf[kBufSize] = 0;
-        LOG(level) << buf;
-        filled_to = 0;
-      }
-    }
-  }
-}
-
 std::string GetAndroidRootSafe(std::string* error_msg) {
   // Prefer ANDROID_ROOT if it's set.
   const char* android_dir = getenv("ANDROID_ROOT");
diff --git a/runtime/base/file_utils.h b/runtime/base/file_utils.h
index 8adb4f7..d4f6c57 100644
--- a/runtime/base/file_utils.h
+++ b/runtime/base/file_utils.h
@@ -28,7 +28,6 @@
 namespace art {
 
 bool ReadFileToString(const std::string& file_name, std::string* result);
-bool PrintFileToLog(const std::string& file_name, android::base::LogSeverity level);
 
 // Find $ANDROID_ROOT, /system, or abort.
 std::string GetAndroidRoot();
diff --git a/runtime/base/mem_map_arena_pool.cc b/runtime/base/mem_map_arena_pool.cc
index d5ea19b..9ac7886 100644
--- a/runtime/base/mem_map_arena_pool.cc
+++ b/runtime/base/mem_map_arena_pool.cc
@@ -26,8 +26,8 @@
 #include <android-base/logging.h>
 
 #include "base/arena_allocator-inl.h"
+#include "base/mem_map.h"
 #include "base/systrace.h"
-#include "mem_map.h"
 
 namespace art {
 
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index 05159e2..f6a5efc 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -30,6 +30,7 @@
 #include "base/file_utils.h"
 #include "base/logging.h"
 #include "base/macros.h"
+#include "base/mem_map.h"
 #include "base/mutex.h"
 #include "base/os.h"
 #include "base/runtime_debug.h"
@@ -49,7 +50,6 @@
 #include "interpreter/unstarted_runtime.h"
 #include "java_vm_ext.h"
 #include "jni_internal.h"
-#include "mem_map.h"
 #include "mirror/class-inl.h"
 #include "mirror/class_loader.h"
 #include "native/dalvik_system_DexFile.h"
diff --git a/runtime/dex/art_dex_file_loader.cc b/runtime/dex/art_dex_file_loader.cc
index f3e6a69..415e451 100644
--- a/runtime/dex/art_dex_file_loader.cc
+++ b/runtime/dex/art_dex_file_loader.cc
@@ -26,11 +26,11 @@
 #include "base/stl_util.h"
 #include "base/systrace.h"
 #include "base/unix_file/fd_file.h"
+#include "base/zip_archive.h"
 #include "dex/compact_dex_file.h"
 #include "dex/dex_file.h"
 #include "dex/dex_file_verifier.h"
 #include "dex/standard_dex_file.h"
-#include "zip_archive.h"
 
 namespace art {
 
@@ -128,7 +128,7 @@
 
     do {
       if (zip_file_only_contains_uncompressed_dex != nullptr) {
-        if (!(zip_entry->IsUncompressed() && zip_entry->IsAlignedToDexHeader())) {
+        if (!(zip_entry->IsUncompressed() && zip_entry->IsAlignedTo(alignof(DexFile::Header)))) {
           *zip_file_only_contains_uncompressed_dex = false;
         }
       }
diff --git a/runtime/dex/art_dex_file_loader_test.cc b/runtime/dex/art_dex_file_loader_test.cc
index 3e0d666..afc2599 100644
--- a/runtime/dex/art_dex_file_loader_test.cc
+++ b/runtime/dex/art_dex_file_loader_test.cc
@@ -21,6 +21,7 @@
 
 #include "art_dex_file_loader.h"
 #include "base/file_utils.h"
+#include "base/mem_map.h"
 #include "base/os.h"
 #include "base/stl_util.h"
 #include "base/unix_file/fd_file.h"
@@ -31,7 +32,6 @@
 #include "dex/dex_file.h"
 #include "dex/dex_file-inl.h"
 #include "dex/dex_file_loader.h"
-#include "mem_map.h"
 #include "scoped_thread_state_change-inl.h"
 #include "thread-current-inl.h"
 
diff --git a/runtime/dexopt_test.cc b/runtime/dexopt_test.cc
index c19fa82..8f0f9c6 100644
--- a/runtime/dexopt_test.cc
+++ b/runtime/dexopt_test.cc
@@ -21,12 +21,12 @@
 #include <gtest/gtest.h>
 
 #include "base/file_utils.h"
+#include "base/mem_map.h"
 #include "common_runtime_test.h"
 #include "compiler_callbacks.h"
 #include "dex2oat_environment_test.h"
 #include "dexopt_test.h"
 #include "gc/space/image_space.h"
-#include "mem_map.h"
 
 namespace art {
 void DexoptTest::SetUp() {
diff --git a/runtime/elf_file_impl.h b/runtime/elf_file_impl.h
index 3143df5..a5808e2 100644
--- a/runtime/elf_file_impl.h
+++ b/runtime/elf_file_impl.h
@@ -24,7 +24,7 @@
 
 // Explicitly include our own elf.h to avoid Linux and other dependencies.
 #include "./elf.h"
-#include "mem_map.h"
+#include "base/mem_map.h"
 
 namespace art {
 
diff --git a/runtime/gc/accounting/atomic_stack.h b/runtime/gc/accounting/atomic_stack.h
index 7a4bd87..e30fef4 100644
--- a/runtime/gc/accounting/atomic_stack.h
+++ b/runtime/gc/accounting/atomic_stack.h
@@ -27,7 +27,7 @@
 
 #include "base/atomic.h"
 #include "base/macros.h"
-#include "mem_map.h"
+#include "base/mem_map.h"
 #include "stack_reference.h"
 
 // This implements a double-ended queue (deque) with various flavors of PushBack operations,
diff --git a/runtime/gc/accounting/bitmap.cc b/runtime/gc/accounting/bitmap.cc
index e535380..d45a0cc 100644
--- a/runtime/gc/accounting/bitmap.cc
+++ b/runtime/gc/accounting/bitmap.cc
@@ -19,9 +19,9 @@
 #include <sys/mman.h>  // For the PROT_* and MAP_* constants.
 
 #include "base/bit_utils.h"
+#include "base/mem_map.h"
 #include "card_table.h"
 #include "jit/jit_code_cache.h"
-#include "mem_map.h"
 
 namespace art {
 namespace gc {
diff --git a/runtime/gc/accounting/card_table-inl.h b/runtime/gc/accounting/card_table-inl.h
index d9c0418..357a498 100644
--- a/runtime/gc/accounting/card_table-inl.h
+++ b/runtime/gc/accounting/card_table-inl.h
@@ -23,7 +23,7 @@
 
 #include "base/atomic.h"
 #include "base/bit_utils.h"
-#include "mem_map.h"
+#include "base/mem_map.h"
 #include "space_bitmap.h"
 
 namespace art {
diff --git a/runtime/gc/accounting/card_table.cc b/runtime/gc/accounting/card_table.cc
index 4eea607..c7f936f 100644
--- a/runtime/gc/accounting/card_table.cc
+++ b/runtime/gc/accounting/card_table.cc
@@ -18,13 +18,13 @@
 
 #include <sys/mman.h>
 
+#include "base/mem_map.h"
 #include "base/systrace.h"
 #include "base/utils.h"
 #include "card_table-inl.h"
 #include "gc/heap.h"
 #include "gc/space/space.h"
 #include "heap_bitmap.h"
-#include "mem_map.h"
 #include "runtime.h"
 
 namespace art {
diff --git a/runtime/gc/accounting/read_barrier_table.h b/runtime/gc/accounting/read_barrier_table.h
index 775746f..57e4db9 100644
--- a/runtime/gc/accounting/read_barrier_table.h
+++ b/runtime/gc/accounting/read_barrier_table.h
@@ -20,10 +20,10 @@
 #include <sys/mman.h>  // For the PROT_* and MAP_* constants.
 
 #include "base/bit_utils.h"
+#include "base/mem_map.h"
 #include "base/mutex.h"
 #include "gc/space/space.h"
 #include "globals.h"
-#include "mem_map.h"
 
 namespace art {
 namespace gc {
diff --git a/runtime/gc/accounting/space_bitmap.cc b/runtime/gc/accounting/space_bitmap.cc
index d84288f..ced62cd 100644
--- a/runtime/gc/accounting/space_bitmap.cc
+++ b/runtime/gc/accounting/space_bitmap.cc
@@ -19,8 +19,8 @@
 #include "android-base/stringprintf.h"
 
 #include "art_field-inl.h"
+#include "base/mem_map.h"
 #include "dex/dex_file-inl.h"
-#include "mem_map.h"
 #include "mirror/class-inl.h"
 #include "mirror/object-inl.h"
 #include "mirror/object_array.h"
diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc
index 928abe8..a4095d8 100644
--- a/runtime/gc/allocator/rosalloc.cc
+++ b/runtime/gc/allocator/rosalloc.cc
@@ -25,9 +25,9 @@
 
 #include "base/logging.h"  // For VLOG
 #include "base/memory_tool.h"
+#include "base/mem_map.h"
 #include "base/mutex-inl.h"
 #include "gc/space/memory_tool_settings.h"
-#include "mem_map.h"
 #include "mirror/class-inl.h"
 #include "mirror/object-inl.h"
 #include "mirror/object.h"
diff --git a/runtime/gc/space/space.h b/runtime/gc/space/space.h
index bc3ab48..d888935 100644
--- a/runtime/gc/space/space.h
+++ b/runtime/gc/space/space.h
@@ -22,11 +22,11 @@
 
 #include "base/atomic.h"
 #include "base/macros.h"
+#include "base/mem_map.h"
 #include "base/mutex.h"
 #include "gc/accounting/space_bitmap.h"
 #include "gc/collector/object_byte_pair.h"
 #include "globals.h"
-#include "mem_map.h"
 
 namespace art {
 namespace mirror {
diff --git a/runtime/gc/space/zygote_space.h b/runtime/gc/space/zygote_space.h
index 10c1398..6fe21d9 100644
--- a/runtime/gc/space/zygote_space.h
+++ b/runtime/gc/space/zygote_space.h
@@ -17,9 +17,9 @@
 #ifndef ART_RUNTIME_GC_SPACE_ZYGOTE_SPACE_H_
 #define ART_RUNTIME_GC_SPACE_ZYGOTE_SPACE_H_
 
+#include "base/mem_map.h"
 #include "gc/accounting/space_bitmap.h"
 #include "malloc_space.h"
-#include "mem_map.h"
 
 namespace art {
 namespace gc {
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc
index dd8d7dd..791ebf0 100644
--- a/runtime/interpreter/unstarted_runtime.cc
+++ b/runtime/interpreter/unstarted_runtime.cc
@@ -34,6 +34,7 @@
 #include "base/enums.h"
 #include "base/macros.h"
 #include "base/quasi_atomic.h"
+#include "base/zip_archive.h"
 #include "class_linker.h"
 #include "common_throws.h"
 #include "dex/descriptors_names.h"
@@ -56,7 +57,6 @@
 #include "thread-inl.h"
 #include "transaction.h"
 #include "well_known_classes.h"
-#include "zip_archive.h"
 
 namespace art {
 namespace interpreter {
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index de64fdd..6dcc871 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -22,6 +22,7 @@
 #include "art_method-inl.h"
 #include "base/enums.h"
 #include "base/logging.h"  // For VLOG.
+#include "base/mem_map.h"
 #include "base/quasi_atomic.h"
 #include "base/stl_util.h"
 #include "base/systrace.h"
@@ -37,7 +38,6 @@
 #include "jit/jit.h"
 #include "jit/profiling_info.h"
 #include "linear_alloc.h"
-#include "mem_map.h"
 #include "oat_file-inl.h"
 #include "oat_quick_method_header.h"
 #include "object_callbacks.h"
diff --git a/runtime/jit/profile_compilation_info.cc b/runtime/jit/profile_compilation_info.cc
index 6bbe78f..f5c2715 100644
--- a/runtime/jit/profile_compilation_info.cc
+++ b/runtime/jit/profile_compilation_info.cc
@@ -44,9 +44,9 @@
 #include "base/time_utils.h"
 #include "base/unix_file/fd_file.h"
 #include "base/utils.h"
+#include "base/zip_archive.h"
 #include "dex/dex_file_loader.h"
 #include "jit/profiling_info.h"
-#include "zip_archive.h"
 
 namespace art {
 
diff --git a/runtime/jit/profile_compilation_info.h b/runtime/jit/profile_compilation_info.h
index f8334ce..c9ab4e5 100644
--- a/runtime/jit/profile_compilation_info.h
+++ b/runtime/jit/profile_compilation_info.h
@@ -25,13 +25,13 @@
 #include "base/atomic.h"
 #include "base/bit_memory_region.h"
 #include "base/malloc_arena_pool.h"
+#include "base/mem_map.h"
 #include "base/safe_map.h"
 #include "dex/dex_cache_resolved_classes.h"
 #include "dex/dex_file.h"
 #include "dex/dex_file_types.h"
 #include "dex/method_reference.h"
 #include "dex/type_reference.h"
-#include "mem_map.h"
 
 namespace art {
 
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc
index 13319c4..8320d9c 100644
--- a/runtime/native/dalvik_system_DexFile.cc
+++ b/runtime/native/dalvik_system_DexFile.cc
@@ -25,6 +25,7 @@
 #include "base/os.h"
 #include "base/stl_util.h"
 #include "base/utils.h"
+#include "base/zip_archive.h"
 #include "class_linker.h"
 #include <class_loader_context.h>
 #include "common_throws.h"
@@ -48,7 +49,6 @@
 #include "runtime.h"
 #include "scoped_thread_state_change-inl.h"
 #include "well_known_classes.h"
-#include "zip_archive.h"
 
 namespace art {
 
diff --git a/runtime/native/java_lang_VMClassLoader.cc b/runtime/native/java_lang_VMClassLoader.cc
index 3a0d760..44585fc 100644
--- a/runtime/native/java_lang_VMClassLoader.cc
+++ b/runtime/native/java_lang_VMClassLoader.cc
@@ -16,6 +16,7 @@
 
 #include "java_lang_VMClassLoader.h"
 
+#include "base/zip_archive.h"
 #include "class_linker.h"
 #include "dex/descriptors_names.h"
 #include "dex/dex_file_loader.h"
@@ -29,7 +30,6 @@
 #include "obj_ptr.h"
 #include "scoped_fast_native_object_access-inl.h"
 #include "well_known_classes.h"
-#include "zip_archive.h"
 
 namespace art {
 
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index cfbcda3..f6bee4d 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -40,6 +40,7 @@
 #include "base/enums.h"
 #include "base/file_utils.h"
 #include "base/logging.h"  // For VLOG_IS_ON.
+#include "base/mem_map.h"
 #include "base/os.h"
 #include "base/stl_util.h"
 #include "base/systrace.h"
@@ -54,7 +55,6 @@
 #include "elf_utils.h"
 #include "gc_root.h"
 #include "gc/space/image_space.h"
-#include "mem_map.h"
 #include "mirror/class.h"
 #include "mirror/object-inl.h"
 #include "oat.h"
diff --git a/runtime/runtime_callbacks_test.cc b/runtime/runtime_callbacks_test.cc
index 5603526..72d9919 100644
--- a/runtime/runtime_callbacks_test.cc
+++ b/runtime/runtime_callbacks_test.cc
@@ -28,13 +28,13 @@
 #include "jni.h"
 
 #include "art_method-inl.h"
+#include "base/mem_map.h"
 #include "base/mutex.h"
 #include "class_linker.h"
 #include "common_runtime_test.h"
 #include "dex/class_reference.h"
 #include "handle.h"
 #include "handle_scope-inl.h"
-#include "mem_map.h"
 #include "mirror/class-inl.h"
 #include "mirror/class_loader.h"
 #include "monitor.h"
diff --git a/runtime/thread_pool.h b/runtime/thread_pool.h
index a465e11..2784953 100644
--- a/runtime/thread_pool.h
+++ b/runtime/thread_pool.h
@@ -21,8 +21,8 @@
 #include <vector>
 
 #include "barrier.h"
+#include "base/mem_map.h"
 #include "base/mutex.h"
-#include "mem_map.h"
 
 namespace art {
 
diff --git a/runtime/vdex_file.h b/runtime/vdex_file.h
index 326fcbc..b7f28f0 100644
--- a/runtime/vdex_file.h
+++ b/runtime/vdex_file.h
@@ -22,9 +22,9 @@
 
 #include "base/array_ref.h"
 #include "base/macros.h"
+#include "base/mem_map.h"
 #include "base/os.h"
 #include "dex/compact_offset_table.h"
-#include "mem_map.h"
 #include "quicken_info.h"
 
 namespace art {
diff --git a/test/305-other-fault-handler/fault_handler.cc b/test/305-other-fault-handler/fault_handler.cc
index f048326..a0831ca 100644
--- a/test/305-other-fault-handler/fault_handler.cc
+++ b/test/305-other-fault-handler/fault_handler.cc
@@ -23,9 +23,9 @@
 #include <stdint.h>
 #include <sys/mman.h>
 
+#include "base/mem_map.h"
 #include "fault_handler.h"
 #include "globals.h"
-#include "mem_map.h"
 
 namespace art {
 
diff --git a/tools/hiddenapi/hiddenapi.cc b/tools/hiddenapi/hiddenapi.cc
index d22998a..97e7f4c 100644
--- a/tools/hiddenapi/hiddenapi.cc
+++ b/tools/hiddenapi/hiddenapi.cc
@@ -21,12 +21,12 @@
 #include "android-base/stringprintf.h"
 #include "android-base/strings.h"
 
+#include "base/mem_map.h"
 #include "base/os.h"
 #include "base/unix_file/fd_file.h"
 #include "dex/art_dex_file_loader.h"
 #include "dex/dex_file-inl.h"
 #include "dex/hidden_api_access_flags.h"
-#include "mem_map.h"
 
 namespace art {
 
diff --git a/tools/hiddenapi/hiddenapi_test.cc b/tools/hiddenapi/hiddenapi_test.cc
index af14395..ed880e0 100644
--- a/tools/hiddenapi/hiddenapi_test.cc
+++ b/tools/hiddenapi/hiddenapi_test.cc
@@ -17,11 +17,11 @@
 #include <fstream>
 
 #include "base/unix_file/fd_file.h"
+#include "base/zip_archive.h"
 #include "common_runtime_test.h"
 #include "dex/art_dex_file_loader.h"
 #include "dex/dex_file-inl.h"
 #include "exec_utils.h"
-#include "zip_archive.h"
 
 namespace art {