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.
Without the JIT, the VM has to interpret the bytecodes itself - a process that requires extra CPU and memory. The JIT compiler doesn't compile every method that gets called because thousands of methods can be called at startup.
A Just-In-Time (JIT) compiler is a feature of the run-time interpreter, that instead of interpreting bytecode every time a method is invoked, will compile the bytecode into the machine code instructions of the running machine, and then invoke this object code instead.
JIT downloads the compiler and compiles code exactly before Displaying in the browser. AOT has already complied with the code while building your application, so it doesn't have to compile at runtime. Loading in JIT is slower than the AOT because it needs to compile your application at runtime.
JIT is the tool which can transform bytecode to the binary code. javac is the tool which can transform code to the Java bytecode.
It sounds like you want something similar to the Compiler Control feature (http://openjdk.java.net/jeps/165).
Unfortunately, it doesn't exist yet, although it is currently scheduled to form part of Java 9.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With