please help me about understanding method "OrderAccess::acquire() and OrderAccess::acquire()"
Kim Barrett
kim.barrett at oracle.com
Wed Oct 19 17:37:34 UTC 2016
> On Oct 19, 2016, at 8:35 AM, 恶灵骑士 <1072213404 at qq.com> wrote:
>
> 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
> }
FYI, this is an old implementation, which was replaced in JDK 9 more than a year and a half ago.
> 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