Merge "Revert "Make libdexfile build independent of runtime dir""
diff --git a/profman/profile_assistant_test.cc b/profman/profile_assistant_test.cc
index 642d26e..c75f3e9 100644
--- a/profman/profile_assistant_test.cc
+++ b/profman/profile_assistant_test.cc
@@ -209,7 +209,8 @@
bool CreateProfile(const std::string& profile_file_contents,
const std::string& filename,
- const std::string& dex_location) {
+ const std::string& dex_location,
+ bool skip_verification) {
ScratchFile class_names_file;
File* file = class_names_file.GetFile();
EXPECT_TRUE(file->WriteFully(profile_file_contents.c_str(), profile_file_contents.length()));
@@ -222,6 +223,9 @@
argv_str.push_back("--reference-profile-file=" + filename);
argv_str.push_back("--apk=" + dex_location);
argv_str.push_back("--dex-location=" + dex_location);
+ if (skip_verification) {
+ argv_str.push_back("--skip-apk-verification");
+ }
std::string error;
EXPECT_EQ(ExecAndReturnCode(argv_str, &error), 0);
return true;
@@ -238,6 +242,7 @@
argv_str.push_back("--profile-file=" + filename);
argv_str.push_back("--apk=" + GetLibCoreDexFileNames()[0]);
argv_str.push_back("--dex-location=" + GetLibCoreDexFileNames()[0]);
+ argv_str.push_back("--skip-apk-verification");
argv_str.push_back("--dump-output-to-fd=" + std::to_string(GetFd(output_file)));
std::string error;
EXPECT_EQ(ExecAndReturnCode(argv_str, &error), 0);
@@ -268,7 +273,8 @@
ScratchFile profile_file;
EXPECT_TRUE(CreateProfile(input_file_contents,
profile_file.GetFilename(),
- GetLibCoreDexFileNames()[0]));
+ GetLibCoreDexFileNames()[0],
+ /* skip_verification */ true));
profile_file.GetFile()->ResetOffset();
EXPECT_TRUE(DumpClassesAndMethods(profile_file.GetFilename(), output_file_contents));
return true;
@@ -675,7 +681,8 @@
ScratchFile profile_file;
EXPECT_TRUE(CreateProfile(input_file_contents,
profile_file.GetFilename(),
- GetLibCoreDexFileNames()[0]));
+ GetLibCoreDexFileNames()[0],
+ /* skip_verification */ true));
ProfileCompilationInfo info;
profile_file.GetFile()->ResetOffset();
ASSERT_TRUE(info.Load(GetFd(profile_file)));
@@ -731,7 +738,8 @@
"H" + kHotMethod + "\n" +
kUncommonDirtyClass;
profiles.emplace_back(ScratchFile());
- EXPECT_TRUE(CreateProfile(dex1, profiles.back().GetFilename(), core_dex));
+ EXPECT_TRUE(CreateProfile(
+ dex1, profiles.back().GetFilename(), core_dex, /* skip_verification */ true));
// Create a bunch of boot profiles.
std::string dex2 =
@@ -741,7 +749,8 @@
"P" + kMultiMethod + "\n" +
kUncommonDirtyClass;
profiles.emplace_back(ScratchFile());
- EXPECT_TRUE(CreateProfile(dex2, profiles.back().GetFilename(), core_dex));
+ EXPECT_TRUE(CreateProfile(
+ dex2, profiles.back().GetFilename(), core_dex, /* skip_verification */ true));
// Create a bunch of boot profiles.
std::string dex3 =
@@ -750,7 +759,8 @@
"P" + kMultiMethod + "\n" +
kDirtyClass + "\n";
profiles.emplace_back(ScratchFile());
- EXPECT_TRUE(CreateProfile(dex3, profiles.back().GetFilename(), core_dex));
+ EXPECT_TRUE(CreateProfile(
+ dex3, profiles.back().GetFilename(), core_dex, /* skip_verification */ true));
// Generate the boot profile.
ScratchFile out_profile;
@@ -763,6 +773,7 @@
args.push_back("--reference-profile-file=" + out_profile.GetFilename());
args.push_back("--apk=" + core_dex);
args.push_back("--dex-location=" + core_dex);
+ args.push_back("--skip-apk-verification");
for (const ScratchFile& profile : profiles) {
args.push_back("--profile-file=" + profile.GetFilename());
}
@@ -858,7 +869,8 @@
ScratchFile profile_file;
ASSERT_TRUE(CreateProfile(input_file_contents,
profile_file.GetFilename(),
- GetTestDexFileName("ProfileTestMultiDex")));
+ GetTestDexFileName("ProfileTestMultiDex"),
+ /* skip_verification */ false));
// Load the profile from disk.
ProfileCompilationInfo info;
@@ -1008,7 +1020,8 @@
std::string dex_filename = GetTestDexFileName("ProfileTestMultiDex");
ASSERT_TRUE(CreateProfile(input_file_contents,
profile_file.GetFilename(),
- dex_filename));
+ dex_filename,
+ /* skip_verification */ false));
// Load the profile from disk.
ProfileCompilationInfo info;
diff --git a/profman/profman.cc b/profman/profman.cc
index ffc3c01..ea6c382 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -137,6 +137,7 @@
UsageError(" --apk-fd=<number>: file descriptor containing an open APK to");
UsageError(" search for dex files");
UsageError(" --apk-=<filename>: an APK to search for dex files");
+ UsageError(" --skip-apk-verification: do not attempt to verify APKs");
UsageError("");
UsageError(" --generate-boot-image-profile: Generate a boot image profile based on input");
UsageError(" profiles. Requires passing in dex files to inspect properties of classes.");
@@ -185,6 +186,7 @@
dump_only_(false),
dump_classes_and_methods_(false),
generate_boot_image_profile_(false),
+ skip_apk_verification_(false),
dump_output_to_fd_(kInvalidFd),
test_profile_num_dex_(kDefaultTestProfileNumDex),
test_profile_method_percerntage_(kDefaultTestProfileMethodPercentage),
@@ -227,6 +229,8 @@
ParseUintOption(option, "--dump-output-to-fd", &dump_output_to_fd_, Usage);
} else if (option == "--generate-boot-image-profile") {
generate_boot_image_profile_ = true;
+ } else if (option == "--skip-apk-verification") {
+ skip_apk_verification_ = true;
} else if (option.starts_with("--boot-image-class-threshold=")) {
ParseUintOption(option,
"--boot-image-class-threshold",
@@ -321,6 +325,10 @@
return result;
}
+ bool ShouldSkipApkVerification() const {
+ return skip_apk_verification_;
+ }
+
void OpenApkFilesFromLocations(std::vector<std::unique_ptr<const DexFile>>* dex_files) const {
bool use_apk_fd_list = !apks_fd_.empty();
if (use_apk_fd_list) {
@@ -342,7 +350,7 @@
if (use_apk_fd_list) {
if (dex_file_loader.OpenZip(apks_fd_[i],
dex_locations_[i],
- /* verify */ true,
+ /* verify */ !ShouldSkipApkVerification(),
kVerifyChecksum,
&error_msg,
&dex_files_for_location)) {
@@ -353,7 +361,7 @@
} else {
if (dex_file_loader.Open(apk_files_[i].c_str(),
dex_locations_[i],
- /* verify */ true,
+ /* verify */ !ShouldSkipApkVerification(),
kVerifyChecksum,
&error_msg,
&dex_files_for_location)) {
@@ -1148,6 +1156,7 @@
bool dump_only_;
bool dump_classes_and_methods_;
bool generate_boot_image_profile_;
+ bool skip_apk_verification_;
int dump_output_to_fd_;
BootImageOptions boot_image_options_;
std::string test_profile_;
diff --git a/runtime/dex/dex_file_loader.cc b/runtime/dex/dex_file_loader.cc
index 7dde0a4..0f2758e 100644
--- a/runtime/dex/dex_file_loader.cc
+++ b/runtime/dex/dex_file_loader.cc
@@ -222,8 +222,8 @@
std::string* error_msg) const {
return OpenCommon(base,
size,
- /*data_base*/ base,
- /*data_size*/ size,
+ /*data_base*/ nullptr,
+ /*data_size*/ 0,
location,
location_checksum,
oat_dex_file,
diff --git a/test/004-ThreadStress/src/Main.java b/test/004-ThreadStress/src/Main.java
index 6ad160c..c03a912 100644
--- a/test/004-ThreadStress/src/Main.java
+++ b/test/004-ThreadStress/src/Main.java
@@ -38,6 +38,8 @@
// -t X ............ number of operations per thread
// -p X ............ number of permits granted by semaphore
// --dumpmap ....... print the frequency map
+// --locks-only .... select a pre-set frequency map with lock-related operations only
+// --allocs-only ... select a pre-set frequency map with allocation-related operations only
// -oom:X .......... frequency of OOM (double)
// -sigquit:X ...... frequency of SigQuit (double)
// -alloc:X ........ frequency of Alloc (double)
@@ -289,26 +291,35 @@
private final static Map<Operation, Double> createDefaultFrequencyMap(Object lock,
Semaphore semaphore) {
Map<Operation, Double> frequencyMap = new HashMap<Operation, Double>();
- frequencyMap.put(new OOM(), 0.005); // 1/200
- frequencyMap.put(new SigQuit(), 0.095); // 19/200
- frequencyMap.put(new Alloc(), 0.225); // 45/200
- frequencyMap.put(new LargeAlloc(), 0.05); // 10/200
- frequencyMap.put(new StackTrace(), 0.1); // 20/200
- frequencyMap.put(new Exit(), 0.225); // 45/200
- frequencyMap.put(new Sleep(), 0.125); // 25/200
- frequencyMap.put(new TimedWait(lock), 0.05); // 10/200
- frequencyMap.put(new Wait(lock), 0.075); // 15/200
- frequencyMap.put(new QueuedWait(semaphore), 0.05); // 10/200
+ frequencyMap.put(new OOM(), 0.005); // 1/200
+ frequencyMap.put(new SigQuit(), 0.095); // 19/200
+ frequencyMap.put(new Alloc(), 0.225); // 45/200
+ frequencyMap.put(new LargeAlloc(), 0.05); // 10/200
+ frequencyMap.put(new StackTrace(), 0.1); // 20/200
+ frequencyMap.put(new Exit(), 0.225); // 45/200
+ frequencyMap.put(new Sleep(), 0.125); // 25/200
+ frequencyMap.put(new TimedWait(lock), 0.05); // 10/200
+ frequencyMap.put(new Wait(lock), 0.075); // 15/200
+ frequencyMap.put(new QueuedWait(semaphore), 0.05); // 10/200
+
+ return frequencyMap;
+ }
+
+ private final static Map<Operation, Double> createAllocFrequencyMap() {
+ Map<Operation, Double> frequencyMap = new HashMap<Operation, Double>();
+ frequencyMap.put(new Sleep(), 0.2); // 40/200
+ frequencyMap.put(new Alloc(), 0.65); // 130/200
+ frequencyMap.put(new LargeAlloc(), 0.15); // 30/200
return frequencyMap;
}
private final static Map<Operation, Double> createLockFrequencyMap(Object lock) {
Map<Operation, Double> frequencyMap = new HashMap<Operation, Double>();
- frequencyMap.put(new Sleep(), 0.2); // 40/200
- frequencyMap.put(new TimedWait(lock), 0.2); // 40/200
- frequencyMap.put(new Wait(lock), 0.2); // 40/200
- frequencyMap.put(new SyncAndWork(lock), 0.4); // 80/200
+ frequencyMap.put(new Sleep(), 0.2); // 40/200
+ frequencyMap.put(new TimedWait(lock), 0.2); // 40/200
+ frequencyMap.put(new Wait(lock), 0.2); // 40/200
+ frequencyMap.put(new SyncAndWork(lock), 0.4); // 80/200
return frequencyMap;
}
@@ -414,11 +425,14 @@
i++;
permits = Integer.parseInt(args[i]);
} else if (args[i].equals("--locks-only")) {
- lock = new Object();
frequencyMap = createLockFrequencyMap(lock);
+ } else if (args[i].equals("--allocs-only")) {
+ frequencyMap = createAllocFrequencyMap();
} else if (args[i].equals("--dumpmap")) {
dumpMap = true;
} else {
+ // Processing an argument of the form "-<operation>:X"
+ // (where X is a double value).
Semaphore semaphore = getSemaphore(permits);
frequencyMap = updateFrequencyMap(frequencyMap, lock, semaphore, args[i]);
}
diff --git a/tools/generate-boot-image-profile.sh b/tools/generate-boot-image-profile.sh
index d87123a..ee53f43 100755
--- a/tools/generate-boot-image-profile.sh
+++ b/tools/generate-boot-image-profile.sh
@@ -46,7 +46,9 @@
fi
done
-jar_args=()
+# Boot jars have hidden API access flags which do not pass dex file
+# verification. Skip it.
+jar_args=("--skip-apk-verification")
boot_jars=$("$ANDROID_BUILD_TOP"/art/tools/bootjars.sh --target)
jar_dir=$ANDROID_BUILD_TOP/$(get_build_var TARGET_OUT_JAVA_LIBRARIES)
for file in $boot_jars; do