summaryrefslogtreecommitdiffstats
path: root/runtime/monitor.h
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2014-07-22 18:08:23 -0700
committerHiroshi Yamauchi <yamauchi@google.com>2014-07-29 13:30:46 -0700
commit94f7b49578b6aaa80de8ffed230648d601393905 (patch)
treecfc69e453faefee38178ceb85378e1f0f1e17812 /runtime/monitor.h
parent8df73882c60451e7f789bf9b1f3db2d7dc228640 (diff)
downloadart-94f7b49578b6aaa80de8ffed230648d601393905.zip
art-94f7b49578b6aaa80de8ffed230648d601393905.tar.gz
art-94f7b49578b6aaa80de8ffed230648d601393905.tar.bz2
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
Diffstat (limited to 'runtime/monitor.h')
-rw-r--r--runtime/monitor.h7
1 files changed, 4 insertions, 3 deletions
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 @@ class Monitor {
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 @@ class Monitor {
// 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_);