[jmm-dev] VarHandle.safepoint() methods

Doug Lea dl at cs.oswego.edu
Thu Jan 5 15:40:34 UTC 2017

On 01/05/2017 09:09 AM, Andrew Haley wrote:
>   if (VarHandles.checkPointed()) // returns true if safepoint
>      VarHandles.fullFence();
> It'd certainly be easier to implement, and it naturally matches
> exactly what a safepoint does.

It matches it so well that it makes sense to specify the
method to perform fullFence after safepoint execution.

You'd still need epoch-returning form to deal with
safepoints occurring in nested calls in loops.

   e = VH.safePointEpoch();
   for (...) {
     e = VH.safePointCheck(e);

The difference between implicit and explicit safepoint checks is
that in the implicit ones, some variables can be restored
to those saved on safepoint entry, but not so in the explicit
case -- they must be freshly read.


More information about the jmm-dev mailing list