// Creates an inline cache which will be destructed at the end of the test.
ProfileCompilationInfo::InlineCacheMap* CreateInlineCacheMap() {
used_inline_caches.emplace_back(new ProfileCompilationInfo::InlineCacheMap(
std::less<uint16_t>(), allocator_->Adapter(kArenaAllocProfile))); return used_inline_caches.back().get();
}
// Cannot sizeof the actual arrays so hard code the values here. // They should not change anyway. static constexpr int kProfileMagicSize = 4; static constexpr int kProfileVersionSize = 4;
std::unique_ptr<ArenaAllocator> allocator_;
// Cache of inline caches generated during tests. // This makes it easier to pass data between different utilities and ensure that // caches are destructed at the end of the test.
std::vector<std::unique_ptr<ProfileCompilationInfo::InlineCacheMap>> used_inline_caches;
};
// Save virtual methods from Main.
std::vector<ArtMethod*> main_methods = GetVirtualMethods(class_loader, "LMain;");
ASSERT_TRUE(SaveProfilingInfo(
profile.GetFilename(),
main_methods, static_cast<Hotness::Flag>(Hotness::kFlagHot | Hotness::kFlagPostStartup)));
// Check that what we saved is in the profile.
ProfileCompilationInfo info1;
ASSERT_TRUE(info1.Load(profile.GetFilename(), /*clear_if_invalid=*/false));
ASSERT_EQ(info1.GetNumberOfMethods(), main_methods.size());
{
ScopedObjectAccess soa(self); for (ArtMethod* m : main_methods) {
Hotness h = info1.GetMethodHotness(MethodReference(m->GetDexFile(), m->GetDexMethodIndex()));
ASSERT_TRUE(h.IsHot());
ASSERT_TRUE(h.IsPostStartup());
}
}
// Save virtual methods from Second.
std::vector<ArtMethod*> second_methods = GetVirtualMethods(class_loader, "LSecond;");
ASSERT_TRUE(SaveProfilingInfo(
profile.GetFilename(),
second_methods, static_cast<Hotness::Flag>(Hotness::kFlagHot | Hotness::kFlagStartup)));
// Check that what we saved is in the profile (methods form Main and Second).
ProfileCompilationInfo info2;
ASSERT_TRUE(info2.Load(profile.GetFilename(), /*clear_if_invalid=*/false));
ASSERT_EQ(info2.GetNumberOfMethods(), main_methods.size() + second_methods.size());
{
ScopedObjectAccess soa(self); for (ArtMethod* m : main_methods) {
Hotness h = info2.GetMethodHotness(MethodReference(m->GetDexFile(), m->GetDexMethodIndex()));
ASSERT_TRUE(h.IsHot());
ASSERT_TRUE(h.IsPostStartup());
} for (ArtMethod* m : second_methods) {
Hotness h = info2.GetMethodHotness(MethodReference(m->GetDexFile(), m->GetDexMethodIndex()));
ASSERT_TRUE(h.IsHot());
ASSERT_TRUE(h.IsStartup());
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.