JVM
framestack.h
Go to the documentation of this file.
1 #ifndef FRAMESTACK_H
2 #define FRAMESTACK_H
3 
4 typedef struct Frame Frame;
5 typedef struct FrameStack FrameStack;
6 
7 #include "operandstack.h"
8 #include "attributes.h"
9 
12 struct Frame
13 {
16 
19  uint8_t returnCount;
20 
23  uint32_t pc;
24 
26  uint32_t code_length;
27 
29  uint8_t* code;
30 
33 
35  int32_t* localVariables;
36 
37 #ifdef DEBUG
38  uint16_t max_locals;
39 #endif
40 };
41 
44 struct FrameStack
45 {
48 
50  struct FrameStack* next;
51 };
52 
54 void freeFrame(Frame* frame);
55 uint8_t pushFrame(FrameStack** fs, Frame* frame);
56 uint8_t popFrame(FrameStack** fs, Frame* outPtr);
57 void freeFrameStack(FrameStack** fs);
58 
59 #endif // FRAMESTACK_H
Structure that will be associated with a method and holds the information necessary to run the method...
Definition: framestack.h:12
uint32_t code_length
Number of bytes the bytecode of the method contains.
Definition: framestack.h:26
uint8_t returnCount
Number of operands that should be moved from this frame to the caller frame when the method returns...
Definition: framestack.h:19
void freeFrameStack(FrameStack **fs)
Free all the elements of the FrameStack passed as parameter by reference.
Definition: framestack.c:110
uint8_t * code
Bytecode of the method.
Definition: framestack.h:29
OperandStack * operands
Stack of operands used by the method.
Definition: framestack.h:32
int32_t * localVariables
Array of local variables used by the method.
Definition: framestack.h:35
uint8_t popFrame(FrameStack **fs, Frame *outPtr)
Pop the Frame passed as parameter by reference.
Definition: framestack.c:91
struct FrameStack * next
Pointer to the next element of the stack.
Definition: framestack.h:50
uint8_t pushFrame(FrameStack **fs, Frame *frame)
Push the Frame into the FrameStack passed as parameter by reference.
Definition: framestack.c:71
Definition: javaclass.h:96
JavaClass * jc
Class of the method associated with this frame.
Definition: framestack.h:15
Frame * frame
The node value of the stack.
Definition: framestack.h:47
void freeFrame(Frame *frame)
Free the Frame passed as parameter.
Definition: framestack.c:54
Definition: operandstack.h:13
Stack of frames to store all frames created by method calling during execution of the JVM...
Definition: framestack.h:44
Definition: methods.h:10
uint32_t pc
Index of the current bytecode being read from the method's instructions, Program Counter.
Definition: framestack.h:23
Frame * newFrame(JavaClass *jc, method_info *method)
A new frame is created each time a method is invoked.
Definition: framestack.c:10