RFR: 8367013: Add Atomic<T> to package/replace idiom of volatile var plus AtomicAccess:: operations [v2]
Kim Barrett
kbarrett at openjdk.org
Wed Oct 8 05:04:48 UTC 2025
> Please review this change that adds the type Atomic<T>, to use as the type
> of a variable that is accessed (including writes) concurrently by multiple
> threads. This is intended to replace (most) uses of the current HotSpot idiom
> of declaring a variable volatile and accessing that variable using functions
> from the AtomicAccess class.
> https://github.com/openjdk/jdk/blame/528f93f8cb9f1fb9c19f31ab80c8a546f47beed2/doc/hotspot-style.md#L138-L147
>
> This change replaces https://github.com/openjdk/jdk/pull/27462. Differences are
>
> * Substantially restructured `Atomic<T>`, to be IDE friendly. It's
> operationally the same, with the same API, hence uses and gtests didn't need
> to change in that respect. Thanks to @stefank for raising this issue, and for
> some suggestions toward improvements.
>
> * Changed how fetch_then_set for atomic translated types is handled, to avoid
> having the function there at all if it isn't usable, rather than just removing
> it via SFINAE, leaving an empty overload set.
>
> * Added more gtests.
>
> Testing: mach5 tier1-6, GHA sanity tests
Kim Barrett has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 12 additional commits since the last revision:
- Merge branch 'master' into atomic-template-tag-select
- add reference to gcc bug we're working around
- fix typo in comment
- update copyrights
- update FreeListAllocator
- update nonblockingQueue
- update LockFreeStack
- convert StringDedupTable
- convert SingleWriterSynchronizer
- test_atomic
- ... and 2 more: https://git.openjdk.org/jdk/compare/8160408a...8cdc458d
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/27539/files
- new: https://git.openjdk.org/jdk/pull/27539/files/0c0f7ceb..8cdc458d
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=27539&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=27539&range=00-01
Stats: 14734 lines in 586 files changed: 8479 ins; 3029 del; 3226 mod
Patch: https://git.openjdk.org/jdk/pull/27539.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/27539/head:pull/27539
PR: https://git.openjdk.org/jdk/pull/27539
More information about the hotspot-dev
mailing list