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
Change-Id: Ia44668f013ceef1f5eb80f653a48d0f8004548c9
diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc
index 21e198c..6d1f944 100644
--- a/compiler/oat_test.cc
+++ b/compiler/oat_test.cc
@@ -199,7 +199,7 @@
for (const std::unique_ptr<const DexFile>& dex_file : opened_dex_files) {
dex_files.push_back(dex_file.get());
ScopedObjectAccess soa(Thread::Current());
- class_linker->RegisterDexFile(*dex_file, runtime->GetLinearAlloc());
+ class_linker->RegisterDexFile(*dex_file, nullptr);
}
linker::MultiOatRelativePatcher patcher(compiler_driver_->GetInstructionSet(),
instruction_set_features_.get());
@@ -491,10 +491,7 @@
ClassLinker* const class_linker = Runtime::Current()->GetClassLinker();
for (const DexFile* dex_file : dex_files) {
ScopedObjectAccess soa(Thread::Current());
- class_linker->RegisterDexFile(
- *dex_file,
- class_linker->GetOrCreateAllocatorForClassLoader(
- soa.Decode<mirror::ClassLoader*>(class_loader)));
+ class_linker->RegisterDexFile(*dex_file, soa.Decode<mirror::ClassLoader*>(class_loader));
}
compiler_driver_->SetDexFilesForOatFile(dex_files);
compiler_driver_->CompileAll(class_loader, dex_files, &timings);