ART: Refactor IRT:Add
Do not abort on overflow. Return null and an error message. The
caller is responsible for handling this, e.g., by aborting. In a
future CL, this may be used for driving additional GCs.
Additional side effect is the removal of a frame from an abortion
stack trace.
Test: m
Test: m test-art-host
Change-Id: I80b1e0ee396fc69906d051f1b661d7dba222fc6f
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index c0d1861..5a16053 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -589,7 +589,12 @@
return nullptr;
}
WriterMutexLock mu(self, *Locks::jni_globals_lock_);
- IndirectRef ref = globals_.Add(kIRTFirstSegment, obj);
+ std::string error_msg;
+ IndirectRef ref = globals_.Add(kIRTFirstSegment, obj, &error_msg);
+ if (UNLIKELY(ref == nullptr)) {
+ LOG(FATAL) << error_msg;
+ UNREACHABLE();
+ }
return reinterpret_cast<jobject>(ref);
}
@@ -607,7 +612,12 @@
self->CheckEmptyCheckpointFromWeakRefAccess(Locks::jni_weak_globals_lock_);
weak_globals_add_condition_.WaitHoldingLocks(self);
}
- IndirectRef ref = weak_globals_.Add(kIRTFirstSegment, obj);
+ std::string error_msg;
+ IndirectRef ref = weak_globals_.Add(kIRTFirstSegment, obj, &error_msg);
+ if (UNLIKELY(ref == nullptr)) {
+ LOG(FATAL) << error_msg;
+ UNREACHABLE();
+ }
return reinterpret_cast<jweak>(ref);
}