This commit is contained in:
Nils Eliasson 2016-02-25 11:17:33 +01:00
commit 1e758f661b
10 changed files with 220 additions and 133 deletions

View File

@ -469,7 +469,6 @@ CompileQueue* CompileBroker::compile_queue(int comp_level) {
void CompileBroker::print_compile_queues(outputStream* st) { void CompileBroker::print_compile_queues(outputStream* st) {
st->print_cr("Current compiles: "); st->print_cr("Current compiles: ");
MutexLocker locker(MethodCompileQueue_lock); MutexLocker locker(MethodCompileQueue_lock);
MutexLocker locker2(Threads_lock);
char buf[2000]; char buf[2000];
int buflen = sizeof(buf); int buflen = sizeof(buf);

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);
@ -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

@ -485,6 +485,10 @@ void VM_Exit::wait_if_vm_exited() {
} }
} }
void VM_PrintCompileQueue::doit() {
CompileBroker::print_compile_queues(_out);
}
#if INCLUDE_SERVICES #if INCLUDE_SERVICES
void VM_PrintClassHierarchy::doit() { void VM_PrintClassHierarchy::doit() {
KlassHierarchy::print_class_hierarchy(_out, _print_interfaces, _print_subclasses, _classname); KlassHierarchy::print_class_hierarchy(_out, _print_interfaces, _print_subclasses, _classname);

View File

@ -105,6 +105,7 @@
template(DumpHashtable) \ template(DumpHashtable) \
template(DumpTouchedMethods) \ template(DumpTouchedMethods) \
template(MarkActiveNMethods) \ template(MarkActiveNMethods) \
template(PrintCompileQueue) \
template(PrintClassHierarchy) \ template(PrintClassHierarchy) \
class VM_Operation: public CHeapObj<mtInternal> { class VM_Operation: public CHeapObj<mtInternal> {
@ -421,6 +422,17 @@ class VM_Exit: public VM_Operation {
void doit(); 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 #if INCLUDE_SERVICES
class VM_PrintClassHierarchy: public VM_Operation { class VM_PrintClassHierarchy: public VM_Operation {
private: private:

View File

@ -832,7 +832,8 @@ void VMDynamicLibrariesDCmd::execute(DCmdSource source, TRAPS) {
} }
void CompileQueueDCmd::execute(DCmdSource source, TRAPS) { void CompileQueueDCmd::execute(DCmdSource source, TRAPS) {
CompileBroker::print_compile_queues(output()); VM_PrintCompileQueue printCompileQueueOp(output());
VMThread::execute(&printCompileQueueOp);
} }
void CodeListDCmd::execute(DCmdSource source, TRAPS) { void CodeListDCmd::execute(DCmdSource source, TRAPS) {

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
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityBase * @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
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * @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
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * @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
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * @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));
} }
} }

View File

@ -24,25 +24,33 @@
/* /*
* @test CompilerQueueTest * @test CompilerQueueTest
* @bug 8054889 * @bug 8054889
* @library /testlibrary * @library /testlibrary /test/lib /
* @modules java.base/sun.misc * @modules java.base/sun.misc
* java.compiler * java.compiler
* java.management * java.management
* jdk.jvmstat/sun.jvmstat.monitor * jdk.jvmstat/sun.jvmstat.monitor
* @ignore 8069160
* @build jdk.test.lib.* * @build jdk.test.lib.*
* @build jdk.test.lib.dcmd.* * jdk.test.lib.dcmd.*
* @run testng CompilerQueueTest * sun.hotspot.WhiteBox
* @run testng/othervm -XX:-TieredCompilation CompilerQueueTest * compiler.testlibrary.CompilerUtils
* @run testng/othervm -Xint CompilerQueueTest * @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 * @summary Test of diagnostic command Compiler.queue
*/ */
import compiler.testlibrary.CompilerUtils;
import jdk.test.lib.OutputAnalyzer; import jdk.test.lib.OutputAnalyzer;
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 sun.hotspot.WhiteBox;
import java.lang.reflect.Executable;
import java.lang.reflect.Method;
import java.util.Iterator; import java.util.Iterator;
public class CompilerQueueTest { public class CompilerQueueTest {
@ -54,70 +62,123 @@ public class CompilerQueueTest {
* *
* Output example: * Output example:
* *
* Contents of C1 compile queue * Current compiles:
* ---------------------------- * C1 CompilerThread14 267 3 java.net.URLStreamHandler::parseURL (1166 bytes)
* 73 3 java.lang.AbstractStringBuilder::append (50 bytes) * C1 CompilerThread13 760 3 javax.management.StandardMBean::getDescription (11 bytes)
* 74 1 java.util.TreeMap::size (5 bytes) * C1 CompilerThread12 757 s 3 com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory::getMapping (27 bytes)
* 75 3 java.lang.StringBuilder::append (8 bytes) * C1 CompilerThread11 756 s! 3 com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory::mappingForType (110 bytes)
* 83 3 java.util.TreeMap$ValueIterator::next (8 bytes) * C1 CompilerThread10 761 3 java.lang.StringLatin1::indexOf (121 bytes)
* 84 1 javax.management.MBeanFeatureInfo::getName (5 bytes) * C2 CompilerThread7 769 4 CompilerQueueTest::testcaseMethod4 (1 bytes)
* ---------------------------- *
* Contents of C2 compile queue * 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::<init> (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 * Empty
* ----------------------------
* *
**/ **/
protected static final WhiteBox WB = WhiteBox.getWhiteBox();
public void run(CommandExecutor executor) { 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) // Get output from dcmd (diagnostic command)
OutputAnalyzer output = executor.execute("Compiler.queue"); OutputAnalyzer output = executor.execute("Compiler.queue");
Iterator<String> lines = output.asLines().iterator(); Iterator<String> lines = output.asLines().iterator();
// Loop over output set result for all found methods
while (lines.hasNext()) { while (lines.hasNext()) {
String str = lines.next(); String str = lines.next();
if (str.startsWith("Contents of C")) { // Fast check for common part of method name
match(lines.next(), "----------------------------"); if (str.contains("testcaseMethod")) {
str = lines.next(); for (TestCase testcase : testcases) {
if (!str.equals("Empty")) { if (str.contains(testcase.methodName)) {
while (str.charAt(0) != '-') { Assert.assertFalse(testcase.check, "Must not be found or already found.");
validateMethodLine(str); testcase.check = true;
str = lines.next();
} }
} else {
str = lines.next();
}
match(str,"----------------------------");
} else {
Assert.fail("Failed parsing dcmd queue, line: " + str);
} }
} }
} }
private static void validateMethodLine(String str) { for (TestCase testcase : testcases) {
// Skip until package/class name begins. Trim to remove whitespace that if (!testcase.check) {
// may differ. // If this method wasn't found it must have been removed by policy,
String name = str.substring(14).trim(); // verify that it is now removed from the queue
int sep = name.indexOf("::"); Assert.assertFalse(WB.isMethodQueuedForCompilation(testcase.method), "Must be found or not in queue");
if (sep == -1) {
Assert.fail("Failed dcmd queue, didn't find separator :: in: " + name);
}
try {
Class.forName(name.substring(0, sep));
} catch (ClassNotFoundException e) {
Assert.fail("Failed dcmd queue, Class for name: " + str);
} }
// Otherwise all good.
} }
public static void match(String line, String str) { // Enable compilations again
if (!line.equals(str)) { WB.unlockCompilation();
Assert.fail("String equals: " + line + ", " + str);
}
} }
@Test @Test
public void jmx() { public void jmx() {
run(new JMXExecutor()); 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;
}
}
} }