mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8271732: Regression in StringBuilder.charAt bounds checking
Reviewed-by: alanb, naoto
This commit is contained in:
parent
ec2fc384e5
commit
a15b659278
3 changed files with 108 additions and 2 deletions
|
@ -24,18 +24,25 @@ package org.openjdk.bench.java.lang;
|
|||
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.BenchmarkMode;
|
||||
import org.openjdk.jmh.annotations.CompilerControl;
|
||||
import org.openjdk.jmh.annotations.Fork;
|
||||
import org.openjdk.jmh.annotations.Measurement;
|
||||
import org.openjdk.jmh.annotations.Mode;
|
||||
import org.openjdk.jmh.annotations.OutputTimeUnit;
|
||||
import org.openjdk.jmh.annotations.Param;
|
||||
import org.openjdk.jmh.annotations.Scope;
|
||||
import org.openjdk.jmh.annotations.Setup;
|
||||
import org.openjdk.jmh.annotations.State;
|
||||
import org.openjdk.jmh.annotations.Warmup;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Measurement(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Fork(3)
|
||||
public class StringBuilders {
|
||||
|
||||
private String[] strings;
|
||||
|
@ -330,6 +337,20 @@ public class StringBuilders {
|
|||
endIndex).append(';').toString();
|
||||
}
|
||||
|
||||
public int charAt_index = 3;
|
||||
|
||||
@Benchmark
|
||||
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
|
||||
public char charAtLatin1() {
|
||||
return sbLatin1.charAt(charAt_index);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
|
||||
public char charAtUtf16() {
|
||||
return sbUtf16.charAt(charAt_index);
|
||||
}
|
||||
|
||||
@State(Scope.Thread)
|
||||
public static class Data {
|
||||
int i = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue