Use of C++ dynamic global object initialization with thread guards

Andrew Haley aph-open at littlepinkcloud.com
Mon Dec 4 15:48:09 UTC 2023


On 12/4/23 07:28, Florian Weimer wrote:
> Furthermore, most uses of C++ dynamic initialization involve a
> computation that is idempotent and have unused bit patterns in the
> initialized value.  This means that a separate guard variable is not
> needed, and a simple atomic store/atomic load could be used.

I used it in HotSpot code to trigger one-time resolution of some JDK
classes. These classes were in an incubator module, so I did not want
them to be loaded by default. I guess we could replace the
C++ mechanism by, one of our own, but that doesn't seem to me to be
much of a maintenance win.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


More information about the hotspot-dev mailing list