diff options
author | David Srbecky <dsrbecky@google.com> | 2021-10-06 17:39:18 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-10-06 17:39:18 +0000 |
commit | ea887d415700cfd9a406b022861ca846cd6af650 (patch) | |
tree | a55ceeacb0f0e9314e11fba46c5928027b22d807 | |
parent | cedad4b625e1c95ee7ae113c1046e136223a7946 (diff) | |
parent | 4af07cd8efc146503e75cc85dfbbb8f10951be9f (diff) | |
download | art-temp_sam_202323961.tar.gz |
DexCache: Remove pre-resolved string dead code. am: 4af07cd8eftemp_sam_202323961
Original change: https://android-review.googlesource.com/c/platform/art/+/1846386
Change-Id: Ia94ba56e0bbafb3e027c719b8a24a40a737a2d9f
-rw-r--r-- | runtime/mirror/dex_cache-inl.h | 92 | ||||
-rw-r--r-- | runtime/mirror/dex_cache.cc | 23 | ||||
-rw-r--r-- | runtime/mirror/dex_cache.h | 39 |
3 files changed, 1 insertions, 153 deletions
diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h index 0553f4fed1..c37aaefade 100644 --- a/runtime/mirror/dex_cache-inl.h +++ b/runtime/mirror/dex_cache-inl.h @@ -83,20 +83,6 @@ 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) { - GcRoot<mirror::String>* preresolved_strings = GetPreResolvedStrings(); - // num_preresolved_strings can become 0 and preresolved_strings can become null in any order - // when ClearPreResolvedStrings is called. - if (preresolved_strings != nullptr) { - DCHECK_LT(string_idx.index_, num_preresolved_strings); - DCHECK_EQ(num_preresolved_strings, GetDexFile()->NumStringIds()); - mirror::String* string = preresolved_strings[string_idx.index_].Read(); - if (LIKELY(string != nullptr)) { - return string; - } - } - } return GetStrings()[StringSlotIndex(string_idx)].load( std::memory_order_relaxed).GetObjectForIndex(string_idx.index_); } @@ -114,28 +100,6 @@ 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::ClearPreResolvedStrings() { - SetFieldPtr64</*kTransactionActive=*/false, - /*kCheckTransaction=*/false, - kVerifyNone, - GcRoot<mirror::String>*>(PreResolvedStringsOffset(), nullptr); - SetField32</*kTransactionActive=*/false, - /*bool kCheckTransaction=*/false, - kVerifyNone, - /*kIsVolatile=*/false>(NumPreResolvedStringsOffset(), 0); -} - inline void DexCache::ClearString(dex::StringIndex string_idx) { DCHECK(Runtime::Current()->IsAotCompiler()); uint32_t slot_idx = StringSlotIndex(string_idx); @@ -365,62 +329,6 @@ 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(); - if (preresolved_strings != nullptr) { - const size_t num_preresolved_strings = NumPreResolvedStrings(); - for (size_t i = 0; i != num_preresolved_strings; ++i) { - visitor.VisitRootIfNonNull(preresolved_strings[i].AddressWithoutBarrier()); - } - } - } -} - -template <ReadBarrierOption kReadBarrierOption, typename Visitor> -inline void DexCache::FixupStrings(StringDexCacheType* dest, const Visitor& visitor) { - StringDexCacheType* src = GetStrings(); - for (size_t i = 0, count = NumStrings(); i < count; ++i) { - StringDexCachePair source = src[i].load(std::memory_order_relaxed); - String* ptr = source.object.Read<kReadBarrierOption>(); - String* new_source = visitor(ptr); - source.object = GcRoot<String>(new_source); - dest[i].store(source, std::memory_order_relaxed); - } -} - -template <ReadBarrierOption kReadBarrierOption, typename Visitor> -inline void DexCache::FixupResolvedTypes(TypeDexCacheType* dest, const Visitor& visitor) { - TypeDexCacheType* src = GetResolvedTypes(); - for (size_t i = 0, count = NumResolvedTypes(); i < count; ++i) { - TypeDexCachePair source = src[i].load(std::memory_order_relaxed); - Class* ptr = source.object.Read<kReadBarrierOption>(); - Class* new_source = visitor(ptr); - source.object = GcRoot<Class>(new_source); - dest[i].store(source, std::memory_order_relaxed); - } -} - -template <ReadBarrierOption kReadBarrierOption, typename Visitor> -inline void DexCache::FixupResolvedMethodTypes(MethodTypeDexCacheType* dest, - const Visitor& visitor) { - MethodTypeDexCacheType* src = GetResolvedMethodTypes(); - for (size_t i = 0, count = NumResolvedMethodTypes(); i < count; ++i) { - MethodTypeDexCachePair source = src[i].load(std::memory_order_relaxed); - MethodType* ptr = source.object.Read<kReadBarrierOption>(); - MethodType* new_source = visitor(ptr); - source.object = GcRoot<MethodType>(new_source); - dest[i].store(source, std::memory_order_relaxed); - } -} - -template <ReadBarrierOption kReadBarrierOption, typename Visitor> -inline void DexCache::FixupResolvedCallSites(GcRoot<mirror::CallSite>* dest, - const Visitor& visitor) { - GcRoot<mirror::CallSite>* src = GetResolvedCallSites(); - for (size_t i = 0, count = NumResolvedCallSites(); i < count; ++i) { - mirror::CallSite* source = src[i].Read<kReadBarrierOption>(); - mirror::CallSite* new_source = visitor(source); - dest[i] = GcRoot<mirror::CallSite>(new_source); } } diff --git a/runtime/mirror/dex_cache.cc b/runtime/mirror/dex_cache.cc index d100f32340..e90afa2ea3 100644 --- a/runtime/mirror/dex_cache.cc +++ b/runtime/mirror/dex_cache.cc @@ -184,29 +184,6 @@ void DexCache::VisitReflectiveTargets(ReflectiveValueVisitor* visitor) { } } -bool DexCache::AddPreResolvedStringsArray() { - DCHECK_EQ(NumPreResolvedStrings(), 0u); - Thread* const self = Thread::Current(); - LinearAlloc* linear_alloc = Runtime::Current()->GetLinearAlloc(); - const size_t num_strings = GetDexFile()->NumStringIds(); - if (num_strings != 0) { - GcRoot<mirror::String>* strings = - linear_alloc->AllocArray<GcRoot<mirror::String>>(self, num_strings); - if (strings == nullptr) { - // Failed to allocate pre-resolved string array (probably due to address fragmentation), bail. - return false; - } - SetField32<false>(NumPreResolvedStringsOffset(), num_strings); - - CHECK(strings != nullptr); - SetPreResolvedStrings(strings); - for (size_t i = 0; i < GetDexFile()->NumStringIds(); ++i) { - CHECK(GetPreResolvedStrings()[i].Read() == nullptr); - } - } - return true; -} - void DexCache::SetNativeArrays(StringDexCacheType* strings, uint32_t num_strings, TypeDexCacheType* resolved_types, diff --git a/runtime/mirror/dex_cache.h b/runtime/mirror/dex_cache.h index f02ddc6bfb..e8f7c21dec 100644 --- a/runtime/mirror/dex_cache.h +++ b/runtime/mirror/dex_cache.h @@ -196,22 +196,6 @@ class MANAGED DexCache final : public Object { // Clear all native fields. void ResetNativeFields() REQUIRES_SHARED(Locks::mutator_lock_); - template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier, typename Visitor> - void FixupStrings(StringDexCacheType* dest, const Visitor& visitor) - REQUIRES_SHARED(Locks::mutator_lock_); - - template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier, typename Visitor> - void FixupResolvedTypes(TypeDexCacheType* dest, const Visitor& visitor) - REQUIRES_SHARED(Locks::mutator_lock_); - - template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier, typename Visitor> - void FixupResolvedMethodTypes(MethodTypeDexCacheType* dest, const Visitor& visitor) - REQUIRES_SHARED(Locks::mutator_lock_); - - template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier, typename Visitor> - void FixupResolvedCallSites(GcRoot<mirror::CallSite>* dest, const Visitor& visitor) - REQUIRES_SHARED(Locks::mutator_lock_); - ObjPtr<String> GetLocation() REQUIRES_SHARED(Locks::mutator_lock_); static constexpr MemberOffset StringsOffset() { @@ -280,14 +264,6 @@ class MANAGED DexCache final : public Object { void SetResolvedString(dex::StringIndex string_idx, ObjPtr<mirror::String> resolved) ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_); - void SetPreResolvedString(dex::StringIndex string_idx, - ObjPtr<mirror::String> resolved) - ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_); - - // Clear the preresolved string cache to prevent further usage. - void ClearPreResolvedStrings() - ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_); - // Clear a string for a string_idx, used to undo string intern transactions to make sure // the string isn't kept live. void ClearString(dex::StringIndex string_idx) REQUIRES_SHARED(Locks::mutator_lock_); @@ -335,21 +311,10 @@ class MANAGED DexCache final : public Object { return GetFieldPtr64<StringDexCacheType*, kVerifyFlags>(StringsOffset()); } - template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> - GcRoot<mirror::String>* GetPreResolvedStrings() ALWAYS_INLINE - REQUIRES_SHARED(Locks::mutator_lock_) { - return GetFieldPtr64<GcRoot<mirror::String>*, kVerifyFlags>(PreResolvedStringsOffset()); - } - void SetStrings(StringDexCacheType* strings) ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_) { SetFieldPtr<false>(StringsOffset(), strings); } - void SetPreResolvedStrings(GcRoot<mirror::String>* strings) - ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_) { - SetFieldPtr<false>(PreResolvedStringsOffset(), strings); - } - template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> TypeDexCacheType* GetResolvedTypes() ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_) { return GetFieldPtr<TypeDexCacheType*, kVerifyFlags>(ResolvedTypesOffset()); @@ -470,12 +435,10 @@ class MANAGED DexCache final : public Object { uint32_t MethodSlotIndex(uint32_t method_idx) REQUIRES_SHARED(Locks::mutator_lock_); uint32_t MethodTypeSlotIndex(dex::ProtoIndex proto_idx) REQUIRES_SHARED(Locks::mutator_lock_); - // Returns true if we succeeded in adding the pre-resolved string array. - bool AddPreResolvedStringsArray() REQUIRES_SHARED(Locks::mutator_lock_); - void VisitReflectiveTargets(ReflectiveValueVisitor* visitor) REQUIRES(Locks::mutator_lock_); void SetClassLoader(ObjPtr<ClassLoader> class_loader) REQUIRES_SHARED(Locks::mutator_lock_); + ObjPtr<ClassLoader> GetClassLoader() REQUIRES_SHARED(Locks::mutator_lock_); private: |