C2 compare and swap fixes

Roman Kennke rkennke at redhat.com
Mon Jun 6 10:11:01 UTC 2016


Am Montag, den 06.06.2016, 10:01 +0200 schrieb Roland Westrelin:
> Hi Roman,
> 
> Thanks for taking a look a this.
> 
> > 
> > Looks mostly good to me.
> > 
> > I believe we don't have to match WeakCompareAndSwap. As far as I
> > understand it, Weak-CAS can fail for unknown reasons. In our case,
> > it
> > should be ok to fail when comparing from- and to-space objects. I
> > am
> > not 100% sure about it though. Would be good to have a testcase or
> > consult somebody who knows for sure.
> I talked to Aleksey Shipilev briefly about this: the expectation is
> that
> if you retry a weakCAS enough times it will eventually succeed.
> 
> http://mail.openjdk.java.net/pipermail/jmm-dev/2016-April/000239.html
> 
> has an example use case, that re-attempts a weakCAS until it
> succeeds.
> 
> What follows is my own interpretation: in case the value in memory is
> a
> from space reference and the expected value passed to weakCAS is a to
> space value, then the weakCAS would fail as long as the value in
> memory
> is not updated to the to space value which as I understand, could
> cause
> a thread to be stuck in a loop with a weakCAS until the GC threads
> finally update the reference and could be a long time. So I don't
> think
> we can simply let the weakCAS fail.

Ok. It's definitely safer and better to implement it with a 'Shenandoah
loop'.

Roman


More information about the shenandoah-dev mailing list