Simplify Class::IsArtFieldClass().
Fix the slight glitch that when ImageSpace::VerifyImageAllocations()
called in ImageSpace::Create(), the ArtField and ArtMethod class roots
weren't set, which were used by DCHECKs in Object::Size(), which
VerifyImageAllocations() calls, by delaying the point of the
VerifyImageAllocations() call to Runtime::Init() at which point the
class linker has set the class roots.
To completely disable read barriers from Object::SizeOf(), the
ReadBarrierOption template parameter should have been added to
Class::GetInstanceField(), which calls GetFieldObject(), when it's
called from Class::IsArtFieldClass(). This change fixes this by
removing the need for the call, instead of adding the
ReadBarrierOption parameter.
Bug: 12687968
Change-Id: Ibbecc08f4e3b898851805d690dff8ccac55e94f2
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 18be2f1..512a66f 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -509,17 +509,12 @@
VisitStaticFieldsReferences<kVisitClass>(this, visitor);
}
-template<ReadBarrierOption kReadBarrierOption>
-inline bool Class::IsArtFieldClass() {
- Class* java_lang_Class = GetClass<kVerifyNone, kReadBarrierOption>();
- Class* java_lang_reflect_ArtField =
- java_lang_Class->GetInstanceField(0)->GetClass<kVerifyNone, kReadBarrierOption>();
- return this == java_lang_reflect_ArtField;
+inline bool Class::IsArtFieldClass() const {
+ return this == ArtField::GetJavaLangReflectArtField();
}
-template<ReadBarrierOption kReadBarrierOption>
-inline bool Class::IsArtMethodClass() {
- return this == ArtMethod::GetJavaLangReflectArtMethod<kReadBarrierOption>();
+inline bool Class::IsArtMethodClass() const {
+ return this == ArtMethod::GetJavaLangReflectArtMethod();
}
template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>