8286182: [BACKOUT] x86: Handle integral division overflow during parsing

8287035: [BACKOUT] PPC64: Handle integral division overflow during parsing

Reviewed-by: mdoerr, thartmann
This commit is contained in:
Quan Anh Mai 2022-05-19 19:12:28 +00:00 committed by Martin Doerr
parent 7b19226be2
commit 079312c835
25 changed files with 502 additions and 713 deletions

View file

@ -24,7 +24,6 @@ package org.openjdk.bench.java.lang;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
@ -35,10 +34,12 @@ import java.util.random.RandomGenerator;
import java.util.random.RandomGeneratorFactory;
import java.util.concurrent.TimeUnit;
/**
* Tests unsigned division and modulus methods in java.lang.Integer
*/
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread)
@Fork(1)
public class IntegerDivMod {
RandomGenerator randomGenerator;
@ -59,37 +60,12 @@ public class IntegerDivMod {
for (int i = 0; i < BUFFER_SIZE; i++) {
dividends[i] = rng.nextInt();
int divisor = rng.nextInt();
if (divisorType.equals("positive")) {
divisor = Math.abs(divisor);
} else if (divisorType.equals("negative")) {
divisor = -Math.abs(divisor);
}
if (divisorType.equals("positive")) divisor = Math.abs(divisor);
else if (divisorType.equals("negative")) divisor = -Math.abs(divisor);
divisors[i] = divisor;
}
}
@Benchmark
public void testDivide() {
for (int i = 0; i < BUFFER_SIZE; i++) {
quotients[i] = dividends[i] / divisors[i];
}
}
@Benchmark
public void testDivideKnownPositive() {
for (int i = 0; i < BUFFER_SIZE; i++) {
quotients[i] = dividends[i] / Math.max(1, divisors[i]);
}
}
@Benchmark
public void testDivideHoistedDivisor() {
int x = divisors[0];
for (int i = 0; i < BUFFER_SIZE; i++) {
quotients[i] = dividends[i] / x;
}
}
@Benchmark
public void testDivideUnsigned() {
for (int i = 0; i < BUFFER_SIZE; i++) {
@ -115,4 +91,8 @@ public class IntegerDivMod {
quotients[i] = Integer.divideUnsigned(dividend, divisor);
remainders[i] = Integer.remainderUnsigned(dividend, divisor);
}
}