RFR(S) 8206183: Possible construct EMPTY_STACK and allocation stack, etc. on first use

Zhengyu Gu zgu at redhat.com
Sat Jul 7 11:36:57 UTC 2018


NMT has to workaround static initialization order issues: some of static 
objects, who allocate memory inside their constructors, may be 
initialized ahead of NMT, so NMT is forced to initialize itself early 
and risks its static objects may be reinitialized by C runtime.

The workaround was to declare storage for the static objects as 
primitive arrays, then use placement new operator to initialize them, or 
just initialize them eagerly, if the results are constants.

But the solution is not elegant, could break with some compilers.
A better solution is to use "construct on First Use Idiom" pattern 
(https://isocpp.org/wiki/faq/ctors#static-init-order), cause we only 
have initialization order problems, those static objects do not have 
dependencies on other static objects, so we don't suffer from static 
deinitialization problems.

Bug: https://bugs.openjdk.java.net/browse/JDK-8206183
Webrev: http://cr.openjdk.java.net/~zgu/8206183/webrev.00/


   hotspot_nmt on Linux 64 (fastdebug and release)



More information about the hotspot-runtime-dev mailing list