RFR(S) 8206183: Possible construct EMPTY_STACK and allocation stack, etc. on first use
zgu at redhat.com
Wed Jul 11 17:19:54 UTC 2018
On 07/11/2018 01:18 PM, yumin qi wrote:
> The changes look good to me.
> On Sat, Jul 7, 2018 at 4:37 AM Zhengyu Gu <zgu at redhat.com
> <mailto:zgu at redhat.com>> wrote:
> NMT has to workaround static initialization order issues: some of
> 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