ART: Use ObjPtr for GetSuperClass
Bug: 37224696
Test: mmma art
Test: m test-art-host
Change-Id: If55db6e26bb1bb05a13c59b849bed17839fca6cf
diff --git a/compiler/debug/elf_debug_info_writer.h b/compiler/debug/elf_debug_info_writer.h
index fe05992..bb550b3 100644
--- a/compiler/debug/elf_debug_info_writer.h
+++ b/compiler/debug/elf_debug_info_writer.h
@@ -372,10 +372,10 @@
}
// Base class.
- mirror::Class* base_class = type->GetSuperClass();
+ ObjPtr<mirror::Class> base_class = type->GetSuperClass();
if (base_class != nullptr) {
info_.StartTag(DW_TAG_inheritance);
- base_class_references.emplace(info_.size(), base_class);
+ base_class_references.emplace(info_.size(), base_class.Ptr());
info_.WriteRef4(DW_AT_type, 0);
info_.WriteUdata(DW_AT_data_member_location, 0);
info_.WriteSdata(DW_AT_accessibility, DW_ACCESS_public);
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index c5416d5..a32de29 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -1146,7 +1146,7 @@
if (klass->IsArrayClass()) {
MaybeAddToImageClasses(self, klass->GetComponentType(), image_classes);
}
- klass.Assign(klass->GetSuperClass());
+ klass = klass->GetSuperClass();
}
}
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index feb05d6..321a447 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -2102,9 +2102,9 @@
}
}
- static void DumpFields(std::ostream& os, mirror::Object* obj, mirror::Class* klass)
+ static void DumpFields(std::ostream& os, mirror::Object* obj, ObjPtr<mirror::Class> klass)
REQUIRES_SHARED(Locks::mutator_lock_) {
- mirror::Class* super = klass->GetSuperClass();
+ ObjPtr<mirror::Class> super = klass->GetSuperClass();
if (super != nullptr) {
DumpFields(os, obj, super);
}
diff --git a/openjdkjvmti/ti_heap.cc b/openjdkjvmti/ti_heap.cc
index 6c79a60..f19d0a0 100644
--- a/openjdkjvmti/ti_heap.cc
+++ b/openjdkjvmti/ti_heap.cc
@@ -1173,7 +1173,7 @@
stop_reports_ = !ReportReferenceMaybeEnqueue(JVMTI_HEAP_REFERENCE_SUPERCLASS,
nullptr,
klass,
- klass->GetSuperClass());
+ klass->GetSuperClass().Ptr());
if (stop_reports_) {
return;
}
diff --git a/runtime/cha.cc b/runtime/cha.cc
index d8cb525..b600df6 100644
--- a/runtime/cha.cc
+++ b/runtime/cha.cc
@@ -277,7 +277,7 @@
};
-static void VerifyNonSingleImplementation(mirror::Class* verify_class,
+static void VerifyNonSingleImplementation(ObjPtr<mirror::Class> verify_class,
uint16_t verify_index,
ArtMethod* excluded_method)
REQUIRES_SHARED(Locks::mutator_lock_) {
@@ -291,7 +291,7 @@
PointerSize image_pointer_size =
Runtime::Current()->GetClassLinker()->GetImagePointerSize();
- mirror::Class* input_verify_class = verify_class;
+ ObjPtr<mirror::Class> input_verify_class = verify_class;
while (verify_class != nullptr) {
if (verify_index >= verify_class->GetVTableLength()) {
@@ -299,7 +299,7 @@
}
ArtMethod* verify_method = verify_class->GetVTableEntry(verify_index, image_pointer_size);
if (verify_method != excluded_method) {
- auto construct_parent_chain = [](mirror::Class* failed, mirror::Class* in)
+ auto construct_parent_chain = [](ObjPtr<mirror::Class> failed, ObjPtr<mirror::Class> in)
REQUIRES_SHARED(Locks::mutator_lock_) {
std::string tmp = in->PrettyClass();
while (in != failed) {
@@ -432,7 +432,7 @@
// method_in_super might be the single-implementation of another abstract method,
// which should be also invalidated of its single-implementation status.
- mirror::Class* super_super = klass->GetSuperClass()->GetSuperClass();
+ ObjPtr<mirror::Class> super_super = klass->GetSuperClass()->GetSuperClass();
while (super_super != nullptr &&
method_index < super_super->GetVTableLength()) {
ArtMethod* method_in_super_super = super_super->GetVTableEntry(method_index, pointer_size);
@@ -564,7 +564,7 @@
return;
}
- mirror::Class* super_class = klass->GetSuperClass();
+ ObjPtr<mirror::Class> super_class = klass->GetSuperClass();
if (super_class == nullptr) {
return;
}
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 16359ac..a97e94c 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -887,7 +887,8 @@
mirror::Class* klass = obj->AsClass<kVerifyNone>();
// Fixup super class before visiting instance fields which require
// information from their super class to calculate offsets.
- mirror::Class* super_class = klass->GetSuperClass<kVerifyNone, kWithoutReadBarrier>();
+ mirror::Class* super_class =
+ klass->GetSuperClass<kVerifyNone, kWithoutReadBarrier>().Ptr();
if (super_class != nullptr) {
mirror::Class* new_super_class = down_cast<mirror::Class*>(ForwardObject(super_class));
if (new_super_class != super_class && IsInAppImage(new_super_class)) {
@@ -1650,7 +1651,8 @@
// we can get a reference to j.l.Object.class and assert that it has only one
// reference instance field (the `klass_` patched above).
if (kIsDebugBuild && klass == class_class) {
- mirror::Class* object_class = klass->GetSuperClass<kVerifyNone, kWithoutReadBarrier>();
+ ObjPtr<mirror::Class> object_class =
+ klass->GetSuperClass<kVerifyNone, kWithoutReadBarrier>();
CHECK_EQ(object_class->NumReferenceInstanceFields<kVerifyNone>(), 1u);
}
// Then patch static fields.
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index f696e25..438af12 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -1252,7 +1252,7 @@
__ AddU1(HPROF_CLASS_DUMP);
__ AddClassId(LookupClassId(klass));
__ AddStackTraceSerialNumber(LookupStackTraceSerialNumber(klass));
- __ AddClassId(LookupClassId(klass->GetSuperClass()));
+ __ AddClassId(LookupClassId(klass->GetSuperClass().Ptr()));
__ AddObjectId(klass->GetClassLoader());
__ AddObjectId(nullptr); // no signer
__ AddObjectId(nullptr); // no prot domain
@@ -1543,7 +1543,7 @@
reinterpret_cast<uintptr_t>(obj) + kObjectAlignment / 2);
__ AddObjectId(fake_object_array);
}
- klass = klass->GetSuperClass();
+ klass = klass->GetSuperClass().Ptr();
} while (klass != nullptr);
// Patch the instance field length.
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index df70fab..31bc5e4 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -57,14 +57,14 @@
}
template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>
-inline Class* Class::GetSuperClass() {
+inline ObjPtr<Class> Class::GetSuperClass() {
// Can only get super class for loaded classes (hack for when runtime is
// initializing)
DCHECK(IsLoaded<kVerifyFlags>() ||
IsErroneous<kVerifyFlags>() ||
!Runtime::Current()->IsStarted()) << IsLoaded();
- return GetFieldObject<Class, kVerifyFlags, kReadBarrierOption>(
- OFFSET_OF_OBJECT_MEMBER(Class, super_class_));
+ return ObjPtr<Class>(GetFieldObject<Class, kVerifyFlags, kReadBarrierOption>(
+ OFFSET_OF_OBJECT_MEMBER(Class, super_class_)));
}
inline void Class::SetSuperClass(ObjPtr<Class> new_super_class) {
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index eddc84b..cbe377e 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -624,7 +624,7 @@
template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
- ALWAYS_INLINE Class* GetSuperClass() REQUIRES_SHARED(Locks::mutator_lock_);
+ ALWAYS_INLINE ObjPtr<Class> GetSuperClass() REQUIRES_SHARED(Locks::mutator_lock_);
// Get first common super class. It will never return null.
// `This` and `klass` must be classes.