From 18090d118bfb04620aeef719e2d7780c26298bf8 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 1 Jun 2018 16:53:12 +0100 Subject: Refactor String resolution. Use the same pattern as type resolution and avoid some unnecessary read barriers in the fast path. Consolidate naming between ArtField and ArtMethod. Test: m test-art-host-gtest Test: testrunner.py --host Change-Id: Iea69129085f61f04a4add09edd0eadbb7ac9ecb2 --- runtime/class_linker-inl.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'runtime/class_linker-inl.h') diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h index 664b917543..2536b23416 100644 --- a/runtime/class_linker-inl.h +++ b/runtime/class_linker-inl.h @@ -61,6 +61,54 @@ inline ObjPtr ClassLinker::FindArrayClass(Thread* self, return array_class; } +inline ObjPtr ClassLinker::ResolveString(dex::StringIndex string_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 resolved = + referrer->GetDexCache()->GetResolvedString(string_idx); + if (resolved == nullptr) { + resolved = DoResolveString(string_idx, referrer->GetDexCache()); + } + return resolved; +} + +inline ObjPtr ClassLinker::ResolveString(dex::StringIndex string_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 resolved = + referrer->GetDexCache()->GetResolvedString(string_idx); + if (resolved == nullptr) { + resolved = DoResolveString(string_idx, referrer->GetDexCache()); + } + return resolved; +} + +inline ObjPtr ClassLinker::ResolveString(dex::StringIndex string_idx, + Handle dex_cache) { + Thread::PoisonObjectPointersIfDebug(); + DCHECK(!Thread::Current()->IsExceptionPending()); + ObjPtr resolved = dex_cache->GetResolvedString(string_idx); + if (resolved == nullptr) { + resolved = DoResolveString(string_idx, dex_cache); + } + return resolved; +} + +inline ObjPtr ClassLinker::LookupString(dex::StringIndex string_idx, + ObjPtr dex_cache) { + ObjPtr resolved = dex_cache->GetResolvedString(string_idx); + if (resolved == nullptr) { + resolved = DoLookupString(string_idx, dex_cache); + } + return resolved; +} + inline ObjPtr ClassLinker::ResolveType(dex::TypeIndex type_idx, ObjPtr referrer) { if (kObjPtrPoisoning) { -- cgit v1.2.3-59-g8ed1b