directory

  • 1. The description of the JVM
  • 2. Class loading subsystem
  • 3. Run time data area
  • 4. Vm stack
  • 5. The heap area
  • 6. Method of area
  • 7. Object instantiation and memory access
  • Overview of garbage collection
  • 9. Classic garbage collector
  • 10. The G1 and ZGC

1. The role of the JVM

Java source code is compiled into.class bytecode files, which are compiled by VMS on different platforms into machine-code instructions that can be read by the machine. With the JVM, programmers don’t have to worry about how the code fits on different platforms.

2. Vm structure

  • Class loading subsystem: responsible for loading. Class files into memory

  • Runtime data area

    • Method area and heap area: shared by the threads being used
    • Method area (JDK7: permanent generation, JDK8: meta-space): used to store data such as class information that has been loaded by the virtual machine, constants, static variables, and code compiled by the JUST-in-time Compiler.
    • Heap: The largest chunk of memory in the Java virtual machine, shared by all threads, where almost all object instances are allocated memory;
    • The program counter: the current thread performed by the number of rows in the bytecode indicator, bytecode parser work is by changing the value of the counter, to select the next need to execute bytecode instruction, branches, loops, jumps, exception handling, restore the basic function such as threads, all need to rely on the counter to complete;
    • Java Virtual Machine Stacks: A separate thread that stores information about local variables, operand Stacks, dynamic links, method exits, etc.
    • Native Method Stack: Serves the same function as virtual machine Stack, except that the virtual machine Stack serves Java methods, while the local Method Stack serves Native methods for virtual machines.
  • Execution engine: The task of the execution engine is to interpret/compile bytecode instructions to local machine instructions on the corresponding platform according to the program counter. Simply put, the execution engine in the JVM acts as a translator for translating high-level languages into machine languages.

  • Native method interface: Java’s interface to call non-Java code

3. Java code execution process

Java source — compiles javac–> bytecode files. Class –> Classloading subsystem generates reflection classes –> Runtime data –> Execution engine –> Interpret execution + Compile Execution (JIT) –> Operating system (Win, Linux, Mac JVM)

Refer to the article: www.cnblogs.com/yanl55555/c…