`asm' in natObject.cc
Andrew Haley
aph@cambridge.redhat.com
Mon Dec 3 11:33:00 GMT 2001
Boehm, Hans writes:
> I think the memory clobber is necessary, since it's used to acquire or
> release a lock. Thus gcc shouldn't move other memory operations across the
> compare_and_swap, since that might move them out of the region in which the
> lock is held.
Yes, I see. The argument is that even though other memory references
aren't volatile they still must never be moved across the locking
code. Clobbering all of memory acheives this.
> To be honest, I'm not sure why the __volatile__ is needed, or whether it has
> any real effect beyond the memory clobber.
It's probably unnecessary and does no harm.
Andrew.
More information about the Java
mailing list