diff --git a/src/share/vm/memory/allocation.inline.hpp b/src/share/vm/memory/allocation.inline.hpp index 79d7ef5d6664370a646443224f296d1de3c29091..795016df8380f9f0f5241af1251f3fe95a974a91 100644 --- a/src/share/vm/memory/allocation.inline.hpp +++ b/src/share/vm/memory/allocation.inline.hpp @@ -32,12 +32,20 @@ void trace_heap_malloc(size_t size, const char* name, void *p); void trace_heap_free(void *p); +#ifndef PRODUCT // Increments unsigned long value for statistics (not atomic on MP). inline void inc_stat_counter(volatile julong* dest, julong add_value) { +#if defined(SPARC) || defined(X86) + // Sparc and X86 have atomic jlong (8 bytes) instructions julong value = Atomic::load((volatile jlong*)dest); value += add_value; Atomic::store((jlong)value, (volatile jlong*)dest); +#else + // possible word-tearing during load/store + *dest += add_value; +#endif } +#endif // allocate using malloc; will fail if no memory available inline char* AllocateHeap(size_t size, const char* name = NULL) {