A first look at the Java virtual machine JVM

Major Events in Java Development

In 2000, JDK1.3 was released and Java's HotSpot virtual machine was released, which officially became the default virtual machine for Java.
In 2011, JDK7 was released and the new garbage collector G1 was officially launched.
2017. JDK9 is released. G1 is set as the default GC instead of GMS.

System virtual machine:
Visual Box, Vmware. The
virtual machine
Java virtual machine, which is an emulation program for physical computers , is specially designed to execute a single computer program

The Java virtual machine is
the operating environment of binary bytecode, which is installed in the bytecode and interpreted/compiled into the execution of machine instructions on the corresponding platform.
Features:
compile once, run everywhere,
automatic memory management,
automatic garbage collection

Java virtual machine operating environment

JVM runs on the operating system and has no direct interaction with hardware
Insert picture description here

HotSpot virtual machine

The HotSpot virtual machine adopted by the Java virtual machine adopts an architecture in which an interpreter and a just-in-time compiler coexist.
Insert picture description here

Architecture model

JVM adopts stack-based instruction set architecture, cross-platform, small instruction set, many instructions, and execution performance is worse than register

Features based on stack architecture:

  1. Design and implementation are simpler. Suitable for systems with limited resources
  2. Avoid the problem of register allocation and use the zero address instruction method to allocate
  3. Most of the instructions in the instruction stream are zero address instructions, and the execution process depends on the operation stack, the instruction set is smaller, and the compiler is easier to implement
  4. No need for hardware support, better portability, better cross-platform

Features based on register architecture

  1. The typical application is x86 binary instruction set; such as traditional PC and Android Davlik virtual machine
  2. The instruction set architecture is completely dependent on hardware and has poor portability
  3. Excellent performance and more efficient execution
  4. Take fewer instructions to complete an operation
  5. In most cases, the instruction set based on the register architecture is often dominated by one-address instructions, two-address instructions and three-address instructions, while the instruction set based on the stack architecture is dominated by zero-address instructions.

Virtual machine startup:
Bootstrap class loader creates an initial class to complete.
Execution of the virtual machine:
A running Java virtual machine has clear tasks: execute a Java program, and the program starts to execute before it runs, and the program technology stops.
When executing a Java program, what is really being executed is a process called the Java Virtual Machine.

Guess you like

Origin blog.csdn.net/qq_43458555/article/details/108350241