Add read barriers for the roots in Runtime.
Bug: 12687968
Change-Id: If26518a8251702cfe4d5cd7d1f50e80e342704cf
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 94d6cdf..c354ad5 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -910,11 +910,13 @@
thread_list_->Unregister(self);
}
- mirror::Throwable* Runtime::GetPreAllocatedOutOfMemoryError() const {
- if (pre_allocated_OutOfMemoryError_ == NULL) {
+mirror::Throwable* Runtime::GetPreAllocatedOutOfMemoryError() {
+ mirror::Throwable* oome = ReadBarrier::BarrierForRoot<mirror::Throwable, kWithReadBarrier>(
+ &pre_allocated_OutOfMemoryError_);
+ if (oome == NULL) {
LOG(ERROR) << "Failed to return pre-allocated OOME";
}
- return pre_allocated_OutOfMemoryError_;
+ return oome;
}
void Runtime::VisitConstantRoots(RootCallback* callback, void* arg) {