RFR: 8354954: Typed static memory for late initialization of static class members in Hotspot [v3]

Johan Sjölen jsjolen at openjdk.org
Thu Apr 17 18:37:48 UTC 2025


On Thu, 17 Apr 2025 18:24:43 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

> > > ... however when working with certain code you may want to allocate before NMT is initialized. This leads to you having to use raw malloc. This is probably something you find out after having used os::malloc and already had a strange crash when building your code.
> > 
> > 
> > ? No, this should not happen. You can, of course, use `os::malloc` before NMT is initialized; that is why NMT preinit mode exists. If you get strange crashes (do you have JBS issues for them?), those are bugs and should be fixed.
> > If this is the only motivation for this PR, we may be able to save a lot of time.
> 
> You're right, I managed to confuse this with another bug I had, where I mmapped before the VMT was intialized. Sloppy of me.
> 
> Happy Easter, let's talk more later.

Aah sorry, I looked at the description again. The `MemBaseline` example comes much further down. There's been a lot of internal talk about this, and  I've forgotten which details I've said here and what I've only said internally.

To me, `StableValue` is an ergonomic feature. We can make do without it, but I'd rather not.

I dislike that I:

1. Can't simply statically allocate values, but I have to always have a null pointer which I do the malloc + new placement for every time. `StableValue` gets rid of that ceremony, which I appreciate.
2. That a trivially allocated data structure can trip up when it becomes non-trivial. `StableValue` let's me be defensive for my own data, without having to resort to malloc.


(But seriously, let's talk about this more after the Easter weekend)

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

PR Comment: https://git.openjdk.org/jdk/pull/24689#issuecomment-2813743030


More information about the hotspot-dev mailing list