RFR: 8367984: Eliminate offset_of in vmStructs

Francesco Andreuzzi fandreuzzi at openjdk.org
Thu Sep 18 12:53:29 UTC 2025


On Thu, 18 Sep 2025 12:44:27 GMT, Francesco Andreuzzi <fandreuzzi at openjdk.org> wrote:

> There are several usages of `offset_of` in `vmStructs`, they can be replaced with standard `offsetof` due to [JDK-8367016](https://bugs.openjdk.org/browse/JDK-8367016).
> 
> Passes `tier1`.

src/hotspot/share/runtime/vmStructs.cpp line 1984:

> 1982: 
> 1983: JNIEXPORT VMStructEntry* gHotSpotVMStructs = VMStructs::localHotSpotVMStructs;
> 1984: extern JNIEXPORT constexpr uint64_t gHotSpotVMStructEntryTypeNameOffset = offsetof(VMStructEntry, typeName);

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?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27362#discussion_r2359088177


More information about the hotspot-runtime-dev mailing list