Support for contention logging with ART futexes.

Remove dangerous postfix operators on AtomicInteger. Clean up the atomic stack.
Factor nanosleep into a useful shared utils.h routine.

Change-Id: I417a73007c23fe247f410f41b2fa41a717c22139
diff --git a/src/gc/atomic_stack.h b/src/gc/atomic_stack.h
index 8de5e35..cd1781d 100644
--- a/src/gc/atomic_stack.h
+++ b/src/gc/atomic_stack.h
@@ -57,12 +57,14 @@
 
   // Returns false if we overflowed the stack.
   bool AtomicPushBack(const T& value) {
-    const int32_t index = back_index_++;
-    if (UNLIKELY(static_cast<size_t>(index) >= capacity_)) {
-      // Stack overflow.
-      back_index_--;
-      return false;
-    }
+    int32_t index;
+    do {
+      index = back_index_;
+      if (UNLIKELY(static_cast<size_t>(index) >= capacity_)) {
+        // Stack overflow.
+        return false;
+      }
+    } while(!back_index_.CompareAndSwap(index, index + 1));
     begin_[index] = value;
     return true;
   }
@@ -81,13 +83,6 @@
     return begin_[back_index_];
   }
 
-  T AtomicPopBack() {
-    // Decrement the back index non atomically.
-    int back_index = back_index_--;
-    DCHECK_GT(back_index, front_index_);
-    return begin_[back_index - 1];
-  }
-
   // Take an item from the front of the stack.
   T PopFront() {
     int32_t index = front_index_;