<>JVM summary

<>1. virtual machine

A virtual machine is a virtual computer . Software simulation with complete hardware system functions , Computer system running in a completely isolated environment . It's a piece of software , Used to execute a series of virtual computer instructions . broadly , Virtual machines can be divided into
System virtual machine ( for example :VMware) And program virtual machine ( for example :java virtual machine ). Whether it is system virtual machine or program virtual machine , The software running on it is limited to the resources provided by the virtual machine .

*
VMware

Complete simulation of physical computer , It provides a software platform to run a complete operating system .

*
java virtual machine (JVM)

Designed to execute a single computer program .Java Virtual machine is a kind of execution java Virtual computer of bytecode file , It has an independent operation mechanism .

java The core of technology is java virtual machine , Because of all of them java The programs are running in java Virtual machine internal .

<>2.JVM effect

java Virtual machine is the running environment of binary bytecode , Responsible for loading bytecode into its internal , explain / Compile to machine code instruction execution on the corresponding platform , Every one java instructions ,java Virtual machines are defined in detail , How to operate the number , How to deal with operands , Where are the processing results .

major function :

* adopt ClassLoader Find and load class file .
* Interpreting bytecode is called instruction and execution , provide class Running environment of file .
* Automatic runtime memory allocation and garbage collection .
* Provide a platform to interact with hardware .
current JVM Not only can it be implemented java Bytecode file , You can also execute bytecode files compiled in other languages , It's a cross language platform .

<>3.JVM The location of

JVM It runs on the operating system , It has no direct interaction with hardware .

<>4.JVM Overall composition

* Class loader (ClassLoader)
* Runtime data area (Runtime Data Area)
* Execution engine (Execution Engine)
* Local library interface (Native Interface)

process : Before the program is executed, the java Code to bytecode (class file ),jvm First of all, we need to load the bytecode into the runtime data area of the memory through the class loader in a certain way
, Bytecode files are jvm A set of instruction set specifications for , It can't be executed directly by the underlying operating system , Therefore, a specific command parser execution engine is needed
Translate the bytecode into the underlying system instructions and hand them in CPU To execute , In this process, we need to call the local library interface of other languages to realize the function of the whole program , This is it 4 Responsibilities and functions of the three main components .

<>5.java Code execution process

java Compiler compilation process , If any node fails to execute, compilation will fail . Although the java The internal implementation details of virtual machines are different , But they execute the same bytecode content .

JVM The main task is to be responsible for loading bytecode into it , explain / Compile to machine instruction execution on the corresponding platform .JVM Loading with class loader class file .

After class loading , Bytecode verification will be performed , After bytecode verification JVM The interpreter translates the bytecode into machine code for the operating system to execute .

But not all code is interpreted and executed ,JVM This is optimized , such as HoySpot virtual machine , It itself provides JIT.

<>6.JVM Architecture model

java The instruction stream input by compiler is basically a stack based instruction set architecture .

Characteristics of two architectures

1. Based on the characteristics of trestle architecture :

* Design and implementation is simpler , For resource constrained systems .
* Use zero address instruction to assign , Its execution depends on the operation stack , Smaller instruction set , The compiler is easy to implement .
* No hardware support required , Good portability , Better cross platform .
* Large number of instruction sets , Small instruction set .
2. Characteristics of register based architecture :

* Instructions are completely hardware dependent , Poor portability .
* Excellent performance , More efficient execution .
* Fewer instructions are used to complete an operation .
Because of the cross platform design ,java Instruction sets are designed based on stacks , Different CPU Different architecture , So it can't be designed as register based .
Interview questions : Today ,HotSpot The host environment of virtual machine is not limited to embedded platform , So why not replace the architecture with a better performance register instruction set architecture ?
answer : The two instruction set architectures have their own advantages and disadvantages , Coexisting development . first , In design and implementation , The structure based on trestle is simpler . Second, whether the resources of the platform are limited or not , Based on the trestle architecture can be used .( For the advantages of trestle , You can continue balabala…)

Technology
©2019-2020 Toolsou All rights reserved,
tkinter Implementation of user login interface Vue Invalid render dynamic component in subcomponent ( First invalid , Valid for the second time )9 ride 9 Sudoku C/C++ Memory model TypeScript actual combat -12-TS The mechanism of type checking - Type inference Java Thread safety and insecurity JLink,STLink,DAPLink,CMSIS DAP Differences in use Chapter 10 use SpringMVC Frame transformation of supermarket order management system -1C Language calculation of deposit interest About the Blue Bridge Cup , Things you should know !