Learning a JVM: JVM architecture and life cycle model

JVM architecture model

Java compiler instruction input stream is essentially based on a stack instruction set architecture , another instruction set architecture is based on the instruction set architecture register .

Specifically, the difference between these two architectures:

  • Based on the characteristics of the stack architecture:
    • Design and implementation easier for resource-constrained systems
    • To avoid the allocation problem register: a zero-address instruction mode assigned
    • Most instruction stream instruction address of the instruction is zero, which depends on the execution stack operation. Smaller instruction set, the compiler to achieve easier
    • No hardware support, better portability, better cross-platform
  • Based on the characteristics of the architecture registers:
    • Typical applications are binary instruction set X86: for example, the traditional PC and Android's virtual machine Davlik
    • Instruction set architecture is completely dependent on the hardware, poor portability
    • Excellent performance and more efficient execution
    • It takes fewer instructions to complete an operation
    • In most cases, a register-based instruction set architecture often at an address of the instruction, the instruction address of two, three-address instruction-based, and the stack-based instruction set architecture has an instruction address based on a zero-based

Due to the design cross-platform, Java instructions are designed according to the stack. Different platforms of different CPU architectures, it is not designed as a register-based. The advantage is cross-platform, small instruction set, the compiler is easy to implement, the disadvantage is performance degradation, perform the same function requires more instruction.

JVM lifecycle

Start the virtual machine

Start the Java virtual machine is created by the bootstrap class loader (bootstrap class loader) an initial class (initial class) to complete, this class is to achieve specified by the specific virtual machine.

Execution of the virtual machine

  • A running Java Virtual Machine has a clear mission: to execute Java programs
  • It only runs when the program execution began, the program ends when it stops
  • The implementation of a so-called Java program when the execution is really a process called the Java Virtual Machine

Exit the virtual machine

Exit the virtual machine has the following situations:

  • Normal program execution ends
  • Encountered an exception or error during execution aborted
  • Because the operating system error caused the process to terminate the Java Virtual Machine
  • a thread calls the exit method of class Runtime or class System, or halt method of class Runtime and Java Security Manager also allows the exit or halt operations
  • In addition, JNI (Java Native Interface) specification describes when using JNI Invocation API to load or unload Java Virtual Machine exits from the Java virtual machine
Published 23 original articles · won praise 21 · views 3714

Guess you like

Origin blog.csdn.net/Gldwolf/article/details/104050348