Extensions to check JNI.
Ensure critical lock isn't held when returning from a down-call.
Log a warning if the critical lock is held for a significant period of
time.
Refactor JNIEnvExt to be a class rather than a struct.
Test: mma test-art-host
Change-Id: I4d149cb04d3a7308a22b92b196e51e2f1ae17ede
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index b3d9561..f5d09de 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1695,10 +1695,10 @@
CHECK(class_loader != nullptr);
ScopedObjectAccess soa(Thread::Current());
// Unload class loader to free RAM.
- jweak weak_class_loader = soa.Env()->vm->AddWeakGlobalRef(
+ jweak weak_class_loader = soa.Env()->GetVm()->AddWeakGlobalRef(
soa.Self(),
soa.Decode<mirror::ClassLoader>(class_loader));
- soa.Env()->vm->DeleteGlobalRef(soa.Self(), class_loader);
+ soa.Env()->GetVm()->DeleteGlobalRef(soa.Self(), class_loader);
runtime_->GetHeap()->CollectGarbage(/*clear_soft_references*/ true);
ObjPtr<mirror::ClassLoader> decoded_weak = soa.Decode<mirror::ClassLoader>(weak_class_loader);
if (decoded_weak != nullptr) {
@@ -2898,7 +2898,7 @@
~ScopedGlobalRef() {
if (obj_ != nullptr) {
ScopedObjectAccess soa(Thread::Current());
- soa.Env()->vm->DeleteGlobalRef(soa.Self(), obj_);
+ soa.Env()->GetVm()->DeleteGlobalRef(soa.Self(), obj_);
}
}