RFR: 8255150: Add utility methods to check long indexes and ranges [v3]

Vladimir Ivanov vlivanov at openjdk.java.net
Sat Nov 7 11:41:58 UTC 2020


On Fri, 6 Nov 2020 08:35:17 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> This change add 3 new methods in Objects:
>> 
>> public static long checkIndex(long index, long length)
>> public static long checkFromToIndex(long fromIndex, long toIndex, long length)
>> public static long checkFromIndexSize(long fromIndex, long size, long length)
>> 
>> This mirrors the int utility methods that were added by JDK-8135248
>> with the same motivations.
>> 
>> As is the case with the int checkIndex(), the long checkIndex() method
>> is JIT compiled as an intrinsic. It allows the JIT to compile
>> checkIndex to an unsigned comparison and properly recognize it as
>> a range check that then becomes a candidate for the existing range check
>> optimizations. This has proven to be important for panama's
>> MemorySegment API and a prototype of this change (with some extra c2
>> improvements) showed that panama micro benchmark results improve
>> significantly.
>> 
>> This change includes:
>> 
>> - the API change
>> - the C2 intrinsic
>> - tests for the API and the C2 intrinsic
>> 
>> This is a joint work with Paul who reviewed and reworked the API change
>> and filled the CSR.
>
> Roland Westrelin has updated the pull request incrementally with one additional commit since the last revision:
> 
>   intrinsic comments

Marked as reviewed by vlivanov (Reviewer).

src/hotspot/share/opto/castnode.cpp line 100:

> 98:   }
> 99:   case Op_CastLL: {
> 100:     assert(!carry_dependency, "carry dependency not supported");

Any particular reason to reject control dependency (except it is not used right now)?

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

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


More information about the core-libs-dev mailing list