Preparing for work on string interning for AppImages.
* Allow classes that have string fields to be put into AppImages.
* Updated tracing messages to be more descriptive and searchable.
* Added new tracing objects to more accurately report time spent in
handling AppImages.
Test: Built image / flashed device / ran applications
(cherry picked from commit e3015b59fb297d236f0b3ce844eef81c67e423d3)
Change-Id: I6e5fba8c8ddeff8e077672b799d244e767478373
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index bcc3a22..d95f71a 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1251,6 +1251,8 @@
ClassTable::ClassSet* new_class_set)
REQUIRES(!Locks::dex_lock_)
REQUIRES_SHARED(Locks::mutator_lock_) {
+ ScopedTrace app_image_timing("AppImage:Updating");
+
Thread* const self = Thread::Current();
gc::Heap* const heap = Runtime::Current()->GetHeap();
const ImageHeader& header = space->GetImageHeader();
@@ -1311,7 +1313,7 @@
}
if (ClassLinker::kAppImageMayContainStrings) {
// Fixup all the literal strings happens at app images which are supposed to be interned.
- ScopedTrace timing("Fixup String Intern in image and dex_cache");
+ ScopedTrace timing("AppImage:InternString");
const auto& image_header = space->GetImageHeader();
const auto bitmap = space->GetMarkBitmap(); // bitmap of objects
const uint8_t* target_base = space->GetMemMap()->Begin();
@@ -1324,7 +1326,7 @@
bitmap->VisitMarkedRange(objects_begin, objects_end, fixup_intern_visitor);
}
if (kVerifyArtMethodDeclaringClasses) {
- ScopedTrace timing("Verify declaring classes");
+ ScopedTrace timing("AppImage:VerifyDeclaringClasses");
ReaderMutexLock rmu(self, *Locks::heap_bitmap_lock_);
VerifyDeclaringClassVisitor visitor;
header.VisitPackedArtMethods(&visitor, space->Begin(), kRuntimePointerSize);
@@ -1842,7 +1844,7 @@
// Force every app image class's SubtypeCheck to be at least kIninitialized.
//
// See also ImageWriter::FixupClass.
- ScopedTrace trace("Recalculate app image SubtypeCheck bitstrings");
+ ScopedTrace trace("AppImage:RecacluateSubtypeCheckBitstrings");
MutexLock subtype_check_lock(Thread::Current(), *Locks::subtype_check_lock_);
for (const ClassTable::TableSlot& root : temp_set) {
SubtypeCheck<ObjPtr<mirror::Class>>::EnsureInitialized(root.Read());
@@ -1862,7 +1864,7 @@
if (kIsDebugBuild && app_image) {
// This verification needs to happen after the classes have been added to the class loader.
// Since it ensures classes are in the class table.
- ScopedTrace trace("VerifyAppImage");
+ ScopedTrace trace("AppImage:Verify");
VerifyAppImage(header, class_loader, dex_caches, class_table, space);
}
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index efe29d3..e06a398 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -111,7 +111,7 @@
class ClassLinker {
public:
- static constexpr bool kAppImageMayContainStrings = false;
+ static constexpr bool kAppImageMayContainStrings = true;
explicit ClassLinker(InternTable* intern_table);
virtual ~ClassLinker();
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 92d2d44..a9ef9a3 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -526,6 +526,8 @@
if (source_oat_file != nullptr) {
bool added_image_space = false;
if (source_oat_file->IsExecutable()) {
+ ScopedTrace app_image_timing("AppImage:Loading");
+
// We need to throw away the image space if we are debuggable but the oat-file source of the
// image is not otherwise we might get classes with inlined methods or other such things.
std::unique_ptr<gc::space::ImageSpace> image_space;