mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
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:
parent
7b19226be2
commit
079312c835
25 changed files with 502 additions and 713 deletions
|
@ -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.Long
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Thread)
|
||||
@Fork(1)
|
||||
public class LongDivMod {
|
||||
|
||||
RandomGenerator randomGenerator;
|
||||
|
@ -59,37 +60,12 @@ public class LongDivMod {
|
|||
for (int i = 0; i < BUFFER_SIZE; i++) {
|
||||
dividends[i] = rng.nextLong();
|
||||
long divisor = rng.nextLong();
|
||||
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() {
|
||||
long 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 LongDivMod {
|
|||
quotients[i] = Long.divideUnsigned(dividend, divisor);
|
||||
remainders[i] = Long.remainderUnsigned(dividend, divisor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue