please help me about understanding method "OrderAccess::acquire() and OrderAccess::acquire()"

恶灵骑士 1072213404 at qq.com
Wed Oct 19 12:35:32 UTC 2016


src/os_cpu/linux_x86/vm/orderAccess_linux_x86.inline.hpp
inline void OrderAccess::acquire() {
  volatile intptr_t local_dummy;
#ifdef AMD64
  __asm__ volatile ("movq 0(%%rsp), %0" : "=r" (local_dummy) : : "memory");
#else
  __asm__ volatile ("movl 0(%%esp),%0" : "=r" (local_dummy) : : "memory");
#endif // AMD64
}


inline void OrderAccess::acquire() {
  // Avoid hitting the same cache-line from
  // different threads.
  volatile jint local_dummy = 0;
}


I have a few questions:
1,does gcc support the c++ keyword 'volatile' aquire/release sematics?


if question 1's answer is 'yes', then i can understand the implemetation of
method 'OrderAccess::acquire()',


2, about the part 0f ' __asm__ volatile ("movq 0(%%rsp), %0" : "=r" (local_dummy) : : "memory");'
the 'volatile' prevents compiler optimize,
the 'memory' ensure compiler no-reordering,


then what about ""movq 0(%%rsp), %0" : "=r" (local_dummy) "? what's this part effect? and the local_dummywas declared as 'volatile ',is it necessary?


thank you so so much!


More information about the hotspot-dev mailing list