Old stack frames:

Some documentation for myself to learn how java methods use stacks local variables etc


Mmmm InitialStackFrame:

Calculates the space needed for the local vars in words and for the stack in words
Converts these to bytes for u16VarSize and u16OpSize. THe size of the actual frame object is u16FrameSize.

Now we set pi32OpBot to point to the frame end. We point pi32Vars to be u16OpSize further ie:

-*- Start of frame structure
    ...
    ...
-*- End of frame structure	
    Op stack here 0		<--------------- pi32OpBot = pi32OpTop
    Op stack here 1
    Op stack here 2
    Local var 1 here		<--------------- pi32Vars
    Local var 2 here
    Local var 3 here
    
then we set the pi32OpTop = pi32OpBot and copy all the local vars into their places
 

Ok, New Method Stacks: (NMS)

First InitialStackFrame, creates the head of the actual frame list and the head of the operand / variable stack, ie:

      tStackFrame* frame -> *-* Start of frame struct *-*                  *-* Start of operand stack *-*
			    pi32Vars ----------------------------------------->  Local var1
			    Frame data						 Local var2
			    pstExOb etc						 Local var3
			    pi32OpBot ----------------------------------------> Operand 1
			    pi32OpTop "						Operand 2
										Operand 3
			    *-* End of frame struct *-*			   *-* End of op stack *-*

Note they don't have to be the same size. Ok, now when PushStackFrame is called, we calculate the frame data and append it to the previous frame data and then create room for local variables not catered for by the previous op stack, plus our own op stack. So if we needed 4 local variables and 2 stack slots we would have:

      tStackFrame* frame -> *-* Start of frame struct *-*                  *-* Start of operand stack *-*
			    pi32Vars ----------------------------------------->  Local var1
			    Frame data						 Local var2
			    pstExOb etc						 Local var3
			    pi32OpBot ----------------------------------------> Operand 1
			    pi32OpTop (same)			  /		Operand 2
								 /		Operand 3
			    *-* End of frame struct *-*		 |	   *-* End of op stack *-*
		            *-* Start of frame struct *-*        |         *-* Start of operand stack *-*
			    pi32Vars----------------------------/              Additional local var 1
			    Frame data				    /------->  Operand 1
			    Blah				   /	       Operand 2
			    pi32OpBot ----------------------------/        *-* End of op stack *-*
			    pi32OpTop (same)
			    *-* End of frame struct *-*			   

Notice that there is only 1 new local variable, which is (4 - 3). 

An example with exact values:

Initial frame for java/lang/Class <clinit>

pi32Vars = 0x807c120
pi32OpBot = 0x807c124
pi32OpTop = 0x807c124

This method does not need a stack or local variables, so we have one space for pi32Vars

Initial frame for java/lang/Thread <clinit>

pi32Vars = 0x8084b10
pi32OpBot = 0x8084b14
pi32OpTop = 0x8084b14

This time we need 3 spaces on the stack (max 2 + 1), and no locals

Initial frame for java/lang/ThreadGroup <clinit>

pi32Vars = 0x8087e78
pi32OpBot = 0x8087e7c
pi32OpTop = 0x8087e7c

Also needs room for 3 stack (2 + 1) and no locals

This method pushes 2 items onto the stack and calls <init>

Now ThreadGroup <init> new frame has opsize 5, var size 3, args 1, additional 0

pi32Vars = 0x8087e80
pi32OpBot = 0x8087e80
pi32OpTop = 0x8087e80





