Use ArtMethod* .bss entries for HInvokeStaticOrDirect.
Test: m test-art-host-gtest
Test: testrunner.py --host
Test: testrunner.py --target
Test: Nexus 6P boots.
Test: Build aosp_mips64-userdebug.
Bug: 30627598
Change-Id: I0e54fdd2e91e983d475b7a04d40815ba89ae3d4f
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 0921bd6..0fa25d1 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -3417,8 +3417,11 @@
// Example dex_cache location is SettingsProvider.apk and
// dex file location is /system/priv-app/SettingsProvider/SettingsProvider.apk
CHECK_EQ(dex_cache_location, dex_file_suffix);
- // Clean up pass to remove null dex caches.
+ const OatFile* oat_file =
+ (dex_file.GetOatDexFile() != nullptr) ? dex_file.GetOatDexFile()->GetOatFile() : nullptr;
+ // Clean up pass to remove null dex caches. Also check if we need to initialize OatFile .bss.
// Null dex caches can occur due to class unloading and we are lazily removing null entries.
+ bool initialize_oat_file_bss = (oat_file != nullptr);
JavaVMExt* const vm = self->GetJniEnv()->vm;
for (auto it = dex_caches_.begin(); it != dex_caches_.end(); ) {
DexCacheData data = *it;
@@ -3426,9 +3429,21 @@
vm->DeleteWeakGlobalRef(self, data.weak_root);
it = dex_caches_.erase(it);
} else {
+ if (initialize_oat_file_bss &&
+ it->dex_file->GetOatDexFile() != nullptr &&
+ it->dex_file->GetOatDexFile()->GetOatFile() == oat_file) {
+ initialize_oat_file_bss = false; // Already initialized.
+ }
++it;
}
}
+ if (initialize_oat_file_bss) {
+ // TODO: Pre-initialize from boot/app image?
+ ArtMethod* resolution_method = Runtime::Current()->GetResolutionMethod();
+ for (ArtMethod*& entry : oat_file->GetBssMethods()) {
+ entry = resolution_method;
+ }
+ }
jweak dex_cache_jweak = vm->AddWeakGlobalRef(self, dex_cache);
dex_cache->SetDexFile(&dex_file);
DexCacheData data;