[JVM] Seven, local method stack

Hello, everyone, I am a pig who is dominated by cabbage.

A person who loves to study, sleepless and forgets to eat, is obsessed with the girl's chic, calm and indifferent coding handsome boy.

If you like my text, please follow the public account "Let go of this cabbage and let me come"

Article Directory

07-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.

  • The operation is 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 cannot apply for enough memory when trying to expand, or there is not enough memory to create the corresponding local method stack when creating a new thread, then the Java virtual machine will throw an OutOfMemoryError abnormal.
  • The native method is implemented in C language.

  • 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.

Insert picture description here

  • 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.
    • Allocate any amount of memory directly from the heap of 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 virtual machine stack are directly combined into one.

to sum up

This chapter contains less content, and it looks better with the local method interface of the previous chapter. The content of the local method stack is similar to the virtual stack, including StackOverflowError and OutOfMemoryError. One is to manage the invocation of Java methods, and the other is to manage the invocation of local methods.

Guess you like

Origin blog.csdn.net/weixin_44226263/article/details/112261431