Observations from a simple JMH benchmark

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Thu Feb 15 18:44:56 UTC 2018


Here's a quick prototype of enhanced array OOB checks:

   http://cr.openjdk.java.net/~vlivanov/panama/vector.oob/webrev.00

-Djdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK:

  =0: no checks

  =1: use Objects.checkFromIndexSize (default)

  =2: enhanced check
+                // vlen > 0, length >=0
+                //
+                // 0 <= i, (i + vlen) <= length
+                //   =>
+                // 0 <= vlen <= length, 0 <= i < (length - vlen);
+                Objects.checkIndex(vlen - 1, length);
+                Objects.checkIndex(ix, length - (vlen - 1));

Best regards,
Vladimir Ivanov

On 2/15/18 3:58 PM, Vladimir Ivanov wrote:
> 
>> I have been playing around with a simple benchmark and JMH (separately 
>> i can get asm hotspots working on the mac now via dtrace!)
> ...
>> Vladimir, i guess this is the kind of thing you were mentioning with 
>> regards to bounds checks?
> 
> Yes.
> 
>> Perhaps there are general optimization possibilities for such bounds 
>> checks. Only Preconditions.checkIndex is currently an intrinsic.
> 
> I proposed some tweaks earlier [1], but haven't done any experiments yet:
> 
>    0 <= i
>    (i + vlen) <= length
> ==>
>    (a) 0 <= i <= (length - vlen)
>    (b) (vlen <= length)
> 
> a - upper bound is loop invariant
> b - loop invariant
> 
> Best regards,
> Vladimir Ivanov
> 
> [1] 
> http://mail.openjdk.java.net/pipermail/panama-dev/2017-December/000889.html
> 


More information about the panama-dev mailing list