mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 17:44:40 +02:00
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
6 changed files with 55 additions and 23 deletions
|
@ -50,6 +50,9 @@
|
||||||
product(bool, StressIGVN, false, DIAGNOSTIC, \
|
product(bool, StressIGVN, false, DIAGNOSTIC, \
|
||||||
"Randomize worklist traversal in IGVN") \
|
"Randomize worklist traversal in IGVN") \
|
||||||
\
|
\
|
||||||
|
product(bool, StressCCP, false, DIAGNOSTIC, \
|
||||||
|
"Randomize worklist traversal in CCP") \
|
||||||
|
\
|
||||||
product(uint, StressSeed, 0, DIAGNOSTIC, \
|
product(uint, StressSeed, 0, DIAGNOSTIC, \
|
||||||
"Seed for randomized stress testing (if unset, a random one is " \
|
"Seed for randomized stress testing (if unset, a random one is " \
|
||||||
"generated). The seed is recorded in the compilation log, if " \
|
"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;
|
if (failing()) return;
|
||||||
NOT_PRODUCT( verify_graph_edges(); )
|
NOT_PRODUCT( verify_graph_edges(); )
|
||||||
|
|
||||||
// If LCM, GCM, or IGVN are randomized for stress testing, seed
|
// If any phase is randomized for stress testing, seed random number
|
||||||
// random number generation and log the seed for repeatability.
|
// generation and log the seed for repeatability.
|
||||||
if (StressLCM || StressGCM || StressIGVN) {
|
if (StressLCM || StressGCM || StressIGVN || StressCCP) {
|
||||||
_stress_seed = FLAG_IS_DEFAULT(StressSeed) ?
|
_stress_seed = FLAG_IS_DEFAULT(StressSeed) ?
|
||||||
static_cast<uint>(Ticks::now().nanoseconds()) : StressSeed;
|
static_cast<uint>(Ticks::now().nanoseconds()) : StressSeed;
|
||||||
if (_log != NULL) {
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.
|
// Pull from worklist; compute new value; push changes out.
|
||||||
// This loop is the meat of CCP.
|
// This loop is the meat of CCP.
|
||||||
while( worklist.size() ) {
|
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);
|
const Type *t = n->Value(this);
|
||||||
if (t != type(n)) {
|
if (t != type(n)) {
|
||||||
assert(ccp_type_widens(t, type(n)), "ccp type must widen");
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -23,19 +23,31 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8252219
|
* @bug 8252219 8256535
|
||||||
* @requires vm.compiler2.enabled
|
* @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.
|
* -XX:StressSeed=N are accepted.
|
||||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN
|
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN
|
||||||
* compiler.arguments.TestStressIGVNOptions
|
* compiler.arguments.TestStressOptions
|
||||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN -XX:StressSeed=42
|
* @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;
|
package compiler.arguments;
|
||||||
|
|
||||||
public class TestStressIGVNOptions {
|
public class TestStressOptions {
|
||||||
|
|
||||||
static public void main(String[] args) {
|
static public void main(String[] args) {
|
||||||
System.out.println("Passed");
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -30,7 +30,7 @@ import jdk.test.lib.Asserts;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8252219
|
* @bug 8252219 8256535
|
||||||
* @requires vm.compiler2.enabled
|
* @requires vm.compiler2.enabled
|
||||||
* @summary Tests that using a stress option without -XX:StressSeed=N generates
|
* @summary Tests that using a stress option without -XX:StressSeed=N generates
|
||||||
* and logs a random seed.
|
* 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 StressLCM
|
||||||
* @run driver compiler.debug.TestGenerateStressSeed StressGCM
|
* @run driver compiler.debug.TestGenerateStressSeed StressGCM
|
||||||
* @run driver compiler.debug.TestGenerateStressSeed StressIGVN
|
* @run driver compiler.debug.TestGenerateStressSeed StressIGVN
|
||||||
|
* @run driver compiler.debug.TestGenerateStressSeed StressCCP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TestGenerateStressSeed {
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -29,28 +29,37 @@ import jdk.test.lib.Asserts;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8252219
|
* @bug 8252219 8256535
|
||||||
* @requires vm.debug == true & vm.compiler2.enabled
|
* @requires vm.debug == true & vm.compiler2.enabled
|
||||||
* @summary Tests that compilations with the same seed yield the same IGVN
|
* @summary Tests that stress compilations with the same seed yield the same
|
||||||
* trace.
|
* IGVN and CCP traces.
|
||||||
* @library /test/lib /
|
* @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 {
|
static String phaseTrace(String stressOption, String traceOption,
|
||||||
String className = TestStressIGVN.class.getName();
|
int stressSeed) throws Exception {
|
||||||
|
String className = TestStressIGVNAndCCP.class.getName();
|
||||||
String[] procArgs = {
|
String[] procArgs = {
|
||||||
"-Xcomp", "-XX:-TieredCompilation", "-XX:-Inline",
|
"-Xcomp", "-XX:-TieredCompilation", "-XX:-Inline",
|
||||||
"-XX:CompileOnly=" + className + "::sum", "-XX:+TraceIterativeGVN",
|
"-XX:CompileOnly=" + className + "::sum", "-XX:+" + traceOption,
|
||||||
"-XX:+StressIGVN", "-XX:StressSeed=" + stressSeed,
|
"-XX:+" + stressOption, "-XX:StressSeed=" + stressSeed,
|
||||||
className, "10"};
|
className, "10"};
|
||||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
|
||||||
OutputAnalyzer out = new OutputAnalyzer(pb.start());
|
OutputAnalyzer out = new OutputAnalyzer(pb.start());
|
||||||
return out.getStdout();
|
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) {
|
static void sum(int n) {
|
||||||
int acc = 0;
|
int acc = 0;
|
||||||
for (int i = 0; i < n; i++) acc += i;
|
for (int i = 0; i < n; i++) acc += i;
|
||||||
|
@ -62,6 +71,8 @@ public class TestStressIGVN {
|
||||||
for (int s = 0; s < 10; s++) {
|
for (int s = 0; s < 10; s++) {
|
||||||
Asserts.assertEQ(igvnTrace(s), igvnTrace(s),
|
Asserts.assertEQ(igvnTrace(s), igvnTrace(s),
|
||||||
"got different IGVN traces for the same seed");
|
"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) {
|
} else if (args.length > 0) {
|
||||||
sum(Integer.parseInt(args[0]));
|
sum(Integer.parseInt(args[0]));
|
Loading…
Add table
Add a link
Reference in a new issue