JDK-8156534 : Check if range checks can be moved into Java wrapper for intrinsics
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9,10
  • Priority: P2
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2016-05-09
  • Updated: 2019-01-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Some of the String related intrinsics have range checks in the intrinsic itself instead of having a Java wrapper (see John's comment here [1]). We should investigate if we can safely move the checks into the Java code while avoiding problems like JDK-8142303. We can probably make use of the intrinsified Preconditions.checkIndex().

[1] http://mail.openjdk.java.net/pipermail/hotspot-dev/2016-April/022936.html
We should re-introduce debug range checks in the intrinsics to catch unchecked calls from the Java wrappers: http://hg.openjdk.java.net/jdk9/sandbox/hotspot/rev/8a7f17b4709f

Vladimir I. noticed that there are redundant bound checks: > Also, noticed redundant bounds checks: > @Override > public char charAt(int index) { > checkIndex(index, count); > if (isLatin1()) { > return (char)(value[index] & 0xff); > } > return StringUTF16.charAt(value, index); > } > ... > public static char charAt(byte[] value, int index) { > if (index < 0 || index >= value.length >> 1) { > throw new StringIndexOutOfBoundsException(index); > } > return getChar(value, index); > }