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()
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
}
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) {
}
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;