[jmm-dev] jdk9 APIs

Andrew Haley aph at redhat.com
Tue Aug 25 08:45:05 UTC 2015


On 08/25/2015 01:01 AM, Hans Boehm wrote:

> Note that the use of "Relaxed" here is seriously weaker than in C &
> C++.  It doesn't promise cache-coherence.  That's a sufficiently
> serious difference that I'm not sure I would use the same word.  For
> example, a field that is only ever atomically incremented can appear
> to decrease, where it can't in C or C++.  Of course that term
> already has a long history of not-very-consistent use in the
> hardware community, so maybe it's OK.

I don't think it's OK.  This is so madly counter-intuitive that we
should forbid non-coherent updates.  And I can think of no reason we
should be weaker than C and C++; the last time I heard we were trying
to be closer.  Are there any non-coherent machines we care about?

> Presumably it's too late to add an annotation?  The simplest would
> probably be an @FinalizationSensitive class annotation that causes
> the compiler to insert a reachabilityFence at the end of the scope
> of every reference with that static type or a subclass type.  (Or
> after the current statement for temporaries.)

I think that's a great idea, although I recall we discussed it before
and rejected it.  I don't know why.

I'm wary of "annotations" with such significant semantics, though.  As
a language feature it's a bit, er, yucky; surely it should be a part
of the declaration.  But an annotation is reliable and robust, and
much more so than a method you'd have to remember to invoke
everywhere; such a thing would be a maintenance problem.

Having said that, there is no reason we should not add
reachabilityFence today and plan for the annotation to be a later
addition.

Andrew.


More information about the jmm-dev mailing list