I'm trying to build a JIT strategy based on method structure with profiling info (provided by JVM) but i didn't able to trigger JIT manually. This documentation says i can run JIT by invoking java.lang.Compiler.compileClass()
but method returns false every time and the property that java.lang.Compiler
checks (java.compiler) is null every time i run the JVM. I tried on OpenJDK and Oracle JVM 1.7 both results the same.
However when i observe the compilation statistics with
$ jstat -printcompilation <PID>
I can see the JIT successfully compiles some method which fits the conditions.
If any way exist I rather trigger it from java code. I tried to search in hotspot VM's code too but I couldn't locate the class and method where the decision made and JIT start.
Edit: After looking around more I found the compilationPolicy.cpp bu still couldn't find the exact location that the decision depend on. I would expect something like (simply thinking)
if(hot_count > Threshold){
compile_method(methodHandle);
}
but instead found this,
void SimpleCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) {
const int comp_level = CompLevel_highest_tier;
const int hot_count = m->invocation_count();
reset_counter_for_invocation_event(m);
const char* comment = "count";
if (is_compilation_enabled() && can_be_compiled(m)) {
nmethod* nm = m->code();
if (nm == NULL ) {
// [MY COMMENT] no check being done on hot_count in here or callee methods
CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, comment, thread);
}
}
}
As far as tracing the native JVM code, im getting away my main topic. Still looking for a simple solution to use in java side of the code.
java.compiler
property enabled on your machine? The documentation you referenced makes an explicit reference of that needing to be set. You can check withSystem.out.println(System.getProperty("java.compiler"));
. – MacraeSystem.out.println(System.getProperty("java.compiler"));
code prints null.And i am not sure i should set a value by myself even if should i cant find any documentation to set a specific value. – Nobility