summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Sehr <sehr@google.com> 2018-04-06 17:58:50 -0700
committer David Sehr <sehr@google.com> 2018-04-13 08:29:30 -0700
commit79e2607ab50163bfdc283f4a49decec26a216df5 (patch)
tree0cdb2c65412b64a55ddf1a486ab3d961a0301a3e
parentb4b91460b2d01d36ddcb7d55111ccd8faf390c2a (diff)
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
-rw-r--r--compiler/jni/jni_compiler_test.cc2
-rw-r--r--dex2oat/dex2oat.cc2
-rw-r--r--dex2oat/linker/image_writer.h2
-rw-r--r--dex2oat/linker/oat_writer.cc4
-rw-r--r--dex2oat/linker/oat_writer.h2
-rw-r--r--dexlayout/dexlayout.cc2
-rw-r--r--dexlayout/dexlayout_main.cc2
-rw-r--r--libartbase/Android.bp38
-rw-r--r--libartbase/base/logging.cc55
-rw-r--r--libartbase/base/logging.h3
-rw-r--r--libartbase/base/mem_map.cc (renamed from runtime/mem_map.cc)4
-rw-r--r--libartbase/base/mem_map.h (renamed from runtime/mem_map.h)7
-rw-r--r--libartbase/base/mem_map_test.cc (renamed from runtime/mem_map_test.cc)0
-rw-r--r--libartbase/base/zip_archive.cc (renamed from runtime/zip_archive.cc)7
-rw-r--r--libartbase/base/zip_archive.h (renamed from runtime/zip_archive.h)9
-rw-r--r--libartbase/base/zip_archive_test.cc (renamed from runtime/zip_archive_test.cc)2
-rw-r--r--openjdkjvmti/ti_class_definition.h2
-rw-r--r--openjdkjvmti/ti_class_loader.h2
-rw-r--r--openjdkjvmti/ti_redefine.h2
-rw-r--r--openjdkjvmti/transform.cc2
-rw-r--r--profman/profman.cc2
-rw-r--r--runtime/Android.bp4
-rw-r--r--runtime/base/file_utils.cc53
-rw-r--r--runtime/base/file_utils.h1
-rw-r--r--runtime/base/mem_map_arena_pool.cc2
-rw-r--r--runtime/common_runtime_test.cc2
-rw-r--r--runtime/dex/art_dex_file_loader.cc4
-rw-r--r--runtime/dex/art_dex_file_loader_test.cc2
-rw-r--r--runtime/dexopt_test.cc2
-rw-r--r--runtime/elf_file_impl.h2
-rw-r--r--runtime/gc/accounting/atomic_stack.h2
-rw-r--r--runtime/gc/accounting/bitmap.cc2
-rw-r--r--runtime/gc/accounting/card_table-inl.h2
-rw-r--r--runtime/gc/accounting/card_table.cc2
-rw-r--r--runtime/gc/accounting/read_barrier_table.h2
-rw-r--r--runtime/gc/accounting/space_bitmap.cc2
-rw-r--r--runtime/gc/allocator/rosalloc.cc2
-rw-r--r--runtime/gc/space/space.h2
-rw-r--r--runtime/gc/space/zygote_space.h2
-rw-r--r--runtime/interpreter/unstarted_runtime.cc2
-rw-r--r--runtime/jit/jit_code_cache.cc2
-rw-r--r--runtime/jit/profile_compilation_info.cc2
-rw-r--r--runtime/jit/profile_compilation_info.h2
-rw-r--r--runtime/native/dalvik_system_DexFile.cc2
-rw-r--r--runtime/native/java_lang_VMClassLoader.cc2
-rw-r--r--runtime/oat_file.cc2
-rw-r--r--runtime/runtime_callbacks_test.cc2
-rw-r--r--runtime/thread_pool.h2
-rw-r--r--runtime/vdex_file.h2
-rw-r--r--test/305-other-fault-handler/fault_handler.cc2
-rw-r--r--tools/hiddenapi/hiddenapi.cc2
-rw-r--r--tools/hiddenapi/hiddenapi_test.cc2
52 files changed, 147 insertions, 120 deletions
diff --git a/compiler/jni/jni_compiler_test.cc b/compiler/jni/jni_compiler_test.cc
index 451a909965..730a1a63e8 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 e2177697bf..fa711748cf 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 c67835b455..9a82fd046e 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 bcc59098e5..6552e9582e 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 @@ bool OatWriter::WriteDexFiles(OutputStream* out,
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 7b7bd13c18..619743ef14 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 ec0cbe6a60..7a8c31ba84 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 f30cfee4ec..f81d16cbf5 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 62157e196d..6d76122373 100644
--- a/libartbase/Android.bp
+++ b/libartbase/Android.bp
@@ -28,6 +28,7 @@ cc_defaults {
"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 @@ cc_defaults {
"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 @@ art_cc_library {
strip: {
keep_symbols: true,
},
- shared_libs: ["libbase"],
+ shared_libs: [
+ "libbase",
+ "libziparchive",
+ ],
export_shared_lib_headers: ["libbase"],
}
@@ -82,7 +109,10 @@ art_cc_library {
"art_debug_defaults",
"libartbase_defaults",
],
- shared_libs: ["libbase"],
+ shared_libs: [
+ "libbase",
+ "libziparchive",
+ ],
export_shared_lib_headers: ["libbase"],
}
@@ -107,6 +137,7 @@ art_cc_test {
"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 @@ art_cc_test {
"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 37b1f8264a..fd2cc20af2 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 @@ void LogHelper::LogLineLowStack(const char* file,
#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 fd5fc74383..986704ec98 100644
--- a/libartbase/base/logging.h
+++ b/libartbase/base/logging.h
@@ -98,6 +98,9 @@ class LogHelper {
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
index b9d51c1125..21634f86b6 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 @@ static bool CheckNonOverlapping(uintptr_t begin,
*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
index 0ecb414614..b7beb08dbc 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 @@ void ZeroAndReleasePages(void* address, size_t length);
} // 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
index 3adbf18a7a..3adbf18a7a 100644
--- a/runtime/mem_map_test.cc
+++ b/libartbase/base/mem_map_test.cc
diff --git a/runtime/zip_archive.cc b/libartbase/base/zip_archive.cc
index 5b3cab42d8..4185c227c8 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 @@ bool ZipEntry::IsAlignedTo(size_t alignment) const {
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
index aa54018574..39c8168519 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 @@ class ZipEntry {
bool IsUncompressed();
bool IsAlignedTo(size_t alignment) const;
- bool IsAlignedToDexHeader() const;
private:
ZipEntry(ZipArchiveHandle handle,
@@ -102,4 +101,4 @@ class ZipArchive {
} // 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
index 48ee94ce8c..03f4cd4d54 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 31c3611e72..f888a7474f 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 5c9497b0b5..dbe30da462 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 778f87e68e..a8877f84cd 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 43b8fe94f4..e88ecef54a 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 90e342d16a..4e1ea23e08 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 00d4a6080a..ec4c272cb7 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -119,7 +119,6 @@ cc_defaults {
"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 @@ cc_defaults {
"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 @@ art_cc_test {
"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 @@ art_cc_test {
"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 2b3e360650..7b0796cf37 100644
--- a/runtime/base/file_utils.cc
+++ b/runtime/base/file_utils.cc
@@ -83,59 +83,6 @@ bool ReadFileToString(const std::string& file_name, std::string* result) {
}
}
-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 8adb4f7bf8..d4f6c576c0 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 d5ea19b70e..9ac7886e5d 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 05159e253d..f6a5efc547 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 f3e6a69279..415e451098 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 @@ bool ArtDexFileLoader::GetMultiDexChecksums(const char* filename,
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 3e0d6662c7..afc2599ea0 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 c19fa82877..8f0f9c61dc 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 3143df537f..a5808e27ba 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 7a4bd87b12..e30fef4fc2 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 e5353807a9..d45a0cc018 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 d9c0418f4a..357a4985b6 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 4eea607c39..c7f936fb11 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 775746f68d..57e4db9b2b 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 d84288f676..ced62cd249 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 928abe873e..a4095d815f 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 bc3ab48cf4..d888935ff2 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 10c1398001..6fe21d99a8 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 dd8d7dd3e2..791ebf09b7 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 de64fdd2c9..6dcc87179b 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 6bbe78f3fd..f5c2715cda 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 f8334cea4f..c9ab4e584f 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 13319c4c57..8320d9c7ba 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 3a0d76032e..44585fc453 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 cfbcda36b9..f6bee4d7e8 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 5603526177..72d9919971 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 a465e11055..2784953d69 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 326fcbc1fe..b7f28f0d03 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 f04832613b..a0831ca8c2 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 d22998ae1b..97e7f4cf3c 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 af1439520f..ed880e0e92 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 {