Add GcRoot to clean up and enforce read barriers.
Introduce a value-type wrapper around Object* for GC roots so that 1)
we won't have to directly add the read barrier code in many places and
2) we can avoid accidentally bypassing/missing read barriers on GC
roots (the GcRoot interface ensures that the read barrier is executed
on a read).
The jdwp test passed.
Bug: 12687968
Change-Id: Ib167c7c325b3c7e3900133578815f04d219972a1
diff --git a/runtime/monitor.h b/runtime/monitor.h
index 0d0ad0b..26d43c9 100644
--- a/runtime/monitor.h
+++ b/runtime/monitor.h
@@ -26,8 +26,9 @@
#include "atomic.h"
#include "base/mutex.h"
+#include "gc_root.h"
#include "object_callbacks.h"
-#include "read_barrier.h"
+#include "read_barrier_option.h"
#include "thread_state.h"
namespace art {
@@ -95,7 +96,7 @@
template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
mirror::Object* GetObject() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- return ReadBarrier::BarrierForRoot<mirror::Object, kReadBarrierOption>(&obj_);
+ return obj_.Read<kReadBarrierOption>();
}
void SetObject(mirror::Object* object);
@@ -197,7 +198,7 @@
// What object are we part of. This is a weak root. Do not access
// this directly, use GetObject() to read it so it will be guarded
// by a read barrier.
- mirror::Object* obj_;
+ GcRoot<mirror::Object> obj_;
// Threads currently waiting on this monitor.
Thread* wait_set_ GUARDED_BY(monitor_lock_);