Initialize dex cache while holding dex_lock

Fixes multiple threads calling RegisterDexFile occasionally getting
DCHECK failures due to the arrays not being null since the BSS ones
is per dex file.

Bug: 31369621

Test: test-art-host, no DCHECK failure during debug booting

Change-Id: I7b6e4cd03460dd1213eb4e044bdcf5f6103fd5f9
diff --git a/runtime/mirror/dex_cache_test.cc b/runtime/mirror/dex_cache_test.cc
index 12301b8..e95ca21 100644
--- a/runtime/mirror/dex_cache_test.cc
+++ b/runtime/mirror/dex_cache_test.cc
@@ -44,9 +44,10 @@
   StackHandleScope<1> hs(soa.Self());
   ASSERT_TRUE(java_lang_dex_file_ != nullptr);
   Handle<DexCache> dex_cache(
-      hs.NewHandle(class_linker_->AllocDexCache(soa.Self(),
-                                                *java_lang_dex_file_,
-                                                Runtime::Current()->GetLinearAlloc())));
+      hs.NewHandle(class_linker_->AllocAndInitializeDexCache(
+          soa.Self(),
+          *java_lang_dex_file_,
+          Runtime::Current()->GetLinearAlloc())));
   ASSERT_TRUE(dex_cache.Get() != nullptr);
 
   EXPECT_TRUE(dex_cache->StaticStringSize() == dex_cache->NumStrings()
@@ -64,9 +65,10 @@
   StackHandleScope<1> hs(soa.Self());
   ASSERT_TRUE(java_lang_dex_file_ != nullptr);
   Handle<DexCache> dex_cache(
-      hs.NewHandle(class_linker_->AllocDexCache(soa.Self(),
-                                                *java_lang_dex_file_,
-                                                Runtime::Current()->GetLinearAlloc())));
+      hs.NewHandle(class_linker_->AllocAndInitializeDexCache(
+          soa.Self(),
+          *java_lang_dex_file_,
+          Runtime::Current()->GetLinearAlloc())));
 
   EXPECT_TRUE(dex_cache->StaticMethodTypeSize() == dex_cache->NumResolvedMethodTypes()
       || java_lang_dex_file_->NumProtoIds() == dex_cache->NumResolvedMethodTypes());