summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2019-03-21 12:49:10 +0000
committerVladimir Marko <vmarko@google.com>2019-03-21 15:11:07 +0000
commit415ac850a273dee846b4d72c30bfef8fd69a003c (patch)
tree56c2cdd89ca78ca8df1b83d3fbd20a83367a57cb
parent7458291cbaf549c4a9739b444e314f40f58a5520 (diff)
downloadandroid_art-415ac850a273dee846b4d72c30bfef8fd69a003c.tar.gz
android_art-415ac850a273dee846b4d72c30bfef8fd69a003c.tar.bz2
android_art-415ac850a273dee846b4d72c30bfef8fd69a003c.zip
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
-rw-r--r--runtime/art_field-inl.h6
-rw-r--r--runtime/art_field.cc2
-rw-r--r--runtime/art_method-inl.h4
3 files changed, 7 insertions, 5 deletions
diff --git a/runtime/art_field-inl.h b/runtime/art_field-inl.h
index 6f976d1c16..99943f51d7 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 void ArtField::SetObject(ObjPtr<mirror::Object> object, ObjPtr<mirror::Ob
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::GetName() REQUIRES_SHARED(Locks::mutator_lock_) {
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 e20e7f3f5e..6e55f9f865 100644
--- a/runtime/art_field.cc
+++ b/runtime/art_field.cc
@@ -45,7 +45,7 @@ void ArtField::SetOffset(MemberOffset num_bytes) {
}
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 e28ffa2122..a81c7e2f01 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -316,8 +316,8 @@ inline mirror::DexCache* ArtMethod::GetDexCache() {
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();
}