From 44905ce1c97613a5cb44046049843fe1029a64cf Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Tue, 2 Jun 2015 21:01:45 -0700 Subject: ART: Prune FindArrayClass cache in image writer The ClassLinker cache speeds up FindArrayClass requests, but all entries are roots. It is possible that an entry is a non-image class when creating the boot image, artificially keeping the class around. Bug: 21596650 Change-Id: Ief9b439945d0e293a3cb5dcddfeb189b5e174f06 --- runtime/class_linker.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'runtime/class_linker.cc') diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 84d10008ea..79c5a0803c 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -277,9 +277,9 @@ ClassLinker::ClassLinker(InternTable* intern_table) quick_to_interpreter_bridge_trampoline_(nullptr), image_pointer_size_(sizeof(void*)) { CHECK(intern_table_ != nullptr); - for (auto& root : find_array_class_cache_) { - root = GcRoot(nullptr); - } + static_assert(kFindArrayCacheSize == arraysize(find_array_class_cache_), + "Array cache size wrong."); + std::fill_n(find_array_class_cache_, kFindArrayCacheSize, GcRoot(nullptr)); } void ClassLinker::InitWithoutImage(std::vector> boot_class_path) { @@ -5877,4 +5877,9 @@ ArtMethod* ClassLinker::CreateRuntimeMethod() { return method; } +void ClassLinker::DropFindArrayClassCache() { + std::fill_n(find_array_class_cache_, kFindArrayCacheSize, GcRoot(nullptr)); + find_array_class_cache_next_victim_ = 0; +} + } // namespace art -- cgit v1.2.3