8151280: update hotspot tests to use vm.compMode instead of their own logic

Update hs compiler tests to use vm.compMode instead of their own logic and to get VM mode using j.t.l.Platform

Reviewed-by: kvn, dpochepk
This commit is contained in:
Igor Ignatyev 2016-07-13 18:03:15 +03:00 committed by Tatiana Pivovarova
parent 558ac48a19
commit e19479825a
29 changed files with 112 additions and 106 deletions

View File

@ -25,6 +25,7 @@
* @test
* @bug 8072016
* @summary Infinite deoptimization/recompilation cycles in case of arraycopy with tightly coupled allocation
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management
@ -86,9 +87,11 @@ public class TestArrayCopyNoInitDeopt {
}
static public void main(String[] args) throws Exception {
if (!Platform.isServer()) {
throw new Error("TESTBUG: Not server VM");
}
// Only execute if C2 is available
if (Platform.isServer() &&
TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) {
if (TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) {
int[] src = new int[10];
Object src_obj = new Object();
Method method_m1 = TestArrayCopyNoInitDeopt.class.getMethod("m1", Object.class);

View File

@ -57,8 +57,6 @@ public class OverloadCompileQueueTest implements Runnable {
private static final String METHOD_TO_ENQUEUE = "method";
private static final int LEVEL_SIMPLE = 1;
private static final int LEVEL_FULL_OPTIMIZATION = 4;
private static final boolean INTERPRETED
= System.getProperty("java.vm.info").startsWith("interpreted ");
private static final boolean TIERED_COMPILATION
= Helper.WHITE_BOX.getBooleanVMFlag("TieredCompilation");
private static final int TIERED_STOP_AT_LEVEL
@ -74,15 +72,13 @@ public class OverloadCompileQueueTest implements Runnable {
} else if (Platform.isClient() || Platform.isMinimal()) {
AVAILABLE_LEVELS = new int[] { LEVEL_SIMPLE };
} else {
throw new Error(String.format(
"TESTBUG: unknown VM: %s", System.getProperty("java.vm.name")));
throw new Error("TESTBUG: unknown VM: " + Platform.vmName);
}
}
public static void main(String[] args) {
if (INTERPRETED) {
System.err.println("Test isn't applicable for interpreter. Skip test.");
return;
if (Platform.isInt()) {
throw new Error("TESTBUG: test can not be run in interpreter");
}
new CodeCacheStressRunner(new OverloadCompileQueueTest()).runTest();
}

View File

@ -78,4 +78,4 @@ public class TestEscapeThroughInvoke {
}
}
}
}
}

View File

@ -52,11 +52,9 @@ import java.lang.reflect.Executable;
import java.util.concurrent.Callable;
public class IntrinsicAvailableTest extends CompilerWhiteBoxTest {
protected String VMName;
public IntrinsicAvailableTest(IntrinsicAvailableTestTestCase testCase) {
super(testCase);
VMName = System.getProperty("java.vm.name");
}
public static class IntrinsicAvailableTestTestCase implements TestCase {

View File

@ -26,6 +26,7 @@
* @test
* @bug 8130150 8131779 8139907
* @summary Verify that the Montgomery multiply and square intrinsic works and correctly checks their arguments.
* @requires vm.flavor == "server"
* @modules java.base/jdk.internal.misc
* @library /testlibrary /test/lib
*
@ -314,9 +315,11 @@ public class MontgomeryMultiplyTest {
}
public static void main(String args[]) {
if (Platform.isServer() &&
wb.isIntrinsicAvailable(getExecutable(true), COMP_LEVEL_FULL_OPTIMIZATION) &&
wb.isIntrinsicAvailable(getExecutable(false), COMP_LEVEL_FULL_OPTIMIZATION)) {
if (!Platform.isServer()) {
throw new Error("TESTBUG: Not server VM");
}
if (wb.isIntrinsicAvailable(getExecutable(true), COMP_LEVEL_FULL_OPTIMIZATION) &&
wb.isIntrinsicAvailable(getExecutable(false), COMP_LEVEL_FULL_OPTIMIZATION)) {
try {
new MontgomeryMultiplyTest().testMontgomeryMultiplyChecks();
new MontgomeryMultiplyTest().testResultValues();

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -60,8 +60,11 @@ public class BmiIntrinsicBase extends CompilerWhiteBoxTest {
}
if (!Platform.isServer()) {
System.out.println("Not server VM, test SKIPPED");
return;
throw new Error("TESTBUG: Not server VM");
}
if (Platform.isInt()) {
throw new Error("TESTBUG: test can not be run in interpreter");
}
if (!CPUInfo.hasFeature(bmiTestCase.getCpuFlag())) {
@ -76,22 +79,12 @@ public class BmiIntrinsicBase extends CompilerWhiteBoxTest {
System.out.println(testCase.name());
switch (MODE) {
case "compiled mode":
case "mixed mode":
if (TIERED_COMPILATION && TIERED_STOP_AT_LEVEL != CompilerWhiteBoxTest.COMP_LEVEL_MAX) {
System.out.println("TieredStopAtLevel value (" + TIERED_STOP_AT_LEVEL + ") is too low, test SKIPPED");
return;
}
deoptimize();
compileAtLevelAndCheck(CompilerWhiteBoxTest.COMP_LEVEL_MAX);
break;
case "interpreted mode": // test is not applicable in this mode;
System.err.println("Warning: This test is not applicable in mode: " + MODE);
break;
default:
throw new AssertionError("Test bug, unknown VM mode: " + MODE);
if (TIERED_COMPILATION && TIERED_STOP_AT_LEVEL != CompilerWhiteBoxTest.COMP_LEVEL_MAX) {
System.out.println("TieredStopAtLevel value (" + TIERED_STOP_AT_LEVEL + ") is too low, test SKIPPED");
return;
}
deoptimize();
compileAtLevelAndCheck(CompilerWhiteBoxTest.COMP_LEVEL_MAX);
}
protected void compileAtLevelAndCheck(int level) {

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -24,6 +24,7 @@
/*
* @test
* @bug 8031321
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management

View File

@ -25,6 +25,7 @@
* @test NullCheckDroppingsTest
* @bug 8054492
* @summary Casting can result in redundant null checks in generated code
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib
* @modules java.base/jdk.internal.misc
* java.management
@ -85,18 +86,16 @@ public class CastNullCheckDroppingsTest {
int[] asink;
public static void main(String[] args) throws Exception {
// Only test C2 in Server VM
if (!Platform.isServer()) {
return;
throw new Error("TESTBUG: Not server VM");
}
// Make sure background compilation is disabled
if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) {
throw new AssertionError("Background compilation enabled");
throw new Error("TESTBUG: Background compilation enabled");
}
// Make sure Tiered compilation is disabled
if (WHITE_BOX.getBooleanVMFlag("TieredCompilation")) {
throw new AssertionError("Tiered compilation enabled");
throw new Error("TESTBUG: Tiered compilation enabled");
}
Method methodClassCast = CastNullCheckDroppingsTest.class.getDeclaredMethod("testClassCast", String.class);

View File

@ -32,12 +32,10 @@ import java.lang.reflect.Executable;
import java.util.Properties;
public abstract class IntrinsicBase extends CompilerWhiteBoxTest {
protected String javaVmName;
protected String useMathExactIntrinsics;
protected IntrinsicBase(TestCase testCase) {
super(testCase);
javaVmName = System.getProperty("java.vm.name");
useMathExactIntrinsics = getVMOption("UseMathExactIntrinsics");
}
@ -46,39 +44,32 @@ public abstract class IntrinsicBase extends CompilerWhiteBoxTest {
//java.lang.Math should be loaded to allow a compilation of the methods that use Math's method
System.out.println("class java.lang.Math should be loaded. Proof: " + Math.class);
printEnvironmentInfo();
if (Platform.isInt()) {
throw new Error("TESTBUG: test can not be run in interpreter");
}
int expectedIntrinsicCount = 0;
switch (MODE) {
case "compiled mode":
case "mixed mode":
if (isServerVM()) {
if (TIERED_COMPILATION) {
int max_level = TIERED_STOP_AT_LEVEL;
expectedIntrinsicCount = (max_level == COMP_LEVEL_MAX) ? 1 : 0;
for (int i = CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE; i <= max_level; ++i) {
deoptimize();
compileAtLevel(i);
}
} else {
expectedIntrinsicCount = 1;
deoptimize();
compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_MAX);
}
} else {
if (Platform.isServer()) {
if (TIERED_COMPILATION) {
int max_level = TIERED_STOP_AT_LEVEL;
expectedIntrinsicCount = (max_level == COMP_LEVEL_MAX) ? 1 : 0;
for (int i = CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE; i <= max_level; ++i) {
deoptimize();
compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
compileAtLevel(i);
}
} else {
expectedIntrinsicCount = 1;
deoptimize();
compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_MAX);
}
} else {
deoptimize();
compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
}
if (!isIntrinsicAvailable()) {
expectedIntrinsicCount = 0;
}
break;
case "interpreted mode": //test is not applicable in this mode;
System.err.println("Warning: This test is not applicable in mode: " + MODE);
break;
default:
throw new RuntimeException("Test bug, unknown VM mode: " + MODE);
if (!isIntrinsicAvailable()) {
expectedIntrinsicCount = 0;
}
System.out.println("Expected intrinsic count is " + expectedIntrinsicCount + " name " + getIntrinsicId());
@ -93,9 +84,8 @@ public abstract class IntrinsicBase extends CompilerWhiteBoxTest {
}
protected void printEnvironmentInfo() {
System.out.println("java.vm.name=" + javaVmName);
System.out.println("os.arch=" + Platform.getOsArch());
System.out.println("java.vm.info=" + MODE);
System.out.println("java.vm.info=" + Platform.vmInfo);
System.out.println("useMathExactIntrinsics=" + useMathExactIntrinsics);
}
@ -125,10 +115,6 @@ public abstract class IntrinsicBase extends CompilerWhiteBoxTest {
protected abstract String getIntrinsicId();
protected boolean isServerVM() {
return javaVmName.toLowerCase().contains("server");
}
static class IntTest extends IntrinsicBase {
protected boolean isIntrinsicAvailable; // The tested intrinsic is available on the current platform.

View File

@ -26,14 +26,15 @@
* @bug 8136421
* @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
* @library / /testlibrary /test/lib
* @library ../common/patches
* ../common/patches
* @modules java.base/jdk.internal.misc
* @modules jdk.vm.ci/jdk.vm.ci.hotspot
* jdk.vm.ci/jdk.vm.ci.hotspot
*
* @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
* @build compiler.jvmci.compilerToVM.IsMatureTest
* @build sun.hotspot.WhiteBox
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
* compiler.jvmci.compilerToVM.IsMatureTest
* sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:.
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
@ -45,6 +46,7 @@ package compiler.jvmci.compilerToVM;
import compiler.jvmci.common.testcases.SimpleClass;
import compiler.whitebox.CompilerWhiteBoxTest;
import jdk.test.lib.Asserts;
import jdk.test.lib.Platform;
import jdk.vm.ci.hotspot.CompilerToVMHelper;
import sun.hotspot.WhiteBox;
@ -52,8 +54,6 @@ import java.lang.reflect.Executable;
public class IsMatureTest {
private static final WhiteBox WB = WhiteBox.getWhiteBox();
private static final boolean IS_XCOMP
= System.getProperty("java.vm.info").contains("compiled mode");
private static final boolean TIERED
= WB.getBooleanVMFlag("TieredCompilation");
@ -82,7 +82,7 @@ public class IsMatureTest {
"Multiple times invoked method should have method data");
/* a method is not mature in Xcomp mode with tiered compilation disabled,
see NonTieredCompPolicy::is_mature */
Asserts.assertEQ(isMature, !(IS_XCOMP && !TIERED),
Asserts.assertEQ(isMature, !(Platform.isComp() && !TIERED),
"Unexpected isMature state for multiple times invoked method");
}
}

View File

@ -41,22 +41,21 @@ package compiler.tiered;
import java.util.function.IntPredicate;
import compiler.whitebox.CompilerWhiteBoxTest;
import jdk.test.lib.Platform;
public class NonTieredLevelsTest extends CompLevelsTest {
private static final int AVAILABLE_COMP_LEVEL;
private static final IntPredicate IS_AVAILABLE_COMPLEVEL;
static {
String vmName = System.getProperty("java.vm.name");
if (vmName.endsWith(" Server VM")) {
if (Platform.isServer()) {
AVAILABLE_COMP_LEVEL = COMP_LEVEL_FULL_OPTIMIZATION;
IS_AVAILABLE_COMPLEVEL = x -> x == COMP_LEVEL_FULL_OPTIMIZATION;
} else if (vmName.endsWith(" Client VM")
|| vmName.endsWith(" Minimal VM")) {
} else if (Platform.isClient() || Platform.isMinimal()) {
AVAILABLE_COMP_LEVEL = COMP_LEVEL_SIMPLE;
IS_AVAILABLE_COMPLEVEL = x -> x >= COMP_LEVEL_SIMPLE
&& x <= COMP_LEVEL_FULL_PROFILE;
} else {
throw new RuntimeException("Unknown VM: " + vmName);
throw new Error("TESTBUG: unknown VM: " + Platform.vmName);
}
}

View File

@ -25,9 +25,11 @@
* @test CorrectnessTest
* @bug 8038418
* @summary Tests correctness of type usage with type profiling and speculations
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management
*
* @ignore 8066173
* @build compiler.types.correctness.CorrectnessTest
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
@ -88,7 +90,7 @@ public class CorrectnessTest {
public static void main(String[] args) {
if (!Platform.isServer()) {
System.out.println("ALL TESTS SKIPPED");
throw new Error("TESTBUG: Not server VM");
}
Asserts.assertGTE(args.length, 1);
ProfilingType profilingType = ProfilingType.valueOf(args[0]);

View File

@ -28,7 +28,7 @@
* @summary tests on constant folding of unsafe get operations
* @library /testlibrary
*
* @requires vm.flavor != "client"
* @requires vm.flavor == "server"
*
* @modules java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.vm.annotation
@ -93,11 +93,12 @@ public class UnsafeGetConstantField {
static final Unsafe U = Unsafe.getUnsafe();
public static void main(String[] args) {
if (Platform.isServer()) {
testUnsafeGetAddress();
testUnsafeGetField();
testUnsafeGetFieldUnaligned();
if (!Platform.isServer()) {
throw new Error("TESTBUG: Not server VM");
}
testUnsafeGetAddress();
testUnsafeGetField();
testUnsafeGetFieldUnaligned();
System.out.println("TEST PASSED");
}

View File

@ -28,7 +28,7 @@
* @summary tests on constant folding of unsafe get operations from stable arrays
* @library /testlibrary
*
* @requires vm.flavor != "client"
* @requires vm.flavor == "server"
*
* @modules java.base/jdk.internal.vm.annotation
* java.base/jdk.internal.misc
@ -332,9 +332,10 @@ public class UnsafeGetStableArrayElement {
}
public static void main(String[] args) throws Exception {
if (Platform.isServer()) {
testUnsafeAccess();
if (!Platform.isServer()) {
throw new Error("TESTBUG: Not server VM");
}
testUnsafeAccess();
System.out.println("TEST PASSED");
}
}

View File

@ -23,6 +23,7 @@
package compiler.whitebox;
import jdk.test.lib.Platform;
import sun.hotspot.WhiteBox;
import sun.hotspot.code.NMethod;
@ -33,6 +34,7 @@ import java.util.function.Function;
/**
* Abstract class for WhiteBox testing of JIT.
* Depends on jdk.test.lib.Platform from testlibrary.
*
* @author igor.ignatyev@oracle.com
*/
@ -75,8 +77,6 @@ public abstract class CompilerWhiteBoxTest {
public static final int THRESHOLD;
/** invocation count to trigger OSR compilation */
protected static final long BACKEDGE_THRESHOLD;
/** Value of {@code java.vm.info} (interpreted|mixed|comp mode) */
protected static final String MODE = System.getProperty("java.vm.info");
static {
if (TIERED_COMPILATION) {
@ -165,10 +165,8 @@ public abstract class CompilerWhiteBoxTest {
* @see #test()
*/
protected final void runTest() {
if (CompilerWhiteBoxTest.MODE.startsWith("interpreted ")) {
System.err.println(
"Warning: test is not applicable in interpreted mode");
return;
if (Platform.isInt()) {
throw new Error("TESTBUG: test can not be run in interpreter");
}
System.out.println("at test's start:");
printInfo();
@ -431,11 +429,10 @@ public abstract class CompilerWhiteBoxTest {
* Xcomp, otherwise {@code false}
*/
protected boolean skipXcompOSR() {
boolean result = testCase.isOsr()
&& CompilerWhiteBoxTest.MODE.startsWith("compiled ");
boolean result = testCase.isOsr() && Platform.isComp();
if (result && IS_VERBOSE) {
System.err.printf("Warning: %s is not applicable in %s%n",
testCase.name(), CompilerWhiteBoxTest.MODE);
testCase.name(), Platform.vmInfo);
}
return result;
}

View File

@ -25,9 +25,11 @@
* @test IsMethodCompilableTest
* @bug 8007270 8006683 8007288 8022832
* @summary testing of WB::isMethodCompilable()
* @requires vm.flavor == "server"
* @library /testlibrary /test/lib /
* @modules java.base/jdk.internal.misc
* java.management
*
* @build jdk.test.lib.*
* sun.hotspot.WhiteBox
* @build compiler.whitebox.IsMethodCompilableTest
@ -84,7 +86,7 @@ public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
// Only c2 compilations can be disabled through PerMethodRecompilationCutoff
if (!Platform.isServer()) {
return;
throw new Error("TESTBUG: Not server VM");
}
if (skipXcompOSR()) {

View File

@ -31,12 +31,13 @@ import java.util.regex.Pattern;
*/
@Deprecated
public class Platform {
public static final String vmName = System.getProperty("java.vm.name");
public static final String vmInfo = System.getProperty("java.vm.info");
private static final String osName = System.getProperty("os.name");
private static final String dataModel = System.getProperty("sun.arch.data.model");
private static final String vmVersion = System.getProperty("java.vm.version");
private static final String jdkDebug = System.getProperty("jdk.debug");
private static final String osArch = System.getProperty("os.arch");
private static final String vmName = System.getProperty("java.vm.name");
private static final String userName = System.getProperty("user.name");
private static final String compiler = System.getProperty("sun.management.compiler");
@ -68,6 +69,18 @@ public class Platform {
return compiler.contains("Tiered Compilers");
}
public static boolean isInt() {
return vmInfo.contains("interpreted");
}
public static boolean isMixed() {
return vmInfo.contains("mixed");
}
public static boolean isComp() {
return vmInfo.contains("compiled");
}
public static boolean is32bit() {
return dataModel.equals("32");
}

View File

@ -49,6 +49,7 @@ public class TestMutuallyExclusivePlatformPredicates {
BITNESS("is32bit", "is64bit"),
OS("isAix", "isLinux", "isOSX", "isSolaris", "isWindows"),
VM_TYPE("isClient", "isServer", "isGraal", "isMinimal", "isZero"),
MODE("isInt", "isMixed", "isComp"),
IGNORED("isEmbedded", "isDebugBuild", "shouldSAAttach",
"canPtraceAttachLinux", "canAttachOSX", "isTieredSupported");