简体   繁体   English

JVM如何考虑计算机组织?

[英]How does the JVM work considering computer organization?

I thought I've always understood why Java was portable, until I took Computer Organization. 在我选择计算机组织之前,我以为我一直都能理解为什么Java是可移植的。

This is my interpretation of a C program from start to finish: 这是我从头到尾对C程序的解释:

C program --> compiler --> assembly --> machine code --> ISA --> micro architecture (how the computer interprets ISA) --> logic gate --> circuit --> device C程序 - >编译器 - >汇编 - >机器码 - > ISA - >微架构(计算机如何解释ISA) - >逻辑门 - >电路 - >设备

Where the compiler must have knowledge of the ISA. 编译器必须具备ISA的知识。 Also, the assembly and machine code will vary based on ISA. 此外,组件和机器代码将根据ISA而变化。

Java is as such: (inside JVM): Java program --> compiler --> bytecode Java就是这样:(在JVM内部):Java程序 - >编译器 - >字节码

bytecode is the ISA for a JVM. 字节码是JVM的ISA。

So, I am guessing the JVM also has it's own micro architecture to interpret it's ISA (bytecode). 所以,我猜JVM也有它自己的微架构来解释它的ISA(字节码)。

Is this accurate? 这准确吗?

So the overall cycle would be: (inside JVM) Java program --> bytecode(ISA) --> JVM micro architecture --> host hardware 所以整个周期将是:(在JVM内部)Java程序 - >字节码(ISA) - > JVM微架构 - >主机硬件

Also, if the micro architecture is implemented in the processor, does the JVM need to use one of the hosts' processors? 此外,如果微处理器在处理器中实现,那么JVM是否需要使用其中一个主机的处理器?

It's more like (following your layering for C): 它更像是(跟随你的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. 这就是Java实现可移植性的方式。

First, java compiler compiles the source code into byte code. 首先,java编译器将源代码编译为字节代码。 At the run time,Java Virtual Machine (JVM) interprets this byte code and generates machine code which will be directly executed by the machine in which java program runs. 在运行时,Java虚拟机(JVM)解释此字节代码并生成机器代码,该机器代码将由运行java程序的机器直接执行。

Visit good tutorial of JVM,JRE and JDK https://javatutorialdetails.blogspot.com/2017/10/java-tutorial-in-details-step-by-step.html 访问JVM,JRE和JDK的优秀教程https://javatutorialdetails.blogspot.com/2017/10/java-tutorial-in-details-step-by-step.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM