summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sehr <sehr@google.com>2018-05-10 17:44:18 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-05-10 17:44:18 +0000
commit42805fa0afeefbc4fd4e3339940582bdda9c77bd (patch)
tree041eb852669b2d40b885a15d192d66e49aae253c
parent57b1bcd19934b447eda315dc1b612ab91a87b2fd (diff)
parent2b80ed488c497393270c98f7a767d8495166db8e (diff)
downloadart-42805fa0afeefbc4fd4e3339940582bdda9c77bd.tar.gz
art-42805fa0afeefbc4fd4e3339940582bdda9c77bd.tar.bz2
art-42805fa0afeefbc4fd4e3339940582bdda9c77bd.zip
Merge "Make dexlayout and profman build without libart"
-rw-r--r--dexlayout/Android.bp9
-rw-r--r--dexlayout/dexlayout.cc32
-rw-r--r--dexlayout/dexlayout_main.cc8
-rw-r--r--libprofile/Android.bp1
-rw-r--r--profman/Android.bp4
-rw-r--r--profman/profman.cc67
6 files changed, 82 insertions, 39 deletions
diff --git a/dexlayout/Android.bp b/dexlayout/Android.bp
index b009774582..5285c08cc2 100644
--- a/dexlayout/Android.bp
+++ b/dexlayout/Android.bp
@@ -27,6 +27,7 @@ art_cc_defaults {
],
export_include_dirs: ["."],
shared_libs: [
+ "libartbase",
"libbase",
],
static_libs: ["libz"],
@@ -39,7 +40,6 @@ art_cc_library {
"dex2oat-pgo-defaults",
],
shared_libs: [
- "libart",
"libdexfile",
"libprofile",
],
@@ -60,7 +60,6 @@ art_cc_library {
"art_debug_defaults",
],
shared_libs: [
- "libartd",
"libdexfiled",
"libprofiled",
],
@@ -80,8 +79,9 @@ art_cc_binary {
name: "dexlayout",
defaults: ["dexlayout-defaults"],
shared_libs: [
+ "libartbase",
+ "libdexfile",
"libprofile",
- "libart",
"libart-dexlayout",
],
}
@@ -93,8 +93,9 @@ art_cc_binary {
"dexlayout-defaults",
],
shared_libs: [
+ "libartbased",
+ "libdexfiled",
"libprofiled",
- "libartd",
"libartd-dexlayout",
],
}
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index 62dd1a9554..03dfee319e 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -36,8 +36,8 @@
#include "base/logging.h" // For VLOG_IS_ON.
#include "base/mem_map.h"
#include "base/os.h"
+#include "base/unix_file/fd_file.h"
#include "base/utils.h"
-#include "dex/art_dex_file_loader.h"
#include "dex/descriptors_names.h"
#include "dex/dex_file-inl.h"
#include "dex/dex_file_layout.h"
@@ -1930,7 +1930,7 @@ bool DexLayout::ProcessDexFile(const char* file_name,
std::string location = "memory mapped file for " + std::string(file_name);
// Dex file verifier cannot handle compact dex.
bool verify = options_.compact_dex_level_ == CompactDexLevel::kCompactDexLevelNone;
- const ArtDexFileLoader dex_file_loader;
+ const DexFileLoader dex_file_loader;
DexContainer::Section* const main_section = (*dex_container)->GetMainSection();
DexContainer::Section* const data_section = (*dex_container)->GetDataSection();
DCHECK_EQ(file_size, main_section->Size())
@@ -1980,10 +1980,32 @@ int DexLayout::ProcessFile(const char* file_name) {
// all of which are Zip archives with "classes.dex" inside.
const bool verify_checksum = !options_.ignore_bad_checksum_;
std::string error_msg;
- const ArtDexFileLoader dex_file_loader;
+ std::unique_ptr<File> input_file(OS::OpenFileForReading(file_name));
+ if (input_file == nullptr) {
+ LOG(ERROR) << "Could not open file " << file_name << " for reading";
+ return -1;
+ }
+ std::unique_ptr<MemMap> mmap(MemMap::MapFile(input_file->GetLength(),
+ PROT_READ,
+ MAP_PRIVATE,
+ input_file->Fd(),
+ /*start*/0,
+ /*low_4gb*/false,
+ file_name,
+ &error_msg));
+ if (mmap == nullptr) {
+ LOG(ERROR) << "MemMap failed for '" << file_name << "' " << error_msg;
+ return -1;
+ }
+ const DexFileLoader dex_file_loader;
std::vector<std::unique_ptr<const DexFile>> dex_files;
- if (!dex_file_loader.Open(
- file_name, file_name, /* verify */ true, verify_checksum, &error_msg, &dex_files)) {
+ if (!dex_file_loader.OpenAll(mmap->Begin(),
+ mmap->Size(),
+ file_name,
+ /*verify*/true,
+ verify_checksum,
+ &error_msg,
+ &dex_files)) {
// Display returned error message to user. Note that this error behavior
// differs from the error messages shown by the original Dalvik dexdump.
LOG(ERROR) << error_msg;
diff --git a/dexlayout/dexlayout_main.cc b/dexlayout/dexlayout_main.cc
index 185c1420ab..3f92d501f6 100644
--- a/dexlayout/dexlayout_main.cc
+++ b/dexlayout/dexlayout_main.cc
@@ -34,7 +34,6 @@
#include "base/logging.h" // For InitLogging.
#include "base/mem_map.h"
#include "profile/profile_compilation_info.h"
-#include "runtime.h"
namespace art {
@@ -66,12 +65,17 @@ static void Usage(void) {
LOG(ERROR) << " -x : compact dex generation level, either 'none' or 'fast'";
}
+NO_RETURN static void Abort(const char* msg) {
+ LOG(ERROR) << "Aborted: " << msg;
+ exit(1);
+}
+
/*
* Main driver of the dexlayout utility.
*/
int DexlayoutDriver(int argc, char** argv) {
// Art specific set up.
- InitLogging(argv, Runtime::Abort);
+ InitLogging(argv, Abort);
MemMap::Init();
Options options;
diff --git a/libprofile/Android.bp b/libprofile/Android.bp
index bcb90cb680..5afe73b353 100644
--- a/libprofile/Android.bp
+++ b/libprofile/Android.bp
@@ -40,7 +40,6 @@ cc_defaults {
],
},
},
- //generated_sources: ["art_libartbase_operator_srcs"],
cflags: ["-DBUILDING_LIBART=1"],
shared_libs: [
"libartbase",
diff --git a/profman/Android.bp b/profman/Android.bp
index 3c8c72c34a..c9c92e6685 100644
--- a/profman/Android.bp
+++ b/profman/Android.bp
@@ -39,7 +39,7 @@ art_cc_binary {
name: "profman",
defaults: ["profman-defaults"],
shared_libs: [
- "libart",
+ "libartbase",
"libprofile",
"libdexfile",
],
@@ -52,7 +52,7 @@ art_cc_binary {
"profman-defaults",
],
shared_libs: [
- "libartd",
+ "libartbased",
"libprofiled",
"libdexfiled",
],
diff --git a/profman/profman.cc b/profman/profman.cc
index cd88d03929..c16fadd828 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
+#include <sys/mman.h>
#include <sys/param.h>
#include <unistd.h>
@@ -40,7 +41,6 @@
#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"
#include "dex/code_item_accessors-inl.h"
#include "dex/dex_file.h"
@@ -49,7 +49,6 @@
#include "dex/type_reference.h"
#include "profile/profile_compilation_info.h"
#include "profile_assistant.h"
-#include "runtime.h"
namespace art {
@@ -177,6 +176,11 @@ static constexpr char kMethodFlagStringHot = 'H';
static constexpr char kMethodFlagStringStartup = 'S';
static constexpr char kMethodFlagStringPostStartup = 'P';
+NO_RETURN static void Abort(const char* msg) {
+ LOG(ERROR) << "Aborted: " << msg;
+ exit(1);
+}
+
// TODO(calin): This class has grown too much from its initial design. Split the functionality
// into smaller, more contained pieces.
class ProfMan FINAL {
@@ -202,8 +206,8 @@ class ProfMan FINAL {
original_argc = argc;
original_argv = argv;
- Locks::Init();
- InitLogging(argv, Runtime::Abort);
+ MemMap::Init();
+ InitLogging(argv, Abort);
// Skip over the command name.
argv++;
@@ -413,36 +417,49 @@ class ProfMan FINAL {
}
static constexpr bool kVerifyChecksum = true;
for (size_t i = 0; i < dex_locations_.size(); ++i) {
- std::string error_msg;
- const ArtDexFileLoader dex_file_loader;
- std::vector<std::unique_ptr<const DexFile>> dex_files_for_location;
+ std::unique_ptr<File> apk_file;
// We do not need to verify the apk for processing profiles.
if (use_apk_fd_list) {
- if (dex_file_loader.OpenZip(apks_fd_[i],
- dex_locations_[i],
- /* verify */ false,
- kVerifyChecksum,
- &error_msg,
- &dex_files_for_location)) {
- } else {
- LOG(ERROR) << "OpenZip failed for '" << dex_locations_[i] << "' " << error_msg;
- return false;
- }
+ apk_file.reset(new File(apks_fd_[i], false/*checkUsage*/));
} else {
- if (dex_file_loader.Open(apk_files_[i].c_str(),
- dex_locations_[i],
- /* verify */ false,
- kVerifyChecksum,
- &error_msg,
- &dex_files_for_location)) {
- } else {
- LOG(ERROR) << "Open failed for '" << dex_locations_[i] << "' " << error_msg;
+ apk_file.reset(new File(apk_files_[i], O_RDONLY, false/*checkUsage*/));
+ if (apk_file == nullptr) {
+ LOG(ERROR) << "Open failed for '" << dex_locations_[i] << "' ";
return false;
}
}
+ std::string error_msg;
+ std::unique_ptr<MemMap> mmap(MemMap::MapFile(apk_file->GetLength(),
+ PROT_READ,
+ MAP_PRIVATE,
+ apk_file->Fd(),
+ /*start*/0,
+ /*low_4gb*/false,
+ dex_locations_[i].c_str(),
+ &error_msg));
+ if (mmap == nullptr) {
+ LOG(ERROR) << "MemMap failed for '" << dex_locations_[i] << "' " << error_msg;
+ return false;
+ }
+ const DexFileLoader dex_file_loader;
+ std::vector<std::unique_ptr<const DexFile>> dex_files_for_location;
+ if (!dex_file_loader.OpenAll(mmap->Begin(),
+ mmap->Size(),
+ dex_locations_[i],
+ /* verify */ false,
+ kVerifyChecksum,
+ &error_msg,
+ &dex_files_for_location)) {
+ LOG(ERROR) << "OpenAll failed for '" << dex_locations_[i] << "' " << error_msg;
+ return false;
+ }
for (std::unique_ptr<const DexFile>& dex_file : dex_files_for_location) {
process_fn(std::move(dex_file));
}
+ // Leak apk_file and mmap for now.
+ // TODO: close fds, etc.
+ apk_file.release();
+ mmap.release();
}
return true;
}