To the stack pointer in RSP register adjusted by the size of the current stack frame, It takes the address of a stack limit for the current thread and compares it Interpreter performs a straightforward check in a method prologue. There are some interesting details though. It simply performs a stack overflow check on every method invocation. But how does JVM know when it’s time to throw an error? Java obviously throws StackOverflowError. When a call chain becomes too deep and there is no free space on the stack to create more frames, This is usually enough to place several thousand average frames. The stack size is configured with -Xss option and defaults to 1 MB on a 64-bit system. This seems intuitive, since the optimizing compiler does not need to haveĪll the local variables and all the monitors on the stack. The compiled frame is often smaller than the interpreter frame for the same method – The maximum stack usage of any Java method is known beforehand,īut may vary depending on whether the method is interpreted or compiled. Unlike C, where stack space can be allocated dynamically with Java methods and native methods share the same stack with Java and native frames HotSpot JVM uses one contiguous stack for all the above purposes. The classical “C” stack required for native method execution. Which holds operands for bytecode instructions. Indeed had chunked stacks allocated in Java heap. Java ME virtual machine (that I worked on at Sun Microsystems) Which stores local variables and keeps track of method invocations.Īs the specification says, this stack does not need to be contiguousĪnd may be heap allocated. That in Java there are at least 3 different notions of a stack: As you probably know, HotSpot JVM has one-to-one mapping of Java threads to OS threads.Įach thread is associated with its own stack.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |