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
diff --git a/runtime/entrypoints/entrypoint_utils.h b/runtime/entrypoints/entrypoint_utils.h
index a8fb6c1..498ac2c 100644
--- a/runtime/entrypoints/entrypoint_utils.h
+++ b/runtime/entrypoints/entrypoint_utils.h
@@ -29,7 +29,6 @@
#include "mirror/class-inl.h"
#include "mirror/object-inl.h"
#include "mirror/throwable.h"
-#include "locks.h"
#include "object_utils.h"
#include "sirt_ref.h"
#include "thread.h"
@@ -642,8 +641,7 @@
}
static inline void UnlockJniSynchronizedMethod(jobject locked, Thread* self)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- UNLOCK_FUNCTION(monitor_lock_) {
+ NO_THREAD_SAFETY_ANALYSIS /* SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) */ {
// Save any pending exception over monitor exit call.
mirror::Throwable* saved_exception = NULL;
ThrowLocation saved_throw_location;
diff --git a/runtime/entrypoints/portable/portable_jni_entrypoints.cc b/runtime/entrypoints/portable/portable_jni_entrypoints.cc
index de1e32e..17ad4d0 100644
--- a/runtime/entrypoints/portable/portable_jni_entrypoints.cc
+++ b/runtime/entrypoints/portable/portable_jni_entrypoints.cc
@@ -23,7 +23,7 @@
// Called on entry to JNI, transition out of Runnable and release share of mutator_lock_.
extern "C" uint32_t art_portable_jni_method_start(Thread* self)
- UNLOCK_FUNCTION(GlobalSynchronizatio::mutator_lock_) {
+ UNLOCK_FUNCTION(Locks::mutator_lock_) {
JNIEnvExt* env = self->GetJniEnv();
uint32_t saved_local_ref_cookie = env->local_ref_cookie;
env->local_ref_cookie = env->locals.GetSegmentState();
@@ -32,7 +32,7 @@
}
extern "C" uint32_t art_portable_jni_method_start_synchronized(jobject to_lock, Thread* self)
- UNLOCK_FUNCTION(Locks::mutator_lock_) {
+ UNLOCK_FUNCTION(Locks::mutator_lock_) NO_THREAD_SAFETY_ANALYSIS {
self->DecodeJObject(to_lock)->MonitorEnter(self);
return art_portable_jni_method_start(self);
}
diff --git a/runtime/entrypoints/portable/portable_lock_entrypoints.cc b/runtime/entrypoints/portable/portable_lock_entrypoints.cc
index 44d3da9..358ac23 100644
--- a/runtime/entrypoints/portable/portable_lock_entrypoints.cc
+++ b/runtime/entrypoints/portable/portable_lock_entrypoints.cc
@@ -20,8 +20,9 @@
namespace art {
extern "C" void art_portable_lock_object_from_code(mirror::Object* obj, Thread* thread)
- EXCLUSIVE_LOCK_FUNCTION(monitor_lock_) {
- DCHECK(obj != NULL); // Assumed to have been checked before entry.
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+ NO_THREAD_SAFETY_ANALYSIS /* EXCLUSIVE_LOCK_FUNCTION(Monitor::monitor_lock_) */ {
+ DCHECK(obj != nullptr); // Assumed to have been checked before entry.
obj->MonitorEnter(thread); // May block.
DCHECK(thread->HoldsLock(obj));
// Only possible exception is NPE and is handled before entry.
@@ -29,8 +30,9 @@
}
extern "C" void art_portable_unlock_object_from_code(mirror::Object* obj, Thread* thread)
- UNLOCK_FUNCTION(monitor_lock_) {
- DCHECK(obj != NULL); // Assumed to have been checked before entry.
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+ NO_THREAD_SAFETY_ANALYSIS /* UNLOCK_FUNCTION(Monitor::monitor_lock_) */ {
+ DCHECK(obj != nullptr); // Assumed to have been checked before entry.
// MonitorExit may throw exception.
obj->MonitorExit(thread);
}
diff --git a/runtime/entrypoints/quick/callee_save_frame.h b/runtime/entrypoints/quick/callee_save_frame.h
index 8f70049..3fd4adc 100644
--- a/runtime/entrypoints/quick/callee_save_frame.h
+++ b/runtime/entrypoints/quick/callee_save_frame.h
@@ -26,8 +26,8 @@
} // namespace mirror
// Place a special frame at the TOS that will save the callee saves for the given type.
-static void FinishCalleeSaveFrameSetup(Thread* self, mirror::ArtMethod** sp,
- Runtime::CalleeSaveType type)
+static inline void FinishCalleeSaveFrameSetup(Thread* self, mirror::ArtMethod** sp,
+ Runtime::CalleeSaveType type)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
// Be aware the store below may well stomp on an incoming argument.
Locks::mutator_lock_->AssertSharedHeld(self);
diff --git a/runtime/entrypoints/quick/quick_lock_entrypoints.cc b/runtime/entrypoints/quick/quick_lock_entrypoints.cc
index 5bc7f4c..817d053 100644
--- a/runtime/entrypoints/quick/quick_lock_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_lock_entrypoints.cc
@@ -21,7 +21,8 @@
namespace art {
extern "C" int artLockObjectFromCode(mirror::Object* obj, Thread* self, mirror::ArtMethod** sp)
- EXCLUSIVE_LOCK_FUNCTION(monitor_lock_) {
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+ NO_THREAD_SAFETY_ANALYSIS /* EXCLUSIVE_LOCK_FUNCTION(Monitor::monitor_lock_) */ {
FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly);
if (UNLIKELY(obj == NULL)) {
ThrowLocation throw_location(self->GetCurrentLocationForThrow());
@@ -42,7 +43,8 @@
}
extern "C" int artUnlockObjectFromCode(mirror::Object* obj, Thread* self, mirror::ArtMethod** sp)
- UNLOCK_FUNCTION(monitor_lock_) {
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+ NO_THREAD_SAFETY_ANALYSIS /* UNLOCK_FUNCTION(Monitor::monitor_lock_) */ {
FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly);
if (UNLIKELY(obj == NULL)) {
ThrowLocation throw_location(self->GetCurrentLocationForThrow());