Add uninterruptible role

Example error:
cannot call function 'CopyOf' while mutex 'uninterruptible_' is held

TODO: Add annotation to more locations.

Bug: 20072211

Change-Id: I1bbf5a77e3deeafa5898df529cb7cb53a6d010d2
diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h
index 6f82f28..d0504d9 100644
--- a/runtime/base/mutex.h
+++ b/runtime/base/mutex.h
@@ -471,11 +471,11 @@
 // upon destruction.
 class SCOPED_CAPABILITY MutexLock {
  public:
-  explicit MutexLock(Thread* self, Mutex& mu) EXCLUSIVE_LOCK_FUNCTION(mu) : self_(self), mu_(mu) {
+  explicit MutexLock(Thread* self, Mutex& mu) ACQUIRE(mu) : self_(self), mu_(mu) {
     mu_.ExclusiveLock(self_);
   }
 
-  ~MutexLock() UNLOCK_FUNCTION() {
+  ~MutexLock() RELEASE() {
     mu_.ExclusiveUnlock(self_);
   }
 
@@ -491,12 +491,12 @@
 // construction and releases it upon destruction.
 class SCOPED_CAPABILITY ReaderMutexLock {
  public:
-  explicit ReaderMutexLock(Thread* self, ReaderWriterMutex& mu) EXCLUSIVE_LOCK_FUNCTION(mu) :
+  explicit ReaderMutexLock(Thread* self, ReaderWriterMutex& mu) ACQUIRE(mu) :
       self_(self), mu_(mu) {
     mu_.SharedLock(self_);
   }
 
-  ~ReaderMutexLock() UNLOCK_FUNCTION() {
+  ~ReaderMutexLock() RELEASE() {
     mu_.SharedUnlock(self_);
   }
 
@@ -531,6 +531,17 @@
 // "WriterMutexLock mu(lock)".
 #define WriterMutexLock(x) static_assert(0, "WriterMutexLock declaration missing variable name")
 
+// For StartNoThreadSuspension and EndNoThreadSuspension.
+class CAPABILITY("role") Role {
+ public:
+  void Acquire() ACQUIRE() {}
+  void Release() RELEASE() {}
+  const Role& operator!() const { return *this; }
+};
+
+class Uninterruptible : public Role {
+};
+
 // Global mutexes corresponding to the levels above.
 class Locks {
  public:
@@ -666,6 +677,11 @@
   static Mutex* lambda_table_lock_ ACQUIRED_AFTER(mutator_lock_);
 };
 
+class Roles {
+ public:
+  static Uninterruptible uninterruptible_;
+};
+
 }  // namespace art
 
 #endif  // ART_RUNTIME_BASE_MUTEX_H_