summaryrefslogtreecommitdiffstats
path: root/runtime/monitor.cc
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.cc
parent8df73882c60451e7f789bf9b1f3db2d7dc228640 (diff)
downloadart-94f7b49578b6aaa80de8ffed230648d601393905.tar.gz
art-94f7b49578b6aaa80de8ffed230648d601393905.tar.bz2
art-94f7b49578b6aaa80de8ffed230648d601393905.zip
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.cc')
-rw-r--r--runtime/monitor.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index 371a9d9dd6..433c1b2d6d 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -84,7 +84,7 @@ Monitor::Monitor(Thread* self, Thread* owner, mirror::Object* obj, int32_t hash_
num_waiters_(0),
owner_(owner),
lock_count_(0),
- obj_(obj),
+ obj_(GcRoot<mirror::Object>(obj)),
wait_set_(NULL),
hash_code_(hash_code),
locking_method_(NULL),
@@ -107,7 +107,7 @@ Monitor::Monitor(Thread* self, Thread* owner, mirror::Object* obj, int32_t hash_
num_waiters_(0),
owner_(owner),
lock_count_(0),
- obj_(obj),
+ obj_(GcRoot<mirror::Object>(obj)),
wait_set_(NULL),
hash_code_(hash_code),
locking_method_(NULL),
@@ -225,7 +225,7 @@ void Monitor::RemoveFromWaitSet(Thread *thread) {
}
void Monitor::SetObject(mirror::Object* object) {
- obj_ = object;
+ obj_ = GcRoot<mirror::Object>(object);
}
void Monitor::Lock(Thread* self) {
@@ -636,7 +636,7 @@ bool Monitor::Deflate(Thread* self, mirror::Object* obj) {
}
// The monitor is deflated, mark the object as nullptr so that we know to delete it during the
// next GC.
- monitor->obj_ = nullptr;
+ monitor->obj_ = GcRoot<mirror::Object>(nullptr);
}
return true;
}