| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
references
each thread in a JVM has its own JVM stack
created when thread is created
LIFO
stores frames
holds local variables and partial results
is never manipulated directly except to push and pop frames
if the computation in a thread requires a larger Java Virtual Machine stack than is permitted, the Java Virtual Machine throws a StackOverflowError
specification permits Java Virtual Machine stacks either to be of a fixed size or to dynamically expand
default stack size (HotSpot): 320k in the 32-bit VM, 1024k in the 64-bit VM
set stack size: -Xss
references
frame size: 4 bytes
is used to store data and partial results, as well as to perform dynamic linking, return values for methods, and dispatch exceptions
new frame is created each time a method is invoked
a frame is destroyed when its method invocation completes, whether that completion is normal or abrupt (it throws an uncaught exception)
represents method invocation (in a given thread)
it is an invocation context of a method
for a given thread only one frame is active at any point
active frame is called current frame , corresponding method - current method, class declaring method - current class
frames are allocated from the Java Virtual Machine stack of the thread creating the frame
each frame has its own array of local variables, its own operand stack, and a reference to the run-time constant pool of the class of the current method
lifecycle:
frame created by a thread is local to that thread and cannot be referenced by any other thread
JVM allows to hide some frames for performance reasons
references
each frame contains an array of variables known as its local variables
length of the local variable array of a frame is determined at compile-time and supplied in the binary representation of a class or interface along with the code for the method associated with the frame
single local variable can hold a value of type boolean, byte, char, short, int, float, reference, or returnAddress
value of type long or type double occupies two consecutive local variables
on class method invocation, any parameters are passed in consecutive local variables starting from local variable 0
on instance method invocation, local variable 0 is always used to pass a reference to the object on which the instance method is being invoked and other parameters are subsequently passed in consecutive local variables starting from local variable 1
references
each frame contains a LIFO stack known as its operand stack
example
iload_0 # Push the value from local variable 0 onto the stack iload_1 # Push the value from local variable 1 onto the stack iadd # Pops those off the stack, adds them, and pushes the result
the iadd instruction adds two int values together - it requires that the int values to be added be the top two values of the operand stack, pushed there by previous instructions.
maximum depth of the operand stack of a frame is determined at compile-time and is supplied along with the code for the method associated with the frame
operand stack is empty when the frame that contains it is created
JVM instructions
the operand stack is also used to prepare parameters to be passed to methods and to receive method results
an operand stack has an associated depth, where a value of type long or double contributes two units to the depth and a value of any other type contributes one unit
System.out.println("Hello, world!");
0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream; 3: ldc #3; //String Hello, world! 5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
| Back | FazBrowse Home | New Git URL |