summaryrefslogtreecommitdiff
path: root/runtime/mirror/dex_cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/mirror/dex_cache.cc')
-rw-r--r--runtime/mirror/dex_cache.cc32
1 files changed, 1 insertions, 31 deletions
diff --git a/runtime/mirror/dex_cache.cc b/runtime/mirror/dex_cache.cc
index abbd23442b..b981f08d97 100644
--- a/runtime/mirror/dex_cache.cc
+++ b/runtime/mirror/dex_cache.cc
@@ -224,6 +224,7 @@ void DexCache::SetResolvedType(dex::TypeIndex type_idx, ObjPtr<Class> resolved)
SetResolvedTypesEntry(type_idx.index_, resolved.Ptr());
// TODO: Fine-grained marking, so that we don't need to go through all arrays in full.
WriteBarrier::ForEveryFieldWrite(this);
+
if (this == resolved->GetDexCache()) {
// If we're updating the dex cache of the class, optimistically update the cache for methods and
// fields if the caches are full arrays.
@@ -254,36 +255,5 @@ void DexCache::SetResolvedType(dex::TypeIndex type_idx, ObjPtr<Class> resolved)
}
}
-static void ReclaimMemoryInternal(uint64_t address, size_t size) {
- if (address == 0u || size <= MemMap::GetPageSize()) {
- return;
- }
- uint8_t* const mem_begin = reinterpret_cast<uint8_t*>(address);
- uint8_t* const mem_end = reinterpret_cast<uint8_t*>(address + size);
- uint8_t* const page_begin = AlignUp(mem_begin, MemMap::GetPageSize());
- uint8_t* const page_end = AlignDown(mem_end, MemMap::GetPageSize());
- DCHECK_GE(page_end, page_begin);
- if (page_end == page_begin) {
- return;
- }
- bool res = madvise(page_begin, page_end - page_begin, MADV_DONTNEED);
- if (res == -1) {
- PLOG(WARNING) << "madvise failed";
- }
-}
-
-void DexCache::ReclaimMemory() {
- ReclaimMemoryInternal(resolved_fields_array_,
- NumResolvedFieldsArray() * sizeof(ArtField*));
- ReclaimMemoryInternal(resolved_method_types_array_,
- NumResolvedMethodTypesArray() * sizeof(GcRoot<mirror::MethodType>));
- ReclaimMemoryInternal(resolved_methods_array_,
- NumResolvedMethodsArray() * sizeof(ArtMethod*));
- ReclaimMemoryInternal(resolved_types_array_,
- NumResolvedTypesArray() * sizeof(GcRoot<mirror::Class>));
- ReclaimMemoryInternal(strings_array_,
- NumStringsArray() * sizeof(GcRoot<mirror::String>));
-}
-
} // namespace mirror
} // namespace art