In Hotspot it is a common design pattern to instantiate one global and static instance of a datatype at some point in the initialization of the program.
We do not use dynamic static initialization, as this often leads to bugs when combined with non-trivial constructors (see "Static Initialization Order Fiasco."
Typically, we avoid this issue by instead using a pointer and a `malloc` in the initialization code.
This requires extra ceremony and an extra malloc call, which is unergonomic.
We can add a StableValue<T> class, which holds enough memory to initialize exactly one instance of T.
By using this, we can have global statics which are alive for the entire duration of the program.
We do not use dynamic static initialization, as this often leads to bugs when combined with non-trivial constructors (see "Static Initialization Order Fiasco."
Typically, we avoid this issue by instead using a pointer and a `malloc` in the initialization code.
This requires extra ceremony and an extra malloc call, which is unergonomic.
We can add a StableValue<T> class, which holds enough memory to initialize exactly one instance of T.
By using this, we can have global statics which are alive for the entire duration of the program.
- links to
-
Commit(master) openjdk/jdk/604225fb
-
Review(master) openjdk/jdk/24689