RFR(M): 8080289: Intermediate writes in a loop not eliminated by optimizer

Roland Westrelin roland.westrelin at oracle.com
Tue Jul 28 18:20:01 UTC 2015

>>> What about
>>> volatile int y;
>>> volatile int x;
>>> y=1
>>> x=1
>>> y=2
>>> transformed to:
>>> x=1
>>> y=2
>>> ?
>> I think this is not allowed, since operations over "x" get tied up in
>> the synchronization order.
> Thanks. Then for support_IRIW_for_not_multiple_copy_atomic_cpu true, I don’t see how incorrect reordering is prevented.

I took another look and I was wrong about that.

void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
  bool is_vol = field->is_volatile();
  // If reference is volatile, prevent following memory ops from                                                                                                                                                                                                                
  // floating down past the volatile write.  Also prevents commoning                                                                                                                                                                                                            
  // another volatile read.                                                                                                                                                                                                                                                      
  if (is_vol)  insert_mem_bar(Op_MemBarRelease);

The barrier prevents y=1 from being optimized out.


More information about the hotspot-compiler-dev mailing list