< prev index next >

src/hotspot/os_cpu/windows_x86/atomic_windows_x86.hpp

Print this page




  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_WINDOWS_X86_ATOMIC_WINDOWS_X86_HPP
  26 #define OS_CPU_WINDOWS_X86_ATOMIC_WINDOWS_X86_HPP
  27 
  28 #include "runtime/os.hpp"
  29 











  30 // The following alternative implementations are needed because
  31 // Windows 95 doesn't support (some of) the corresponding Windows NT
  32 // calls. Furthermore, these versions allow inlining in the caller.
  33 // (More precisely: The documentation for InterlockedExchange says
  34 // it is supported for Windows 95. However, when single-stepping
  35 // through the assembly code we cannot step into the routine and
  36 // when looking at the routine address we see only garbage code.
  37 // Better safe then sorry!). Was bug 7/31/98 (gri).
  38 //
  39 // Performance note: On uniprocessors, the 'lock' prefixes are not
  40 // necessary (and expensive). We should generate separate cases if
  41 // this becomes a performance problem.
  42 
  43 #pragma warning(disable: 4035) // Disables warnings reporting missing return statement
  44 
  45 template<size_t byte_size>
  46 struct Atomic::PlatformAdd
  47   : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> >
  48 {
  49   template<typename I, typename D>


 200   return dest;
 201 }
 202 
 203 template<>
 204 template<typename T>
 205 inline void Atomic::PlatformStore<8>::operator()(T store_value,
 206                                                  T volatile* dest) const {
 207   STATIC_ASSERT(8 == sizeof(T));
 208   volatile T* src = &store_value;
 209   __asm {
 210     mov eax, src
 211     fild     qword ptr [eax]
 212     mov eax, dest
 213     fistp    qword ptr [eax]
 214   }
 215 }
 216 
 217 #endif // AMD64
 218 
 219 #pragma warning(default: 4035) // Enables warnings reporting missing return statement









































 220 
 221 #endif // OS_CPU_WINDOWS_X86_ATOMIC_WINDOWS_X86_HPP


  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_WINDOWS_X86_ATOMIC_WINDOWS_X86_HPP
  26 #define OS_CPU_WINDOWS_X86_ATOMIC_WINDOWS_X86_HPP
  27 
  28 #include "runtime/os.hpp"
  29 
  30 // Note that in MSVC, volatile memory accesses are explicitly
  31 // guaranteed to have acquire release semantics (w.r.t. compiler
  32 // reordering) and therefore does not even need a compiler barrier
  33 // for normal acquire release accesses. And all generalized
  34 // bound calls like release_store go through OrderAccess::load
  35 // and OrderAccess::store which do volatile memory accesses.
  36 template<> inline void ScopedFence<X_ACQUIRE>::postfix()       { }
  37 template<> inline void ScopedFence<RELEASE_X>::prefix()        { }
  38 template<> inline void ScopedFence<RELEASE_X_FENCE>::prefix()  { }
  39 template<> inline void ScopedFence<RELEASE_X_FENCE>::postfix() { OrderAccess::fence(); }
  40 
  41 // The following alternative implementations are needed because
  42 // Windows 95 doesn't support (some of) the corresponding Windows NT
  43 // calls. Furthermore, these versions allow inlining in the caller.
  44 // (More precisely: The documentation for InterlockedExchange says
  45 // it is supported for Windows 95. However, when single-stepping
  46 // through the assembly code we cannot step into the routine and
  47 // when looking at the routine address we see only garbage code.
  48 // Better safe then sorry!). Was bug 7/31/98 (gri).
  49 //
  50 // Performance note: On uniprocessors, the 'lock' prefixes are not
  51 // necessary (and expensive). We should generate separate cases if
  52 // this becomes a performance problem.
  53 
  54 #pragma warning(disable: 4035) // Disables warnings reporting missing return statement
  55 
  56 template<size_t byte_size>
  57 struct Atomic::PlatformAdd
  58   : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> >
  59 {
  60   template<typename I, typename D>


 211   return dest;
 212 }
 213 
 214 template<>
 215 template<typename T>
 216 inline void Atomic::PlatformStore<8>::operator()(T store_value,
 217                                                  T volatile* dest) const {
 218   STATIC_ASSERT(8 == sizeof(T));
 219   volatile T* src = &store_value;
 220   __asm {
 221     mov eax, src
 222     fild     qword ptr [eax]
 223     mov eax, dest
 224     fistp    qword ptr [eax]
 225   }
 226 }
 227 
 228 #endif // AMD64
 229 
 230 #pragma warning(default: 4035) // Enables warnings reporting missing return statement
 231 
 232 #ifndef AMD64
 233 template<>
 234 struct Atomic::PlatformOrderedStore<1, RELEASE_X_FENCE>
 235 {
 236   template <typename T>
 237   void operator()(T v, volatile T* p) const {
 238     __asm {
 239       mov edx, p;
 240       mov al, v;
 241       xchg al, byte ptr [edx];
 242     }
 243   }
 244 };
 245 
 246 template<>
 247 struct Atomic::PlatformOrderedStore<2, RELEASE_X_FENCE>
 248 {
 249   template <typename T>
 250   void operator()(T v, volatile T* p) const {
 251     __asm {
 252       mov edx, p;
 253       mov ax, v;
 254       xchg ax, word ptr [edx];
 255     }
 256   }
 257 };
 258 
 259 template<>
 260 struct Atomic::PlatformOrderedStore<4, RELEASE_X_FENCE>
 261 {
 262   template <typename T>
 263   void operator()(T v, volatile T* p) const {
 264     __asm {
 265       mov edx, p;
 266       mov eax, v;
 267       xchg eax, dword ptr [edx];
 268     }
 269   }
 270 };
 271 #endif // AMD64
 272 
 273 #endif // OS_CPU_WINDOWS_X86_ATOMIC_WINDOWS_X86_HPP
< prev index next >