Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/hotspot/share/runtime/vmStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1981,31 +1981,31 @@ extern "C" {
#define STRIDE(array) ((char*)&array[1] - (char*)&array[0])

JNIEXPORT VMStructEntry* gHotSpotVMStructs = VMStructs::localHotSpotVMStructs;
JNIEXPORT uint64_t gHotSpotVMStructEntryTypeNameOffset = offset_of(VMStructEntry, typeName);
JNIEXPORT uint64_t gHotSpotVMStructEntryFieldNameOffset = offset_of(VMStructEntry, fieldName);
JNIEXPORT uint64_t gHotSpotVMStructEntryTypeStringOffset = offset_of(VMStructEntry, typeString);
JNIEXPORT uint64_t gHotSpotVMStructEntryIsStaticOffset = offset_of(VMStructEntry, isStatic);
JNIEXPORT uint64_t gHotSpotVMStructEntryOffsetOffset = offset_of(VMStructEntry, offset);
JNIEXPORT uint64_t gHotSpotVMStructEntryAddressOffset = offset_of(VMStructEntry, address);
extern JNIEXPORT constexpr uint64_t gHotSpotVMStructEntryTypeNameOffset = offsetof(VMStructEntry, typeName);
Copy link
Contributor Author

@fandreuz fandreuz Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got a partial understanding about this change, I thought having JNIEXPORT and constexpr together wouldn't work. But the symbols are exported:

objdump --syms build/gcc/jdk/lib/server/libjvm.so | grep gHotSpotVMTypeEntryIsIntegerTypeOffset
000000000137ca78 g     O .rodata	0000000000000008              gHotSpotVMTypeEntryIsIntegerTypeOffset

and I tested that the values are still readable. I was wondering if this wouldn't be portable?

extern JNIEXPORT constexpr uint64_t gHotSpotVMStructEntryFieldNameOffset = offsetof(VMStructEntry, fieldName);
extern JNIEXPORT constexpr uint64_t gHotSpotVMStructEntryTypeStringOffset = offsetof(VMStructEntry, typeString);
extern JNIEXPORT constexpr uint64_t gHotSpotVMStructEntryIsStaticOffset = offsetof(VMStructEntry, isStatic);
extern JNIEXPORT constexpr uint64_t gHotSpotVMStructEntryOffsetOffset = offsetof(VMStructEntry, offset);
extern JNIEXPORT constexpr uint64_t gHotSpotVMStructEntryAddressOffset = offsetof(VMStructEntry, address);
JNIEXPORT uint64_t gHotSpotVMStructEntryArrayStride = STRIDE(gHotSpotVMStructs);

JNIEXPORT VMTypeEntry* gHotSpotVMTypes = VMStructs::localHotSpotVMTypes;
JNIEXPORT uint64_t gHotSpotVMTypeEntryTypeNameOffset = offset_of(VMTypeEntry, typeName);
JNIEXPORT uint64_t gHotSpotVMTypeEntrySuperclassNameOffset = offset_of(VMTypeEntry, superclassName);
JNIEXPORT uint64_t gHotSpotVMTypeEntryIsOopTypeOffset = offset_of(VMTypeEntry, isOopType);
JNIEXPORT uint64_t gHotSpotVMTypeEntryIsIntegerTypeOffset = offset_of(VMTypeEntry, isIntegerType);
JNIEXPORT uint64_t gHotSpotVMTypeEntryIsUnsignedOffset = offset_of(VMTypeEntry, isUnsigned);
JNIEXPORT uint64_t gHotSpotVMTypeEntrySizeOffset = offset_of(VMTypeEntry, size);
extern JNIEXPORT constexpr uint64_t gHotSpotVMTypeEntryTypeNameOffset = offsetof(VMTypeEntry, typeName);
extern JNIEXPORT constexpr uint64_t gHotSpotVMTypeEntrySuperclassNameOffset = offsetof(VMTypeEntry, superclassName);
extern JNIEXPORT constexpr uint64_t gHotSpotVMTypeEntryIsOopTypeOffset = offsetof(VMTypeEntry, isOopType);
extern JNIEXPORT constexpr uint64_t gHotSpotVMTypeEntryIsIntegerTypeOffset = offsetof(VMTypeEntry, isIntegerType);
extern JNIEXPORT constexpr uint64_t gHotSpotVMTypeEntryIsUnsignedOffset = offsetof(VMTypeEntry, isUnsigned);
extern JNIEXPORT constexpr uint64_t gHotSpotVMTypeEntrySizeOffset = offsetof(VMTypeEntry, size);
JNIEXPORT uint64_t gHotSpotVMTypeEntryArrayStride = STRIDE(gHotSpotVMTypes);

JNIEXPORT VMIntConstantEntry* gHotSpotVMIntConstants = VMStructs::localHotSpotVMIntConstants;
JNIEXPORT uint64_t gHotSpotVMIntConstantEntryNameOffset = offset_of(VMIntConstantEntry, name);
JNIEXPORT uint64_t gHotSpotVMIntConstantEntryValueOffset = offset_of(VMIntConstantEntry, value);
extern JNIEXPORT constexpr uint64_t gHotSpotVMIntConstantEntryNameOffset = offsetof(VMIntConstantEntry, name);
extern JNIEXPORT constexpr uint64_t gHotSpotVMIntConstantEntryValueOffset = offsetof(VMIntConstantEntry, value);
JNIEXPORT uint64_t gHotSpotVMIntConstantEntryArrayStride = STRIDE(gHotSpotVMIntConstants);

JNIEXPORT VMLongConstantEntry* gHotSpotVMLongConstants = VMStructs::localHotSpotVMLongConstants;
JNIEXPORT uint64_t gHotSpotVMLongConstantEntryNameOffset = offset_of(VMLongConstantEntry, name);
JNIEXPORT uint64_t gHotSpotVMLongConstantEntryValueOffset = offset_of(VMLongConstantEntry, value);
extern JNIEXPORT constexpr uint64_t gHotSpotVMLongConstantEntryNameOffset = offsetof(VMLongConstantEntry, name);
extern JNIEXPORT constexpr uint64_t gHotSpotVMLongConstantEntryValueOffset = offsetof(VMLongConstantEntry, value);
JNIEXPORT uint64_t gHotSpotVMLongConstantEntryArrayStride = STRIDE(gHotSpotVMLongConstants);
} // "C"

Expand Down
6 changes: 4 additions & 2 deletions src/hotspot/share/runtime/vmStructs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"

#include <cstddef>
#ifdef COMPILER1
#include "c1/c1_Runtime1.hpp"
#endif
Expand Down Expand Up @@ -157,7 +159,7 @@ class VMStructs {

// This macro generates a VMStructEntry line for a nonstatic field
#define GENERATE_NONSTATIC_VM_STRUCT_ENTRY(typeName, fieldName, type) \
{ QUOTE(typeName), QUOTE(fieldName), QUOTE(type), 0, offset_of(typeName, fieldName), nullptr },
{ QUOTE(typeName), QUOTE(fieldName), QUOTE(type), 0, offsetof(typeName, fieldName), nullptr },

// This macro generates a VMStructEntry line for a static field
#define GENERATE_STATIC_VM_STRUCT_ENTRY(typeName, fieldName, type) \
Expand All @@ -172,7 +174,7 @@ class VMStructs {
// nonstatic field, in which the size of the type is also specified.
// The type string is given as null, indicating an "opaque" type.
#define GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY(typeName, fieldName, size) \
{ QUOTE(typeName), QUOTE(fieldName), nullptr, 0, offset_of(typeName, fieldName), nullptr },
{ QUOTE(typeName), QUOTE(fieldName), nullptr, 0, offsetof(typeName, fieldName), nullptr },

// This macro generates a VMStructEntry line for an unchecked
// static field, in which the size of the type is also specified.
Expand Down