RFC: 8160369 - Memory fences needed around setting and reading object lengths

Andrew Haley aph at redhat.com
Thu Jun 30 08:33:22 UTC 2016

On 29/06/16 20:46, Derek White wrote:
> And I agree that the implicit loadload barrier in code like 
> oop->klass()->layout_helper() is sufficient for the processors we care 
> about.

I'm not sure.  While we know that the hardware respects address
dependency ordering in these cases, a smart optimizing compiler might
work out that it doesn't need to read the klass field.  It is
extremely hard (impossible!) to reason about dependencies at the C++
source level, especially in the presence of data races.

C++ now provides order_access_consume for exactly this use, and if
we're going to make assumptions about address dependencies we should
use consume.  This might mean that we'll have to define a "fake" macro
for now.  Then, wen we start to use a more up-to-date C++ compiler we
can re-implement this stuff with real C++ atomics.


More information about the hotspot-gc-dev mailing list