Lao Li share: JVM structure Introduction 2

Source: Internet
Author: User

2.2.4 Program counter regsiters: Programs counter

Similar to the PC register , is a small area of memory, through the value of the program counter to find the code to execute the bytecode, because the switch between multiple threads to restore the current execution location of each thread, so each thread has its own program calculator . There will be no outofmemeryerror in this area. When executing a Java method, the address of the executed instruction is stored here, and if the local method is executed, the value here is undefined

2.2.5 Java Stack: virtual machine stack

The virtual machine stack is also thread-private, each creation of a thread , the virtual machine will create a virtual machine stack for this thread, the virtual machine stack represents the Java method execution of the memory model, each call to a method, will generate a stack frame (stack frame) is used to store the local variable table of the method, the Operation Stack, the method exit, and so on, when the method executes, the corresponding stack frame pops up.

If the requested stack is too deep, the virtual machine may throw a stackoverflowerror exception, and if the virtual machine's implementation allows the virtual machine stack to scale dynamically, it throws outofmemoryerror when the memory is not enough to expand the stack. exception

Each thread will

Stack frame:

1. Local variable area

The local variable area is organized into a 0-based word group, where byte, short, and Char are converted to Int,boolean before being stored and converted to int,0 for false, not 0 for True,long and double to occupy two words in length.

2. Operand Stacks

The operand stack is also organized into a word group , but unlike the local variable area, it is not accessed by an array subscript, but can be pushed and pop operations over the stack , The data from the previous operation push can be used by the next action pop.

3. Stack Data area

a) data parsing in a constant pool

b) after the method has finished executing the method return, the calling method will be resumed on site

c) Exception handling when an exception is thrown during the execution of the method, the store has an exception table, and when an exception occurs, the virtual machine looks for the corresponding exception table to see if there is a corresponding catch statement, and if not, throws an abnormal termination

2.3 Execution engine running engines

JIT compiler:just-in-time Compiler compile in time

Garbage Collector: Garbage Collection

Three. JVM Run

Here very rough simulation of how the JVM runs

Lao Li share: JVM structure Introduction 2

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.