--- old/src/hotspot/share/runtime/perfMemory.cpp 2017-10-18 16:35:43.164171307 +0900 +++ new/src/hotspot/share/runtime/perfMemory.cpp 2017-10-18 16:35:42.996167966 +0900 @@ -53,6 +53,7 @@ size_t PerfMemory::_capacity = 0; jint PerfMemory::_initialized = false; PerfDataPrologue* PerfMemory::_prologue = NULL; +bool PerfMemory::_destroyed = false; void perfMemory_init() { @@ -64,7 +65,7 @@ void perfMemory_exit() { if (!UsePerfData) return; - if (!PerfMemory::is_initialized()) return; + if (!PerfMemory::is_useable()) return; // Only destroy PerfData objects if we're at a safepoint and the // StatSampler is not active. Otherwise, we risk removing PerfData @@ -88,7 +89,7 @@ void PerfMemory::initialize() { - if (_prologue != NULL) + if (is_initialized()) // initialization already performed return; @@ -160,7 +161,7 @@ void PerfMemory::destroy() { - if (_prologue == NULL) return; + if (!is_useable()) return; if (_start != NULL && _prologue->overflow != 0) { @@ -196,11 +197,7 @@ delete_memory_region(); } - _start = NULL; - _end = NULL; - _top = NULL; - _prologue = NULL; - _capacity = 0; + _destroyed = true; } // allocate an aligned block of memory from the PerfData memory @@ -213,7 +210,7 @@ MutexLocker ml(PerfDataMemAlloc_lock); - assert(_prologue != NULL, "called before initialization"); + assert(is_useable(), "called before init or after destroy"); // check that there is enough memory for this request if ((_top + size) >= _end) { @@ -238,6 +235,8 @@ void PerfMemory::mark_updated() { if (!UsePerfData) return; + assert(is_useable(), "called before init or after destroy"); + _prologue->mod_time_stamp = os::elapsed_counter(); }