# HG changeset patch # User neliasso # Date 1456395453 -3600 # Node ID 7f71620b8732b9598ec8ee5635b977d468f9413e # Parent 3d35d1e1dfde1e1ac08f18fc32e5078c52e14293# Parent f7d5ddfbb5ce75a09fb198388f5eb0fa96793d2a Merge diff -r 3d35d1e1dfde -r 7f71620b8732 hotspot/src/share/vm/compiler/compileBroker.cpp --- a/hotspot/src/share/vm/compiler/compileBroker.cpp Thu Feb 25 08:47:57 2016 +0100 +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp Thu Feb 25 11:17:33 2016 +0100 @@ -469,7 +469,6 @@ void CompileBroker::print_compile_queues(outputStream* st) { st->print_cr("Current compiles: "); MutexLocker locker(MethodCompileQueue_lock); - MutexLocker locker2(Threads_lock); char buf[2000]; int buflen = sizeof(buf); diff -r 3d35d1e1dfde -r 7f71620b8732 hotspot/src/share/vm/prims/whitebox.cpp --- a/hotspot/src/share/vm/prims/whitebox.cpp Thu Feb 25 08:47:57 2016 +0100 +++ b/hotspot/src/share/vm/prims/whitebox.cpp Thu Feb 25 11:17:33 2016 +0100 @@ -644,12 +644,12 @@ return (mh->queued_for_compilation() || nm != NULL); 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); CHECK_JNI_EXCEPTION_(env, JNI_FALSE); 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; DirectivesStack::release(directive); @@ -1556,8 +1556,8 @@ #endif // INCLUDE_NMT {CC"deoptimizeFrames", CC"(Z)I", (void*)&WB_DeoptimizeFrames }, {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll }, - {CC"deoptimizeMethod0", CC"(Ljava/lang/reflect/Executable;Z)I", - (void*)&WB_DeoptimizeMethod }, + {CC"deoptimizeMethod0", CC"(Ljava/lang/reflect/Executable;Z)I", + (void*)&WB_DeoptimizeMethod }, {CC"isMethodCompiled0", CC"(Ljava/lang/reflect/Executable;Z)Z", (void*)&WB_IsMethodCompiled }, {CC"isMethodCompilable0", CC"(Ljava/lang/reflect/Executable;IZ)Z", @@ -1592,7 +1592,7 @@ CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)I", (void*)&WB_MatchesInline}, {CC"shouldPrintAssembly", - CC"(Ljava/lang/reflect/Executable;)Z", + CC"(Ljava/lang/reflect/Executable;I)Z", (void*)&WB_ShouldPrintAssembly}, {CC"isConstantVMFlag", CC"(Ljava/lang/String;)Z", (void*)&WB_IsConstantVMFlag}, diff -r 3d35d1e1dfde -r 7f71620b8732 hotspot/src/share/vm/runtime/vm_operations.cpp --- a/hotspot/src/share/vm/runtime/vm_operations.cpp Thu Feb 25 08:47:57 2016 +0100 +++ b/hotspot/src/share/vm/runtime/vm_operations.cpp Thu Feb 25 11:17:33 2016 +0100 @@ -485,6 +485,10 @@ } } +void VM_PrintCompileQueue::doit() { + CompileBroker::print_compile_queues(_out); +} + #if INCLUDE_SERVICES void VM_PrintClassHierarchy::doit() { KlassHierarchy::print_class_hierarchy(_out, _print_interfaces, _print_subclasses, _classname); diff -r 3d35d1e1dfde -r 7f71620b8732 hotspot/src/share/vm/runtime/vm_operations.hpp --- a/hotspot/src/share/vm/runtime/vm_operations.hpp Thu Feb 25 08:47:57 2016 +0100 +++ b/hotspot/src/share/vm/runtime/vm_operations.hpp Thu Feb 25 11:17:33 2016 +0100 @@ -105,6 +105,7 @@ template(DumpHashtable) \ template(DumpTouchedMethods) \ template(MarkActiveNMethods) \ + template(PrintCompileQueue) \ template(PrintClassHierarchy) \ class VM_Operation: public CHeapObj { @@ -421,6 +422,17 @@ void doit(); }; +class VM_PrintCompileQueue: public VM_Operation { + private: + outputStream* _out; + + public: + VM_PrintCompileQueue(outputStream* st) : _out(st) {} + VMOp_Type type() const { return VMOp_PrintCompileQueue; } + Mode evaluation_mode() const { return _safepoint; } + void doit(); +}; + #if INCLUDE_SERVICES class VM_PrintClassHierarchy: public VM_Operation { private: diff -r 3d35d1e1dfde -r 7f71620b8732 hotspot/src/share/vm/services/diagnosticCommand.cpp --- a/hotspot/src/share/vm/services/diagnosticCommand.cpp Thu Feb 25 08:47:57 2016 +0100 +++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp Thu Feb 25 11:17:33 2016 +0100 @@ -832,7 +832,8 @@ } void CompileQueueDCmd::execute(DCmdSource source, TRAPS) { - CompileBroker::print_compile_queues(output()); + VM_PrintCompileQueue printCompileQueueOp(output()); + VMThread::execute(&printCompileQueueOp); } void CodeListDCmd::execute(DCmdSource source, TRAPS) { diff -r 3d35d1e1dfde -r 7f71620b8732 hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityBase.java --- a/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityBase.java Thu Feb 25 08:47:57 2016 +0100 +++ b/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityBase.java Thu Feb 25 11:17:33 2016 +0100 @@ -24,25 +24,26 @@ /* * @test TestCompilerDirectivesCompatibilityBase * @bug 8137167 - * @library /testlibrary /test/lib + * @library /testlibrary /test/lib / * @modules java.base/sun.misc * java.compiler * java.management * @build jdk.test.lib.* - * @build jdk.test.lib.dcmd.* - * @build sun.hotspot.WhiteBox - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityBase + * jdk.test.lib.dcmd.* + * sun.hotspot.WhiteBox + * compiler.testlibrary.CompilerUtils + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityBase * @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.JMXExecutor; - import org.testng.annotations.Test; import org.testng.Assert; - import sun.hotspot.WhiteBox; import java.io.BufferedReader; @@ -64,32 +65,38 @@ method = getMethod(TestCompilerDirectivesCompatibilityBase.class, "helper"); 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 // Flag is default off expect(!WB.getBooleanVMFlag("PrintAssembly")); - expect(!WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); - expect(!WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); // load directives that turn it on executor.execute("Compiler.directives_add " + control_on); - expect(WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); - expect(WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); // remove and see that it is true again executor.execute("Compiler.directives_remove"); - expect(!WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); - expect(!WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); } public void expect(boolean test) throws Exception { diff -r 3d35d1e1dfde -r 7f71620b8732 hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOff.java --- a/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOff.java Thu Feb 25 08:47:57 2016 +0100 +++ b/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOff.java Thu Feb 25 11:17:33 2016 +0100 @@ -24,16 +24,17 @@ /* * @test TestCompilerDirectivesCompatibilityCommandOff * @bug 8137167 - * @library /testlibrary /test/lib + * @library /testlibrary /test/lib / * @modules java.base/sun.misc * java.compiler * java.management * @build jdk.test.lib.* - * @build jdk.test.lib.dcmd.* - * @build sun.hotspot.WhiteBox - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * jdk.test.lib.dcmd.* + * sun.hotspot.WhiteBox + * compiler.testlibrary.CompilerUtils + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions * -XX:-PrintAssembly -XX:CompileCommand=option,*.helper,bool,PrintAssembly,false * -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityCommandOff * @summary Test compiler control compatibility with compile command @@ -55,27 +56,27 @@ 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 // Flag is default off - expect(!WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); - expect(!WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); // load directives that turn it on executor.execute("Compiler.directives_add " + control_on); - expect(WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); - expect(WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); // remove and see that it is false again executor.execute("Compiler.directives_remove"); - expect(!WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); - expect(!WB.shouldPrintAssembly(method)); - expect(!WB.shouldPrintAssembly(nomatch)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(!WB.shouldPrintAssembly(nomatch, comp_level)); } } diff -r 3d35d1e1dfde -r 7f71620b8732 hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOn.java --- a/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOn.java Thu Feb 25 08:47:57 2016 +0100 +++ b/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOn.java Thu Feb 25 11:17:33 2016 +0100 @@ -24,16 +24,17 @@ /* * @test TestCompilerDirectivesCompatibilityCommandOn * @bug 8137167 - * @library /testlibrary /test/lib + * @library /testlibrary /test/lib / * @modules java.base/sun.misc * java.compiler * java.management * @build jdk.test.lib.* - * @build jdk.test.lib.dcmd.* - * @build sun.hotspot.WhiteBox - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * jdk.test.lib.dcmd.* + * sun.hotspot.WhiteBox + * compiler.testlibrary.CompilerUtils + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions * -XX:-PrintAssembly -XX:CompileCommand=print,*.* -XX:+WhiteBoxAPI * TestCompilerDirectivesCompatibilityCommandOn * @summary Test compiler control compatibility with compile command @@ -55,27 +56,27 @@ 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 // Flag is default on - expect(WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); - expect(WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); // load directives that turn it off executor.execute("Compiler.directives_add " + control_off); - expect(!WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); - expect(!WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); // remove and see that it is true again executor.execute("Compiler.directives_remove"); - expect(WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); - expect(WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); } } diff -r 3d35d1e1dfde -r 7f71620b8732 hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityFlag.java --- a/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityFlag.java Thu Feb 25 08:47:57 2016 +0100 +++ b/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityFlag.java Thu Feb 25 11:17:33 2016 +0100 @@ -24,16 +24,17 @@ /* * @test TestCompilerDirectivesCompatibilityFlag * @bug 8137167 - * @library /testlibrary /test/lib + * @library /testlibrary /test/lib / * @modules java.base/sun.misc * java.compiler * java.management * @build jdk.test.lib.* - * @build jdk.test.lib.dcmd.* - * @build sun.hotspot.WhiteBox - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * jdk.test.lib.dcmd.* + * sun.hotspot.WhiteBox + * compiler.testlibrary.CompilerUtils + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions * -XX:+PrintAssembly -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityFlag * @summary Test compiler control compatibility with compile command */ @@ -54,28 +55,28 @@ 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 // Flag is default on expect(WB.getBooleanVMFlag("PrintAssembly")); - expect(WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); - expect(WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); // load directives that turn it off executor.execute("Compiler.directives_add " + control_off); - expect(!WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); - expect(!WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); + expect(!WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); // remove and see that it is true again executor.execute("Compiler.directives_remove"); - expect(WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); - expect(WB.shouldPrintAssembly(method)); - expect(WB.shouldPrintAssembly(nomatch)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); + expect(WB.shouldPrintAssembly(method, comp_level)); + expect(WB.shouldPrintAssembly(nomatch, comp_level)); } } diff -r 3d35d1e1dfde -r 7f71620b8732 hotspot/test/serviceability/dcmd/compiler/CompilerQueueTest.java --- a/hotspot/test/serviceability/dcmd/compiler/CompilerQueueTest.java Thu Feb 25 08:47:57 2016 +0100 +++ b/hotspot/test/serviceability/dcmd/compiler/CompilerQueueTest.java Thu Feb 25 11:17:33 2016 +0100 @@ -24,25 +24,33 @@ /* * @test CompilerQueueTest * @bug 8054889 - * @library /testlibrary + * @library /testlibrary /test/lib / * @modules java.base/sun.misc * java.compiler * java.management * jdk.jvmstat/sun.jvmstat.monitor - * @ignore 8069160 * @build jdk.test.lib.* - * @build jdk.test.lib.dcmd.* - * @run testng CompilerQueueTest - * @run testng/othervm -XX:-TieredCompilation CompilerQueueTest - * @run testng/othervm -Xint CompilerQueueTest + * jdk.test.lib.dcmd.* + * sun.hotspot.WhiteBox + * compiler.testlibrary.CompilerUtils + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xmixed -XX:+WhiteBoxAPI CompilerQueueTest + * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xmixed -XX:-TieredCompilation -XX:+WhiteBoxAPI CompilerQueueTest + * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xint -XX:+WhiteBoxAPI CompilerQueueTest * @summary Test of diagnostic command Compiler.queue */ +import compiler.testlibrary.CompilerUtils; import jdk.test.lib.OutputAnalyzer; import jdk.test.lib.dcmd.CommandExecutor; import jdk.test.lib.dcmd.JMXExecutor; import org.testng.annotations.Test; +import org.testng.Assert; +import sun.hotspot.WhiteBox; +import java.lang.reflect.Executable; +import java.lang.reflect.Method; import java.util.Iterator; public class CompilerQueueTest { @@ -54,70 +62,123 @@ * * Output example: * - * Contents of C1 compile queue - * ---------------------------- - * 73 3 java.lang.AbstractStringBuilder::append (50 bytes) - * 74 1 java.util.TreeMap::size (5 bytes) - * 75 3 java.lang.StringBuilder::append (8 bytes) - * 83 3 java.util.TreeMap$ValueIterator::next (8 bytes) - * 84 1 javax.management.MBeanFeatureInfo::getName (5 bytes) - * ---------------------------- - * Contents of C2 compile queue - * ---------------------------- + * Current compiles: + * C1 CompilerThread14 267 3 java.net.URLStreamHandler::parseURL (1166 bytes) + * C1 CompilerThread13 760 3 javax.management.StandardMBean::getDescription (11 bytes) + * C1 CompilerThread12 757 s 3 com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory::getMapping (27 bytes) + * C1 CompilerThread11 756 s! 3 com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory::mappingForType (110 bytes) + * C1 CompilerThread10 761 3 java.lang.StringLatin1::indexOf (121 bytes) + * C2 CompilerThread7 769 4 CompilerQueueTest::testcaseMethod4 (1 bytes) + * + * C1 compile queue: + * 762 3 java.lang.invoke.MethodType::basicType (8 bytes) + * 763 3 java.util.ArrayList::rangeCheck (22 bytes) + * 764 3 java.util.ArrayList::elementData (7 bytes) + * 765 3 jdk.internal.org.objectweb.asm.MethodVisitor:: (35 bytes) + * 766 1 CompilerQueueTest::testcaseMethod1 (1 bytes) + * 767 2 CompilerQueueTest::testcaseMethod2 (1 bytes) + * 768 3 CompilerQueueTest::testcaseMethod3 (1 bytes) + * 770 3 java.util.Properties::getProperty (46 bytes) + * + * C2 compile queue: * Empty - * ---------------------------- * **/ + protected static final WhiteBox WB = WhiteBox.getWhiteBox(); + public void run(CommandExecutor executor) { + TestCase[] testcases = { + new TestCase(1, "testcaseMethod1"), + new TestCase(2, "testcaseMethod2"), + new TestCase(3, "testcaseMethod3"), + new TestCase(4, "testcaseMethod4"), + }; + + // Lock compilation makes all compiles stay in queue or compile thread before completion + WB.lockCompilation(); + + // Enqueue one test method for each available level + int[] complevels = CompilerUtils.getAvailableCompilationLevels(); + for (int level : complevels) { + TestCase testcase = testcases[level - 1]; + + boolean added = WB.enqueueMethodForCompilation(testcase.method, testcase.level); + // Set results to false for those methods we must to find + // We will also assert if we find any test method we don't expect + Assert.assertTrue(WB.isMethodQueuedForCompilation(testcase.method)); + testcase.check = false; + } + // Get output from dcmd (diagnostic command) OutputAnalyzer output = executor.execute("Compiler.queue"); Iterator lines = output.asLines().iterator(); + // Loop over output set result for all found methods while (lines.hasNext()) { String str = lines.next(); - if (str.startsWith("Contents of C")) { - match(lines.next(), "----------------------------"); - str = lines.next(); - if (!str.equals("Empty")) { - while (str.charAt(0) != '-') { - validateMethodLine(str); - str = lines.next(); + // Fast check for common part of method name + if (str.contains("testcaseMethod")) { + for (TestCase testcase : testcases) { + if (str.contains(testcase.methodName)) { + Assert.assertFalse(testcase.check, "Must not be found or already found."); + testcase.check = true; } - } else { - str = lines.next(); } - match(str,"----------------------------"); - } else { - Assert.fail("Failed parsing dcmd queue, line: " + str); } } - } - private static void validateMethodLine(String str) { - // Skip until package/class name begins. Trim to remove whitespace that - // may differ. - String name = str.substring(14).trim(); - int sep = name.indexOf("::"); - if (sep == -1) { - Assert.fail("Failed dcmd queue, didn't find separator :: in: " + name); + for (TestCase testcase : testcases) { + if (!testcase.check) { + // If this method wasn't found it must have been removed by policy, + // verify that it is now removed from the queue + Assert.assertFalse(WB.isMethodQueuedForCompilation(testcase.method), "Must be found or not in queue"); + } + // Otherwise all good. } - try { - Class.forName(name.substring(0, sep)); - } catch (ClassNotFoundException e) { - Assert.fail("Failed dcmd queue, Class for name: " + str); - } - } - public static void match(String line, String str) { - if (!line.equals(str)) { - Assert.fail("String equals: " + line + ", " + str); - } + // Enable compilations again + WB.unlockCompilation(); } @Test public void jmx() { run(new JMXExecutor()); } + + public void testcaseMethod1() { + } + + public void testcaseMethod2() { + } + + public void testcaseMethod3() { + } + + public void testcaseMethod4() { + } + + public static Method getMethod(Class klass, String name, Class... parameterTypes) { + try { + return klass.getDeclaredMethod(name, parameterTypes); + } catch (NoSuchMethodException | SecurityException e) { + throw new RuntimeException("exception on getting method Helper." + name, e); + } + } + + class TestCase { + Method method; + int level; + String methodName; + Boolean check; + + public TestCase(int level, String methodName) { + this.method = getMethod(CompilerQueueTest.class, methodName); + this.level = level; + this.methodName = methodName; + this.check = true; + } + } + }