Atomic op cleanup.
Replaced VM-local macros for barrier and CAS calls with the actual
versions provided by cutils.
ATOMIC_CMP_SWAP(addr,old,new) --> android_atomic_release_cas(old,new,addr)
MEM_BARRIER --> ANDROID_MEMBAR_FULL
Renamed android_quasiatomic* to dvmQuasiAtomic*.
Didn't change how anything works, just the names.
Change-Id: I8c68f28e1f7c9cb832183e0918d097dfe6a2cac8
diff --git a/vm/Sync.c b/vm/Sync.c
index 8f906ac..5380f3e 100644
--- a/vm/Sync.c
+++ b/vm/Sync.c
@@ -170,8 +170,8 @@
/* replace the head of the list with the new monitor */
do {
mon->next = gDvm.monitorList;
- } while (!ATOMIC_CMP_SWAP((int32_t*)(void*)&gDvm.monitorList,
- (int32_t)mon->next, (int32_t)mon));
+ } while (android_atomic_release_cas((int32_t)mon->next, (int32_t)mon,
+ (int32_t*)(void*)&gDvm.monitorList) != 0);
return mon;
}
@@ -894,7 +894,7 @@
thin &= LW_HASH_STATE_MASK << LW_HASH_STATE_SHIFT;
thin |= (u4)mon | LW_SHAPE_FAT;
/* Publish the updated lock word. */
- MEM_BARRIER();
+ ANDROID_MEMBAR_FULL();
obj->lock = thin;
}
@@ -937,7 +937,8 @@
* will have tried this before calling out to the VM.
*/
newThin = thin | (threadId << LW_LOCK_OWNER_SHIFT);
- if (!ATOMIC_CMP_SWAP((int32_t *)thinp, thin, newThin)) {
+ if (android_atomic_release_cas(thin, newThin,
+ (int32_t*)thinp) != 0) {
/*
* The acquire failed. Try again.
*/
@@ -969,8 +970,8 @@
* owner field.
*/
newThin = thin | (threadId << LW_LOCK_OWNER_SHIFT);
- if (ATOMIC_CMP_SWAP((int32_t *)thinp,
- thin, newThin)) {
+ if (android_atomic_release_cas(thin, newThin,
+ (int32_t *)thinp) == 0) {
/*
* The acquire succeed. Break out of the
* loop and proceed to inflate the lock.
@@ -1291,7 +1292,7 @@
* something.
*/
thread->interrupted = true;
- MEM_BARRIER();
+ ANDROID_MEMBAR_FULL();
/*
* Is the thread waiting?
@@ -1379,9 +1380,10 @@
*/
lock = DVM_LOCK_INITIAL_THIN_VALUE;
lock |= (LW_HASH_STATE_HASHED << LW_HASH_STATE_SHIFT);
- if (ATOMIC_CMP_SWAP((int32_t *)lw,
+ if (android_atomic_release_cas(
(int32_t)DVM_LOCK_INITIAL_THIN_VALUE,
- (int32_t)lock)) {
+ (int32_t)lock,
+ (int32_t *)lw) == 0) {
/*
* A new lockword has been installed with a hash state
* of hashed. Use the raw object address.