summaryrefslogtreecommitdiff
path: root/runtime/monitor.cc
diff options
context:
space:
mode:
author Hiroshi Yamauchi <yamauchi@google.com> 2017-01-12 19:50:46 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-01-12 19:50:47 +0000
commit29eabfa6c46215dab09a3a3a3362dce53d780eed (patch)
treea0ffaee08c43ed90bfc5e48266ee6ad9247a7fd7 /runtime/monitor.cc
parent9e68f5043323eaf4543ebf3b6f496145d8ae77a2 (diff)
parentf1c6f8742e2ac980c7259f4dc70b4326ecc245e1 (diff)
Merge "Don't need to block in AddWeakGlobalRef and MonitorList::Add under CC."
Diffstat (limited to 'runtime/monitor.cc')
-rw-r--r--runtime/monitor.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index 893abd5462..9c0927584e 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -1361,8 +1361,10 @@ void MonitorList::BroadcastForNewMonitors() {
void MonitorList::Add(Monitor* m) {
Thread* self = Thread::Current();
MutexLock mu(self, monitor_list_lock_);
- while (UNLIKELY((!kUseReadBarrier && !allow_new_monitors_) ||
- (kUseReadBarrier && !self->GetWeakRefAccessEnabled()))) {
+ // CMS needs this to block for concurrent reference processing because an object allocated during
+ // the GC won't be marked and concurrent reference processing would incorrectly clear the JNI weak
+ // ref. But CC (kUseReadBarrier == true) doesn't because of the to-space invariant.
+ while (!kUseReadBarrier && UNLIKELY(!allow_new_monitors_)) {
// Check and run the empty checkpoint before blocking so the empty checkpoint will work in the
// presence of threads blocking for weak ref access.
self->CheckEmptyCheckpoint();