summaryrefslogtreecommitdiffstats
path: root/runtime/monitor.cc
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-03-06 12:13:39 -0800
committerIan Rogers <irogers@google.com>2014-03-06 19:16:01 -0800
commit719d1a33f6569864f529e5a3fff59e7bca97aad0 (patch)
treefcd84efd7b9806b93ec1a44e2317e6f882e7fe0e /runtime/monitor.cc
parent5365eea9940269b662cfbe103caa348816ff1558 (diff)
downloadart-719d1a33f6569864f529e5a3fff59e7bca97aad0.zip
art-719d1a33f6569864f529e5a3fff59e7bca97aad0.tar.gz
art-719d1a33f6569864f529e5a3fff59e7bca97aad0.tar.bz2
Enable annotalysis on clang ART builds.
Fix clang build errors aswell as restructure locking/mutex code for correct thread safety analysis support. Reorder make dependencies so that host builds build first as they should provide better compilation errors than target. Remove host's use of -fno-omit-frame-pointer as it has no value with correct use of CFI, which we should have. Change-Id: I72cea8da9a3757b1a0b3acb4081feccb7c6cef90
Diffstat (limited to 'runtime/monitor.cc')
-rw-r--r--runtime/monitor.cc21
1 files changed, 16 insertions, 5 deletions
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index 64794fe..332aef0 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -650,9 +650,22 @@ void Monitor::InflateThinLocked(Thread* self, SirtRef<mirror::Object>& obj, Lock
}
}
+// Fool annotalysis into thinking that the lock on obj is acquired.
+static mirror::Object* FakeLock(mirror::Object* obj)
+ EXCLUSIVE_LOCK_FUNCTION(obj) NO_THREAD_SAFETY_ANALYSIS {
+ return obj;
+}
+
+// Fool annotalysis into thinking that the lock on obj is release.
+static mirror::Object* FakeUnlock(mirror::Object* obj)
+ UNLOCK_FUNCTION(obj) NO_THREAD_SAFETY_ANALYSIS {
+ return obj;
+}
+
mirror::Object* Monitor::MonitorEnter(Thread* self, mirror::Object* obj) {
DCHECK(self != NULL);
DCHECK(obj != NULL);
+ obj = FakeLock(obj);
uint32_t thread_id = self->GetThreadId();
size_t contention_count = 0;
SirtRef<mirror::Object> sirt_obj(self, obj);
@@ -698,24 +711,22 @@ mirror::Object* Monitor::MonitorEnter(Thread* self, mirror::Object* obj) {
mon->Lock(self);
return sirt_obj.get(); // Success!
}
- case LockWord::kHashCode: {
+ case LockWord::kHashCode:
// Inflate with the existing hashcode.
Inflate(self, nullptr, sirt_obj.get(), lock_word.GetHashCode());
- break;
- }
+ continue; // Start from the beginning.
default: {
LOG(FATAL) << "Invalid monitor state " << lock_word.GetState();
return sirt_obj.get();
}
}
}
- return sirt_obj.get();
}
bool Monitor::MonitorExit(Thread* self, mirror::Object* obj) {
DCHECK(self != NULL);
DCHECK(obj != NULL);
-
+ obj = FakeUnlock(obj);
LockWord lock_word = obj->GetLockWord();
SirtRef<mirror::Object> sirt_obj(self, obj);
switch (lock_word.GetState()) {