diff options
| -rw-r--r-- | runtime/gc/collector/concurrent_copying.cc | 8 | ||||
| -rw-r--r-- | runtime/mirror/class-inl.h | 5 | ||||
| -rw-r--r-- | runtime/mirror/object.cc | 10 |
3 files changed, 16 insertions, 7 deletions
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc index bcf5008939..792c191017 100644 --- a/runtime/gc/collector/concurrent_copying.cc +++ b/runtime/gc/collector/concurrent_copying.cc @@ -1031,13 +1031,15 @@ class ConcurrentCopying::VerifyNoFromSpaceRefsVisitor : public SingleRootVisitor explicit VerifyNoFromSpaceRefsVisitor(ConcurrentCopying* collector) : collector_(collector) {} - void operator()(mirror::Object* ref) const + void operator()(mirror::Object* ref, + MemberOffset offset = MemberOffset(0), + mirror::Object* holder = nullptr) const REQUIRES_SHARED(Locks::mutator_lock_) ALWAYS_INLINE { if (ref == nullptr) { // OK. return; } - collector_->AssertToSpaceInvariant(nullptr, MemberOffset(0), ref); + collector_->AssertToSpaceInvariant(holder, offset, ref); if (kUseBakerReadBarrier) { CHECK_EQ(ref->GetReadBarrierState(), ReadBarrier::WhiteState()) << "Ref " << ref << " " << ref->PrettyTypeOf() @@ -1067,7 +1069,7 @@ class ConcurrentCopying::VerifyNoFromSpaceRefsFieldVisitor { mirror::Object* ref = obj->GetFieldObject<mirror::Object, kDefaultVerifyFlags, kWithoutReadBarrier>(offset); VerifyNoFromSpaceRefsVisitor visitor(collector_); - visitor(ref); + visitor(ref, offset, obj.Ptr()); } void operator()(ObjPtr<mirror::Class> klass, ObjPtr<mirror::Reference> ref) const diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index be3b937f3e..9124a3ad84 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -823,7 +823,10 @@ inline bool Class::IsClassClass() { } inline const DexFile& Class::GetDexFile() { - return *GetDexCache()->GetDexFile(); + // From-space version is the same as the to-space version since the dex file never changes. + // Avoiding the read barrier here is important to prevent recursive AssertToSpaceInvariant issues + // from PrettyTypeOf. + return *GetDexCache<kDefaultVerifyFlags, kWithoutReadBarrier>()->GetDexFile(); } inline bool Class::DescriptorEquals(const char* match) { diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc index f5b9ab36de..eabc29adad 100644 --- a/runtime/mirror/object.cc +++ b/runtime/mirror/object.cc @@ -281,12 +281,16 @@ std::string Object::PrettyTypeOf(ObjPtr<mirror::Object> obj) { } std::string Object::PrettyTypeOf() { - if (GetClass() == nullptr) { + // From-space version is the same as the to-space version since the dex file never changes. + // Avoiding the read barrier here is important to prevent recursive AssertToSpaceInvariant + // issues. + ObjPtr<mirror::Class> klass = GetClass<kDefaultVerifyFlags, kWithoutReadBarrier>(); + if (klass == nullptr) { return "(raw)"; } std::string temp; - std::string result(PrettyDescriptor(GetClass()->GetDescriptor(&temp))); - if (IsClass()) { + std::string result(PrettyDescriptor(klass->GetDescriptor(&temp))); + if (klass->IsClassClass()) { result += "<" + PrettyDescriptor(AsClass()->GetDescriptor(&temp)) + ">"; } return result; |