Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
84 views
in Technique[技术] by (71.8m points)

java - How does the JVM work considering computer organization?

I thought I've always understood why Java was portable, until I took Computer Organization.

This is my interpretation of a C program from start to finish:

C program --> compiler --> assembly --> machine code --> ISA --> micro architecture (how the computer interprets ISA) --> logic gate --> circuit --> device

Where the compiler must have knowledge of the ISA. Also, the assembly and machine code will vary based on ISA.

Java is as such: (inside JVM): Java program --> compiler --> bytecode

bytecode is the ISA for a JVM.

So, I am guessing the JVM also has it's own micro architecture to interpret it's ISA (bytecode).

Is this accurate?

So the overall cycle would be: (inside JVM) Java program --> bytecode(ISA) --> JVM micro architecture --> host hardware

Also, if the micro architecture is implemented in the processor, does the JVM need to use one of the hosts' processors?

question from:https://stackoverflow.com/questions/65865029/how-does-jvm-compile-to-machine-code-from-bytecode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It's more like (following your layering for C):

Java program --> Java compiler --> bytecode --> JVM compiler --> assembly 
--> machine code --> ISA --> micro architecture (how the computer interprets ISA)
--> logic gate --> circuit --> device

Note that there are essentially two compilers. That's how Java achieves portability.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...