Move ArtField to ObjPtr
Added EXPECT_OBJ_PTR_EQ and variants to gtests.
Fixed moving GC bugs in:
ClassLinker::CreatePathClassLoader
ClassLinkerTest: StaticFields
ObjPtr Decode call sites: 186 -> 181.
Some tests fail due to ResolvedFieldAccessTest, will fix in follow
up CL.
Bug: 31113334
Test: test-art-host CC baker
Change-Id: I8b266ad00f3c20c8cbe7cfdf280d175083df0b88
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index be5224b..4d0dc56 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -1687,7 +1687,9 @@
ImageDumper* const image_dumper_;
};
- static void PrettyObjectValue(std::ostream& os, mirror::Class* type, mirror::Object* value)
+ static void PrettyObjectValue(std::ostream& os,
+ ObjPtr<mirror::Class> type,
+ ObjPtr<mirror::Object> value)
REQUIRES_SHARED(Locks::mutator_lock_) {
CHECK(type != nullptr);
if (value == nullptr) {
@@ -1700,11 +1702,11 @@
mirror::Class* klass = value->AsClass();
os << StringPrintf("%p Class: %s\n", klass, PrettyDescriptor(klass).c_str());
} else {
- os << StringPrintf("%p %s\n", value, PrettyDescriptor(type).c_str());
+ os << StringPrintf("%p %s\n", value.Decode(), PrettyDescriptor(type).c_str());
}
}
- static void PrintField(std::ostream& os, ArtField* field, mirror::Object* obj)
+ static void PrintField(std::ostream& os, ArtField* field, ObjPtr<mirror::Object> obj)
REQUIRES_SHARED(Locks::mutator_lock_) {
os << StringPrintf("%s: ", field->GetName());
switch (field->GetTypeAsPrimitiveType()) {
@@ -1736,16 +1738,17 @@
case Primitive::kPrimNot: {
// Get the value, don't compute the type unless it is non-null as we don't want
// to cause class loading.
- mirror::Object* value = field->GetObj(obj);
+ ObjPtr<mirror::Object> value = field->GetObj(obj);
if (value == nullptr) {
os << StringPrintf("null %s\n", PrettyDescriptor(field->GetTypeDescriptor()).c_str());
} else {
// Grab the field type without causing resolution.
- mirror::Class* field_type = field->GetType<false>();
+ ObjPtr<mirror::Class> field_type = field->GetType<false>();
if (field_type != nullptr) {
PrettyObjectValue(os, field_type, value);
} else {
- os << StringPrintf("%p %s\n", value,
+ os << StringPrintf("%p %s\n",
+ value.Decode(),
PrettyDescriptor(field->GetTypeDescriptor()).c_str());
}
}