Skip to content
Chance edited this page Aug 10, 2024 · 2 revisions

Welcome to the ashlang wiki!

Variable locations

Variables are defined as either Stack based, Memory based, or Const (VarLocation). Stack variables live on the stack and must be a single field element. Memory variables live in memory and can be a vector of any dimension. Const variables live only in the compiler and can be either a scalar or a vector of any dimension.

Memory layout

The TritonVM supports 2^63 memory elements. This is ~67,108,864 Terabytes. As a result we can give each function ~1 TB of memory, if we have less than 67 million functions in the program.

Memory is statically laid out at compile time. Each scope defines a start index, and length of the desired memory. Each slot can store a single field element. Right now each function receives 2^32 memory slots (~32 GB of memory).

Function invocation

Functions reserve the first slots in their memory for any memory based arguments. Before a caller executes a function they are responsible for writing the memory arguments into the functions memory space, or zero-ing the memory as appropriate.

Stack based arguments are passed on the stack, and are expected to be on the top of the stack at invocation. The function will remove arguments from the stack and push a single stack element as a return value. If the function does not explicitly return a scalar the value 0 is returned.

Memory return values will be stored at a special offset in the function memory. These values exist in memory until the next invocation of the function. If values need to exist longer they should be explicitly copied before the next invocation.

Clone this wiki locally