annotate src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.inline.hpp @ 2140:85c73c0edb06

7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API Summary: Use LDX/STX on v9 and LDD/STD on v8 sparc for volatile long moves. Reviewed-by: never
author kvn
date Tue, 18 Jan 2011 17:10:03 -0800
parents f95d63e2154a
children f7de3327c683
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2140
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef OS_CPU_SOLARIS_SPARC_VM_ATOMIC_SOLARIS_SPARC_INLINE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define OS_CPU_SOLARIS_SPARC_VM_ATOMIC_SOLARIS_SPARC_INLINE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "orderAccess_solaris_sparc.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "runtime/atomic.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "runtime/os.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "vm_version_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Implementation of class atomic
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 inline void Atomic::store (jbyte store_value, jbyte* dest) { *dest = store_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
36 inline void Atomic::store (jshort store_value, jshort* dest) { *dest = store_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
37 inline void Atomic::store (jint store_value, jint* dest) { *dest = store_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
38 inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
39 inline void Atomic::store_ptr(void* store_value, void* dest) { *(void**)dest = store_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 inline void Atomic::store (jbyte store_value, volatile jbyte* dest) { *dest = store_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
42 inline void Atomic::store (jshort store_value, volatile jshort* dest) { *dest = store_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
43 inline void Atomic::store (jint store_value, volatile jint* dest) { *dest = store_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
44 inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
45 inline void Atomic::store_ptr(void* store_value, volatile void* dest) { *(void* volatile *)dest = store_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 inline void Atomic::inc (volatile jint* dest) { (void)add (1, dest); }
a61af66fc99e Initial load
duke
parents:
diff changeset
48 inline void Atomic::inc_ptr(volatile intptr_t* dest) { (void)add_ptr(1, dest); }
a61af66fc99e Initial load
duke
parents:
diff changeset
49 inline void Atomic::inc_ptr(volatile void* dest) { (void)add_ptr(1, dest); }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 inline void Atomic::dec (volatile jint* dest) { (void)add (-1, dest); }
a61af66fc99e Initial load
duke
parents:
diff changeset
52 inline void Atomic::dec_ptr(volatile intptr_t* dest) { (void)add_ptr(-1, dest); }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 inline void Atomic::dec_ptr(volatile void* dest) { (void)add_ptr(-1, dest); }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
2140
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
55
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
56 #ifdef _LP64
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
57
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
58 inline void Atomic::store(jlong store_value, jlong* dest) { *dest = store_value; }
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
59 inline void Atomic::store(jlong store_value, volatile jlong* dest) { *dest = store_value; }
894
665be97e8704 6863420: os::javaTimeNanos() go backward on Solaris x86
kvn
parents: 0
diff changeset
60 inline jlong Atomic::load(volatile jlong* src) { return *src; }
665be97e8704 6863420: os::javaTimeNanos() go backward on Solaris x86
kvn
parents: 0
diff changeset
61
2140
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
62 #else
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
63
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
64 extern "C" void _Atomic_move_long_v8(volatile jlong* src, volatile jlong* dst);
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
65 extern "C" void _Atomic_move_long_v9(volatile jlong* src, volatile jlong* dst);
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
66
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
67 inline void Atomic_move_long(volatile jlong* src, volatile jlong* dst) {
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
68 #ifdef COMPILER2
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
69 // Compiler2 does not support v8, it is used only for v9.
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
70 assert (VM_Version::v9_instructions_work(), "only supported on v9");
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
71 _Atomic_move_long_v9(src, dst);
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
72 #else
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
73 // The branch is cheaper then emulated LDD.
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
74 if (VM_Version::v9_instructions_work()) {
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
75 _Atomic_move_long_v9(src, dst);
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
76 } else {
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
77 _Atomic_move_long_v8(src, dst);
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
78 }
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
79 #endif
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
80 }
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
81
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
82 inline jlong Atomic::load(volatile jlong* src) {
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
83 volatile jlong dest;
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
84 Atomic_move_long(src, &dest);
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
85 return dest;
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
86 }
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
87
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
88 inline void Atomic::store(jlong store_value, jlong* dest) {
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
89 Atomic_move_long((volatile jlong*)&store_value, (volatile jlong*)dest);
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
90 }
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
91
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
92 inline void Atomic::store(jlong store_value, volatile jlong* dest) {
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
93 Atomic_move_long((volatile jlong*)&store_value, dest);
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
94 }
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
95
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
96 #endif
85c73c0edb06 7012965: Fix failed on sparc for 7009756: volatile variables could be broken throw reflection API
kvn
parents: 1972
diff changeset
97
0
a61af66fc99e Initial load
duke
parents:
diff changeset
98 #ifdef _GNU_SOURCE
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 inline jint Atomic::add (jint add_value, volatile jint* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 intptr_t rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 __asm__ volatile(
a61af66fc99e Initial load
duke
parents:
diff changeset
103 "1: \n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
104 " ld [%2], %%o2\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
105 " add %1, %%o2, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
106 " cas [%2], %%o2, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
107 " cmp %%o2, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
108 " bne 1b\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
109 " nop\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
110 " add %1, %%o2, %0\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
111 : "=r" (rv)
a61af66fc99e Initial load
duke
parents:
diff changeset
112 : "r" (add_value), "r" (dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
113 : "memory", "o2", "o3");
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 intptr_t rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
120 __asm__ volatile(
a61af66fc99e Initial load
duke
parents:
diff changeset
121 "1: \n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
122 " ldx [%2], %%o2\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
123 " add %0, %%o2, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
124 " casx [%2], %%o2, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
125 " cmp %%o2, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
126 " bne %%xcc, 1b\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
127 " nop\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
128 " add %0, %%o2, %0\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
129 : "=r" (rv)
a61af66fc99e Initial load
duke
parents:
diff changeset
130 : "r" (add_value), "r" (dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
131 : "memory", "o2", "o3");
a61af66fc99e Initial load
duke
parents:
diff changeset
132 #else //_LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
133 __asm__ volatile(
a61af66fc99e Initial load
duke
parents:
diff changeset
134 "1: \n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
135 " ld [%2], %%o2\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
136 " add %1, %%o2, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
137 " cas [%2], %%o2, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
138 " cmp %%o2, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
139 " bne 1b\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
140 " nop\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
141 " add %1, %%o2, %0\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
142 : "=r" (rv)
a61af66fc99e Initial load
duke
parents:
diff changeset
143 : "r" (add_value), "r" (dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
144 : "memory", "o2", "o3");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 return (void*)add_ptr((intptr_t)add_value, (volatile intptr_t*)dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 inline jint Atomic::xchg (jint exchange_value, volatile jint* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 intptr_t rv = exchange_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 __asm__ volatile(
a61af66fc99e Initial load
duke
parents:
diff changeset
157 " swap [%2],%1\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
158 : "=r" (rv)
a61af66fc99e Initial load
duke
parents:
diff changeset
159 : "0" (exchange_value) /* we use same register as for return value */, "r" (dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
160 : "memory");
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 intptr_t rv = exchange_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
167 __asm__ volatile(
a61af66fc99e Initial load
duke
parents:
diff changeset
168 "1:\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
169 " mov %1, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
170 " ldx [%2], %%o2\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
171 " casx [%2], %%o2, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
172 " cmp %%o2, %%o3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
173 " bne %%xcc, 1b\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
174 " nop\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
175 " mov %%o2, %0\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
176 : "=r" (rv)
a61af66fc99e Initial load
duke
parents:
diff changeset
177 : "r" (exchange_value), "r" (dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
178 : "memory", "o2", "o3");
a61af66fc99e Initial load
duke
parents:
diff changeset
179 #else //_LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
180 __asm__ volatile(
a61af66fc99e Initial load
duke
parents:
diff changeset
181 "swap [%2],%1\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
182 : "=r" (rv)
a61af66fc99e Initial load
duke
parents:
diff changeset
183 : "0" (exchange_value) /* we use same register as for return value */, "r" (dest)
a61af66fc99e Initial load
duke
parents:
diff changeset
184 : "memory");
a61af66fc99e Initial load
duke
parents:
diff changeset
185 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 inline jint Atomic::cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 jint rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 __asm__ volatile(
a61af66fc99e Initial load
duke
parents:
diff changeset
197 " cas [%2], %3, %0"
a61af66fc99e Initial load
duke
parents:
diff changeset
198 : "=r" (rv)
a61af66fc99e Initial load
duke
parents:
diff changeset
199 : "0" (exchange_value), "r" (dest), "r" (compare_value)
a61af66fc99e Initial load
duke
parents:
diff changeset
200 : "memory");
a61af66fc99e Initial load
duke
parents:
diff changeset
201 return rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 inline jlong Atomic::cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
206 jlong rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 __asm__ volatile(
a61af66fc99e Initial load
duke
parents:
diff changeset
208 " casx [%2], %3, %0"
a61af66fc99e Initial load
duke
parents:
diff changeset
209 : "=r" (rv)
a61af66fc99e Initial load
duke
parents:
diff changeset
210 : "0" (exchange_value), "r" (dest), "r" (compare_value)
a61af66fc99e Initial load
duke
parents:
diff changeset
211 : "memory");
a61af66fc99e Initial load
duke
parents:
diff changeset
212 return rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 #else //_LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
214 assert(VM_Version::v9_instructions_work(), "cas only supported on v9");
a61af66fc99e Initial load
duke
parents:
diff changeset
215 volatile jlong_accessor evl, cvl, rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 evl.long_value = exchange_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
217 cvl.long_value = compare_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 __asm__ volatile(
a61af66fc99e Initial load
duke
parents:
diff changeset
220 " sllx %2, 32, %2\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
221 " srl %3, 0, %3\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
222 " or %2, %3, %2\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
223 " sllx %5, 32, %5\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
224 " srl %6, 0, %6\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
225 " or %5, %6, %5\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
226 " casx [%4], %5, %2\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
227 " srl %2, 0, %1\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
228 " srlx %2, 32, %0\n\t"
a61af66fc99e Initial load
duke
parents:
diff changeset
229 : "=r" (rv.words[0]), "=r" (rv.words[1])
a61af66fc99e Initial load
duke
parents:
diff changeset
230 : "r" (evl.words[0]), "r" (evl.words[1]), "r" (dest), "r" (cvl.words[0]), "r" (cvl.words[1])
a61af66fc99e Initial load
duke
parents:
diff changeset
231 : "memory");
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 return rv.long_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
234 #endif //_LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 intptr_t rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
240 __asm__ volatile(
a61af66fc99e Initial load
duke
parents:
diff changeset
241 " casx [%2], %3, %0"
a61af66fc99e Initial load
duke
parents:
diff changeset
242 : "=r" (rv)
a61af66fc99e Initial load
duke
parents:
diff changeset
243 : "0" (exchange_value), "r" (dest), "r" (compare_value)
a61af66fc99e Initial load
duke
parents:
diff changeset
244 : "memory");
a61af66fc99e Initial load
duke
parents:
diff changeset
245 #else //_LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
246 __asm__ volatile(
a61af66fc99e Initial load
duke
parents:
diff changeset
247 " cas [%2], %3, %0"
a61af66fc99e Initial load
duke
parents:
diff changeset
248 : "=r" (rv)
a61af66fc99e Initial load
duke
parents:
diff changeset
249 : "0" (exchange_value), "r" (dest), "r" (compare_value)
a61af66fc99e Initial load
duke
parents:
diff changeset
250 : "memory");
a61af66fc99e Initial load
duke
parents:
diff changeset
251 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
252 return rv;
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 return (void*)cmpxchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest, (intptr_t)compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 #else // _GNU_SOURCE
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 #if defined(COMPILER2) || defined(_LP64)
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // This is the interface to the atomic instructions in solaris_sparc.il.
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // It's very messy because we need to support v8 and these instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // are illegal there. When sparc v8 is dropped, we can drop out lots of
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // this code. Also compiler2 does not support v8 so the conditional code
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // omits the instruction set check.
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 extern "C" jint _Atomic_swap32(jint exchange_value, volatile jint* dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
270 extern "C" intptr_t _Atomic_swap64(intptr_t exchange_value, volatile intptr_t* dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 extern "C" jint _Atomic_cas32(jint exchange_value, volatile jint* dest, jint compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 extern "C" intptr_t _Atomic_cas64(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 extern "C" jlong _Atomic_casl (jlong exchange_value, volatile jlong* dest, jlong compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 extern "C" jint _Atomic_add32(jint inc, volatile jint* dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
277 extern "C" intptr_t _Atomic_add64(intptr_t add_value, volatile intptr_t* dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 inline jint Atomic::add (jint add_value, volatile jint* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 return _Atomic_add32(add_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
286 return _Atomic_add64(add_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 #else //_LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
288 return _Atomic_add32(add_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
289 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
293 return (void*)add_ptr((intptr_t)add_value, (volatile intptr_t*)dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 inline jint Atomic::xchg (jint exchange_value, volatile jint* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 return _Atomic_swap32(exchange_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
303 return _Atomic_swap64(exchange_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
304 #else // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
305 return _Atomic_swap32(exchange_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313
a61af66fc99e Initial load
duke
parents:
diff changeset
314 inline jint Atomic::cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
315 return _Atomic_cas32(exchange_value, dest, compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
316 }
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 inline jlong Atomic::cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // Return 64 bit value in %o0
a61af66fc99e Initial load
duke
parents:
diff changeset
321 return _Atomic_cas64((intptr_t)exchange_value, (intptr_t *)dest, (intptr_t)compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
322 #else // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
323 assert (VM_Version::v9_instructions_work(), "only supported on v9");
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // Return 64 bit value in %o0,%o1 by hand
a61af66fc99e Initial load
duke
parents:
diff changeset
325 return _Atomic_casl(exchange_value, dest, compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
326 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
330 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
331 return _Atomic_cas64(exchange_value, dest, compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
332 #else // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
333 return _Atomic_cas32(exchange_value, dest, compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 #endif // _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337 inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
338 return (void*)cmpxchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest, (intptr_t)compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 #else // _LP64 || COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
343
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // 32-bit compiler1 only
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 inline jint Atomic::add (jint add_value, volatile jint* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
348 return (*os::atomic_add_func)(add_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
349 }
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
352 return (intptr_t)add((jint)add_value, (volatile jint*)dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
353 }
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 return (void*)add((jint)add_value, (volatile jint*)dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 inline jint Atomic::xchg (jint exchange_value, volatile jint* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 return (*os::atomic_xchg_func)(exchange_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
365 return (intptr_t)xchg((jint)exchange_value, (volatile jint*)dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
366 }
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
369 return (void*)xchg((jint)exchange_value, (volatile jint*)dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372
a61af66fc99e Initial load
duke
parents:
diff changeset
373 inline jint Atomic::cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
374 return (*os::atomic_cmpxchg_func)(exchange_value, dest, compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
376
a61af66fc99e Initial load
duke
parents:
diff changeset
377 inline jlong Atomic::cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
378 return (*os::atomic_cmpxchg_long_func)(exchange_value, dest, compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
379 }
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
382 return (intptr_t)cmpxchg((jint)exchange_value, (volatile jint*)dest, (jint)compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
384
a61af66fc99e Initial load
duke
parents:
diff changeset
385 inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 return (void*)cmpxchg((jint)exchange_value, (volatile jint*)dest, (jint)compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
388
a61af66fc99e Initial load
duke
parents:
diff changeset
389 #endif // _LP64 || COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 #endif // _GNU_SOURCE
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
392
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
393 #endif // OS_CPU_SOLARIS_SPARC_VM_ATOMIC_SOLARIS_SPARC_INLINE_HPP