Skip to content

Commit 05459df

Browse files
robcaslozTobiHartmann
authored andcommitted
8253765: C2: Control randomization in StressLCM and StressGCM
Use the compilation-local seed in 'StressLCM' and 'StressGCM' rather than the global one. As a consequence, these options use by default a fresh seed in every compilation, unless 'StressSeed=N' is specified, in which case they behave deterministically. Annotate tests that use 'StressLCM' and 'StressGCM' with the 'stress' and 'randomness' keys to reflect this change in default behavior. Reviewed-by: kvn, thartmann
1 parent 6620b61 commit 05459df

18 files changed

+105
-15
lines changed

src/hotspot/share/opto/c2_globals.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
"Randomize worklist traversal in IGVN") \
5454
\
5555
product(uint, StressSeed, 0, DIAGNOSTIC, \
56-
"Seed for IGVN stress testing (if unset, a random one is " \
57-
"generated") \
56+
"Seed for randomized stress testing (if unset, a random one is " \
57+
"generated)") \
5858
range(0, max_juint) \
5959
\
6060
develop(bool, StressMethodHandleLinkerInlining, false, \

src/hotspot/share/opto/compile.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,9 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci,
729729
if (failing()) return;
730730
NOT_PRODUCT( verify_graph_edges(); )
731731

732-
// If IGVN is randomized for stress testing, seed random number
733-
// generation and log the seed for repeatability.
734-
if (StressIGVN) {
732+
// If LCM, GCM, or IGVN are randomized for stress testing, seed
733+
// random number generation and log the seed for repeatability.
734+
if (StressLCM || StressGCM || StressIGVN) {
735735
_stress_seed = FLAG_IS_DEFAULT(StressSeed) ?
736736
static_cast<uint>(Ticks::now().nanoseconds()) : StressSeed;
737737
if (_log != NULL) {
@@ -4489,7 +4489,7 @@ int Compile::random() {
44894489
#define RANDOMIZED_DOMAIN_MASK ((1 << (RANDOMIZED_DOMAIN_POW + 1)) - 1)
44904490
bool Compile::randomized_select(int count) {
44914491
assert(count > 0, "only positive");
4492-
return (os::random() & RANDOMIZED_DOMAIN_MASK) < (RANDOMIZED_DOMAIN / count);
4492+
return (random() & RANDOMIZED_DOMAIN_MASK) < (RANDOMIZED_DOMAIN / count);
44934493
}
44944494

44954495
CloneMap& Compile::clone_map() { return _clone_map; }

src/hotspot/share/opto/compile.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ class Compile : public Phase {
11401140

11411141
// Auxiliary methods for randomized fuzzing/stressing
11421142
int random();
1143-
static bool randomized_select(int count);
1143+
bool randomized_select(int count);
11441144

11451145
// supporting clone_map
11461146
CloneMap& clone_map();

src/hotspot/share/opto/gcm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ Block* PhaseCFG::hoist_to_cheaper_block(Block* LCA, Block* early, Node* self) {
11981198
#endif
11991199
cand_cnt++;
12001200
if (LCA_freq < least_freq || // Better Frequency
1201-
(StressGCM && Compile::randomized_select(cand_cnt)) || // Should be randomly accepted in stress mode
1201+
(StressGCM && C->randomized_select(cand_cnt)) || // Should be randomly accepted in stress mode
12021202
(!StressGCM && // Otherwise, choose with latency
12031203
!in_latency && // No block containing latency
12041204
LCA_freq < least_freq * delta && // No worse frequency

src/hotspot/share/opto/lcm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ Node* PhaseCFG::select(
632632
cand_cnt++;
633633
if (choice < n_choice ||
634634
(choice == n_choice &&
635-
((StressLCM && Compile::randomized_select(cand_cnt)) ||
635+
((StressLCM && C->randomized_select(cand_cnt)) ||
636636
(!StressLCM &&
637637
(latency < n_latency ||
638638
(latency == n_latency &&

test/hotspot/jtreg/compiler/arraycopy/TestCloneAccessStressGCM.java

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

2424
/*
2525
* @test
26+
* @key stress randomness
2627
* @bug 8235332 8248226
2728
* @summary Test cloning with more than 8 (=ArrayCopyLoadStoreMaxElem) fields with StressGCM
2829
* @library /

test/hotspot/jtreg/compiler/arraycopy/TestInitializingACLoadWithBadMem.java

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

2424
/**
2525
* @test
26+
* @key stress randomness
2627
* @bug 8182036
2728
* @summary Load from initializing arraycopy uses wrong memory state
2829
*

test/hotspot/jtreg/compiler/arraycopy/TestLoadBypassACWithWrongMem.java

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

2424
/**
2525
* @test
26+
* @key stress randomness
2627
* @bug 8181742
2728
* @summary Loads that bypass arraycopy ends up with wrong memory state
2829
*

test/hotspot/jtreg/compiler/controldependency/TestEliminatedCastPPAtPhi.java

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

2424
/**
2525
* @test
26+
* @key stress randomness
2627
* @bug 8139771
2728
* @summary Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
2829
* @requires vm.gc=="Serial" | vm.gc=="Parallel"

test/hotspot/jtreg/compiler/debug/TestGenerateStressSeed.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
* @test
3333
* @bug 8252219
3434
* @requires vm.compiler2.enabled
35-
* @summary Tests that using -XX:+StressIGVN without -XX:StressSeed=N generates
35+
* @summary Tests that using a stress option without -XX:StressSeed=N generates
3636
* and logs a random seed.
3737
* @library /test/lib /
38-
* @run driver compiler.debug.TestGenerateStressSeed
38+
* @run driver compiler.debug.TestGenerateStressSeed StressLCM
39+
* @run driver compiler.debug.TestGenerateStressSeed StressGCM
40+
* @run driver compiler.debug.TestGenerateStressSeed StressIGVN
3941
*/
4042

4143
public class TestGenerateStressSeed {
@@ -47,17 +49,18 @@ static void sum(int n) {
4749
}
4850

4951
public static void main(String[] args) throws Exception {
50-
if (args.length == 0) {
52+
if (args[0].startsWith("Stress")) {
5153
String className = TestGenerateStressSeed.class.getName();
54+
String stressOpt = args[0];
5255
String log = "test.log";
5356
String[] procArgs = {
5457
"-Xcomp", "-XX:-TieredCompilation", "-XX:+UnlockDiagnosticVMOptions",
55-
"-XX:CompileOnly=" + className + "::sum", "-XX:+StressIGVN",
58+
"-XX:CompileOnly=" + className + "::sum", "-XX:+" + stressOpt,
5659
"-XX:+LogCompilation", "-XX:LogFile=" + log, className, "10"};
5760
ProcessTools.createJavaProcessBuilder(procArgs).start().waitFor();
5861
new OutputAnalyzer(Paths.get(log))
5962
.shouldContain("stress_test seed");
60-
} else if (args.length > 0) {
63+
} else {
6164
sum(Integer.parseInt(args[0]));
6265
}
6366
}

0 commit comments

Comments
 (0)