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

Johan Sjölen jsjolen at openjdk.org
Tue Apr 22 10:48:55 UTC 2025


On Sat, 19 Apr 2025 12:05:52 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Johan Sjölen has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Move semantics would be nice.
>
> src/hotspot/share/utilities/stableValue.hpp line 41:
> 
>> 39: // May be initialized exactly once.
>> 40: template<typename T>
>> 41: class StableValue {
> 
> Coming in late with more bike shedding on the name.  DeferredInit, DelayedInit, or something along those
> lines?  The idea is to emphasize that the object's construction is deferred/delayed until the call to `initialize()`.

I prefer fully spelled out words. David's comment re stable values in Java rings true, it's not a good name. I'll wait with renaming, see if something else is suggested. 'Deferred' and 'Delayed' are good prefixes. Could *just* be 'Delayed<T>'.

> src/hotspot/share/utilities/stableValue.hpp line 57:
> 
>> 55: 
>> 56:   T* ptr() {
>> 57:     return LAUNDER(&this->_t);
> 
> Do we actually need a function that potentially returns the uninitialized data?  I'd prefer `ptr` and
> `operator->()` were identical, and `initialize` just directly accessed `_t`.  And maybe drop `ptr`.
> The one external use of `ptr` that I see in the PR would be better served by adding `operator*()`.
> But our code tends to use pointers more than references, so maybe it's worth retaining `ptr`, so
> long as it has the is-initialized assertion too.

I'm keeping `ptr` as a we prefer to get references out of pointers rather than pointers out of references. Maybe I'm wrong about that, not 100% sure.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24689#discussion_r2053849359
PR Review Comment: https://git.openjdk.org/jdk/pull/24689#discussion_r2053846700


More information about the hotspot-dev mailing list