--- a/src/hotspot/share/runtime/perfMemory.cpp Wed Oct 18 13:52:32 2017 -0700
+++ b/src/hotspot/share/runtime/perfMemory.cpp Sat Oct 21 07:00:23 2017 +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_usable()) 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_usable()) 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_usable(), "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_usable(), "called before init or after destroy");
+
_prologue->mod_time_stamp = os::elapsed_counter();
}
@@ -268,3 +267,7 @@
return dest_file;
}
+
+bool PerfMemory::is_initialized() {
+ return OrderAccess::load_acquire(&_initialized) != 0;
+}