KrkThreadState Struct Reference

Execution state of a VM thread. More...

#include <vm.h>

Data Fields

struct KrkThreadStatenext
size_t frameCount
size_t stackSize
ssize_t exitOnFrame
KrkValue currentException
int flags
unsigned int maximumCallDepth
KrkValue scratchSpace [KRK_THREAD_SCRATCH_SIZE]

Detailed Description

Execution state of a VM thread.

Each thread in the VM has its own local thread state, which contains the thread's stack, stack pointer, call frame stack, a thread-specific VM flags bitarray, and an exception state.

See also

Definition at line 152 of file vm.h.

Field Documentation

◆ currentException

KrkValue KrkThreadState::currentException

When an exception is thrown, it is stored here.

Definition at line 164 of file vm.h.

◆ exitOnFrame

ssize_t KrkThreadState::exitOnFrame

When called in a nested context, the frame offset to exit the VM dispatch loop on.

Definition at line 161 of file vm.h.

◆ flags

int KrkThreadState::flags

Thread-local VM flags; each thread inherits the low byte of the global VM flags.

Definition at line 165 of file vm.h.

◆ frameCount

size_t KrkThreadState::frameCount

Number of active call frames.

Definition at line 156 of file vm.h.

◆ frames

KrkCallFrame* KrkThreadState::frames

Call frame stack for this thread, max KRK_CALL_FRAMES_MAX

Definition at line 155 of file vm.h.

◆ maximumCallDepth

unsigned int KrkThreadState::maximumCallDepth

Maximum recursive call depth.

Definition at line 166 of file vm.h.

◆ module

KrkInstance* KrkThreadState::module

The current module execution context.

Definition at line 163 of file vm.h.

◆ next

struct KrkThreadState* KrkThreadState::next

Invasive list pointer to next thread.

Definition at line 153 of file vm.h.

◆ openUpvalues

KrkUpvalue* KrkThreadState::openUpvalues

Flexible array of unclosed upvalues.

Definition at line 160 of file vm.h.

◆ scratchSpace

KrkValue KrkThreadState::scratchSpace[KRK_THREAD_SCRATCH_SIZE]

A place to store a few values to keep them from being prematurely GC'd.

Definition at line 169 of file vm.h.

◆ stack

KrkValue* KrkThreadState::stack

Pointer to the bottom of the stack for this thread.

Definition at line 158 of file vm.h.

◆ stackMax

KrkValue* KrkThreadState::stackMax

End of allocated stack space.

Definition at line 167 of file vm.h.

◆ stackSize

size_t KrkThreadState::stackSize

Size of the allocated stack space for this thread.

Definition at line 157 of file vm.h.

◆ stackTop

KrkValue* KrkThreadState::stackTop

Pointer to the top of the stack.

Definition at line 159 of file vm.h.

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