CVMstoreImpl assembly code
I have two questions about CVMstoreImpl in src/linux-arm/javavm/include/sync_arch.h.
/* NOTE: CVMmicrolockUnlock() could conceptually be implemented using a
a normal assignment statement. It is implemented using a call to
CVMatomicSwapImpl() instead to enforce the 'volatile' status of the
lockWord. Calling a function to set it ensures that it is done at
the location that the programmer intended and not shuffled around
by the compiler. */
#define CVMmicrolockUnlock(m) \
static inline void
CVMstoreImpl(CVMAddr new_value, volatile CVMAddr *addr)
asm volatile (
"str %1, [%2];"
"ldr %0, [%2]"
: "=r" (scratch)
: "r" (new_value), "r" (addr)
/* clobber? */);
str new_value, [addr];
ldr scratch, [addr]
Why "ldr %0, [%2]" is needed?
There is no use for variable scratch.
The comment says, CVMmicrolockUnlock is implemented using a call to CVMatomicSwapImpl() to enforce the "volatile" status of the lockword.
As far as I know, inline function does not have its own body. And
CVMstoreImple is inline function. Therefore, instuctions of CVMstoreImpl may be moved to the location that the programmer did not intend. Is it right?