Skip to content
Permalink
Browse files
8242310: use reproducible random in hotspot compiler tests
Reviewed-by: kvn, thartmann
  • Loading branch information
iignatev committed Apr 9, 2020
1 parent 0eb72d4 commit 7c351405c4a43c8af40a63f63b70bfcb7719b570
Showing 94 changed files with 258 additions and 159 deletions.
@@ -11,6 +11,7 @@

/**
* @test
* @key randomness
* @bug 8005956
* @summary C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
* @library /test/lib
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,16 +23,19 @@

/*
* @test
* @key randomness
* @bug 6661247
* @summary Internal bug in 32-bit HotSpot optimizer while bit manipulations
*
* @library /test/lib
* @run main compiler.c2.Test6661247
*/

package compiler.c2;

import java.nio.LongBuffer;
import java.util.Random;
import jdk.test.lib.Utils;

// This isn't a completely reliable test for 6661247 since the results
// depend on what the local schedule looks like but it does reproduce
@@ -133,7 +136,7 @@ public static void test(boolean[] src, int srcPos, LongBuffer dest, long destPos
}
}
public static void main(String[] args) {
Random r = new Random();
Random r = Utils.getRandomInstance();
int entries = 1000;
boolean[] src = new boolean[entries * 64];
long[] dest = new long[entries];
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,16 +23,20 @@

/**
* @test
* @key randomness
* @bug 7047069
* @summary Array can dynamically change size when assigned to an object field
* @modules java.desktop
*
* @library /test/lib
* @run main/othervm -Xbatch compiler.c2.Test7047069
*/

package compiler.c2;

import java.awt.geom.Line2D;
import java.util.Random;
import jdk.test.lib.Utils;

public class Test7047069 {
static boolean verbose;
@@ -119,12 +123,13 @@ public Test7047069() {
this.squareflat = .0001f * .0001f;
holdIndex = hold.length - 6;
holdEnd = hold.length - 2;
hold[holdIndex + 0] = (float) (Math.random() * 100);
hold[holdIndex + 1] = (float) (Math.random() * 100);
hold[holdIndex + 2] = (float) (Math.random() * 100);
hold[holdIndex + 3] = (float) (Math.random() * 100);
hold[holdIndex + 4] = (float) (Math.random() * 100);
hold[holdIndex + 5] = (float) (Math.random() * 100);
Random rng = Utils.getRandomInstance();
hold[holdIndex + 0] = (float) (rng.nextDouble() * 100);
hold[holdIndex + 1] = (float) (rng.nextDouble() * 100);
hold[holdIndex + 2] = (float) (rng.nextDouble() * 100);
hold[holdIndex + 3] = (float) (rng.nextDouble() * 100);
hold[holdIndex + 4] = (float) (rng.nextDouble() * 100);
hold[holdIndex + 5] = (float) (rng.nextDouble() * 100);
levelIndex = 0;
this.limit = 10;
this.levels = new int[limit + 1];
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,28 +23,34 @@

/**
* @test
* @key randomness
* @bug 7160610
* @summary Unknown Native Code compilation issue.
*
* @library /test/lib
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-OptimizeFill compiler.c2.Test7160610
*/

package compiler.c2;

import jdk.test.lib.Utils;

import java.util.Random;

public class Test7160610 {
private static final byte[] BYTE_ARRAY = new byte[7];
private static int[] anIntArray1190 = new int[32768];
private static int[] anIntArray1191 = new int[32768];

public static void main(String arg[]) {
Random rng = Utils.getRandomInstance();
int i = 256;
for(int j = BYTE_ARRAY[2]; j < anIntArray1190.length; j++) {
anIntArray1190[j] = BYTE_ARRAY[2];
}

for(int k = BYTE_ARRAY[2]; (k ^ BYTE_ARRAY[1]) > -5001; k++) {
int i1 = (int)(Math.random() * 128D * (double)i);
anIntArray1190[i1] = (int)(Math.random() * 256D);
int i1 = (int)(rng.nextDouble() * 128D * (double)i);
anIntArray1190[i1] = (int)(rng.nextDouble() * 256D);
}

for(int l = BYTE_ARRAY[2]; (l ^ BYTE_ARRAY[1]) > -21; l++) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@

/**
* @test
* @key randomness
* @bug 7177917
* @summary Micro-benchmark for Math.pow() and Math.exp()
* @modules java.base/jdk.internal.misc
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@

/**
* @test
* @key randomness
* @bug 8015774
* @summary Verify processing of options related to code heaps sizing.
* @library /test/lib /
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@

/*
* @test SegmentedCodeCacheDtraceTest
* @key randomness
* @bug 8015774
* @summary testing of dtrace for segmented code cache
* @requires os.family=="solaris"
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,18 +26,15 @@
import jdk.test.lib.Asserts;
import jdk.test.lib.ByteCodeLoader;
import jdk.test.lib.InfiniteLoop;
import jdk.test.lib.Utils;
import sun.hotspot.WhiteBox;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.Callable;

public final class Helper {
public static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
public static final Random RNG = Utils.getRandomInstance();

private static final long THRESHOLD = WHITE_BOX.getIntxVMFlag("CompileThreshold");
private static final String TEST_CASE_IMPL_CLASS_NAME = "compiler.codecache.stress.TestCaseImpl";
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@

/*
* @test OverloadCompileQueueTest
* @key stress randomness
* @summary stressing code cache by overloading compile queues
* @library /test/lib /
* @modules java.base/jdk.internal.misc
@@ -46,9 +47,11 @@
package compiler.codecache.stress;

import jdk.test.lib.Platform;
import jdk.test.lib.Utils;

import java.lang.reflect.Method;
import java.util.stream.IntStream;
import java.util.Random;

public class OverloadCompileQueueTest implements Runnable {
private static final int MAX_SLEEP = 10000;
@@ -60,6 +63,7 @@ public class OverloadCompileQueueTest implements Runnable {
private static final int TIERED_STOP_AT_LEVEL
= Helper.WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue();
private static final int[] AVAILABLE_LEVELS;
private final Random rng = Utils.getRandomInstance();
static {
if (TIERED_COMPILATION) {
AVAILABLE_LEVELS = IntStream
@@ -104,7 +108,7 @@ public void run() {

private void lockUnlock() {
try {
int sleep = Helper.RNG.nextInt(MAX_SLEEP);
int sleep = rng.nextInt(MAX_SLEEP);
Helper.WHITE_BOX.lockCompilation();
Thread.sleep(sleep);
} catch (InterruptedException e) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@

/*
* @test RandomAllocationTest
* @key stress
* @key stress randomness
* @summary stressing code cache by allocating randomly sized "dummy" code blobs
* @library /test/lib /
* @modules java.base/jdk.internal.misc
@@ -49,13 +49,16 @@
import sun.hotspot.code.BlobType;

import java.util.ArrayList;
import java.util.Random;
import jdk.test.lib.Utils;

public class RandomAllocationTest implements Runnable {
private static final long CODE_CACHE_SIZE
= Helper.WHITE_BOX.getUintxVMFlag("ReservedCodeCacheSize");
private static final int MAX_BLOB_SIZE = (int) (CODE_CACHE_SIZE >> 7);
private static final BlobType[] BLOB_TYPES
= BlobType.getAvailable().toArray(new BlobType[0]);
private final Random rng = Utils.getRandomInstance();

public static void main(String[] args) {
new CodeCacheStressRunner(new RandomAllocationTest()).runTest();
@@ -64,16 +67,16 @@ public static void main(String[] args) {
private final ArrayList<Long> blobs = new ArrayList<>();
@Override
public void run() {
boolean allocate = blobs.isEmpty() || Helper.RNG.nextBoolean();
boolean allocate = blobs.isEmpty() || rng.nextBoolean();
if (allocate) {
int type = Helper.RNG.nextInt(BLOB_TYPES.length);
int type = rng.nextInt(BLOB_TYPES.length);
long addr = Helper.WHITE_BOX.allocateCodeBlob(
Helper.RNG.nextInt(MAX_BLOB_SIZE), BLOB_TYPES[type].id);
rng.nextInt(MAX_BLOB_SIZE), BLOB_TYPES[type].id);
if (addr != 0) {
blobs.add(addr);
}
} else {
int index = Helper.RNG.nextInt(blobs.size());
int index = rng.nextInt(blobs.size());
Helper.WHITE_BOX.freeCodeBlob(blobs.remove(index));
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@

/*
* @test UnexpectedDeoptimizationTest
* @key stress
* @key stress randomness
* @summary stressing code cache by forcing unexpected deoptimizations
* @library /test/lib /
* @modules java.base/jdk.internal.misc
@@ -48,15 +48,19 @@

package compiler.codecache.stress;

import java.util.Random;
import jdk.test.lib.Utils;

public class UnexpectedDeoptimizationTest implements Runnable {
private final Random rng = Utils.getRandomInstance();

public static void main(String[] args) {
new CodeCacheStressRunner(new UnexpectedDeoptimizationTest()).runTest();
}

@Override
public void run() {
Helper.WHITE_BOX.deoptimizeFrames(Helper.RNG.nextBoolean());
Helper.WHITE_BOX.deoptimizeFrames(rng.nextBoolean());
}

}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@

/*
* @test
* @key randomness
* @bug 6896617
* @summary Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() with SSE instructions on x86
* @library /test/lib
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@

/**
* @test
* @key randomness
* @bug 7100757
* @summary The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
* @library /test/lib
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@

/**
* @test
* @key randomness
* @bug 8210215
* @summary Test that C2 correctly optimizes trichotomy expressions.
* @library /test/lib

0 comments on commit 7c35140

Please sign in to comment.