summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc26
1 files changed, 11 insertions, 15 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index b98708ebe5..0fe8caa49e 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1937,13 +1937,10 @@ bool ClassLinker::AddImageSpace(
return false;
}
- LinearAlloc* linear_alloc = GetOrCreateAllocatorForClassLoader(class_loader.Get());
- DCHECK(linear_alloc != nullptr);
- DCHECK_EQ(linear_alloc == Runtime::Current()->GetLinearAlloc(), !app_image);
{
- // Native fields are all null. Initialize them and allocate native memory.
+ // Native fields are all null. Initialize them.
WriterMutexLock mu(self, *Locks::dex_lock_);
- dex_cache->InitializeNativeFields(dex_file.get(), linear_alloc);
+ dex_cache->Initialize(dex_file.get(), class_loader.Get());
}
if (!app_image) {
// Register dex files, keep track of existing ones that are conflicts.
@@ -2404,13 +2401,14 @@ ObjPtr<mirror::DexCache> ClassLinker::AllocDexCache(Thread* self, const DexFile&
return dex_cache.Get();
}
-ObjPtr<mirror::DexCache> ClassLinker::AllocAndInitializeDexCache(Thread* self,
- const DexFile& dex_file,
- LinearAlloc* linear_alloc) {
+ObjPtr<mirror::DexCache> ClassLinker::AllocAndInitializeDexCache(
+ Thread* self, const DexFile& dex_file, ObjPtr<mirror::ClassLoader> class_loader) {
+ StackHandleScope<1> hs(self);
+ Handle<mirror::ClassLoader> h_class_loader(hs.NewHandle(class_loader));
ObjPtr<mirror::DexCache> dex_cache = AllocDexCache(self, dex_file);
if (dex_cache != nullptr) {
WriterMutexLock mu(self, *Locks::dex_lock_);
- dex_cache->InitializeNativeFields(&dex_file, linear_alloc);
+ dex_cache->Initialize(&dex_file, h_class_loader.Get());
}
return dex_cache;
}
@@ -3845,10 +3843,8 @@ void ClassLinker::LoadMethod(const DexFile& dex_file,
}
void ClassLinker::AppendToBootClassPath(Thread* self, const DexFile* dex_file) {
- ObjPtr<mirror::DexCache> dex_cache = AllocAndInitializeDexCache(
- self,
- *dex_file,
- Runtime::Current()->GetLinearAlloc());
+ ObjPtr<mirror::DexCache> dex_cache =
+ AllocAndInitializeDexCache(self, *dex_file, /* class_loader= */ nullptr);
CHECK(dex_cache != nullptr) << "Failed to allocate dex cache for " << dex_file->GetLocation();
AppendToBootClassPath(dex_file, dex_cache);
}
@@ -4038,10 +4034,10 @@ ObjPtr<mirror::DexCache> ClassLinker::RegisterDexFile(const DexFile& dex_file,
const DexCacheData* old_data = FindDexCacheDataLocked(dex_file);
old_dex_cache = DecodeDexCacheLocked(self, old_data);
if (old_dex_cache == nullptr && h_dex_cache != nullptr) {
- // Do InitializeNativeFields while holding dex lock to make sure two threads don't call it
+ // Do Initialize while holding dex lock to make sure two threads don't call it
// at the same time with the same dex cache. Since the .bss is shared this can cause failing
// DCHECK that the arrays are null.
- h_dex_cache->InitializeNativeFields(&dex_file, linear_alloc);
+ h_dex_cache->Initialize(&dex_file, h_class_loader.Get());
RegisterDexFileLocked(dex_file, h_dex_cache.Get(), h_class_loader.Get());
}
if (old_dex_cache != nullptr) {