Skip to content

Commit 078eac8

Browse files
committed
8242310: use reproducible random in hotspot compiler tests
Reviewed-by: mdoerr Backport-of: 7c35140
1 parent 60e771f commit 078eac8

File tree

91 files changed

+249
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+249
-153
lines changed

test/hotspot/jtreg/compiler/c2/PolynomialRoot.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
/**
1313
* @test
14+
* @key randomness
1415
* @bug 8005956
1516
* @summary C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
1617
* @library /test/lib

test/hotspot/jtreg/compiler/c2/Test6661247.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,16 +23,19 @@
2323

2424
/*
2525
* @test
26+
* @key randomness
2627
* @bug 6661247
2728
* @summary Internal bug in 32-bit HotSpot optimizer while bit manipulations
2829
*
30+
* @library /test/lib
2931
* @run main compiler.c2.Test6661247
3032
*/
3133

3234
package compiler.c2;
3335

3436
import java.nio.LongBuffer;
3537
import java.util.Random;
38+
import jdk.test.lib.Utils;
3639

3740
// This isn't a completely reliable test for 6661247 since the results
3841
// 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
133136
}
134137
}
135138
public static void main(String[] args) {
136-
Random r = new Random();
139+
Random r = Utils.getRandomInstance();
137140
int entries = 1000;
138141
boolean[] src = new boolean[entries * 64];
139142
long[] dest = new long[entries];

test/hotspot/jtreg/compiler/c2/Test7047069.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,16 +23,20 @@
2323

2424
/**
2525
* @test
26+
* @key randomness
2627
* @bug 7047069
2728
* @summary Array can dynamically change size when assigned to an object field
2829
* @modules java.desktop
2930
*
31+
* @library /test/lib
3032
* @run main/othervm -Xbatch compiler.c2.Test7047069
3133
*/
3234

3335
package compiler.c2;
3436

3537
import java.awt.geom.Line2D;
38+
import java.util.Random;
39+
import jdk.test.lib.Utils;
3640

3741
public class Test7047069 {
3842
static boolean verbose;
@@ -119,12 +123,13 @@ public Test7047069() {
119123
this.squareflat = .0001f * .0001f;
120124
holdIndex = hold.length - 6;
121125
holdEnd = hold.length - 2;
122-
hold[holdIndex + 0] = (float) (Math.random() * 100);
123-
hold[holdIndex + 1] = (float) (Math.random() * 100);
124-
hold[holdIndex + 2] = (float) (Math.random() * 100);
125-
hold[holdIndex + 3] = (float) (Math.random() * 100);
126-
hold[holdIndex + 4] = (float) (Math.random() * 100);
127-
hold[holdIndex + 5] = (float) (Math.random() * 100);
126+
Random rng = Utils.getRandomInstance();
127+
hold[holdIndex + 0] = (float) (rng.nextDouble() * 100);
128+
hold[holdIndex + 1] = (float) (rng.nextDouble() * 100);
129+
hold[holdIndex + 2] = (float) (rng.nextDouble() * 100);
130+
hold[holdIndex + 3] = (float) (rng.nextDouble() * 100);
131+
hold[holdIndex + 4] = (float) (rng.nextDouble() * 100);
132+
hold[holdIndex + 5] = (float) (rng.nextDouble() * 100);
128133
levelIndex = 0;
129134
this.limit = 10;
130135
this.levels = new int[limit + 1];

test/hotspot/jtreg/compiler/c2/Test7160610.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,28 +23,34 @@
2323

2424
/**
2525
* @test
26+
* @key randomness
2627
* @bug 7160610
2728
* @summary Unknown Native Code compilation issue.
28-
*
29+
* @library /test/lib
2930
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-OptimizeFill compiler.c2.Test7160610
3031
*/
3132

3233
package compiler.c2;
3334

35+
import jdk.test.lib.Utils;
36+
37+
import java.util.Random;
38+
3439
public class Test7160610 {
3540
private static final byte[] BYTE_ARRAY = new byte[7];
3641
private static int[] anIntArray1190 = new int[32768];
3742
private static int[] anIntArray1191 = new int[32768];
3843

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

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

5056
for(int l = BYTE_ARRAY[2]; (l ^ BYTE_ARRAY[1]) > -21; l++) {

test/hotspot/jtreg/compiler/c2/Test7177917.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
2323

2424
/**
2525
* @test
26+
* @key randomness
2627
* @bug 7177917
2728
* @summary Micro-benchmark for Math.pow() and Math.exp()
2829
* @modules java.base/jdk.internal.misc

test/hotspot/jtreg/compiler/codecache/cli/codeheapsize/TestCodeHeapSizeOptions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
2323

2424
/**
2525
* @test
26+
* @key randomness
2627
* @bug 8015774
2728
* @summary Verify processing of options related to code heaps sizing.
2829
* @library /test/lib /

test/hotspot/jtreg/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
2323

2424
/*
2525
* @test SegmentedCodeCacheDtraceTest
26+
* @key randomness
2627
* @bug 8015774
2728
* @summary testing of dtrace for segmented code cache
2829
* @requires os.family=="solaris"

test/hotspot/jtreg/compiler/codecache/stress/Helper.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,18 +26,15 @@
2626
import jdk.test.lib.Asserts;
2727
import jdk.test.lib.ByteCodeLoader;
2828
import jdk.test.lib.InfiniteLoop;
29-
import jdk.test.lib.Utils;
3029
import sun.hotspot.WhiteBox;
3130

3231
import java.io.BufferedInputStream;
3332
import java.io.ByteArrayOutputStream;
3433
import java.io.IOException;
35-
import java.util.Random;
3634
import java.util.concurrent.Callable;
3735

3836
public final class Helper {
3937
public static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
40-
public static final Random RNG = Utils.getRandomInstance();
4138

4239
private static final long THRESHOLD = WHITE_BOX.getIntxVMFlag("CompileThreshold");
4340
private static final String TEST_CASE_IMPL_CLASS_NAME = "compiler.codecache.stress.Helper$TestCaseImpl";

test/hotspot/jtreg/compiler/codecache/stress/OverloadCompileQueueTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
2323

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

4849
import jdk.test.lib.Platform;
50+
import jdk.test.lib.Utils;
4951

5052
import java.lang.reflect.Method;
5153
import java.util.stream.IntStream;
54+
import java.util.Random;
5255

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

105109
private void lockUnlock() {
106110
try {
107-
int sleep = Helper.RNG.nextInt(MAX_SLEEP);
111+
int sleep = rng.nextInt(MAX_SLEEP);
108112
Helper.WHITE_BOX.lockCompilation();
109113
Thread.sleep(sleep);
110114
} catch (InterruptedException e) {

test/hotspot/jtreg/compiler/codecache/stress/RandomAllocationTest.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

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

5151
import java.util.ArrayList;
52+
import java.util.Random;
53+
import jdk.test.lib.Utils;
5254

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

6063
public static void main(String[] args) {
6164
new CodeCacheStressRunner(new RandomAllocationTest()).runTest();
@@ -64,16 +67,16 @@ public static void main(String[] args) {
6467
private final ArrayList<Long> blobs = new ArrayList<>();
6568
@Override
6669
public void run() {
67-
boolean allocate = blobs.isEmpty() || Helper.RNG.nextBoolean();
70+
boolean allocate = blobs.isEmpty() || rng.nextBoolean();
6871
if (allocate) {
69-
int type = Helper.RNG.nextInt(BLOB_TYPES.length);
72+
int type = rng.nextInt(BLOB_TYPES.length);
7073
long addr = Helper.WHITE_BOX.allocateCodeBlob(
71-
Helper.RNG.nextInt(MAX_BLOB_SIZE), BLOB_TYPES[type].id);
74+
rng.nextInt(MAX_BLOB_SIZE), BLOB_TYPES[type].id);
7275
if (addr != 0) {
7376
blobs.add(addr);
7477
}
7578
} else {
76-
int index = Helper.RNG.nextInt(blobs.size());
79+
int index = rng.nextInt(blobs.size());
7780
Helper.WHITE_BOX.freeCodeBlob(blobs.remove(index));
7881
}
7982
}

0 commit comments

Comments
 (0)