JVM_03 Runtime data area 1_Native Method stack_Native Method stack

3 Local method stack

The Java virtual machine stack is used to manage the invocation of Java methods, and the local method stack is used to manage the invocation of
local methods. The local method stack is also private to the thread.
Allows to be implemented as a fixed or dynamically expandable memory size. (The same in terms of memory overflow)

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, then the java virtual machine will throw an OutOfMemoryError abnormal.

The native method is implemented using the C language.
The 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.
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 local method can access the runtime data area inside the virtual machine through the local method interface.
It can even directly use the registers in the local processor and
directly allocate any amount of memory from the heap of the local memory.

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.
In hotSpot JVM, the local method stack and the virtual machine stack are directly combined into one.

Guess you like

Origin blog.csdn.net/qq_43141726/article/details/114585726