Remove mirror:: and ArtMethod deps in utils.{h,cc}
The latest chapter in the ongoing saga of attempting to dump a DEX
file without having to start a whole runtime instance. This episode
finds us removing references to ArtMethod/ArtField/mirror.
One aspect of this change that I would like to call out specfically
is that the utils versions of the "Pretty*" functions all were written
to accept nullptr as an argument. I have split these functions up as
follows:
1) an instance method, such as PrettyClass that obviously requires
this != nullptr.
2) a static method, that behaves the same way as the util method, but
calls the instance method if p != nullptr.
This requires using a full class qualifier for the static methods,
which isn't exactly beautiful. I have tried to remove as many cases
as possible where it was clear p != nullptr.
Bug: 22322814
Test: test-art-host
Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
diff --git a/runtime/gc/accounting/mod_union_table.cc b/runtime/gc/accounting/mod_union_table.cc
index 3b6750e..14f5997 100644
--- a/runtime/gc/accounting/mod_union_table.cc
+++ b/runtime/gc/accounting/mod_union_table.cc
@@ -276,8 +276,9 @@
Heap* heap = mod_union_table_->GetHeap();
space::ContinuousSpace* from_space = heap->FindContinuousSpaceFromObject(obj, false);
space::ContinuousSpace* to_space = heap->FindContinuousSpaceFromObject(ref, false);
- LOG(INFO) << "Object " << reinterpret_cast<const void*>(obj) << "(" << PrettyTypeOf(obj)
- << ")" << "References " << reinterpret_cast<const void*>(ref) << "(" << PrettyTypeOf(ref)
+ LOG(INFO) << "Object " << reinterpret_cast<const void*>(obj) << "(" << obj->PrettyTypeOf()
+ << ")" << "References "
+ << reinterpret_cast<const void*>(ref) << "(" << mirror::Object::PrettyTypeOf(ref)
<< ") without being in mod-union table";
LOG(INFO) << "FromSpace " << from_space->GetName() << " type "
<< from_space->GetGcRetentionPolicy();
diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc
index a7f2aa0..40186f8 100644
--- a/runtime/gc/allocator/rosalloc.cc
+++ b/runtime/gc/allocator/rosalloc.cc
@@ -1966,7 +1966,7 @@
CHECK_LE(obj_size + memory_tool_modifier, kLargeSizeThreshold)
<< "A run slot contains a large object " << Dump();
CHECK_EQ(SizeToIndex(obj_size + memory_tool_modifier), idx)
- << PrettyTypeOf(obj) << " "
+ << obj->PrettyTypeOf() << " "
<< "obj_size=" << obj_size << "(" << obj_size + memory_tool_modifier << "), idx=" << idx
<< " A run slot contains an object with wrong size " << Dump();
}
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index 3dee974..1931caf 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -396,8 +396,8 @@
CHECK(Runtime::Current()->GetHeap()->GetLargeObjectsSpace()->IsZygoteLargeObject(
Thread::Current(), ref.Ptr()))
<< "Non gray object references non immune, non zygote large object "<< ref << " "
- << PrettyTypeOf(ref) << " in holder " << holder << " " << PrettyTypeOf(holder)
- << " offset=" << offset.Uint32Value();
+ << mirror::Object::PrettyTypeOf(ref) << " in holder " << holder << " "
+ << mirror::Object::PrettyTypeOf(holder) << " offset=" << offset.Uint32Value();
} else {
// Make sure the large object class is immune since we will never scan the large object.
CHECK(collector_->immune_spaces_.ContainsObject(
@@ -862,7 +862,7 @@
void ConcurrentCopying::PushOntoMarkStack(mirror::Object* to_ref) {
CHECK_EQ(is_mark_stack_push_disallowed_.LoadRelaxed(), 0)
- << " " << to_ref << " " << PrettyTypeOf(to_ref);
+ << " " << to_ref << " " << mirror::Object::PrettyTypeOf(to_ref);
Thread* self = Thread::Current(); // TODO: pass self as an argument from call sites?
CHECK(thread_running_gc_ != nullptr);
MarkStackMode mark_stack_mode = mark_stack_mode_.LoadRelaxed();
@@ -951,7 +951,7 @@
collector_->AssertToSpaceInvariant(nullptr, MemberOffset(0), ref);
if (kUseBakerReadBarrier) {
CHECK_EQ(ref->GetReadBarrierPointer(), ReadBarrier::WhitePtr())
- << "Ref " << ref << " " << PrettyTypeOf(ref)
+ << "Ref " << ref << " " << ref->PrettyTypeOf()
<< " has non-white rb_ptr ";
}
}
@@ -1454,10 +1454,10 @@
mirror::Object* obj = mark_stack->PopBack();
if (kUseBakerReadBarrier) {
mirror::Object* rb_ptr = obj->GetReadBarrierPointer();
- LOG(INFO) << "On mark queue : " << obj << " " << PrettyTypeOf(obj) << " rb_ptr=" << rb_ptr
- << " is_marked=" << IsMarked(obj);
+ LOG(INFO) << "On mark queue : " << obj << " " << obj->PrettyTypeOf() << " rb_ptr="
+ << rb_ptr << " is_marked=" << IsMarked(obj);
} else {
- LOG(INFO) << "On mark queue : " << obj << " " << PrettyTypeOf(obj)
+ LOG(INFO) << "On mark queue : " << obj << " " << obj->PrettyTypeOf()
<< " is_marked=" << IsMarked(obj);
}
}
@@ -1630,7 +1630,7 @@
LogFromSpaceRefHolder(obj, offset);
}
ref->GetLockWord(false).Dump(LOG_STREAM(FATAL_WITHOUT_ABORT));
- CHECK(false) << "Found from-space ref " << ref << " " << PrettyTypeOf(ref);
+ CHECK(false) << "Found from-space ref " << ref << " " << ref->PrettyTypeOf();
} else {
AssertToSpaceInvariantInNonMovingSpace(obj, ref);
}
@@ -1677,12 +1677,14 @@
// No info.
} else if (gc_root_source->HasArtField()) {
ArtField* field = gc_root_source->GetArtField();
- LOG(FATAL_WITHOUT_ABORT) << "gc root in field " << field << " " << PrettyField(field);
+ LOG(FATAL_WITHOUT_ABORT) << "gc root in field " << field << " "
+ << ArtField::PrettyField(field);
RootPrinter root_printer;
field->VisitRoots(root_printer);
} else if (gc_root_source->HasArtMethod()) {
ArtMethod* method = gc_root_source->GetArtMethod();
- LOG(FATAL_WITHOUT_ABORT) << "gc root in method " << method << " " << PrettyMethod(method);
+ LOG(FATAL_WITHOUT_ABORT) << "gc root in method " << method << " "
+ << ArtMethod::PrettyMethod(method);
RootPrinter root_printer;
method->VisitRoots(root_printer, kRuntimePointerSize);
}
@@ -1690,7 +1692,7 @@
region_space_->DumpNonFreeRegions(LOG_STREAM(FATAL_WITHOUT_ABORT));
PrintFileToLog("/proc/self/maps", LogSeverity::FATAL_WITHOUT_ABORT);
MemMap::DumpMaps(LOG_STREAM(FATAL_WITHOUT_ABORT), true);
- CHECK(false) << "Found from-space ref " << ref << " " << PrettyTypeOf(ref);
+ CHECK(false) << "Found from-space ref " << ref << " " << ref->PrettyTypeOf();
} else {
AssertToSpaceInvariantInNonMovingSpace(nullptr, ref);
}
@@ -1699,10 +1701,10 @@
void ConcurrentCopying::LogFromSpaceRefHolder(mirror::Object* obj, MemberOffset offset) {
if (kUseBakerReadBarrier) {
- LOG(INFO) << "holder=" << obj << " " << PrettyTypeOf(obj)
+ LOG(INFO) << "holder=" << obj << " " << obj->PrettyTypeOf()
<< " holder rb_ptr=" << obj->GetReadBarrierPointer();
} else {
- LOG(INFO) << "holder=" << obj << " " << PrettyTypeOf(obj);
+ LOG(INFO) << "holder=" << obj << " " << obj->PrettyTypeOf();
}
if (region_space_->IsInFromSpace(obj)) {
LOG(INFO) << "holder is in the from-space.";
diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc
index c05719d..77d7274 100644
--- a/runtime/gc/collector/mark_sweep.cc
+++ b/runtime/gc/collector/mark_sweep.cc
@@ -423,7 +423,7 @@
<< (mark_sweep_->GetHeap()->IsLiveObjectLocked(holder_)
? "alive" : "dead")
<< " holder_size=" << holder_size
- << " holder_type=" << PrettyTypeOf(holder_)
+ << " holder_type=" << holder_->PrettyTypeOf()
<< " offset=" << offset_.Uint32Value()
<< " field=" << (field != nullptr ? field->GetName() : "nullptr")
<< " field_type="
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index f4a3aea..ba18699 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -2926,7 +2926,7 @@
if (root == nullptr) {
LOG(ERROR) << "Root is null with info " << root_info.GetType();
} else if (!VerifyReference(nullptr, root, MemberOffset(0))) {
- LOG(ERROR) << "Root " << root << " is dead with type " << PrettyTypeOf(root)
+ LOG(ERROR) << "Root " << root << " is dead with type " << mirror::Object::PrettyTypeOf(root)
<< " thread_id= " << root_info.GetThreadId() << " root_type= " << root_info.GetType();
}
}
@@ -2953,7 +2953,7 @@
LOG(ERROR) << "Object " << obj << " references dead object " << ref << " at offset "
<< offset << "\n card value = " << static_cast<int>(*card_addr);
if (heap_->IsValidObjectAddress(obj->GetClass())) {
- LOG(ERROR) << "Obj type " << PrettyTypeOf(obj);
+ LOG(ERROR) << "Obj type " << obj->PrettyTypeOf();
} else {
LOG(ERROR) << "Object " << obj << " class(" << obj->GetClass() << ") not a heap address";
}
@@ -2965,7 +2965,7 @@
mirror::Class* ref_class = space->FindRecentFreedObject(ref);
if (ref_class != nullptr) {
LOG(ERROR) << "Reference " << ref << " found as a recently freed object with class "
- << PrettyClass(ref_class);
+ << ref_class->PrettyClass();
} else {
LOG(ERROR) << "Reference " << ref << " not found as a recently freed object";
}
@@ -2973,7 +2973,7 @@
if (ref->GetClass() != nullptr && heap_->IsValidObjectAddress(ref->GetClass()) &&
ref->GetClass()->IsClass()) {
- LOG(ERROR) << "Ref type " << PrettyTypeOf(ref);
+ LOG(ERROR) << "Ref type " << ref->PrettyTypeOf();
} else {
LOG(ERROR) << "Ref " << ref << " class(" << ref->GetClass()
<< ") is not a valid heap address";
@@ -3182,8 +3182,9 @@
if (heap_->GetLiveBitmap()->Test(obj)) {
LOG(ERROR) << "Object " << obj << " found in live bitmap";
}
- LOG(ERROR) << "Object " << obj << " " << PrettyTypeOf(obj)
- << " references " << ref << " " << PrettyTypeOf(ref) << " in live stack";
+ LOG(ERROR) << "Object " << obj << " " << mirror::Object::PrettyTypeOf(obj)
+ << " references " << ref << " " << mirror::Object::PrettyTypeOf(ref)
+ << " in live stack";
// Print which field of the object is dead.
if (!obj->IsObjectArray()) {
@@ -3192,7 +3193,7 @@
for (ArtField& field : (is_static ? klass->GetSFields() : klass->GetIFields())) {
if (field.GetOffset().Int32Value() == offset.Int32Value()) {
LOG(ERROR) << (is_static ? "Static " : "") << "field in the live stack is "
- << PrettyField(&field);
+ << field.PrettyField();
break;
}
}
diff --git a/runtime/gc/reference_processor.cc b/runtime/gc/reference_processor.cc
index 4b8f38d..798ecd3 100644
--- a/runtime/gc/reference_processor.cc
+++ b/runtime/gc/reference_processor.cc
@@ -211,7 +211,7 @@
} else if (klass->IsPhantomReferenceClass()) {
phantom_reference_queue_.AtomicEnqueueIfNotEnqueued(self, ref);
} else {
- LOG(FATAL) << "Invalid reference type " << PrettyClass(klass) << " " << std::hex
+ LOG(FATAL) << "Invalid reference type " << klass->PrettyClass() << " " << std::hex
<< klass->GetAccessFlags();
}
}
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index e9c8b95..6035406 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -398,7 +398,7 @@
CHECK_ALIGNED(current, kObjectAlignment);
auto* obj = reinterpret_cast<mirror::Object*>(current);
CHECK(obj->GetClass() != nullptr) << "Image object at address " << obj << " has null class";
- CHECK(live_bitmap_->Test(obj)) << PrettyTypeOf(obj);
+ CHECK(live_bitmap_->Test(obj)) << obj->PrettyTypeOf();
if (kUseBakerOrBrooksReadBarrier) {
obj->AssertReadBarrierPointer();
}