equal
deleted
inserted
replaced
32 #include "utilities/globalDefinitions.hpp" |
32 #include "utilities/globalDefinitions.hpp" |
33 |
33 |
34 // Explicit C-heap memory management |
34 // Explicit C-heap memory management |
35 |
35 |
36 #ifndef PRODUCT |
36 #ifndef PRODUCT |
37 // Increments unsigned long value for statistics (not atomic on MP). |
37 // Increments unsigned long value for statistics (not atomic on MP, but avoids word-tearing on 32 bit). |
38 inline void inc_stat_counter(volatile julong* dest, julong add_value) { |
38 inline void inc_stat_counter(volatile julong* dest, julong add_value) { |
39 #if defined(SPARC) || defined(X86) |
39 #ifdef _LP64 |
40 // Sparc and X86 have atomic jlong (8 bytes) instructions |
40 *dest += add_value; |
|
41 #else |
41 julong value = Atomic::load(dest); |
42 julong value = Atomic::load(dest); |
42 value += add_value; |
43 Atomic::store(value + add_value, dest); |
43 Atomic::store(value, dest); |
|
44 #else |
|
45 // possible word-tearing during load/store |
|
46 *dest += add_value; |
|
47 #endif |
44 #endif |
48 } |
45 } |
49 #endif |
46 #endif |
50 |
47 |
51 template <class E> |
48 template <class E> |