RFR: 8254162: Implementation of Foreign-Memory Access API (Third Incubator) [v3]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri Oct 9 11:37:19 UTC 2020


On Thu, 8 Oct 2020 23:17:33 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

>> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fix indent in GensrcScopedMemoryAccess.gmk
>
> Reviewed this when updated in [panama-foreign](https://github.com/openjdk/panama-foreign/tree/foreign-memaccess), hence
> the lack of substantial comments for this PR.

When re-running all benchmarks, I noted an issue with the `BulkOps` microbenchmark: calling `MemorySegment::mismatch`
on a small segment (< 8 bytes) was 10x slower than with ByteBuffers. After some investigation, I realized that the
issue is caused by the fact that the `AbstractMemorySegmentImpl::mismatch` method contains inexact var handle calls,
where the segment coordinate has type `AbstractMemorySegmentImpl` instead of the expected `MemorySegment`, so we take
the slow path.

A simple solution is to avoid using var handles directly here, and use the helper functions in MemoryAccess, which
widens the type accordingly and produce an exact var handle call.

With this change, perfomance of mismatch on small segment is on par with ByteBuffer.

-------------

PR: https://git.openjdk.java.net/jdk/pull/548



More information about the security-dev mailing list