Merge
This commit is contained in:
commit
1e758f661b
@ -469,7 +469,6 @@ CompileQueue* CompileBroker::compile_queue(int comp_level) {
|
||||
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);
|
||||
|
@ -644,12 +644,12 @@ WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobjec
|
||||
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 @@ static JNINativeMethod methods[] = {
|
||||
#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 @@ static JNINativeMethod methods[] = {
|
||||
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},
|
||||
|
@ -485,6 +485,10 @@ void VM_Exit::wait_if_vm_exited() {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -105,6 +105,7 @@
|
||||
template(DumpHashtable) \
|
||||
template(DumpTouchedMethods) \
|
||||
template(MarkActiveNMethods) \
|
||||
template(PrintCompileQueue) \
|
||||
template(PrintClassHierarchy) \
|
||||
|
||||
class VM_Operation: public CHeapObj<mtInternal> {
|
||||
@ -421,6 +422,17 @@ class VM_Exit: public VM_Operation {
|
||||
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:
|
||||
|
@ -832,7 +832,8 @@ void VMDynamicLibrariesDCmd::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) {
|
||||
|
@ -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 @@ public class TestCompilerDirectivesCompatibilityBase {
|
||||
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 {
|
||||
|
@ -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 @@ import java.util.Objects;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ import java.util.Objects;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ import java.util.Objects;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class CompilerQueueTest {
|
||||
*
|
||||
* 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::<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
|
||||
* ----------------------------
|
||||
*
|
||||
**/
|
||||
|
||||
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<String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user