< prev index next >
src/hotspot/share/memory/arena.hpp
Print this page
rev 55658 : 8227597: [fastdbg build] Arena::inc_bytes_allocated should get inlined
Reviewed-by:
@@ -24,10 +24,11 @@
#ifndef SHARE_MEMORY_ARENA_HPP
#define SHARE_MEMORY_ARENA_HPP
#include "memory/allocation.hpp"
+#include "runtime/atomic.hpp"
#include "runtime/globals.hpp"
#include "utilities/globalDefinitions.hpp"
#include <new>
@@ -104,15 +105,22 @@
char *_hwm, *_max; // High water mark and max in current chunk
// Get a new Chunk of at least size x
void* grow(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
size_t _size_in_bytes; // Size of arena (used for native memory tracking)
- NOT_PRODUCT(static julong _bytes_allocated;) // total #bytes allocated since start
+#ifndef PRODUCT
+ static julong _bytes_allocated; // total #bytes allocated since start
+ // Inlinable increment function (not atomic on MP, but avoids word-tearing on 32 bit)
+ void inc_bytes_allocated(size_t x) {
+ julong value = Atomic::load(&_bytes_allocated);
+ Atomic::store(value + x, &_bytes_allocated);
+ }
+#endif
+
friend class AllocStats;
debug_only(void* malloc(size_t size);)
debug_only(void* internal_malloc_4(size_t x);)
- NOT_PRODUCT(void inc_bytes_allocated(size_t x);)
void signal_out_of_memory(size_t request, const char* whence) const;
bool check_for_overflow(size_t request, const char* whence,
AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) const {
< prev index next >