Add read barrier comments for ArtField::IsProxyField().

Also use the same formulation for ArtMethod::IsProxyMethod()
and use the ArtField::IsProxyField() where appropriate, thus
avoiding some read barriers.

Test: Rely on TreeHugger.
Bug: 119486698
Change-Id: Ie71de0e4d163ecde2ebac55d27b46a8ca51859bf
diff --git a/runtime/art_field-inl.h b/runtime/art_field-inl.h
index 6f976d1..99943f5 100644
--- a/runtime/art_field-inl.h
+++ b/runtime/art_field-inl.h
@@ -34,6 +34,8 @@
 namespace art {
 
 inline bool ArtField::IsProxyField() {
+  // No read barrier needed, we're reading the constant declaring class only to read
+  // the constant proxy flag. See ReadBarrierOption.
   return GetDeclaringClass<kWithoutReadBarrier>()->IsProxyClass<kVerifyNone>();
 }
 
@@ -272,7 +274,7 @@
 
 inline const char* ArtField::GetName() REQUIRES_SHARED(Locks::mutator_lock_) {
   uint32_t field_index = GetDexFieldIndex();
-  if (UNLIKELY(GetDeclaringClass()->IsProxyClass())) {
+  if (UNLIKELY(IsProxyField())) {
     DCHECK(IsStatic());
     DCHECK_LT(field_index, 2U);
     return field_index == 0 ? "interfaces" : "throws";
@@ -283,7 +285,7 @@
 
 inline const char* ArtField::GetTypeDescriptor() REQUIRES_SHARED(Locks::mutator_lock_) {
   uint32_t field_index = GetDexFieldIndex();
-  if (UNLIKELY(GetDeclaringClass()->IsProxyClass())) {
+  if (UNLIKELY(IsProxyField())) {
     DCHECK(IsStatic());
     DCHECK_LT(field_index, 2U);
     // 0 == Class[] interfaces; 1 == Class[][] throws;
diff --git a/runtime/art_field.cc b/runtime/art_field.cc
index e20e7f3..6e55f9f 100644
--- a/runtime/art_field.cc
+++ b/runtime/art_field.cc
@@ -45,7 +45,7 @@
 }
 
 ObjPtr<mirror::Class> ArtField::ProxyFindSystemClass(const char* descriptor) {
-  DCHECK(GetDeclaringClass()->IsProxyClass());
+  DCHECK(IsProxyField());
   ObjPtr<mirror::Class> klass = Runtime::Current()->GetClassLinker()->LookupClass(
       Thread::Current(), descriptor, /* class_loader= */ nullptr);
   DCHECK(klass != nullptr);
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h
index e28ffa2..a81c7e2 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -316,8 +316,8 @@
 
 inline bool ArtMethod::IsProxyMethod() {
   DCHECK(!IsRuntimeMethod()) << "ArtMethod::IsProxyMethod called on a runtime method";
-  // Avoid read barrier since the from-space version of the class will have the correct proxy class
-  // flags since they are constant for the lifetime of the class.
+  // No read barrier needed, we're reading the constant declaring class only to read
+  // the constant proxy flag. See ReadBarrierOption.
   return GetDeclaringClass<kWithoutReadBarrier>()->IsProxyClass();
 }