Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know method is JITed or interpreted

Tags:

java

jvm

As I understand there is no clear rule to determine whether Java method will be JITed or interpreted while call. So is there somehow to tell JVM that I need a certain method to be JITed. And is there a way to know for sure which method will be JITed and which not.

like image 460
NDeveloper Avatar asked May 26 '11 08:05

NDeveloper


People also ask

Is Java JIT?

The Just-In-Time (JIT) compiler is a component of the Java™ Runtime Environment that improves the performance of Java applications at run time. Java programs consists of classes, which contain platform-neutral bytecodes that can be interpreted by a JVM on many different computer architectures.

How does JIT and JVM work?

JVM compiles complete byte code to machine code. JIT compiles only the reusable byte code to machine code. JVM provides platform independence. JIT improves the performance of JVM.

Why is Java a hybrid language?

Java is Hybrid Language i.e. it is both Compiled(work done upfront) and Interpreted(work done receiving-end). Byte code is an IL(Intermediate Language) to Java. Java source code compiles to Bytecode by javac .

What is JVM and JIT in Java?

JIT stands for Just In time compilation and JVM stands for Java Virtual Machine. JVM is a virtual machine used in Java programming platforms to execute or run Java programs. The main advantage of JVM is that JVM makes Java platform-independent by executing bytecodes.


1 Answers

As far as I know you don't know (from inside the JVM) and can not enforce a method being JITed or not, but using -XX:+PrintCompilation JVM argument you can watch the JIT compiler doing it's work and check if a method gets JITed in that particular run of the program or not.

like image 118
Waldheinz Avatar answered Sep 29 '22 09:09

Waldheinz