Expand description
The stack a compiled program’s Main runs on.
A LOGOS program recurses as deep as its data: a tree of a million nodes is built and walked by recursion. A
compiled program’s Main therefore runs on a stack of MAIN_STACK_BYTES mapped for it at start, on the thread
that started it. Switching stacks rather than starting a thread keeps the process single-threaded, and that is
worth having: once a second thread exists, even one only waiting for another to finish, the C library takes its
locked, atomic path through every malloc and free, which doubled the time of an allocation-heavy program.
Recursion that runs past the end of the stack reaches an inaccessible guard page. The program then reports
logicaffeine_data::failure::CALL_DEPTH_EXCEEDED, the sentence every tier reports for it, after writing out what
it had shown, and ends with exit status 1. A native target whose stack the switch does not support runs Main on a
thread of its own instead, and WebAssembly, which has one thread and a stack its module declares, runs it in place.
Constants§
- MAIN_
STACK_ BYTES - The room a compiled program’s
Mainhas for its calls.
Functions§
- run_
main - Run
main, a compiled program’sMain, on a stack ofMAIN_STACK_BYTES.