Add verify-profile compiler filter
Only verifies and dex2dex compiles classes in the profile. Goal
is to reduce application launch time.
~2x faster than interpret-only for Facebook.
Bug: 27688727
(cherry picked from commit a079e3aa62cceb76c1c1811e6e09bcaf75e20289)
Change-Id: Iad5aa1adee3aa6c2408820e8cbbab2d4412021b8
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index d8e309d..e2ef7ac 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -3964,7 +3964,12 @@
oat_file_class_status = oat_dex_file->GetOatClass(class_def_index).GetStatus();
if (oat_file_class_status == mirror::Class::kStatusVerified ||
oat_file_class_status == mirror::Class::kStatusInitialized) {
- return true;
+ return true;
+ }
+ // If we only verified a subset of the classes at compile time, we can end up with classes that
+ // were resolved by the verifier.
+ if (oat_file_class_status == mirror::Class::kStatusResolved) {
+ return false;
}
if (oat_file_class_status == mirror::Class::kStatusRetryVerificationAtRuntime) {
// Compile time verification failed with a soft error. Compile time verification can fail
diff --git a/runtime/jit/offline_profiling_info.cc b/runtime/jit/offline_profiling_info.cc
index ecf34f5..f181ca3 100644
--- a/runtime/jit/offline_profiling_info.cc
+++ b/runtime/jit/offline_profiling_info.cc
@@ -367,6 +367,18 @@
return false;
}
+bool ProfileCompilationInfo::ContainsClass(const DexFile& dex_file, uint16_t class_def_idx) const {
+ auto info_it = info_.find(GetProfileDexFileKey(dex_file.GetLocation()));
+ if (info_it != info_.end()) {
+ if (dex_file.GetLocationChecksum() != info_it->second.checksum) {
+ return false;
+ }
+ const std::set<uint16_t>& classes = info_it->second.class_set;
+ return classes.find(class_def_idx) != classes.end();
+ }
+ return false;
+}
+
uint32_t ProfileCompilationInfo::GetNumberOfMethods() const {
uint32_t total = 0;
for (const auto& it : info_) {
diff --git a/runtime/jit/offline_profiling_info.h b/runtime/jit/offline_profiling_info.h
index ee7ce27..df03244 100644
--- a/runtime/jit/offline_profiling_info.h
+++ b/runtime/jit/offline_profiling_info.h
@@ -60,6 +60,9 @@
// Returns true if the method reference is present in the profiling info.
bool ContainsMethod(const MethodReference& method_ref) const;
+ // Returns true if the class is present in the profiling info.
+ bool ContainsClass(const DexFile& dex_file, uint16_t class_def_idx) const;
+
// Dumps all the loaded profile info into a string and returns it.
// If dex_files is not null then the method indices will be resolved to their
// names.