RFR 8136924 Vectorized support for array equals/compare/mismatch using Unsafe

Peter Levart peter.levart at gmail.com
Wed Nov 25 17:29:59 UTC 2015



On 11/25/2015 12:46 PM, Paul Sandoz wrote:
> We are in Unsafe territory:-)
>
> Since the Java mismatch method and the intrinsic only make temporary reads, IIUC such updates by GC to the array can only occur at a safe points, and i don’t think int loops produce a safe point check within the hot loop and nor does the intrinsic, is this really an issue?

IIUC, in interpreter, safepoint can happen between any two bytecodes:

"Safepoints are initiated using a cooperative, polling-based mechanism. 
In simple terms, every so often a thread asks “should I block for a 
safepoint?”. Asking this question efficiently is not so simple. One 
place where the question is often asked is during a thread state 
transition. Not all state transitions do this, for example a thread 
leaving the VM to go to native code, but many do. The other places where 
a thread asks are in compiled code when returning from a method or at 
certain stages during loop iteration. *Threads executing interpreted 
code don't usually ask the question, instead when the safepoint is 
requested the interpreter switches to a different dispatch table that 
includes the code to ask the question; when the safepoint is over, the 
dispatch table is switched back again*. Once a safepoint has been 
requested, the VMThread must wait until all threads are known to be in a 
safepoint-safe state before proceeding to execute the VM operation. 
During a safepoint the Threads_lock is used to block any threads that 
were running, with the VMThread finally releasing the Threads_lock after 
the VM operation has been performed."


You could treat a "false positive" mismatch like you do with NaN floats 
and doubles (fall-back to normal code), but what about "false negatives"?

Suppose that you take a snapshot of address of object A from the 1st 
array, followed by safepoint which moves object A to somewhere else and 
moves object B to the same address A has occupied before (compacting 
collector). After safepoint returns, you take the snapshot of address of 
object B from the corresponding slot of the 2nd array. Now you compare 
the addresses and they are the same, but they  represent(ed) pointers to 
distinct objects.

Regards, Peter

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20151125/6f01448b/attachment.html>


More information about the hotspot-compiler-dev mailing list