JVM from entry to master (eight) JVM runtime data area-local method stack

First, the characteristics of the local method stack

  1. The Java virtual machine stack is used to manage the calls of Java methods, while the local method stack is used to manage the calls of local methods (generally non-Java implemented methods).
  2. The local method stack is also private to the thread.
  3. Allows to be implemented as a fixed or dynamically expandable memory size . (The memory overflow situation is the same as the Java virtual machine stack)

If the stack capacity allocated by the thread request exceeds the maximum capacity allowed by the local method stack, the Java virtual machine will throw a StackOverFlowError exception.

If the local method stack can be dynamically expanded, and enough memory cannot be applied for when trying to expand, or there is not enough memory to create the corresponding local method stack when a new thread is created, the java virtual machine will throw an OutOfMemoryError abnormal.

  1. Native method is implemented in C language
  2. Its specific method is to register the native method in the Native Method Stack, and load the native method library when the Execution Engine is executed.

2. Matters needing attention

  1. When a thread calls a local method, it enters a new world that is no longer restricted by the virtual machine. It has the same permissions as the virtual machine.

    The method may be by local native method interface to access virtual machines running inside the data area

    It can even directly use the registers in the local processor

    Allocate any amount of memory directly from the heap of local memory

  2. Not all JVMs support native methods. Because the Java virtual machine specification does not explicitly require the language, specific implementation, data structure, etc. of the local method stack. If the JVM product does not plan to support native methods, there is no need to implement a native method stack.

  3. In Hotspot JVM, the local method stack and the virtual machine stack are directly combined into one.

Guess you like

Origin blog.csdn.net/BeiisBei/article/details/108999717