On Thu, 25 Jun 2026 09:43:06 GMT, Joel Sikström <[email protected]> wrote:

> Hello,
> 
> This is (yet another) cleanup to remove redundant memory barriers after the 
> new ValuePayload abstraction API in the runtime. The ValuePayload API's 
> (including FlatValuePayload::read) does the necessary calls to order stores 
> of the copy before the oop is published (OrderAccess::storestore), making the 
> platform-specific memory barriers redundant.
> 
> I don't have hardware access to RISCV or PPC, but looking at the runtime 
> implementations of OrderAccess::storestore, they achieve the same thing as 
> the platform-specific memory barriers that I suggest we remove in this PR. 
> GHA will show that this compiles at least.
> 
> `membar(Assembler::StoreStore | Assembler::LoadLoad);` and 
> `OrderAccess::storestore()` both boil down to `lwsync`.
> 
> The C1 call to `load_flat_array` already omits the memory barrier, so we 
> don't need to remove it here.
> 
> Testing:
> * Oracle's tier1-3 linux-aarch64
> * GHA
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This makes sense. Thanks for taking care of all platforms! I prefer a small 
change for PPC64.

src/hotspot/cpu/ppc/templateTable_ppc_64.cpp line 3420:

> 3418:       __ read_flat_field(Rcache, R17_tos);
> 3419:       __ verify_oop(R17_tos);
> 3420:       // memory barrier in read_flat_field

I think we should better add
```C++
      __ twi_0(R17_tos);
      __ isync();

to be on the safe side.

-------------

PR Review: 
https://git.openjdk.org/valhalla/pull/2581#pullrequestreview-4570240969
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2581#discussion_r3473815894

Reply via email to