DexCache: Remove pre-resolved string dead code.
Pre-resolved strings are no longer used,
so remove some of the dead methods.
Test: ./art/test.py -b -r --host --64
Change-Id: I02974b1910a8b455f787f9a791fb06de2b3c229a
diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h
index 0553f4f..c37aaef 100644
--- a/runtime/mirror/dex_cache-inl.h
+++ b/runtime/mirror/dex_cache-inl.h
@@ -83,20 +83,6 @@
}
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 @@
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 @@
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 d100f32..e90afa2 100644
--- a/runtime/mirror/dex_cache.cc
+++ b/runtime/mirror/dex_cache.cc
@@ -184,29 +184,6 @@
}
}
-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 f02ddc6..e8f7c21 100644
--- a/runtime/mirror/dex_cache.h
+++ b/runtime/mirror/dex_cache.h
@@ -196,22 +196,6 @@
// 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 @@
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 @@
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 @@
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: