Intermediate code by virtual machines

0

I was reading about instruction set and I came across following line from WIKI

Some virtual machines that support bytecode as their ISA such as Smalltalk, the Java virtual machine, and Microsoft's Common Language Runtime, implement this by translating the bytecode for commonly used code paths into native machine code.

Please correct me on my overall understanding on "instruction set" and virtual machines handling of the same:

  • Basically processors have instructions or instruction sets loaded into their memory which are used for processing. Now processors receive binary input which is nothing but the “binary” representation of those instructions set. Right?
  • Instruction set can also be called as “machine code” or “machine language”. Right?
  • JVM accept Java bytecode and produce the binary form of “instruction set” or “machine code” or “machine language”. So, in this way I can say that bytecode is the machine language of JVM because JVM understand the bytecode or takes bytecode as input and produces binary form of “machine code” for the Operating System and then OS will further convert those “machine code” into “machine code” for the processor. Right?
    • Bolded portion in my above question is among main thing I want to understand. Because we don't have JVM's for specific processors, we have JVM's for specific OS, so my understanding is that JVM cannot produce "machine code" for the processor and will produce the "machine code" for the OS and then finally OS will produce the "machine code" to be executed by the processor.

Please confirm my understanding and if it is wrong then please provide details and/or reference on why it is incorrect and what is the corrected concept.

pjj

Posted 2017-02-04T23:03:54.463

Reputation: 139

You say there is no JVM for specific processors, but I see 32bits, 64bits and SPARC JVMs on the download page : https://www.java.com/en/download/manual.jsp

– user2313067 – 2017-02-05T08:32:55.767

@user2313067 I am kind of surprised with your comment because bitness and processor are different things, I know there are different JVMs for 32 and 64 bit. If you can prove me that there are different JVMs for Intel, AMD, Motorola, Qualcomm etc. processors then I will humbly accept that statements I made in my question were wrong. – pjj – 2017-02-06T17:34:08.260

But AMD and Intel both make mostly x86 (32bits) and x86_64 (64bits) processors. Those use the same instruction set so they process the same machine code. I think qualcomm makes mostly arm processors, so you'd need an arm JVM, but I'm not certain.

– user2313067 – 2017-02-06T17:47:46.483

With all due respect sir, it looks like that you don't have knowledge on Java, you said - "you'd need an arm JVM", this is not at all right because for this to be true, the most important Java feature has to be broken i.e. Java being architecture neutral and portable. – pjj – 2017-02-06T23:14:27.297

Well the Java bytecode remains architecture neutral and portable. You only need a JVM for the current architecture. x86 and x86_64 are different architectures and SPARC is completely different. Yet you have a JVM for SPARC Solaris and one for x86_64 Solaris. The point of Java is that the bytecode generated is independent of the system on which it will run. You still need a JVM for the OS and architecture it runs on. – user2313067 – 2017-02-07T07:43:18.927

@user2313067 I can agree on what you have said above except for "*Yet you have a JVM for SPARC Solaris and one for x86_64 Solaris.*", but your other comments were totally out of line, and none of your comments help answering my questions. I am bit surprised that even without knowledge of Java you have chosen to down vote my question. – pjj – 2017-02-07T12:21:55.053

I am not the downvoter, and don't really know why people downvoted it. In fact, I just upvoted it as I think it's quite clear. I'm a bit unclear whether it's on topic or not though. Rereading my comments, I think I should have written JRE instead of JVM, but my point is you go directly from Java bytecode to processor machine code. There is no OS machine code. – user2313067 – 2017-02-07T13:01:55.020

@user2313067 Oh, please accept my sincere apologies since I thought of you as down voter. As such in Java technology, JRE is nothing but JVM, so whether you say JRE or JVM, it is same. – pjj – 2017-02-07T21:40:32.573

Well the JVM is the abstract computer, the JRE contains an implementation of the JVM specific to your OS and instruction state. See the wikipedia page

– user2313067 – 2017-02-07T21:44:54.800

No answers