From cd43591b5b8f72e6899b639c7991ed741c88c251 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Mon, 25 Aug 2025 20:24:45 -0400 Subject: [PATCH] 8366121: Hotspot Style Guide should document conventions for lock-free code --- doc/hotspot-style.html | 10 ++++++++++ doc/hotspot-style.md | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/doc/hotspot-style.html b/doc/hotspot-style.html index dafd29d6f546c..88ec07475fd75 100644 --- a/doc/hotspot-style.html +++ b/doc/hotspot-style.html @@ -209,6 +209,16 @@

Factoring and Class Design

attribute, the change should be done with a "setter" accessor matched to the simple "getter".

+

Conventions for Lock-free +Code

+

Sometimes variables are accessed concurrently without appropriate +synchronization context, such as a held mutex or at a safepoint. In such +cases the variable should be declared volatile and it +should NOT be accessed as a normal C++ lvalue. Rather, access should be +performed via functions from Atomic, such as +Atomic::load, Atomic::store, etc.

+

This special formulation makes it more clear to maintainers that the +variable is accessed concurrently in a lock-free manner.

Source Files