Virtual Machine State
A virtual machine's state is defined in ./src/types/types.d.ts
Any running instance of virtual machine can be described by a VM_State
value and the corresponding heap memory status.
P
- The Byte Code to be Executed
P
- The Byte Code to be ExecutedThe property P
stores the byte code that C0VM is currently executing. The C0ByteCode
value is a parsed result of raw string of .bc0
file.
All fields except nativePool
property are the same with the original C0VM (implemented in C
). The property nativePool
is an array of C0Native
objects which are dynamically loaded during the parsing process.
For more information of C0Native
, refer to the page that describes Native Functions
C
- Important Constants of Virtual Machine
C
- Important Constants of Virtual MachineUp to now, the VM_Constants
only stores the pointer points to the start of string pool in heap memory.
This is stored explicitly since all the string literals are loaded by adding an offset on this address during runtime.
CurrFrame
- The Function Frame currently Executing
CurrFrame
- The Function Frame currently ExecutingWhen a function is executed by the C0VM.ts, a stack frame will be created to store the "context" of function execution. Specifically, the
PC - Program Counter that indicates the position of next instruction in
bc0
programLocal Variables
Operand Stack
The code of function itself
Will be stored inside each stack frame.
CallStack
- The Call Stack of Virtual Machine
CallStack
- The Call Stack of Virtual MachineWhen a user-defined function get called, (specifically, the invokestatic
instruction is executed, a new function frame will be created to store the status of callee. The original caller frame will be pushed into a stack called "call stack" so that the execution progress can be resumed after callee returns.
CurrLineNumber
- Line Number of bc0 File VM is on
CurrLineNumber
- Line Number of bc0 File VM is onRecords the current line number in bc0
file that VM is executing.
TypeRecord
- The Type information of Structs
TypeRecord
- The Type information of StructsThe hash map that records the type information within each struct. The Struct_Type_Record
is defined as:
The name
refers to the field name of the struct.
The type
refers to the type of that field of the struct.
Last updated