Skip to content

Commit

Permalink
Make needed perfMemory fields volatile and added needed vmstructs sup…
Browse files Browse the repository at this point in the history
…port for volatile static.
  • Loading branch information
plummercj committed Aug 21, 2023
1 parent 78f74bc commit 08c1b6a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/gc/shared/vmStructs_gc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#endif

#define VM_STRUCTS_GC(nonstatic_field, \
volatile_static_field, \
volatile_nonstatic_field, \
static_field, \
unchecked_nonstatic_field) \
Expand Down
11 changes: 8 additions & 3 deletions src/hotspot/share/runtime/perfMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ char* PerfMemory::_start = nullptr;
char* PerfMemory::_end = nullptr;
char* PerfMemory::_top = nullptr;
size_t PerfMemory::_capacity = 0;
int PerfMemory::_initialized = false;
volatile int PerfMemory::_initialized = 0;
PerfDataPrologue* PerfMemory::_prologue = nullptr;
bool PerfMemory::_destroyed = false;
volatile int PerfMemory::_destroyed = 0;

void perfMemory_init() {

Expand Down Expand Up @@ -197,7 +197,7 @@ void PerfMemory::destroy() {
delete_memory_region();
}

_destroyed = true;
Atomic::release_store(&_destroyed, 1);
}

// allocate an aligned block of memory from the PerfData memory
Expand Down Expand Up @@ -271,3 +271,8 @@ char* PerfMemory::get_perfdata_file_path() {
bool PerfMemory::is_initialized() {
return Atomic::load_acquire(&_initialized) != 0;
}

bool PerfMemory::is_destroyed() {
return Atomic::load_acquire(&_destroyed) != 0;
}

6 changes: 3 additions & 3 deletions src/hotspot/share/runtime/perfMemory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ class PerfMemory : AllStatic {
static char* _top;
static size_t _capacity;
static PerfDataPrologue* _prologue;
static int _initialized;
static bool _destroyed;
static volatile int _initialized;
static volatile int _destroyed;

static void create_memory_region(size_t sizep);
static void delete_memory_region();
Expand All @@ -134,7 +134,7 @@ class PerfMemory : AllStatic {
static size_t used() { return (size_t) (_top - _start); }
static size_t capacity() { return _capacity; }
static bool is_initialized();
static bool is_destroyed() { return _destroyed; }
static bool is_destroyed();
static bool is_usable() { return is_initialized() && !is_destroyed(); }
static bool contains(char* addr) {
return ((_start != nullptr) && (addr >= _start) && (addr < _end));
Expand Down
13 changes: 7 additions & 6 deletions src/hotspot/share/runtime/vmStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@

#define VM_STRUCTS(nonstatic_field, \
static_field, \
static_ptr_volatile_field, \
volatile_static_field, \
unchecked_nonstatic_field, \
volatile_nonstatic_field, \
nonproduct_nonstatic_field, \
Expand All @@ -194,6 +194,7 @@
/*************/ \
\
VM_STRUCTS_GC(nonstatic_field, \
volatile_static_field, \
volatile_nonstatic_field, \
static_field, \
unchecked_nonstatic_field) \
Expand Down Expand Up @@ -447,7 +448,7 @@
static_field(PerfMemory, _top, char*) \
static_field(PerfMemory, _capacity, size_t) \
static_field(PerfMemory, _prologue, PerfDataPrologue*) \
static_field(PerfMemory, _initialized, int) \
volatile_static_field(PerfMemory, _initialized, int) \
\
/********************/ \
/* SystemDictionary */ \
Expand Down Expand Up @@ -477,7 +478,7 @@
volatile_nonstatic_field(ClassLoaderData, _klasses, Klass*) \
nonstatic_field(ClassLoaderData, _has_class_mirror_holder, bool) \
\
static_ptr_volatile_field(ClassLoaderDataGraph, _head, ClassLoaderData*) \
volatile_static_field(ClassLoaderDataGraph, _head, ClassLoaderData*) \
\
/**********/ \
/* Arrays */ \
Expand Down Expand Up @@ -638,7 +639,7 @@
static_field(Threads, _number_of_non_daemon_threads, int) \
static_field(Threads, _return_code, int) \
\
static_ptr_volatile_field(ThreadsSMRSupport, _java_thread_list, ThreadsList*) \
volatile_static_field(ThreadsSMRSupport, _java_thread_list, ThreadsList*) \
nonstatic_field(ThreadsList, _length, const uint) \
nonstatic_field(ThreadsList, _threads, JavaThread *const *const) \
\
Expand Down Expand Up @@ -2685,7 +2686,7 @@ VMStructEntry VMStructs::localHotSpotVMStructs[] = {

VM_STRUCTS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_STATIC_VM_STRUCT_ENTRY,
GENERATE_STATIC_PTR_VOLATILE_VM_STRUCT_ENTRY,
GENERATE_VOLATILE_STATIC_VM_STRUCT_ENTRY,
GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY,
Expand Down Expand Up @@ -2887,7 +2888,7 @@ JNIEXPORT uint64_t gHotSpotVMLongConstantEntryArrayStride = STRIDE(gHotSpotVMLon
void VMStructs::init() {
VM_STRUCTS(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_STATIC_VM_STRUCT_ENTRY,
CHECK_STATIC_PTR_VOLATILE_VM_STRUCT_ENTRY,
CHECK_VOLATILE_STATIC_VM_STRUCT_ENTRY,
CHECK_NO_OP,
CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY,
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/runtime/vmStructs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ class VMStructs {

// This macro generates a VMStructEntry line for a static pointer volatile field,
// e.g.: "static ObjectMonitor * volatile g_block_list;"
#define GENERATE_STATIC_PTR_VOLATILE_VM_STRUCT_ENTRY(typeName, fieldName, type) \
{ QUOTE(typeName), QUOTE(fieldName), QUOTE(type), 1, 0, (void *)&typeName::fieldName },
#define GENERATE_VOLATILE_STATIC_VM_STRUCT_ENTRY(typeName, fieldName, type) \
{ QUOTE(typeName), QUOTE(fieldName), QUOTE(type), 1, 0, (type*)&typeName::fieldName },

// This macro generates a VMStructEntry line for an unchecked
// nonstatic field, in which the size of the type is also specified.
Expand Down Expand Up @@ -207,7 +207,7 @@ class VMStructs {

// This macro checks the type of a static pointer volatile VMStructEntry by comparing pointer types,
// e.g.: "static ObjectMonitor * volatile g_block_list;"
#define CHECK_STATIC_PTR_VOLATILE_VM_STRUCT_ENTRY(typeName, fieldName, type) \
#define CHECK_VOLATILE_STATIC_VM_STRUCT_ENTRY(typeName, fieldName, type) \
{type volatile * dummy = &typeName::fieldName; }

// This macro ensures the type of a field and its containing type are
Expand Down

0 comments on commit 08c1b6a

Please sign in to comment.