src/os_cpu/linux_x86/vm/orderAccess_linux_x86.inline.hpp

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 






  25 // Implementation of class OrderAccess.
  26 
  27 inline void OrderAccess::loadload()   { acquire(); }
  28 inline void OrderAccess::storestore() { release(); }
  29 inline void OrderAccess::loadstore()  { acquire(); }
  30 inline void OrderAccess::storeload()  { fence(); }
  31 
  32 inline void OrderAccess::acquire() {
  33   volatile intptr_t local_dummy;
  34 #ifdef AMD64
  35   __asm__ volatile ("movq 0(%%rsp), %0" : "=r" (local_dummy) : : "memory");
  36 #else
  37   __asm__ volatile ("movl 0(%%esp),%0" : "=r" (local_dummy) : : "memory");
  38 #endif // AMD64
  39 }
  40 
  41 inline void OrderAccess::release() {
  42   // Avoid hitting the same cache-line from
  43   // different threads.
  44   volatile jint local_dummy = 0;


 187 inline void     OrderAccess::release_store_ptr_fence(volatile intptr_t* p, intptr_t v) {
 188 #ifdef AMD64
 189   __asm__ __volatile__ (  "xchgq (%2), %0"
 190                           : "=r" (v)
 191                           : "0" (v), "r" (p)
 192                           : "memory");
 193 #else
 194   release_store_fence((volatile jint*)p, (jint)v);
 195 #endif // AMD64
 196 }
 197 inline void     OrderAccess::release_store_ptr_fence(volatile void*     p, void*    v) {
 198 #ifdef AMD64
 199   __asm__ __volatile__ (  "xchgq (%2), %0"
 200                           : "=r" (v)
 201                           : "0" (v), "r" (p)
 202                           : "memory");
 203 #else
 204   release_store_fence((volatile jint*)p, (jint)v);
 205 #endif // AMD64
 206 }




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef OS_CPU_LINUX_X86_VM_ORDERACCESS_LINUX_X86_INLINE_HPP
  26 #define OS_CPU_LINUX_X86_VM_ORDERACCESS_LINUX_X86_INLINE_HPP
  27 
  28 #include "runtime/orderAccess.hpp"
  29 #include "vm_version_x86.hpp"
  30 
  31 // Implementation of class OrderAccess.
  32 
  33 inline void OrderAccess::loadload()   { acquire(); }
  34 inline void OrderAccess::storestore() { release(); }
  35 inline void OrderAccess::loadstore()  { acquire(); }
  36 inline void OrderAccess::storeload()  { fence(); }
  37 
  38 inline void OrderAccess::acquire() {
  39   volatile intptr_t local_dummy;
  40 #ifdef AMD64
  41   __asm__ volatile ("movq 0(%%rsp), %0" : "=r" (local_dummy) : : "memory");
  42 #else
  43   __asm__ volatile ("movl 0(%%esp),%0" : "=r" (local_dummy) : : "memory");
  44 #endif // AMD64
  45 }
  46 
  47 inline void OrderAccess::release() {
  48   // Avoid hitting the same cache-line from
  49   // different threads.
  50   volatile jint local_dummy = 0;


 193 inline void     OrderAccess::release_store_ptr_fence(volatile intptr_t* p, intptr_t v) {
 194 #ifdef AMD64
 195   __asm__ __volatile__ (  "xchgq (%2), %0"
 196                           : "=r" (v)
 197                           : "0" (v), "r" (p)
 198                           : "memory");
 199 #else
 200   release_store_fence((volatile jint*)p, (jint)v);
 201 #endif // AMD64
 202 }
 203 inline void     OrderAccess::release_store_ptr_fence(volatile void*     p, void*    v) {
 204 #ifdef AMD64
 205   __asm__ __volatile__ (  "xchgq (%2), %0"
 206                           : "=r" (v)
 207                           : "0" (v), "r" (p)
 208                           : "memory");
 209 #else
 210   release_store_fence((volatile jint*)p, (jint)v);
 211 #endif // AMD64
 212 }
 213 
 214 #endif // OS_CPU_LINUX_X86_VM_ORDERACCESS_LINUX_X86_INLINE_HPP