diff options
Diffstat (limited to 'runtime/mirror/dex_cache-inl.h')
-rw-r--r-- | runtime/mirror/dex_cache-inl.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h index 13eaf3da45..47b621ad1a 100644 --- a/runtime/mirror/dex_cache-inl.h +++ b/runtime/mirror/dex_cache-inl.h @@ -84,6 +84,15 @@ inline uint32_t DexCache::StringSlotIndex(dex::StringIndex string_idx) { } inline String* DexCache::GetResolvedString(dex::StringIndex string_idx) { + const uint32_t num_preresolved_strings = NumPreResolvedStrings(); + if (num_preresolved_strings != 0u) { + DCHECK_LT(string_idx.index_, num_preresolved_strings); + DCHECK_EQ(num_preresolved_strings, GetDexFile()->NumStringIds()); + mirror::String* string = GetPreResolvedStrings()[string_idx.index_].Read(); + if (LIKELY(string != nullptr)) { + return string; + } + } return GetStrings()[StringSlotIndex(string_idx)].load( std::memory_order_relaxed).GetObjectForIndex(string_idx.index_); } @@ -101,6 +110,18 @@ inline void DexCache::SetResolvedString(dex::StringIndex string_idx, ObjPtr<Stri WriteBarrier::ForEveryFieldWrite(this); } +inline void DexCache::SetPreResolvedString(dex::StringIndex string_idx, + ObjPtr<String> resolved) { + DCHECK(resolved != nullptr); + DCHECK_LT(string_idx.index_, GetDexFile()->NumStringIds()); + GetPreResolvedStrings()[string_idx.index_] = GcRoot<mirror::String>(resolved); + Runtime* const runtime = Runtime::Current(); + CHECK(runtime->IsAotCompiler()); + CHECK(!runtime->IsActiveTransaction()); + // TODO: Fine-grained marking, so that we don't need to go through all arrays in full. + WriteBarrier::ForEveryFieldWrite(this); +} + inline void DexCache::ClearString(dex::StringIndex string_idx) { DCHECK(Runtime::Current()->IsAotCompiler()); uint32_t slot_idx = StringSlotIndex(string_idx); @@ -344,6 +365,12 @@ inline void DexCache::VisitReferences(ObjPtr<Class> klass, const Visitor& visito for (size_t i = 0; i != num_call_sites; ++i) { visitor.VisitRootIfNonNull(resolved_call_sites[i].AddressWithoutBarrier()); } + + GcRoot<mirror::String>* const preresolved_strings = GetPreResolvedStrings(); + const size_t num_preresolved_strings = NumPreResolvedStrings(); + for (size_t i = 0; i != num_preresolved_strings; ++i) { + visitor.VisitRootIfNonNull(preresolved_strings[i].AddressWithoutBarrier()); + } } } |