Clean up explicit conversions to ObjPtr<>.
Add an ObjPtr<>::DownCast() overload that takes a plain
pointer and remove unnecessary calls to MakeObjPtr(),
usually preceding DownCast(). Move the MakeObjPtr() to
common_art_test.h .
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 31113334
Change-Id: I2a243b6d8f3b2e773396dfc53b659c5f7d9ea44a
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 80e0f46..b74e81f 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -463,8 +463,8 @@
auto class_class_size = mirror::Class::ClassClassSize(image_pointer_size_);
// Allocate the object as non-movable so that there are no cases where Object::IsClass returns
// the incorrect result when comparing to-space vs from-space.
- Handle<mirror::Class> java_lang_Class(hs.NewHandle(ObjPtr<mirror::Class>::DownCast(MakeObjPtr(
- heap->AllocNonMovableObject<true>(self, nullptr, class_class_size, VoidFunctor())))));
+ Handle<mirror::Class> java_lang_Class(hs.NewHandle(ObjPtr<mirror::Class>::DownCast(
+ heap->AllocNonMovableObject<true>(self, nullptr, class_class_size, VoidFunctor()))));
CHECK(java_lang_Class != nullptr);
java_lang_Class->SetClassFlags(mirror::kClassFlagClass);
java_lang_Class->SetClass(java_lang_Class.Get());
@@ -1053,8 +1053,8 @@
}
class_roots_ = GcRoot<mirror::ObjectArray<mirror::Class>>(
- ObjPtr<mirror::ObjectArray<mirror::Class>>::DownCast(MakeObjPtr(
- spaces[0]->GetImageHeader().GetImageRoot(ImageHeader::kClassRoots))));
+ ObjPtr<mirror::ObjectArray<mirror::Class>>::DownCast(
+ spaces[0]->GetImageHeader().GetImageRoot(ImageHeader::kClassRoots)));
DCHECK_EQ(GetClassRoot<mirror::Class>(this)->GetClassFlags(), mirror::kClassFlagClass);
ObjPtr<mirror::Class> java_lang_Object = GetClassRoot<mirror::Object>(this);
@@ -6621,8 +6621,8 @@
DCHECK(if_table != nullptr);
DCHECK(if_table->GetMethodArray(i) != nullptr);
// If we are working on a super interface, try extending the existing method array.
- method_array = ObjPtr<mirror::PointerArray>::DownCast(MakeObjPtr(
- if_table->GetMethodArray(i)->Clone(self)));
+ method_array = ObjPtr<mirror::PointerArray>::DownCast(
+ if_table->GetMethodArray(i)->Clone(self));
} else {
method_array = AllocPointerArray(self, num_methods);
}