Atomic

Kim Barrett kim.barrett at oracle.com
Tue Mar 21 07:07:58 UTC 2023



> On Mar 20, 2023, at 9:23 PM, David Holmes <david.holmes at oracle.com> wrote:
> 
> On 21/03/2023 1:42 am, Justin King wrote:
>> While messing around with seeing if ThreadSanitizer would be useful in Hotspot, I rewrote runtime/atomic.hpp using compiler intrinsics (__atomic_* on GCC/Clang/XLC, interlocked for MSVC) instead of inline assembly.
> 
> I assume you mean the platform specific atomic*.hpp files?
> 
> Inline assembly doesn't get instrumented very well and the
>> compiler cannot optimize it very well. Is there any want for replacing the inline assembly with compiler intrinsics, regardless of ThreadSanitizer? They also have intrinsics that can be used to build optimized implementations of parallel bit set manipulation as well.
> 
> Sorry but this just seems like churn to me. First we have to go through the process of establishing the equivalence of the compiler intrinsics with the assembly code. Then make all the changes. Then deal with the potential that some os_cpu code might be compiled by multiple compilers. Then we have to deal with the possibility that the compilers might change behaviour or introduce bugs across releases (yeah these low-level things _should_ be stable but ...).
> 
> What would we gain by doing any of this?

I pretty much agree with David on this.

> IMO the ideal place we would like to get to is use of C++ atomic operations, but I wouldn't want to go there via use of compiler intrinsics. And I don't know what challenges we would face trying to use C++ atomic ops.

We’ve discussed and explicitly rejected the use of <atomic> facilities in shared code.  See the HotSpot Style Guide.

Some platforms might use some of them (or corresponding built-ins) to implement some of Atomic.  That’s a
decision for the developers and maintainers of the various ports.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <https://mail.openjdk.org/pipermail/hotspot-runtime-dev/attachments/20230321/11ab655a/signature-0001.asc>


More information about the hotspot-runtime-dev mailing list