8148159: [TESTBUG] TestCompilerDirectivesCompatibility tests fails on non-tiered server VMs

Add whitebox for checking available compilers

Reviewed-by: kvn
This commit is contained in:
Nils Eliasson 2016-02-25 10:42:42 +01:00
parent 7c3120b3da
commit e09bb29c2d
5 changed files with 94 additions and 84 deletions

View file

@ -644,12 +644,12 @@ WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobjec
return (mh->queued_for_compilation() || nm != NULL); return (mh->queued_for_compilation() || nm != NULL);
WB_END WB_END
WB_ENTRY(jboolean, WB_ShouldPrintAssembly(JNIEnv* env, jobject o, jobject method)) WB_ENTRY(jboolean, WB_ShouldPrintAssembly(JNIEnv* env, jobject o, jobject method, jint comp_level))
jmethodID jmid = reflected_method_to_jmid(thread, env, method); jmethodID jmid = reflected_method_to_jmid(thread, env, method);
CHECK_JNI_EXCEPTION_(env, JNI_FALSE); CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
DirectiveSet* directive = DirectivesStack::getMatchingDirective(mh, CompileBroker::compiler(CompLevel_simple)); DirectiveSet* directive = DirectivesStack::getMatchingDirective(mh, CompileBroker::compiler(comp_level));
bool result = directive->PrintAssemblyOption; bool result = directive->PrintAssemblyOption;
DirectivesStack::release(directive); DirectivesStack::release(directive);
@ -1556,8 +1556,8 @@ static JNINativeMethod methods[] = {
#endif // INCLUDE_NMT #endif // INCLUDE_NMT
{CC"deoptimizeFrames", CC"(Z)I", (void*)&WB_DeoptimizeFrames }, {CC"deoptimizeFrames", CC"(Z)I", (void*)&WB_DeoptimizeFrames },
{CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll },
{CC"deoptimizeMethod0", CC"(Ljava/lang/reflect/Executable;Z)I", {CC"deoptimizeMethod0", CC"(Ljava/lang/reflect/Executable;Z)I",
(void*)&WB_DeoptimizeMethod }, (void*)&WB_DeoptimizeMethod },
{CC"isMethodCompiled0", CC"(Ljava/lang/reflect/Executable;Z)Z", {CC"isMethodCompiled0", CC"(Ljava/lang/reflect/Executable;Z)Z",
(void*)&WB_IsMethodCompiled }, (void*)&WB_IsMethodCompiled },
{CC"isMethodCompilable0", CC"(Ljava/lang/reflect/Executable;IZ)Z", {CC"isMethodCompilable0", CC"(Ljava/lang/reflect/Executable;IZ)Z",
@ -1592,7 +1592,7 @@ static JNINativeMethod methods[] = {
CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)I", CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)I",
(void*)&WB_MatchesInline}, (void*)&WB_MatchesInline},
{CC"shouldPrintAssembly", {CC"shouldPrintAssembly",
CC"(Ljava/lang/reflect/Executable;)Z", CC"(Ljava/lang/reflect/Executable;I)Z",
(void*)&WB_ShouldPrintAssembly}, (void*)&WB_ShouldPrintAssembly},
{CC"isConstantVMFlag", CC"(Ljava/lang/String;)Z", (void*)&WB_IsConstantVMFlag}, {CC"isConstantVMFlag", CC"(Ljava/lang/String;)Z", (void*)&WB_IsConstantVMFlag},

View file

@ -24,25 +24,26 @@
/* /*
* @test TestCompilerDirectivesCompatibilityBase * @test TestCompilerDirectivesCompatibilityBase
* @bug 8137167 * @bug 8137167
* @library /testlibrary /test/lib * @library /testlibrary /test/lib /
* @modules java.base/sun.misc * @modules java.base/sun.misc
* java.compiler * java.compiler
* java.management * java.management
* @build jdk.test.lib.* * @build jdk.test.lib.*
* @build jdk.test.lib.dcmd.* * jdk.test.lib.dcmd.*
* @build sun.hotspot.WhiteBox * sun.hotspot.WhiteBox
* @run main ClassFileInstaller sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils
* sun.hotspot.WhiteBox$WhiteBoxPermission * @run driver ClassFileInstaller sun.hotspot.WhiteBox
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityBase * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityBase
* @summary Test compiler control compatibility with compile command * @summary Test compiler control compatibility with compile command
*/ */
import compiler.testlibrary.CompilerUtils;
import compiler.whitebox.CompilerWhiteBoxTest;
import jdk.test.lib.dcmd.CommandExecutor; import jdk.test.lib.dcmd.CommandExecutor;
import jdk.test.lib.dcmd.JMXExecutor; import jdk.test.lib.dcmd.JMXExecutor;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.testng.Assert; import org.testng.Assert;
import sun.hotspot.WhiteBox; import sun.hotspot.WhiteBox;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -64,32 +65,38 @@ public class TestCompilerDirectivesCompatibilityBase {
method = getMethod(TestCompilerDirectivesCompatibilityBase.class, "helper"); method = getMethod(TestCompilerDirectivesCompatibilityBase.class, "helper");
nomatch = getMethod(TestCompilerDirectivesCompatibilityBase.class, "another"); nomatch = getMethod(TestCompilerDirectivesCompatibilityBase.class, "another");
testCompatibility(executor); int[] levels = CompilerUtils.getAvailableCompilationLevels();
for (int complevel : levels) {
// Only test the major compilers, ignore profiling levels
if (complevel == CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE || complevel == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION){
testCompatibility(executor, complevel);
}
}
} }
public void testCompatibility(CommandExecutor executor) throws Exception { public void testCompatibility(CommandExecutor executor, int comp_level) throws Exception {
// Call all validation twice to catch error when overwriting a directive // Call all validation twice to catch error when overwriting a directive
// Flag is default off // Flag is default off
expect(!WB.getBooleanVMFlag("PrintAssembly")); expect(!WB.getBooleanVMFlag("PrintAssembly"));
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
// load directives that turn it on // load directives that turn it on
executor.execute("Compiler.directives_add " + control_on); executor.execute("Compiler.directives_add " + control_on);
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
// remove and see that it is true again // remove and see that it is true again
executor.execute("Compiler.directives_remove"); executor.execute("Compiler.directives_remove");
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
} }
public void expect(boolean test) throws Exception { public void expect(boolean test) throws Exception {

View file

@ -24,16 +24,17 @@
/* /*
* @test TestCompilerDirectivesCompatibilityCommandOff * @test TestCompilerDirectivesCompatibilityCommandOff
* @bug 8137167 * @bug 8137167
* @library /testlibrary /test/lib * @library /testlibrary /test/lib /
* @modules java.base/sun.misc * @modules java.base/sun.misc
* java.compiler * java.compiler
* java.management * java.management
* @build jdk.test.lib.* * @build jdk.test.lib.*
* @build jdk.test.lib.dcmd.* * jdk.test.lib.dcmd.*
* @build sun.hotspot.WhiteBox * sun.hotspot.WhiteBox
* @run main ClassFileInstaller sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils
* sun.hotspot.WhiteBox$WhiteBoxPermission * @run driver ClassFileInstaller sun.hotspot.WhiteBox
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions
* -XX:-PrintAssembly -XX:CompileCommand=option,*.helper,bool,PrintAssembly,false * -XX:-PrintAssembly -XX:CompileCommand=option,*.helper,bool,PrintAssembly,false
* -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityCommandOff * -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityCommandOff
* @summary Test compiler control compatibility with compile command * @summary Test compiler control compatibility with compile command
@ -55,27 +56,27 @@ import java.util.Objects;
public class TestCompilerDirectivesCompatibilityCommandOff extends TestCompilerDirectivesCompatibilityBase { public class TestCompilerDirectivesCompatibilityCommandOff extends TestCompilerDirectivesCompatibilityBase {
public void testCompatibility(CommandExecutor executor) throws Exception { public void testCompatibility(CommandExecutor executor, int comp_level) throws Exception {
// Call all validation twice to catch error when overwriting a directive // Call all validation twice to catch error when overwriting a directive
// Flag is default off // Flag is default off
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
// load directives that turn it on // load directives that turn it on
executor.execute("Compiler.directives_add " + control_on); executor.execute("Compiler.directives_add " + control_on);
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
// remove and see that it is false again // remove and see that it is false again
executor.execute("Compiler.directives_remove"); executor.execute("Compiler.directives_remove");
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(!WB.shouldPrintAssembly(nomatch)); expect(!WB.shouldPrintAssembly(nomatch, comp_level));
} }
} }

View file

@ -24,16 +24,17 @@
/* /*
* @test TestCompilerDirectivesCompatibilityCommandOn * @test TestCompilerDirectivesCompatibilityCommandOn
* @bug 8137167 * @bug 8137167
* @library /testlibrary /test/lib * @library /testlibrary /test/lib /
* @modules java.base/sun.misc * @modules java.base/sun.misc
* java.compiler * java.compiler
* java.management * java.management
* @build jdk.test.lib.* * @build jdk.test.lib.*
* @build jdk.test.lib.dcmd.* * jdk.test.lib.dcmd.*
* @build sun.hotspot.WhiteBox * sun.hotspot.WhiteBox
* @run main ClassFileInstaller sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils
* sun.hotspot.WhiteBox$WhiteBoxPermission * @run driver ClassFileInstaller sun.hotspot.WhiteBox
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions
* -XX:-PrintAssembly -XX:CompileCommand=print,*.* -XX:+WhiteBoxAPI * -XX:-PrintAssembly -XX:CompileCommand=print,*.* -XX:+WhiteBoxAPI
* TestCompilerDirectivesCompatibilityCommandOn * TestCompilerDirectivesCompatibilityCommandOn
* @summary Test compiler control compatibility with compile command * @summary Test compiler control compatibility with compile command
@ -55,27 +56,27 @@ import java.util.Objects;
public class TestCompilerDirectivesCompatibilityCommandOn extends TestCompilerDirectivesCompatibilityBase{ public class TestCompilerDirectivesCompatibilityCommandOn extends TestCompilerDirectivesCompatibilityBase{
public void testCompatibility(CommandExecutor executor) throws Exception { public void testCompatibility(CommandExecutor executor, int comp_level) throws Exception {
// Call all validation twice to catch error when overwriting a directive // Call all validation twice to catch error when overwriting a directive
// Flag is default on // Flag is default on
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
// load directives that turn it off // load directives that turn it off
executor.execute("Compiler.directives_add " + control_off); executor.execute("Compiler.directives_add " + control_off);
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
// remove and see that it is true again // remove and see that it is true again
executor.execute("Compiler.directives_remove"); executor.execute("Compiler.directives_remove");
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
} }
} }

View file

@ -24,16 +24,17 @@
/* /*
* @test TestCompilerDirectivesCompatibilityFlag * @test TestCompilerDirectivesCompatibilityFlag
* @bug 8137167 * @bug 8137167
* @library /testlibrary /test/lib * @library /testlibrary /test/lib /
* @modules java.base/sun.misc * @modules java.base/sun.misc
* java.compiler * java.compiler
* java.management * java.management
* @build jdk.test.lib.* * @build jdk.test.lib.*
* @build jdk.test.lib.dcmd.* * jdk.test.lib.dcmd.*
* @build sun.hotspot.WhiteBox * sun.hotspot.WhiteBox
* @run main ClassFileInstaller sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils
* sun.hotspot.WhiteBox$WhiteBoxPermission * @run driver ClassFileInstaller sun.hotspot.WhiteBox
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions
* -XX:+PrintAssembly -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityFlag * -XX:+PrintAssembly -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityFlag
* @summary Test compiler control compatibility with compile command * @summary Test compiler control compatibility with compile command
*/ */
@ -54,28 +55,28 @@ import java.util.Objects;
public class TestCompilerDirectivesCompatibilityFlag extends TestCompilerDirectivesCompatibilityBase { public class TestCompilerDirectivesCompatibilityFlag extends TestCompilerDirectivesCompatibilityBase {
public void testCompatibility(CommandExecutor executor) throws Exception { public void testCompatibility(CommandExecutor executor, int comp_level) throws Exception {
// Call all validation twice to catch error when overwriting a directive // Call all validation twice to catch error when overwriting a directive
// Flag is default on // Flag is default on
expect(WB.getBooleanVMFlag("PrintAssembly")); expect(WB.getBooleanVMFlag("PrintAssembly"));
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
// load directives that turn it off // load directives that turn it off
executor.execute("Compiler.directives_add " + control_off); executor.execute("Compiler.directives_add " + control_off);
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
expect(!WB.shouldPrintAssembly(method)); expect(!WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
// remove and see that it is true again // remove and see that it is true again
executor.execute("Compiler.directives_remove"); executor.execute("Compiler.directives_remove");
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
expect(WB.shouldPrintAssembly(method)); expect(WB.shouldPrintAssembly(method, comp_level));
expect(WB.shouldPrintAssembly(nomatch)); expect(WB.shouldPrintAssembly(nomatch, comp_level));
} }
} }