KrkVM Struct Reference

Global VM state. More...

#include <vm.h>

Public Member Functions

void krk_initVM (int flags)
 Initialize the VM at program startup. More...
 
void krk_freeVM (void)
 Release resources from the VM. More...
 

Data Fields

int globalFlags
 
char * binpath
 
KrkTable strings
 
KrkTable modules
 
KrkInstancebuiltins
 
KrkInstancesystem
 
KrkValuespecialMethodNames
 
struct BaseClassesbaseClasses
 
struct Exceptionsexceptions
 
KrkObjobjects
 
size_t bytesAllocated
 
size_t nextGC
 
size_t grayCount
 
size_t grayCapacity
 
KrkObj ** grayStack
 
KrkThreadStatethreads
 
FILE * callgrindFile
 
struct DebuggerStatedbgState
 

Detailed Description

Global VM state.

This state is shared by all VM threads and stores the path to the VM binary, global execution flags, the string and module tables, tables of builtin types, and the state of the (shared) garbage collector.

Definition at line 184 of file vm.h.

Member Function Documentation

◆ krk_freeVM()

void krk_freeVM ( void  )

Release resources from the VM.

Generally, it is desirable to call this once before the hosting program exits. If a fresh VM state is needed, krk_freeVM should be called before a further call to krk_initVM is made. The resources released here can include allocated heap memory, FILE pointers or descriptors, or various other things which were initialized by C extension modules.

Definition at line 992 of file vm.c.

◆ krk_initVM()

void krk_initVM ( int  flags)

Initialize the VM at program startup.

All library users must call this exactly once on startup to create the built-in types, modules, and functions for the VM and prepare the string and module tables. Optionally, callers may set vm.binpath before calling krk_initVM to allow the VM to locate the interpreter binary and establish the default module paths.

Parameters
flagsCombination of global VM flags and initial thread flags.

Definition at line 907 of file vm.c.

Field Documentation

◆ baseClasses

struct BaseClasses* KrkVM::baseClasses

Pointer to a (static) namespacing struct for the KrkClass*'s of built-in object types

Definition at line 192 of file vm.h.

◆ binpath

char* KrkVM::binpath

A string representing the name of the interpreter binary.

Definition at line 186 of file vm.h.

◆ builtins

KrkInstance* KrkVM::builtins

'__builtins__' module

Definition at line 189 of file vm.h.

◆ bytesAllocated

size_t KrkVM::bytesAllocated

Running total of bytes allocated

Definition at line 197 of file vm.h.

◆ callgrindFile

FILE* KrkVM::callgrindFile

File to write unprocessed callgrind data to.

Definition at line 204 of file vm.h.

◆ dbgState

struct DebuggerState* KrkVM::dbgState

Opaque debugger state pointer.

Definition at line 205 of file vm.h.

◆ exceptions

struct Exceptions* KrkVM::exceptions

Pointer to a (static) namespacing struct for the KrkClass*'s of basic exception types

Definition at line 193 of file vm.h.

◆ globalFlags

int KrkVM::globalFlags

Global VM state flags

Definition at line 185 of file vm.h.

◆ grayCapacity

size_t KrkVM::grayCapacity

How many objects we can fit in the scan list.

Definition at line 200 of file vm.h.

◆ grayCount

size_t KrkVM::grayCount

Count of objects marked by scan.

Definition at line 199 of file vm.h.

◆ grayStack

KrkObj** KrkVM::grayStack

Scan list

Definition at line 201 of file vm.h.

◆ modules

KrkTable KrkVM::modules

Module cache

Definition at line 188 of file vm.h.

◆ nextGC

size_t KrkVM::nextGC

Point at which we should sweep again

Definition at line 198 of file vm.h.

◆ objects

KrkObj* KrkVM::objects

Linked list of all objects in the GC

Definition at line 196 of file vm.h.

◆ specialMethodNames

KrkValue* KrkVM::specialMethodNames

Cached strings of important method and function names

Definition at line 191 of file vm.h.

◆ strings

KrkTable KrkVM::strings

Strings table

Definition at line 187 of file vm.h.

◆ system

KrkInstance* KrkVM::system

'kuroko' module

Definition at line 190 of file vm.h.

◆ threads

KrkThreadState* KrkVM::threads

Invasive linked list of all VM threads.

Definition at line 203 of file vm.h.


The documentation for this struct was generated from the following file: