help understanding lock instruction in OrderAccess::fence()

恶灵骑士 1072213404 at
Tue Nov 8 08:48:44 UTC 2016

inline void OrderAccess::fence() {
  if (os::is_MP()) {
    // always use locked addl since mfence is sometimes expensive
#ifdef AMD64
    __asm__ volatile ("lock; addl $0,0(%%rsp)" : : : "cc", "memory");
    __asm__ volatile ("lock; addl $0,0(%%esp)" : : : "cc", "memory");

my classmates think that code “addl $0,0(%%esp)” having some specific effect,
because esp points to the top of stack .
it that true ?
or the code “addl $0,0(%%esp)”  just equals no op, 
needing one operation after lock at least,  otherwise  lock instruction will produce an error .

Thank you !


More information about the hotspot-dev mailing list