[foreign-memaccess] RFR: JDK-8242495: Restructure implementation of memory segments
Paul Sandoz
psandoz at openjdk.java.net
Fri Apr 10 16:44:06 UTC 2020
On Fri, 10 Apr 2020 16:33:19 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java line 55:
>>
>>> 54: @ForceInline
>>> 55: HeapMemorySegmentImpl(long offset, Supplier<H> baseProvider, long length, int mask, Thread owner, MemoryScope
>>> scope) { 56: super(length, mask, owner, scope);
>>
>> Instead of a `Supplier` i wonder if one could pass in `H base, Class<H> baseType` then `base()` becomes:
>>
>> H base() {
>> return Objects.requireNonNull(baseType.cast(base));
>> }
>>
>> If that works there is less for the JIT to do.
>
> Just tried this - makes benchmarks revert to old behavior - roughly 10x slower. Worth a try, but I think using
> reflection probably makes thing less transparent to the JIT.
Interesting, I thought it might be the explicit casts introduced in the MH machinery of lambdas, and since everything
is final and stable (?) the casts usually help the JIT, if so then there is clearly more going on with the MH machinery.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/109
More information about the panama-dev
mailing list