• Post Reply Bookmark Topic Watch Topic
  • New Topic

More Questions on Just-In Time compiler  RSS feed

 
vishal mishra
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Namaste Friends !!

I have already asked question about JIT and I thought my doubt is clear but it is not so.

I have Jdk 1.7 installed on my system.

Please tell me whether JIT is included in jdk1.7 or not ?

Is there any difference between stack trace of JIT and JVM interpreter?

Thanks
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whether JIT is included in jdk1.7 or not ?


Yes. The relevant part is "HotSpot":

java -version
java version "1.7.0_13"
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode, sharing)
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any difference between stack trace of JIT and JVM interpreter?


If the stack trace is not complete due to some parts getting replaced by something like ".. compiled code" then yes.
You'll recognize it when you see it.

JIT is not something you should usually be worried about too much.
 
vishal mishra
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Jozsef Balazs wrote:
Is there any difference between stack trace of JIT and JVM interpreter?


If the stack trace is not complete due to some parts getting replaced by something like ".. compiled code" then yes.
You'll recognize it when you see it.

JIT is not something you should usually be worried about too much.


Thanks for your quick reply

I have jdk1.7.0_02 that means JIT is not included.

Thank you
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what you conclude that from. A JIT has been part of all JVM releases for about 15 years, give or take.
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have jdk1.7.0_02 that means JIT is not included.


My point was not that the JIT is included only from the version up I am using, but that HotSpot is a JVM architecture supporting JIT.


What is the output of this command?

java -version

And why are you so keen on this topic?

Several years ago (unfortunately I don't remember the version) I made a test with a little number crunching test program which I had written in both C/C++ and Java.
To my sincere astonishment the C/C++ was not really faster, they were of about the same speed, one measurement was even in favour of the Java version!
I let run the Java version run even without any special option.
 
vishal mishra
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Not sure what you conclude that from. A JIT has been part of all JVM releases for about 15 years, give or take.


Well....I am still at the Beginner's level of java programing, trying to learn more....

I just want to experience the difference or to observe the difference in execution of java program by using JIT compiler and without using JIT i.e. turning off JIT compiler by using command


"java -Djava.compiler=none"
I have read somewhere that there is difference between stack trace produce by JIT and the stack trace produce by JVM
But not able to find any difference on executing the following program first by command java IpScanner, secondly by command "java -Djava.compiler=none IpScanner" and throwing NullPointerException



Thank you
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure where you got "java.compiler=none" from; the way to turn off the JIT is to start the JVM via "java -Xint ...".

Note that the JIT is a part of the JVM, and while you can explicitly turn it off (in the way I mentioned), whether or not it is used is up to the JVM (meaning, you can't force it to be used). Some methods will be JITed, and some may not be; that is up to the JVM (which gathers extensive statistics about class and method usage in order to determine whether it should or should not JIT a piece of code).

But all this goes way beyond what a beginner should concern himself with. It is just as likely to confuse you as it is to make things clearer.
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need an instance of the class as a member? Where does the variable ip get a value?
public class IpScanner {
IpScanner ip;
..



System.out.print(80+" port is open" +new IpScanner().ip.toString());


ip is null, invoking toString() against it is asking for trouble.

There is a proverb in my native tongue (Hungarian) which literally translates to "To shoot with a (big calibre) gun on a sparrow".
Who knows why this came to my mind...
 
vishal mishra
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Not sure where you got "java.compiler=none" from; the way to turn off the JIT is to start the JVM via "java -Xint ...".

Note that the JIT is a part of the JVM, and while you can explicitly turn it off (in the way I mentioned), whether or not it is used is up to the JVM (meaning, you can't force it to be used). Some methods will be JITed, and some may not be; that is up to the JVM (which gathers extensive statistics about class and method usage in order to determine whether it should or should not JIT a piece of code).

But all this goes way beyond what a beginner should concern himself with. It is just as likely to confuse you as it is to make things clearer.


Thanks for explaining me about JIT, I have searched through various sources in the net but nowhere it is specifically mentioned that JIT is a part of each version of JDK thanks for mentioning this.

Following is the source where i have read about command "java -Djava.compiler=none" for turning off JIT

http://www.coderanch.com/t/367496/java/java/turn-JIT

One last question:-

Does stack trace produced JVM using JIT contains line numbers of source-code ?

Thanks
 
vishal mishra
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Jozsef Balazs wrote:Why do you need an instance of the class as a member? Where does the variable ip get a value?
public class IpScanner {
IpScanner ip;
..



System.out.print(80+" port is open" +new IpScanner().ip.toString());


ip is null, invoking toString() against it is asking for trouble.

There is a proverb in my native tongue (Hungarian) which literally translates to "To shoot with a (big calibre) gun on a sparrow".
Who knows why this came to my mind...



This program was coded for different purpose.

I have mutated it just for watching the different behavior of JVM, when it uses JIT ans when it doesn't .
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vishal mishra wrote:I have mutated it just for watching the different behavior of JVM, when it uses JIT ans when it doesn't .

Why did you expect the JVM to behave differently with or without JIT when runnning that program?

Anyway, as I already mentioned in my answer to your previous question, you can switch the JIT off with the -Xint option. Run your program with:

java -Xint IpScanner

I don't think you will notice any difference with out without the JIT.
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you should experience once that file/class names and line numbers are lacking from the stack trace, run the JVM in pure interpreting mode,
otherwise one should not take care of the issue.

-Xint interpreted mode execution only
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!