From 86d6cd53385eae365f16f45e1a5947cc6595eb63 Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Wed, 2 Dec 2020 18:13:10 +0000 Subject: Remove DexCache arrays from image. Remove the hashtable storage from the image and allocate it at runtime instead (but keep the DexCache object in the image). For compiled code, we have largely moved to using .bss, so the DexCache just costs us unnecessary extra space and dirty pages. For interpreted code, the hashtables are too small and will be overridden many times over at run-time regardless. The next step will be to make DexCache variable-size so it can adapt to both of the extremes (taking minimal amount of memory for compiled code and avoiding cache evictions in interpreter). Test: test.py --host Change-Id: I9f89e8f19829b812cf85dea1a964259ed8b87f4d --- runtime/class_linker_test.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'runtime/class_linker_test.cc') diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index ef851910bf..c677601c0d 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -1528,13 +1528,10 @@ TEST_F(ClassLinkerTest, RegisterDexFileName) { } ASSERT_TRUE(dex_cache != nullptr); } - // Make a copy of the dex cache and change the name. - dex_cache.Assign(mirror::Object::Clone(dex_cache, soa.Self())->AsDexCache()); const uint16_t data[] = { 0x20AC, 0x20A1 }; Handle location(hs.NewHandle(mirror::String::AllocFromUtf16(soa.Self(), arraysize(data), data))); - dex_cache->SetLocation(location.Get()); const DexFile* old_dex_file = dex_cache->GetDexFile(); std::unique_ptr dex_file(new StandardDexFile(old_dex_file->Begin(), @@ -1543,6 +1540,10 @@ TEST_F(ClassLinkerTest, RegisterDexFileName) { 0u, nullptr, nullptr)); + // Make a copy of the dex cache with changed name. + LinearAlloc* alloc = Runtime::Current()->GetLinearAlloc(); + dex_cache.Assign(class_linker->AllocAndInitializeDexCache(Thread::Current(), *dex_file, alloc)); + DCHECK_EQ(dex_cache->GetLocation()->CompareTo(location.Get()), 0); { WriterMutexLock mu(soa.Self(), *Locks::dex_lock_); // Check that inserting with a UTF16 name works. -- cgit v1.2.3-59-g8ed1b