comparison src/share/vm/runtime/atomic.hpp @ 8108:0598674c0056

8008314: Unimplemented() Atomic::load breaks the applications Summary: jlong atomics isn't fully implemented om all 32-bit platforms so we try to avoid it. In this case the atomic add wasn't needed. Reviewed-by: dholmes, dlong
author jwilhelm
date Thu, 21 Feb 2013 11:16:50 +0100
parents cd3d6a6b95d9
children d9eed26d638a
comparison
equal deleted inserted replaced
8074:b9c5e46bf915 8108:0598674c0056
27 27
28 #include "memory/allocation.hpp" 28 #include "memory/allocation.hpp"
29 29
30 class Atomic : AllStatic { 30 class Atomic : AllStatic {
31 public: 31 public:
32 // Atomic operations on jlong types are not available on all 32-bit
33 // platforms. If atomic ops on jlongs are defined here they must only
34 // be used from code that verifies they are available at runtime and
35 // can provide an alternative action if not - see supports_cx8() for
36 // a means to test availability.
37
32 // Atomically store to a location 38 // Atomically store to a location
33 inline static void store (jbyte store_value, jbyte* dest); 39 inline static void store (jbyte store_value, jbyte* dest);
34 inline static void store (jshort store_value, jshort* dest); 40 inline static void store (jshort store_value, jshort* dest);
35 inline static void store (jint store_value, jint* dest); 41 inline static void store (jint store_value, jint* dest);
42 // See comment above about using jlong atomics on 32-bit platforms
36 inline static void store (jlong store_value, jlong* dest); 43 inline static void store (jlong store_value, jlong* dest);
37 inline static void store_ptr(intptr_t store_value, intptr_t* dest); 44 inline static void store_ptr(intptr_t store_value, intptr_t* dest);
38 inline static void store_ptr(void* store_value, void* dest); 45 inline static void store_ptr(void* store_value, void* dest);
39 46
40 inline static void store (jbyte store_value, volatile jbyte* dest); 47 inline static void store (jbyte store_value, volatile jbyte* dest);
41 inline static void store (jshort store_value, volatile jshort* dest); 48 inline static void store (jshort store_value, volatile jshort* dest);
42 inline static void store (jint store_value, volatile jint* dest); 49 inline static void store (jint store_value, volatile jint* dest);
50 // See comment above about using jlong atomics on 32-bit platforms
43 inline static void store (jlong store_value, volatile jlong* dest); 51 inline static void store (jlong store_value, volatile jlong* dest);
44 inline static void store_ptr(intptr_t store_value, volatile intptr_t* dest); 52 inline static void store_ptr(intptr_t store_value, volatile intptr_t* dest);
45 inline static void store_ptr(void* store_value, volatile void* dest); 53 inline static void store_ptr(void* store_value, volatile void* dest);
46 54
55 // See comment above about using jlong atomics on 32-bit platforms
47 inline static jlong load(volatile jlong* src); 56 inline static jlong load(volatile jlong* src);
48 57
49 // Atomically add to a location, return updated value 58 // Atomically add to a location, return updated value
50 inline static jint add (jint add_value, volatile jint* dest); 59 inline static jint add (jint add_value, volatile jint* dest);
51 inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest); 60 inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest);
52 inline static void* add_ptr(intptr_t add_value, volatile void* dest); 61 inline static void* add_ptr(intptr_t add_value, volatile void* dest);
53 62 // See comment above about using jlong atomics on 32-bit platforms
54 static jlong add (jlong add_value, volatile jlong* dest); 63 static jlong add (jlong add_value, volatile jlong* dest);
55 64
56 // Atomically increment location 65 // Atomically increment location
57 inline static void inc (volatile jint* dest); 66 inline static void inc (volatile jint* dest);
58 inline static void inc_ptr(volatile intptr_t* dest); 67 inline static void inc_ptr(volatile intptr_t* dest);
73 // Performs atomic compare of *dest and compare_value, and exchanges *dest with exchange_value 82 // Performs atomic compare of *dest and compare_value, and exchanges *dest with exchange_value
74 // if the comparison succeeded. Returns prior value of *dest. Guarantees a two-way memory 83 // if the comparison succeeded. Returns prior value of *dest. Guarantees a two-way memory
75 // barrier across the cmpxchg. I.e., it's really a 'fence_cmpxchg_acquire'. 84 // barrier across the cmpxchg. I.e., it's really a 'fence_cmpxchg_acquire'.
76 static jbyte cmpxchg (jbyte exchange_value, volatile jbyte* dest, jbyte compare_value); 85 static jbyte cmpxchg (jbyte exchange_value, volatile jbyte* dest, jbyte compare_value);
77 inline static jint cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value); 86 inline static jint cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value);
87 // See comment above about using jlong atomics on 32-bit platforms
78 inline static jlong cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value); 88 inline static jlong cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value);
79 89
80 static unsigned int cmpxchg(unsigned int exchange_value, 90 static unsigned int cmpxchg(unsigned int exchange_value,
81 volatile unsigned int* dest, 91 volatile unsigned int* dest,
82 unsigned int compare_value); 92 unsigned int compare_value);