Java virtual machine principle learning

one,

(1) The virtual machine is the operating support system of Java. The inherent versatility, security and efficiency of Java are built on the Java virtual machine. The reason why these three features can be realized on the Java virtual machine, This is because the result of compiling Java source code is not native machine instructions, but bytecode.

(2) The reason why Java can compile once and run everywhere is due to the bytecode. Unlike traditional languages ​​such as C/C++, the default compilation result of Java source code is not executable code (local machine instructions) , but the bytecode with platform versatility. Although the implementation mechanisms of Java virtual machines on different platforms are not the same, the bytecodes they jointly explain are the same, so the bytecode is the cross-platform implementation of Java. key factor.

(3) The core of Java technology is the Java virtual machine, because all Java programs run inside the Java virtual machine. The reason why JVM becomes a VM is that it is an abstract computer defined by a set of specifications. The main task of JVM is to Responsible for loading bytecode into it, interpreting and compiling it into machine instructions for execution on the corresponding platform.

      HotSpot VM is one of the representative works of high-performance virtual machines on the market. Inside, the compiler and the interpreter coexist. Through the cooperative work of the compiler and the interpreter, it can not only ensure the response time of the program, but also improve the The execution performance of the program, and the work pressure on the compiler is also reduced to a certain extent.

      The current Java virtual machine specification on the market does not mandate that the internal implementation of the virtual machine must adopt an architectural solution in which the interpreter and the compiler coexist, but currently mainstream virtual machines will adopt this architecture, because when the virtual machine starts, the interpretation The compiler can come into play first without having to wait for the compiler to fully compile. And as the running time of the program goes on, the compiler gradually comes into play, compiling valuable bytecodes into native machine instructions according to the hotspot detection function, in exchange for higher program execution efficiency.

(4) Java templating: The so-called templating refers to the fact that developers can independently develop and physically deploy each functional module in the system when building a large-scale system. The coupling between modules can also ensure that when a single module fails, it will not affect the overall operation of the system. In general, developers choose OSGi technology as the first choice for modular programming. For now, OSGi technology has long been the Java modular specification standard.

(5) Language independence: The Java virtual machine has language independence, and will not simply have a private life with the Java language, as long as the compilation results of other programming languages ​​satisfy and include the Java virtual machine's internal instruction set, symbol table, and other Auxiliary information, it is a valid bytecode file that can be recognized by the virtual machine and loaded and run. If the compilation result of any programming language can satisfy the composition structure and storage form of the bytecode, then theoretically, it can run inside the Java virtual machine.

(6) Use the Fork/Join framework to achieve multi-core operation: With the development of today's hardware level, even the CPU core of smartphones such as mobile phones adopts multi-core hyper-threading technology, while traditional PC devices, enterprise-level servers, etc. are also concerned. High frequency conversion to multiple cores to handle daily tasks.

To be continued. . . .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326310767&siteId=291194637