The Thru virtual machine uses a 48-bit segmented address space designed to provide memory isolation and efficient access to different types of data during program execution. The address format follows a three-component structure that enables both type safety and performance optimization.
Write operations to read-only segments cause access violations and will fail.
Note that programs should not pass pointers to their own program bytecode
to other programs, since the bytecode will be changed upon invocation
to the invoked program’s bytecode.
The shadow stack segment (0x0002) provides read-only access to call frame metadata, enabling cross-program communication and state inspection during execution. Each call frame stores information about the current program invocation context.
The saved_regs array stores all 32 RISC-V registers (x0-x31) at the time of program invocation.
The register values stored in the public shadow stack represent the state at invoke time. When a program exits, the VM restores registers from this public shadow stack.
Compute Cost: Each invocation saves 256 bytes (registers to public shadow stack) and restores 256 bytes (from public shadow stack), for a total of 512 bytes of memory operations. The base syscall cost is 512 CUs (32 registers × 8 bytes × 2 operations).
Stack memory segment that grows downward from high addresses to low addresses.
Characteristic
Value
Growth Direction
Downward (0xFFFFFF → 0x000000)
Page Size
4096 bytes
Max Segments
1 per VM instance
Size Limit
16MB per segment
Permission Model
Frame-based access control
Growth Behavior:
The stack segment grows downward, meaning as more memory is allocated, the segment size increases toward lower addresses. When you allocate new stack space, the valid address range expands from the bottom (higher addresses) toward the top (lower addresses), similar to traditional hardware stacks.Address Layout:
Virtual address range: 0xFFFFFF down to current stack size
Stack pointer typically points to 0x000000 offset initially
As stack grows, valid addresses extend from 0xFFFFFF downward
Heap memory segment that grows upward from low addresses to high addresses.
Characteristic
Value
Growth Direction
Upward (0x000000 → 0xFFFFFF)
Page Size
4096 bytes
Max Segments
1 per VM instance
Size Limit
16MB per segment
Permission Model
Frame-based access control
Growth Behavior:
The heap segment grows upward, meaning as more memory is allocated, the segment size increases toward higher addresses. When you allocate new heap space, the valid address range expands from the base (0x000000) toward higher addresses, similar to traditional heap allocators.