RFR [15] 8247696: Incorrect tail computation for large segments in AbstractMemorySegmentImpl::mismatch

Chris Hegarty chris.hegarty at oracle.com
Wed Jun 17 15:33:08 UTC 2020


The MemorySegment::mismatch implementation added vectorized mismatch of long sizes. The implementation is trivial, but the starting point for a more optimized implementation, if needed. ArraysSupport::vectorizedMismatchLarge incorrectly returns the bitwise complement of the offset of the first mismatch, where it should return the bitwise complement of the number of remaining pairs of elements to be checked in the tail of the two arrays. The AbstractMemorySegmentImpl::mismatch masked this problem, since it seamlessly compared the remaining tail, which is larger than it should be.

Webrev:
  https://cr.openjdk.java.net/~chegar/8247696/webrev.00/

I updated the exiting BulkOps micro-benchmark to cover mismatch. Here are the results, compared to ByteBuffer::mismatch, on my machine:

Benchmark                          Mode  Cnt        Score        Error  Units
BulkOps.mismatch_large_bytebuffer  avgt   30   740186.973 ? 119314.207  ns/op
BulkOps.mismatch_large_segment     avgt   30   683475.305 ?  76355.043  ns/op
BulkOps.mismatch_small_bytebuffer  avgt   30        7.367 ?      0.523  ns/op
BulkOps.mismatch_small_segment     avgt   30        4.140 ?      0.602  ns/op


-Chris.


More information about the core-libs-dev mailing list