From d6d49e56c2b7b11f474acb80cb02bb1fe9b7861e Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 2 Jun 2016 11:48:30 -0700 Subject: Hold dex caches live in class table Prevents temporary dex caches being unloaded for the same dex file. Usually this is OK, but if someone resolved a string in that dex cache, it could leave stale pointers in BSS. Also it can use extra memory in linear alloc if we allocate dex cache arrays multiple times. Bug: 29083330 (cherry picked from commit f284d448e3edd428b6ade473d0993028638b2064) Change-Id: Ie1b0b0cf835a998e19227cbb90014011a6cd40c4 --- runtime/class_table.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'runtime/class_table.h') diff --git a/runtime/class_table.h b/runtime/class_table.h index 686381d35c..854a85e816 100644 --- a/runtime/class_table.h +++ b/runtime/class_table.h @@ -133,8 +133,8 @@ class ClassTable { REQUIRES(!lock_) SHARED_REQUIRES(Locks::mutator_lock_); - // Return true if we inserted the dex file, false if it already exists. - bool InsertDexFile(mirror::Object* dex_file) + // Return true if we inserted the strong root, false if it already exists. + bool InsertStrongRoot(mirror::Object* obj) REQUIRES(!lock_) SHARED_REQUIRES(Locks::mutator_lock_); @@ -162,9 +162,10 @@ class ClassTable { mutable ReaderWriterMutex lock_; // We have a vector to help prevent dirty pages after the zygote forks by calling FreezeSnapshot. std::vector classes_ GUARDED_BY(lock_); - // Dex files used by the class loader which may not be owned by the class loader. We keep these - // live so that we do not have issues closing any of the dex files. - std::vector> dex_files_ GUARDED_BY(lock_); + // Extra strong roots that can be either dex files or dex caches. Dex files used by the class + // loader which may not be owned by the class loader must be held strongly live. Also dex caches + // are held live to prevent them being unloading once they have classes in them. + std::vector> strong_roots_ GUARDED_BY(lock_); }; } // namespace art -- cgit v1.2.3-59-g8ed1b