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/AtomicCache.c b/vm/AtomicCache.c
index f91de1e..b4f9862 100644
--- a/vm/AtomicCache.c
+++ b/vm/AtomicCache.c
@@ -105,8 +105,9 @@
* the version counter (at 2^31). Probably not a real concern.
*/
if ((firstVersion & ATOMIC_LOCK_FLAG) != 0 ||
- !ATOMIC_CMP_SWAP((volatile s4*) &pEntry->version,
- firstVersion, firstVersion | ATOMIC_LOCK_FLAG))
+ android_atomic_release_cas(
+ firstVersion, firstVersion | ATOMIC_LOCK_FLAG,
+ (volatile s4*) &pEntry->version) != 0)
{
/*
* We couldn't get the write lock. Return without updating the table.
@@ -130,7 +131,7 @@
/* volatile incr */
pEntry->version++;
- MEM_BARRIER();
+ ANDROID_MEMBAR_FULL();
pEntry->key1 = key1;
pEntry->key2 = key2;
@@ -138,15 +139,16 @@
/* volatile incr */
pEntry->version++;
- MEM_BARRIER();
+ ANDROID_MEMBAR_FULL();
/*
* Clear the lock flag. Nobody else should have been able to modify
* pEntry->version, so if this fails the world is broken.
*/
firstVersion += 2;
- if (!ATOMIC_CMP_SWAP((volatile s4*) &pEntry->version,
- firstVersion | ATOMIC_LOCK_FLAG, firstVersion))
+ if (android_atomic_release_cas(
+ firstVersion | ATOMIC_LOCK_FLAG, firstVersion,
+ (volatile s4*) &pEntry->version) != 0)
{
//LOGE("unable to reset the instanceof cache ownership\n");
dvmAbort();