Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
1546:a00b51b2dda4 | 1547:fb1a39993f69 |
---|---|
45 inline void Atomic::dec_ptr(volatile void* dest) { (void)add_ptr(-1, dest); } | 45 inline void Atomic::dec_ptr(volatile void* dest) { (void)add_ptr(-1, dest); } |
46 | 46 |
47 // For Sun Studio - implementation is in solaris_x86_[32/64].il. | 47 // For Sun Studio - implementation is in solaris_x86_[32/64].il. |
48 // For gcc - implementation is just below. | 48 // For gcc - implementation is just below. |
49 | 49 |
50 extern "C" jint _Atomic_add(jint add_value, volatile jint* dest, int mp); | 50 // The lock prefix can be omitted for certain instructions on uniprocessors; to |
51 extern "C" jint _Atomic_xchg(jint exchange_value, volatile jint* dest); | 51 // facilitate this, os::is_MP() is passed as an additional argument. 64-bit |
52 extern "C" jint _Atomic_cmpxchg(jint exchange_value, volatile jint* dest, jint compare_value, int mp); | 52 // processors are assumed to be multi-threaded and/or multi-core, so the extra |
53 extern "C" jlong _Atomic_cmpxchg_long(jlong exchange_value, volatile jlong* dest, jlong compare_value, int mp); | 53 // argument is unnecessary. |
54 #ifndef _LP64 | |
55 #define IS_MP_DECL() , int is_mp | |
56 #define IS_MP_ARG() , (int) os::is_MP() | |
57 #else | |
58 #define IS_MP_DECL() | |
59 #define IS_MP_ARG() | |
60 #endif // _LP64 | |
61 | |
62 extern "C" { | |
63 jint _Atomic_add(jint add_value, volatile jint* dest IS_MP_DECL()); | |
64 jint _Atomic_xchg(jint exchange_value, volatile jint* dest); | |
65 jint _Atomic_cmpxchg(jint exchange_value, volatile jint* dest, | |
66 jint compare_value IS_MP_DECL()); | |
67 jlong _Atomic_cmpxchg_long(jlong exchange_value, volatile jlong* dest, | |
68 jlong compare_value IS_MP_DECL()); | |
69 } | |
54 | 70 |
55 inline jint Atomic::add (jint add_value, volatile jint* dest) { | 71 inline jint Atomic::add (jint add_value, volatile jint* dest) { |
56 return _Atomic_add(add_value, dest, (int) os::is_MP()); | 72 return _Atomic_add(add_value, dest IS_MP_ARG()); |
73 } | |
74 | |
75 inline jint Atomic::xchg (jint exchange_value, volatile jint* dest) { | |
76 return _Atomic_xchg(exchange_value, dest); | |
57 } | 77 } |
58 | 78 |
59 inline jint Atomic::cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value) { | 79 inline jint Atomic::cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value) { |
60 return _Atomic_cmpxchg(exchange_value, dest, compare_value, (int) os::is_MP()); | 80 return _Atomic_cmpxchg(exchange_value, dest, compare_value IS_MP_ARG()); |
61 } | 81 } |
62 | 82 |
63 inline jlong Atomic::cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value) { | 83 inline jlong Atomic::cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value) { |
64 return _Atomic_cmpxchg_long(exchange_value, dest, compare_value, (int) os::is_MP()); | 84 return _Atomic_cmpxchg_long(exchange_value, dest, compare_value IS_MP_ARG()); |
65 } | 85 } |
66 | 86 |
67 | 87 |
68 #ifdef AMD64 | 88 #ifdef AMD64 |
69 inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; } | 89 inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; } |
70 inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; } | 90 inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; } |
71 extern "C" jlong _Atomic_add_long(jlong add_value, volatile jlong* dest, int mp); | 91 extern "C" jlong _Atomic_add_long(jlong add_value, volatile jlong* dest); |
72 extern "C" jlong _Atomic_xchg_long(jlong exchange_value, volatile jlong* dest); | 92 extern "C" jlong _Atomic_xchg_long(jlong exchange_value, volatile jlong* dest); |
73 | 93 |
74 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { | 94 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { |
75 return (intptr_t)_Atomic_add_long((jlong)add_value, (volatile jlong*)dest, (int) os::is_MP()); | 95 return (intptr_t)_Atomic_add_long((jlong)add_value, (volatile jlong*)dest); |
76 } | 96 } |
77 | 97 |
78 inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) { | 98 inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) { |
79 return (void*)_Atomic_add_long((jlong)add_value, (volatile jlong*)dest, (int) os::is_MP()); | 99 return (void*)_Atomic_add_long((jlong)add_value, (volatile jlong*)dest); |
80 } | |
81 | |
82 inline jint Atomic::xchg (jint exchange_value, volatile jint* dest) { | |
83 return _Atomic_xchg(exchange_value, dest); | |
84 } | 100 } |
85 | 101 |
86 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) { | 102 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) { |
87 return (intptr_t)_Atomic_xchg_long((jlong)exchange_value, (volatile jlong*)dest); | 103 return (intptr_t)_Atomic_xchg_long((jlong)exchange_value, (volatile jlong*)dest); |
88 } | 104 } |
90 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) { | 106 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) { |
91 return (void*)_Atomic_xchg_long((jlong)exchange_value, (volatile jlong*)dest); | 107 return (void*)_Atomic_xchg_long((jlong)exchange_value, (volatile jlong*)dest); |
92 } | 108 } |
93 | 109 |
94 inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) { | 110 inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) { |
95 return (intptr_t)_Atomic_cmpxchg_long((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value, (int) os::is_MP()); | 111 return (intptr_t)_Atomic_cmpxchg_long((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value); |
96 } | 112 } |
97 | 113 |
98 inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value) { | 114 inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value) { |
99 return (void*)_Atomic_cmpxchg_long((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value, (int) os::is_MP()); | 115 return (void*)_Atomic_cmpxchg_long((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value); |
100 } | 116 } |
101 | 117 |
102 inline jlong Atomic::load(volatile jlong* src) { return *src; } | 118 inline jlong Atomic::load(volatile jlong* src) { return *src; } |
103 | 119 |
104 #else // !AMD64 | 120 #else // !AMD64 |
107 return (intptr_t)add((jint)add_value, (volatile jint*)dest); | 123 return (intptr_t)add((jint)add_value, (volatile jint*)dest); |
108 } | 124 } |
109 | 125 |
110 inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) { | 126 inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) { |
111 return (void*)add((jint)add_value, (volatile jint*)dest); | 127 return (void*)add((jint)add_value, (volatile jint*)dest); |
112 } | |
113 | |
114 inline jint Atomic::xchg (jint exchange_value, volatile jint* dest) { | |
115 // We noticed a CC5.5 bug (4894807), so keep calling the stub just to be safe. | |
116 // Will use the inline template version after 4894807 is fixed. | |
117 // return _Atomic_xchg(exchange_value, dest); | |
118 return (*os::atomic_xchg_func)(exchange_value, dest); | |
119 } | 128 } |
120 | 129 |
121 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) { | 130 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) { |
122 return (intptr_t)xchg((jint)exchange_value, (volatile jint*)dest); | 131 return (intptr_t)xchg((jint)exchange_value, (volatile jint*)dest); |
123 } | 132 } |
177 } | 186 } |
178 | 187 |
179 #endif // AMD64 | 188 #endif // AMD64 |
180 | 189 |
181 inline jint _Atomic_xchg(jint exchange_value, volatile jint* dest) { | 190 inline jint _Atomic_xchg(jint exchange_value, volatile jint* dest) { |
182 | |
183 // 32bit version originally did nothing!! | |
184 | |
185 __asm__ __volatile__ ("xchgl (%2),%0" | 191 __asm__ __volatile__ ("xchgl (%2),%0" |
186 : "=r" (exchange_value) | 192 : "=r" (exchange_value) |
187 : "0" (exchange_value), "r" (dest) | 193 : "0" (exchange_value), "r" (dest) |
188 : "memory"); | 194 : "memory"); |
189 return exchange_value; | 195 return exchange_value; |