RFR: 8189871: Refactor GC barriers to use declarative semantics

Kim Barrett kim.barrett at oracle.com
Thu Nov 23 20:23:19 UTC 2017


> On Nov 21, 2017, at 2:50 PM, Erik Österlund <erik.osterlund at oracle.com> wrote:
> 
> Hi Kim,
> 
> 
> On 2017-11-21 19:48, Kim Barrett wrote:
>>> On Nov 21, 2017, at 11:20 AM, Erik Österlund <erik.osterlund at oracle.com> wrote:
>>> 
>>> Hi Kim,
>>> 
>>> I am merely more precisely annotating that unsafe accesses on oops have explicitly unknown oop ref strength. However, the GC backends do not do more about it than they did before. I.e. only G1 loads check the actual reference strength and act accordingly (as before), and other exotic accesses are treated the same in the backends (as before) since their pre-write barriers are enough anyway. The behaviour is the same before and after.
>> For the operations in question, there were no checks for reference
>> strength before, not even for G1. So the behavior is not the same
>> before and after the Access changes.
>> 
>> Unsafe_CompareAndExchangeObject on a referent was effectively UB. I
>> don't think adding the special handling for referents makes it any
>> less UB; it's still an abuse of Unsafe to break invariants. In which
>> case, any potential additional work that might be done to handle that
>> specific case is not just pointless, but actively harmful.
> 
> For the operations in question, there were no checks for reference strength before or after. The unsafe.cpp file annotates that this is an unknown oop ref, the backends don't check for it or care. Seems very much the same to me. Am I missing something?

Apparently not.  I was sure I saw a call to
resolve_possibly_unknown_oop_ref_strength in the relevant code path.
That seems to have been a mirage.  Sorry for the noise.

However, while re-exploring that code path, I did notice something
that bothered me.

ModRefBarrierSet::AccessBarrier<...>::oop_atomic_cmpxchg_in_heap
  bs->template write_ref_field_pre<decorators>(addr);
  oop result = Raw::oop_atomic_cmpxchg(...);
  if (result == compare_value) {
    bs->template write_ref_field_post<decorators>(...);
  }
  return result;

does an extra load for G1, to apply the pre-barrier.  The old code
applied the pre-barrier to the result obtained from the raw cmpxchg.



More information about the hotspot-dev mailing list