3: Java virtual machine architecture

Source: Internet
Author: User
Java virtual machine specification

According to Java Virtual Machine specifications, its structure includes subsystems, memory areas, data types, and commands.

By defining these abstract components and interactions between them, the specification itself defines that any Java Virtual Machine implementation must follow this structure to implement a specific Java Virtual Machine

 


Internal Architecture of Java Virtual Machine

 

 

Class Loader Subsystem

Each Java virtual machine has a class loader subsystem, which loads the type (class or interface) according to the given full limit name)

 

Execution engine

Each Java virtual machine has an execution engine that executes commands contained in the methods of the loaded class.

 

Runtime data Zone

When the Java Virtual Machine runsProgramIt requires memory to store many things, such as bytecode, other information obtained from the mounted class file, and the object created by the program, the parameters, return values, local variables, and intermediate calculation results passed to the method. The Java Virtual Machine organizes these items into several "RunTime data zones" for ease of management.

 

Method Area and heap

Each Java Virtual Machine instance has a method zone and a heap, which are shared by all threads of the virtual machine.

When a virtual machine loads a class file, it parses the type information from the binary data contained in this class file. Then it places the type information in the method area. When the program is running, the virtual opportunity puts all the objects created by the program at runtime into the heap.

 

Java stack and PC register (program counter)

Each thread in the Java Virtual Machine has its own java stack and program counter.

When a new thread is created, it will get its own PC register and a java stack. If the thread is executing a Java method (non-local method ), the value of the PC register always indicates the next instruction to be executed, its java stack always stores the status of Java method calls in the thread (including its local variables, parameters passed in When called, and its return values, and intermediate calculation results)

Note:

1: Each method has its own attributes. These attributes are not mixed in the java stack, but are stored in the java stack frame. A java stack is composed of many stack frames. When a thread calls a Java method, the VM pushes a new stack frame to the java stack of the thread. When the method returns, this stack frame pops up from the java stack and is discarded.

2: Java Virtual Machine has no registers, and its instruction set uses java stack to store intermediate data. The reason for this design is to keep the instruction set of the Java Virtual Machine as compact as possible, and to facilitate JAVA Implementation on platforms with few General registers. In addition, this stack-based architecture of Java virtual machine also helps dynamic compilers and real-time compilers implemented by some virtual machines during runtime.CodeOptimized.

 

Local method Stack

The local Method Invocation status is stored in the local method stack in a way dependent on the specific implementation, or in registers or some other memory areas related to the specific implementation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.