8265518: C1: Intrinsic support for Preconditions.checkIndex

Reviewed-by: dfuchs, iveresov
This commit is contained in:
Yi Yang 2021-06-12 01:03:50 +00:00
parent a466b49e71
commit 5cee23a9ed
11 changed files with 270 additions and 98 deletions

View file

@ -34,9 +34,9 @@ import jdk.internal.misc.ScopedMemoryAccess.Scope;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM.BufferPool;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import java.io.FileDescriptor;
import java.util.Objects;
import java.util.Spliterator;
/**
@ -737,11 +737,8 @@ public abstract class Buffer {
* IndexOutOfBoundsException} if it is not smaller than the limit
* or is smaller than zero.
*/
@IntrinsicCandidate
final int checkIndex(int i) { // package-private
if ((i < 0) || (i >= limit))
throw new IndexOutOfBoundsException();
return i;
return Objects.checkIndex(i, limit);
}
final int checkIndex(int i, int nb) { // package-private