summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2016-04-29 12:03:56 -0700
committer Mathieu Chartier <mathieuc@google.com> 2016-04-29 14:07:37 -0700
commit9275af6ec0d71d1a13a97a1d292806b73f755717 (patch)
tree3768c629647df0c499d180e9dc277e8c62c37e9a
parent206d27da4e38df51e2fc44de3ed4d1f54198662a (diff)
Fix profile saver to use base dex location
Previously we were using the dex location. This only matches the base location for the main dex file, and resulted in only the main dex file to have classes recorded. Bug: 28463739 Change-Id: I0117352150c7244dd048338dbb677abdd4554eb0
-rw-r--r--runtime/class_linker.cc1
-rw-r--r--runtime/dex_cache_resolved_classes.h11
-rw-r--r--runtime/jit/offline_profiling_info.cc3
-rw-r--r--runtime/jit/profile_saver.cc11
4 files changed, 21 insertions, 5 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index a4eed4cb1d..c92304f647 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -7987,6 +7987,7 @@ std::set<DexCacheResolvedClasses> ClassLinker::GetResolvedClasses(bool ignore_bo
VLOG(class_linker) << "Collecting class profile for dex file " << location
<< " types=" << num_types << " class_defs=" << num_class_defs;
DexCacheResolvedClasses resolved_classes(dex_file->GetLocation(),
+ dex_file->GetBaseLocation(),
dex_file->GetLocationChecksum());
size_t num_resolved = 0;
std::unordered_set<uint16_t> class_set;
diff --git a/runtime/dex_cache_resolved_classes.h b/runtime/dex_cache_resolved_classes.h
index 80c12cb642..0febbedf03 100644
--- a/runtime/dex_cache_resolved_classes.h
+++ b/runtime/dex_cache_resolved_classes.h
@@ -26,8 +26,11 @@ namespace art {
// Data structure for passing around which classes belonging to a dex cache / dex file are resolved.
class DexCacheResolvedClasses {
public:
- DexCacheResolvedClasses(const std::string& dex_location, uint32_t location_checksum)
+ DexCacheResolvedClasses(const std::string& dex_location,
+ const std::string& base_location,
+ uint32_t location_checksum)
: dex_location_(dex_location),
+ base_location_(base_location),
location_checksum_(location_checksum) {}
// Only compare the key elements, ignore the resolved classes.
@@ -35,6 +38,7 @@ class DexCacheResolvedClasses {
if (location_checksum_ != other.location_checksum_) {
return static_cast<int>(location_checksum_ - other.location_checksum_);
}
+ // Don't need to compare base_location_ since dex_location_ has more info.
return dex_location_.compare(other.dex_location_);
}
@@ -47,6 +51,10 @@ class DexCacheResolvedClasses {
return dex_location_;
}
+ const std::string& GetBaseLocation() const {
+ return base_location_;
+ }
+
uint32_t GetLocationChecksum() const {
return location_checksum_;
}
@@ -57,6 +65,7 @@ class DexCacheResolvedClasses {
private:
const std::string dex_location_;
+ const std::string base_location_;
const uint32_t location_checksum_;
// Array of resolved class def indexes.
mutable std::unordered_set<uint16_t> classes_;
diff --git a/runtime/jit/offline_profiling_info.cc b/runtime/jit/offline_profiling_info.cc
index a79bcf05ae..b378bed183 100644
--- a/runtime/jit/offline_profiling_info.cc
+++ b/runtime/jit/offline_profiling_info.cc
@@ -644,7 +644,8 @@ std::set<DexCacheResolvedClasses> ProfileCompilationInfo::GetResolvedClasses() c
for (auto&& pair : info_) {
const std::string& profile_key = pair.first;
const DexFileData& data = pair.second;
- DexCacheResolvedClasses classes(profile_key, data.checksum);
+ // TODO: Is it OK to use the same location for both base and dex location here?
+ DexCacheResolvedClasses classes(profile_key, profile_key, data.checksum);
classes.AddClasses(data.class_set.begin(), data.class_set.end());
ret.insert(classes);
}
diff --git a/runtime/jit/profile_saver.cc b/runtime/jit/profile_saver.cc
index 6af0c1addb..e8462a1188 100644
--- a/runtime/jit/profile_saver.cc
+++ b/runtime/jit/profile_saver.cc
@@ -145,20 +145,25 @@ ProfileCompilationInfo* ProfileSaver::GetCachedProfiledInfo(const std::string& f
void ProfileSaver::FetchAndCacheResolvedClasses() {
ScopedTrace trace(__PRETTY_FUNCTION__);
-
ClassLinker* const class_linker = Runtime::Current()->GetClassLinker();
std::set<DexCacheResolvedClasses> resolved_classes =
class_linker->GetResolvedClasses(/*ignore boot classes*/ true);
MutexLock mu(Thread::Current(), *Locks::profiler_lock_);
uint64_t total_number_of_profile_entries_cached = 0;
+
for (const auto& it : tracked_dex_base_locations_) {
- std::set<DexCacheResolvedClasses> resolved_classes_for_location;
+ std::set<DexCacheResolvedClasses> resolved_classes_for_location;
const std::string& filename = it.first;
const std::set<std::string>& locations = it.second;
for (const DexCacheResolvedClasses& classes : resolved_classes) {
- if (locations.find(classes.GetDexLocation()) != locations.end()) {
+ if (locations.find(classes.GetBaseLocation()) != locations.end()) {
+ VLOG(profiler) << "Added classes for location " << classes.GetBaseLocation()
+ << " (" << classes.GetDexLocation() << ")";
resolved_classes_for_location.insert(classes);
+ } else {
+ VLOG(profiler) << "Location not found " << classes.GetBaseLocation()
+ << " (" << classes.GetDexLocation() << ")";
}
}
ProfileCompilationInfo* info = GetCachedProfiledInfo(filename);