Consider a smaller stack size #427
Labels
ark/compiler
Related to the compiler
ark/virtual machine
Related to the ark virtual machine
enhancement
New feature or request
optimization
❗️ priority/medium
The problem
Creating a VM requires creating an
ExecutionContext
, that holds a few important values, such as the stack for the VM, defined as astd::array<Value, VmStackSize>
. As of today,sizeof(Value)
returns 40B, and the stack size is set to 8192 ; creating a VM thus requires 327kB.Some tidbits about the compiler
The compiler can handle stack cleaning (ie a
(while true 1)
won't trash the stack luckily), and also handles correctly self tail calls (something is in the works to handle generic tail calls).Generic tail calls will require a new instruction, akin to
JUMP
but for pages, so that we can jump between functions. Development on this should start shortly after having integrated the new parser.Questions and experiments
(async foo arg...)
?Data will be needed on the optimal stack size and the average stack size for common scripts.
Final words
Even though this would change a critical part of the virtual machine, this can not be considered a breaking change as the stack is never exposed to the end user (nor to plugin authors).
The text was updated successfully, but these errors were encountered: