diff src/os_cpu/solaris_x86/vm/atomic_solaris_x86.inline.hpp @ 1547:fb1a39993f69

6951319: enable solaris builds using Sun Studio 12 update 1 Reviewed-by: kamg, ysr, dholmes, johnc
author jcoomes
date Tue, 18 May 2010 11:02:18 -0700
parents 89e0543e1737
children c18cbe5936b8
line wrap: on
line diff
--- a/src/os_cpu/solaris_x86/vm/atomic_solaris_x86.inline.hpp	Mon May 17 00:47:28 2010 -0700
+++ b/src/os_cpu/solaris_x86/vm/atomic_solaris_x86.inline.hpp	Tue May 18 11:02:18 2010 -0700
@@ -47,40 +47,56 @@
 // For Sun Studio - implementation is in solaris_x86_[32/64].il.
 // For gcc - implementation is just below.
 
-extern "C" jint _Atomic_add(jint add_value, volatile jint* dest, int mp);
-extern "C" jint _Atomic_xchg(jint exchange_value, volatile jint* dest);
-extern "C" jint _Atomic_cmpxchg(jint exchange_value, volatile jint* dest, jint compare_value, int mp);
-extern "C" jlong _Atomic_cmpxchg_long(jlong exchange_value, volatile jlong* dest, jlong compare_value, int mp);
+// The lock prefix can be omitted for certain instructions on uniprocessors; to
+// facilitate this, os::is_MP() is passed as an additional argument.  64-bit
+// processors are assumed to be multi-threaded and/or multi-core, so the extra
+// argument is unnecessary.
+#ifndef _LP64
+#define IS_MP_DECL() , int is_mp
+#define IS_MP_ARG()  , (int) os::is_MP()
+#else
+#define IS_MP_DECL()
+#define IS_MP_ARG()
+#endif // _LP64
+
+extern "C" {
+  jint _Atomic_add(jint add_value, volatile jint* dest IS_MP_DECL());
+  jint _Atomic_xchg(jint exchange_value, volatile jint* dest);
+  jint _Atomic_cmpxchg(jint exchange_value, volatile jint* dest,
+                       jint compare_value IS_MP_DECL());
+  jlong _Atomic_cmpxchg_long(jlong exchange_value, volatile jlong* dest,
+                             jlong compare_value IS_MP_DECL());
+}
 
 inline jint     Atomic::add    (jint     add_value, volatile jint*     dest) {
-  return _Atomic_add(add_value, dest, (int) os::is_MP());
+  return _Atomic_add(add_value, dest IS_MP_ARG());
+}
+
+inline jint     Atomic::xchg       (jint     exchange_value, volatile jint*     dest) {
+  return _Atomic_xchg(exchange_value, dest);
 }
 
 inline jint     Atomic::cmpxchg    (jint     exchange_value, volatile jint*     dest, jint     compare_value) {
-  return _Atomic_cmpxchg(exchange_value, dest, compare_value, (int) os::is_MP());
+  return _Atomic_cmpxchg(exchange_value, dest, compare_value IS_MP_ARG());
 }
 
 inline jlong    Atomic::cmpxchg    (jlong    exchange_value, volatile jlong*    dest, jlong    compare_value) {
-  return _Atomic_cmpxchg_long(exchange_value, dest, compare_value, (int) os::is_MP());
+  return _Atomic_cmpxchg_long(exchange_value, dest, compare_value IS_MP_ARG());
 }
 
 
 #ifdef AMD64
 inline void Atomic::store    (jlong    store_value, jlong*             dest) { *dest = store_value; }
 inline void Atomic::store    (jlong    store_value, volatile jlong*    dest) { *dest = store_value; }
-extern "C" jlong _Atomic_add_long(jlong add_value, volatile jlong* dest, int mp);
+extern "C" jlong _Atomic_add_long(jlong add_value, volatile jlong* dest);
 extern "C" jlong _Atomic_xchg_long(jlong exchange_value, volatile jlong* dest);
 
 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
-  return (intptr_t)_Atomic_add_long((jlong)add_value, (volatile jlong*)dest, (int) os::is_MP());
+  return (intptr_t)_Atomic_add_long((jlong)add_value, (volatile jlong*)dest);
 }
 
 inline void*    Atomic::add_ptr(intptr_t add_value, volatile void*     dest) {
-  return (void*)_Atomic_add_long((jlong)add_value, (volatile jlong*)dest, (int) os::is_MP());
-}
-
-inline jint     Atomic::xchg    (jint     exchange_value, volatile jint*     dest) {
-  return _Atomic_xchg(exchange_value, dest);
+  return (void*)_Atomic_add_long((jlong)add_value, (volatile jlong*)dest);
 }
 
 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
@@ -92,11 +108,11 @@
 }
 
 inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) {
-  return (intptr_t)_Atomic_cmpxchg_long((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value, (int) os::is_MP());
+  return (intptr_t)_Atomic_cmpxchg_long((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value);
 }
 
 inline void*    Atomic::cmpxchg_ptr(void*    exchange_value, volatile void*     dest, void*    compare_value) {
-  return (void*)_Atomic_cmpxchg_long((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value, (int) os::is_MP());
+  return (void*)_Atomic_cmpxchg_long((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value);
 }
 
 inline jlong Atomic::load(volatile jlong* src) { return *src; }
@@ -111,13 +127,6 @@
   return (void*)add((jint)add_value, (volatile jint*)dest);
 }
 
-inline jint     Atomic::xchg    (jint     exchange_value, volatile jint*     dest) {
-  // We noticed a CC5.5 bug (4894807), so keep calling the stub just to be safe.
-  // Will use the inline template version after 4894807 is fixed.
-  // return _Atomic_xchg(exchange_value, dest);
-  return (*os::atomic_xchg_func)(exchange_value, dest);
-}
-
 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
   return (intptr_t)xchg((jint)exchange_value, (volatile jint*)dest);
 }
@@ -179,9 +188,6 @@
 #endif // AMD64
 
   inline jint _Atomic_xchg(jint exchange_value, volatile jint* dest) {
-
-    // 32bit version originally did nothing!!
-
     __asm__ __volatile__ ("xchgl (%2),%0"
                           : "=r" (exchange_value)
                         : "0" (exchange_value), "r" (dest)