[aarch64-port-dev ] RFR: aarch64: minor improvements of atomic operations

Andrew Haley aph at redhat.com
Mon Nov 11 16:36:38 UTC 2019

On 11/11/19 3:05 PM, Andrew Haley wrote:
> And finally, is there any operation in HotSpot that actually requires
> such strong memory semantics? Probably not, but no-one has ever been
> brave enough to say so.

Here's a place where it really does matter.

void ShenandoahPacer::restart_with(size_t non_taxable_bytes, double tax_rate) {
  size_t initial = (size_t)(non_taxable_bytes * tax_rate) >> LogHeapWordSize;
  STATIC_ASSERT(sizeof(size_t) <= sizeof(intptr_t));
  Atomic::xchg((intptr_t)initial, &_budget);
  Atomic::store(tax_rate, &_tax_rate);

Note: the xchg is conservative, the store is plain. The xchg value should be
visible before the store.

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

More information about the hotspot-dev mailing list