Mercurial > hg > graal-compiler
comparison src/os_cpu/linux_x86/vm/atomic_linux_x86.inline.hpp @ 2114:4fc084dac61e
7009756: volatile variables could be broken throw reflection API
Summary: Use Atomic::load() and Atomic::store() to access a volatile long.
Reviewed-by: iveresov, jrose, dholmes, never
author | kvn |
---|---|
date | Fri, 07 Jan 2011 10:16:57 -0800 |
parents | f95d63e2154a |
children | 63e54c37ac64 |
comparison
equal
deleted
inserted
replaced
2113:0e52ef6e94d3 | 2114:4fc084dac61e |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
98 : "r" (exchange_value), "a" (compare_value), "r" (dest), "r" (mp) | 98 : "r" (exchange_value), "a" (compare_value), "r" (dest), "r" (mp) |
99 : "cc", "memory"); | 99 : "cc", "memory"); |
100 return exchange_value; | 100 return exchange_value; |
101 } | 101 } |
102 | 102 |
103 extern "C" { | |
104 // defined in linux_x86.s | |
105 jlong _Atomic_cmpxchg_long(jlong, volatile jlong*, jlong, bool); | |
106 } | |
107 | |
108 #ifdef AMD64 | 103 #ifdef AMD64 |
109 inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; } | 104 inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; } |
110 inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; } | 105 inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; } |
111 | 106 |
112 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { | 107 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { |
162 | 157 |
163 inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value) { | 158 inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value) { |
164 return (void*)cmpxchg((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value); | 159 return (void*)cmpxchg((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value); |
165 } | 160 } |
166 | 161 |
167 #else | 162 inline jlong Atomic::load(volatile jlong* src) { return *src; } |
168 //inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; } | 163 |
169 //inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; } | 164 #else // !AMD64 |
170 | 165 |
171 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { | 166 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { |
172 return (intptr_t)Atomic::add((jint)add_value, (volatile jint*)dest); | 167 return (intptr_t)Atomic::add((jint)add_value, (volatile jint*)dest); |
173 } | 168 } |
174 | 169 |
187 | 182 |
188 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) { | 183 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) { |
189 return (intptr_t)xchg((jint)exchange_value, (volatile jint*)dest); | 184 return (intptr_t)xchg((jint)exchange_value, (volatile jint*)dest); |
190 } | 185 } |
191 | 186 |
187 extern "C" { | |
188 // defined in linux_x86.s | |
189 jlong _Atomic_cmpxchg_long(jlong, volatile jlong*, jlong, bool); | |
190 void _Atomic_move_long(volatile jlong* src, volatile jlong* dst); | |
191 } | |
192 | |
192 inline jlong Atomic::cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value) { | 193 inline jlong Atomic::cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value) { |
193 return _Atomic_cmpxchg_long(exchange_value, dest, compare_value, os::is_MP()); | 194 return _Atomic_cmpxchg_long(exchange_value, dest, compare_value, os::is_MP()); |
194 } | 195 } |
195 | 196 |
196 inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) { | 197 inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) { |
198 } | 199 } |
199 | 200 |
200 inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value) { | 201 inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value) { |
201 return (void*)cmpxchg((jint)exchange_value, (volatile jint*)dest, (jint)compare_value); | 202 return (void*)cmpxchg((jint)exchange_value, (volatile jint*)dest, (jint)compare_value); |
202 } | 203 } |
204 | |
205 inline jlong Atomic::load(volatile jlong* src) { | |
206 volatile jlong dest; | |
207 _Atomic_move_long(src, &dest); | |
208 return dest; | |
209 } | |
210 | |
211 inline void Atomic::store(jlong store_value, jlong* dest) { | |
212 _Atomic_move_long((volatile jlong*)&store_value, (volatile jlong*)dest); | |
213 } | |
214 | |
215 inline void Atomic::store(jlong store_value, volatile jlong* dest) { | |
216 _Atomic_move_long((volatile jlong*)&store_value, dest); | |
217 } | |
218 | |
203 #endif // AMD64 | 219 #endif // AMD64 |
204 | 220 |
205 #endif // OS_CPU_LINUX_X86_VM_ATOMIC_LINUX_X86_INLINE_HPP | 221 #endif // OS_CPU_LINUX_X86_VM_ATOMIC_LINUX_X86_INLINE_HPP |