Skip to content

Commit b8fa6c2

Browse files
committed
8316186: RISC-V: Remove PlatformCmpxchg<4>
Reviewed-by: fyang, mli
1 parent fb055e7 commit b8fa6c2

File tree

1 file changed

+2
-35
lines changed

1 file changed

+2
-35
lines changed

src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -152,50 +152,17 @@ inline T Atomic::PlatformCmpxchg<byte_size>::operator()(T volatile* dest __attri
152152
#endif
153153

154154
STATIC_ASSERT(byte_size == sizeof(T));
155-
T value = compare_value;
156155
if (order != memory_order_relaxed) {
157156
FULL_MEM_BARRIER;
158157
}
159158

160-
__atomic_compare_exchange(dest, &value, &exchange_value, /* weak */ false,
159+
__atomic_compare_exchange(dest, &compare_value, &exchange_value, /* weak */ false,
161160
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
162161

163162
if (order != memory_order_relaxed) {
164163
FULL_MEM_BARRIER;
165164
}
166-
return value;
167-
}
168-
169-
template<>
170-
template<typename T>
171-
inline T Atomic::PlatformCmpxchg<4>::operator()(T volatile* dest __attribute__((unused)),
172-
T compare_value,
173-
T exchange_value,
174-
atomic_memory_order order) const {
175-
STATIC_ASSERT(4 == sizeof(T));
176-
177-
T old_value;
178-
long rc;
179-
180-
if (order != memory_order_relaxed) {
181-
FULL_MEM_BARRIER;
182-
}
183-
184-
__asm__ __volatile__ (
185-
"1: sext.w %1, %3 \n\t" // sign-extend compare_value
186-
" lr.w %0, %2 \n\t"
187-
" bne %0, %1, 2f \n\t"
188-
" sc.w %1, %4, %2 \n\t"
189-
" bnez %1, 1b \n\t"
190-
"2: \n\t"
191-
: /*%0*/"=&r" (old_value), /*%1*/"=&r" (rc), /*%2*/"+A" (*dest)
192-
: /*%3*/"r" (compare_value), /*%4*/"r" (exchange_value)
193-
: "memory" );
194-
195-
if (order != memory_order_relaxed) {
196-
FULL_MEM_BARRIER;
197-
}
198-
return old_value;
165+
return compare_value;
199166
}
200167

201168
template<size_t byte_size>

0 commit comments

Comments
 (0)