8256535: C2: randomize CCP processing order for stress testing
Add 'StressCCP' option to randomize the selection of the node to be examined in each CCP iteration. Reviewed-by: chagedorn, kvn, thartmann
This commit is contained in:
parent
d8ad63019a
commit
bc56541424
@ -50,6 +50,9 @@
|
||||
product(bool, StressIGVN, false, DIAGNOSTIC, \
|
||||
"Randomize worklist traversal in IGVN") \
|
||||
\
|
||||
product(bool, StressCCP, false, DIAGNOSTIC, \
|
||||
"Randomize worklist traversal in CCP") \
|
||||
\
|
||||
product(uint, StressSeed, 0, DIAGNOSTIC, \
|
||||
"Seed for randomized stress testing (if unset, a random one is " \
|
||||
"generated). The seed is recorded in the compilation log, if " \
|
||||
|
@ -767,9 +767,9 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci,
|
||||
if (failing()) return;
|
||||
NOT_PRODUCT( verify_graph_edges(); )
|
||||
|
||||
// If LCM, GCM, or IGVN are randomized for stress testing, seed
|
||||
// random number generation and log the seed for repeatability.
|
||||
if (StressLCM || StressGCM || StressIGVN) {
|
||||
// If any phase is randomized for stress testing, seed random number
|
||||
// generation and log the seed for repeatability.
|
||||
if (StressLCM || StressGCM || StressIGVN || StressCCP) {
|
||||
_stress_seed = FLAG_IS_DEFAULT(StressSeed) ?
|
||||
static_cast<uint>(Ticks::now().nanoseconds()) : StressSeed;
|
||||
if (_log != NULL) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, 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
|
||||
@ -1714,7 +1714,12 @@ void PhaseCCP::analyze() {
|
||||
// Pull from worklist; compute new value; push changes out.
|
||||
// This loop is the meat of CCP.
|
||||
while( worklist.size() ) {
|
||||
Node *n = worklist.pop();
|
||||
Node* n; // Node to be examined in this iteration
|
||||
if (StressCCP) {
|
||||
n = worklist.remove(C->random() % worklist.size());
|
||||
} else {
|
||||
n = worklist.pop();
|
||||
}
|
||||
const Type *t = n->Value(this);
|
||||
if (t != type(n)) {
|
||||
assert(ccp_type_widens(t, type(n)), "ccp type must widen");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, 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,19 +23,31 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8252219
|
||||
* @bug 8252219 8256535
|
||||
* @requires vm.compiler2.enabled
|
||||
* @summary Tests that different combinations of the options -XX:+StressIGVN and
|
||||
* @summary Tests that different combinations of stress options and
|
||||
* -XX:StressSeed=N are accepted.
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN
|
||||
* compiler.arguments.TestStressIGVNOptions
|
||||
* compiler.arguments.TestStressOptions
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN -XX:StressSeed=42
|
||||
* compiler.arguments.TestStressIGVNOptions
|
||||
* compiler.arguments.TestStressOptions
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressCCP
|
||||
* compiler.arguments.TestStressOptions
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressCCP -XX:StressSeed=42
|
||||
* compiler.arguments.TestStressOptions
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressLCM
|
||||
* compiler.arguments.TestStressOptions
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressLCM -XX:StressSeed=42
|
||||
* compiler.arguments.TestStressOptions
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM
|
||||
* compiler.arguments.TestStressOptions
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:StressSeed=42
|
||||
* compiler.arguments.TestStressOptions
|
||||
*/
|
||||
|
||||
package compiler.arguments;
|
||||
|
||||
public class TestStressIGVNOptions {
|
||||
public class TestStressOptions {
|
||||
|
||||
static public void main(String[] args) {
|
||||
System.out.println("Passed");
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, 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
|
||||
@ -30,7 +30,7 @@ import jdk.test.lib.Asserts;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8252219
|
||||
* @bug 8252219 8256535
|
||||
* @requires vm.compiler2.enabled
|
||||
* @summary Tests that using a stress option without -XX:StressSeed=N generates
|
||||
* and logs a random seed.
|
||||
@ -38,6 +38,7 @@ import jdk.test.lib.Asserts;
|
||||
* @run driver compiler.debug.TestGenerateStressSeed StressLCM
|
||||
* @run driver compiler.debug.TestGenerateStressSeed StressGCM
|
||||
* @run driver compiler.debug.TestGenerateStressSeed StressIGVN
|
||||
* @run driver compiler.debug.TestGenerateStressSeed StressCCP
|
||||
*/
|
||||
|
||||
public class TestGenerateStressSeed {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, 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
|
||||
@ -29,28 +29,37 @@ import jdk.test.lib.Asserts;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8252219
|
||||
* @bug 8252219 8256535
|
||||
* @requires vm.debug == true & vm.compiler2.enabled
|
||||
* @summary Tests that compilations with the same seed yield the same IGVN
|
||||
* trace.
|
||||
* @summary Tests that stress compilations with the same seed yield the same
|
||||
* IGVN and CCP traces.
|
||||
* @library /test/lib /
|
||||
* @run driver compiler.debug.TestStressIGVN
|
||||
* @run driver compiler.debug.TestStressIGVNAndCCP
|
||||
*/
|
||||
|
||||
public class TestStressIGVN {
|
||||
public class TestStressIGVNAndCCP {
|
||||
|
||||
static String igvnTrace(int stressSeed) throws Exception {
|
||||
String className = TestStressIGVN.class.getName();
|
||||
static String phaseTrace(String stressOption, String traceOption,
|
||||
int stressSeed) throws Exception {
|
||||
String className = TestStressIGVNAndCCP.class.getName();
|
||||
String[] procArgs = {
|
||||
"-Xcomp", "-XX:-TieredCompilation", "-XX:-Inline",
|
||||
"-XX:CompileOnly=" + className + "::sum", "-XX:+TraceIterativeGVN",
|
||||
"-XX:+StressIGVN", "-XX:StressSeed=" + stressSeed,
|
||||
"-XX:CompileOnly=" + className + "::sum", "-XX:+" + traceOption,
|
||||
"-XX:+" + stressOption, "-XX:StressSeed=" + stressSeed,
|
||||
className, "10"};
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
|
||||
OutputAnalyzer out = new OutputAnalyzer(pb.start());
|
||||
return out.getStdout();
|
||||
}
|
||||
|
||||
static String igvnTrace(int stressSeed) throws Exception {
|
||||
return phaseTrace("StressIGVN", "TraceIterativeIGVN", stressSeed);
|
||||
}
|
||||
|
||||
static String ccpTrace(int stressSeed) throws Exception {
|
||||
return phaseTrace("StressCCP", "TracePhaseCCP", stressSeed);
|
||||
}
|
||||
|
||||
static void sum(int n) {
|
||||
int acc = 0;
|
||||
for (int i = 0; i < n; i++) acc += i;
|
||||
@ -62,6 +71,8 @@ public class TestStressIGVN {
|
||||
for (int s = 0; s < 10; s++) {
|
||||
Asserts.assertEQ(igvnTrace(s), igvnTrace(s),
|
||||
"got different IGVN traces for the same seed");
|
||||
Asserts.assertEQ(ccpTrace(s), ccpTrace(s),
|
||||
"got different CCP traces for the same seed");
|
||||
}
|
||||
} else if (args.length > 0) {
|
||||
sum(Integer.parseInt(args[0]));
|
Loading…
Reference in New Issue
Block a user