summaryrefslogtreecommitdiff
path: root/runtime/class_linker-inl.h
diff options
context:
space:
mode:
author David Srbecky <dsrbecky@google.com> 2021-09-21 10:47:59 +0100
committer Treehugger Robot <treehugger-gerrit@google.com> 2021-09-21 13:53:53 +0000
commit9f98fc31900571e701dc02c5749f9f192f997d47 (patch)
tree4ec53000edaa61d8e9bef5a1b02473be554a6a8e /runtime/class_linker-inl.h
parentad0daef0da6be2cb613b879437d607c7b2ff2dbe (diff)
Add couple DexCache read-barriers.
I intend to make some of the fields mutable in the next CL, which means we cannot skip the read-barrier any more. Split this into own CL to make it easier to check if there are any significant performance changes. Bug: 182072259 Test: test.py -b -r --host --64 Change-Id: Ia20a3ba8285eb56ae6ff9e7fa5c0a62b14d88b65
Diffstat (limited to 'runtime/class_linker-inl.h')
-rw-r--r--runtime/class_linker-inl.h58
1 files changed, 12 insertions, 46 deletions
diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h
index 65b2afd949..da066d1180 100644
--- a/runtime/class_linker-inl.h
+++ b/runtime/class_linker-inl.h
@@ -70,10 +70,7 @@ inline ObjPtr<mirror::String> ClassLinker::ResolveString(dex::StringIndex string
ArtField* referrer) {
Thread::PoisonObjectPointersIfDebug();
DCHECK(!Thread::Current()->IsExceptionPending());
- // We do not need the read barrier for getting the DexCache for the initial resolved type
- // lookup as both from-space and to-space copies point to the same native resolved types array.
- ObjPtr<mirror::String> resolved =
- referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedString(string_idx);
+ ObjPtr<mirror::String> resolved = referrer->GetDexCache()->GetResolvedString(string_idx);
if (resolved == nullptr) {
resolved = DoResolveString(string_idx, referrer->GetDexCache());
}
@@ -84,10 +81,7 @@ inline ObjPtr<mirror::String> ClassLinker::ResolveString(dex::StringIndex string
ArtMethod* referrer) {
Thread::PoisonObjectPointersIfDebug();
DCHECK(!Thread::Current()->IsExceptionPending());
- // We do not need the read barrier for getting the DexCache for the initial resolved type
- // lookup as both from-space and to-space copies point to the same native resolved types array.
- ObjPtr<mirror::String> resolved =
- referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedString(string_idx);
+ ObjPtr<mirror::String> resolved = referrer->GetDexCache()->GetResolvedString(string_idx);
if (resolved == nullptr) {
resolved = DoResolveString(string_idx, referrer->GetDexCache());
}
@@ -122,10 +116,8 @@ inline ObjPtr<mirror::Class> ClassLinker::ResolveType(dex::TypeIndex type_idx,
Thread::Current()->PoisonObjectPointers();
}
DCHECK(!Thread::Current()->IsExceptionPending());
- // We do not need the read barrier for getting the DexCache for the initial resolved type
- // lookup as both from-space and to-space copies point to the same native resolved types array.
ObjPtr<mirror::Class> resolved_type =
- referrer->GetDexCache<kDefaultVerifyFlags, kWithoutReadBarrier>()->GetResolvedType(type_idx);
+ referrer->GetDexCache<kDefaultVerifyFlags>()->GetResolvedType(type_idx);
if (resolved_type == nullptr) {
resolved_type = DoResolveType(type_idx, referrer);
}
@@ -136,10 +128,7 @@ inline ObjPtr<mirror::Class> ClassLinker::ResolveType(dex::TypeIndex type_idx,
ArtField* referrer) {
Thread::PoisonObjectPointersIfDebug();
DCHECK(!Thread::Current()->IsExceptionPending());
- // We do not need the read barrier for getting the DexCache for the initial resolved type
- // lookup as both from-space and to-space copies point to the same native resolved types array.
- ObjPtr<mirror::Class> resolved_type =
- referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedType(type_idx);
+ ObjPtr<mirror::Class> resolved_type = referrer->GetDexCache()->GetResolvedType(type_idx);
if (UNLIKELY(resolved_type == nullptr)) {
resolved_type = DoResolveType(type_idx, referrer);
}
@@ -150,10 +139,7 @@ inline ObjPtr<mirror::Class> ClassLinker::ResolveType(dex::TypeIndex type_idx,
ArtMethod* referrer) {
Thread::PoisonObjectPointersIfDebug();
DCHECK(!Thread::Current()->IsExceptionPending());
- // We do not need the read barrier for getting the DexCache for the initial resolved type
- // lookup as both from-space and to-space copies point to the same native resolved types array.
- ObjPtr<mirror::Class> resolved_type =
- referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedType(type_idx);
+ ObjPtr<mirror::Class> resolved_type = referrer->GetDexCache()->GetResolvedType(type_idx);
if (UNLIKELY(resolved_type == nullptr)) {
resolved_type = DoResolveType(type_idx, referrer);
}
@@ -175,10 +161,8 @@ inline ObjPtr<mirror::Class> ClassLinker::ResolveType(dex::TypeIndex type_idx,
inline ObjPtr<mirror::Class> ClassLinker::LookupResolvedType(dex::TypeIndex type_idx,
ObjPtr<mirror::Class> referrer) {
- // We do not need the read barrier for getting the DexCache for the initial resolved type
- // lookup as both from-space and to-space copies point to the same native resolved types array.
ObjPtr<mirror::Class> type =
- referrer->GetDexCache<kDefaultVerifyFlags, kWithoutReadBarrier>()->GetResolvedType(type_idx);
+ referrer->GetDexCache<kDefaultVerifyFlags>()->GetResolvedType(type_idx);
if (type == nullptr) {
type = DoLookupResolvedType(type_idx, referrer);
}
@@ -187,10 +171,7 @@ inline ObjPtr<mirror::Class> ClassLinker::LookupResolvedType(dex::TypeIndex type
inline ObjPtr<mirror::Class> ClassLinker::LookupResolvedType(dex::TypeIndex type_idx,
ArtField* referrer) {
- // We do not need the read barrier for getting the DexCache for the initial resolved type
- // lookup as both from-space and to-space copies point to the same native resolved types array.
- ObjPtr<mirror::Class> type =
- referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedType(type_idx);
+ ObjPtr<mirror::Class> type = referrer->GetDexCache()->GetResolvedType(type_idx);
if (type == nullptr) {
type = DoLookupResolvedType(type_idx, referrer->GetDeclaringClass());
}
@@ -199,10 +180,7 @@ inline ObjPtr<mirror::Class> ClassLinker::LookupResolvedType(dex::TypeIndex type
inline ObjPtr<mirror::Class> ClassLinker::LookupResolvedType(dex::TypeIndex type_idx,
ArtMethod* referrer) {
- // We do not need the read barrier for getting the DexCache for the initial resolved type
- // lookup as both from-space and to-space copies point to the same native resolved types array.
- ObjPtr<mirror::Class> type =
- referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedType(type_idx);
+ ObjPtr<mirror::Class> type = referrer->GetDexCache()->GetResolvedType(type_idx);
if (type == nullptr) {
type = DoLookupResolvedType(type_idx, referrer->GetDeclaringClass());
}
@@ -311,10 +289,7 @@ inline ArtMethod* ClassLinker::GetResolvedMethod(uint32_t method_idx, ArtMethod*
// lookup in the context of the original method from where it steals the code.
// However, we delay the GetInterfaceMethodIfProxy() until needed.
DCHECK(!referrer->IsProxyMethod() || referrer->IsConstructor());
- // We do not need the read barrier for getting the DexCache for the initial resolved method
- // lookup as both from-space and to-space copies point to the same native resolved methods array.
- ArtMethod* resolved_method = referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedMethod(
- method_idx);
+ ArtMethod* resolved_method = referrer->GetDexCache()->GetResolvedMethod(method_idx);
if (resolved_method == nullptr) {
return nullptr;
}
@@ -364,10 +339,7 @@ inline ArtMethod* ClassLinker::ResolveMethod(Thread* self,
// However, we delay the GetInterfaceMethodIfProxy() until needed.
DCHECK(!referrer->IsProxyMethod() || referrer->IsConstructor());
Thread::PoisonObjectPointersIfDebug();
- // We do not need the read barrier for getting the DexCache for the initial resolved method
- // lookup as both from-space and to-space copies point to the same native resolved methods array.
- ArtMethod* resolved_method = referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedMethod(
- method_idx);
+ ArtMethod* resolved_method = referrer->GetDexCache()->GetResolvedMethod(method_idx);
DCHECK(resolved_method == nullptr || !resolved_method->IsRuntimeMethod());
if (UNLIKELY(resolved_method == nullptr)) {
referrer = referrer->GetInterfaceMethodIfProxy(image_pointer_size_);
@@ -432,10 +404,7 @@ inline ArtMethod* ClassLinker::ResolveMethod(Thread* self,
inline ArtField* ClassLinker::LookupResolvedField(uint32_t field_idx,
ArtMethod* referrer,
bool is_static) {
- // We do not need the read barrier for getting the DexCache for the initial resolved field
- // lookup as both from-space and to-space copies point to the same native resolved fields array.
- ArtField* field = referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedField(
- field_idx);
+ ArtField* field = referrer->GetDexCache()->GetResolvedField(field_idx);
if (field == nullptr) {
referrer = referrer->GetInterfaceMethodIfProxy(image_pointer_size_);
ObjPtr<mirror::ClassLoader> class_loader = referrer->GetDeclaringClass()->GetClassLoader();
@@ -448,10 +417,7 @@ inline ArtField* ClassLinker::ResolveField(uint32_t field_idx,
ArtMethod* referrer,
bool is_static) {
Thread::PoisonObjectPointersIfDebug();
- // We do not need the read barrier for getting the DexCache for the initial resolved field
- // lookup as both from-space and to-space copies point to the same native resolved fields array.
- ArtField* resolved_field = referrer->GetDexCache<kWithoutReadBarrier>()->GetResolvedField(
- field_idx);
+ ArtField* resolved_field = referrer->GetDexCache()->GetResolvedField(field_idx);
if (UNLIKELY(resolved_field == nullptr)) {
StackHandleScope<2> hs(Thread::Current());
referrer = referrer->GetInterfaceMethodIfProxy(image_pointer_size_);