Crate stacker [] [src]

A library to help grow the stack when it runs out of space.

This is an implementation of manually instrumented segmented stacks where points in a program's control flow are annotated with "maybe grow the stack here". Each point of annotation indicates how far away from the end of the stack it's allowed to be, plus the amount of stack to allocate if it does reach the end.

Once a program has reached the end of its stack, a temporary stack on the heap is allocated and is switched to for the duration of a closure.

Examples

// Grow the stack if we are within the "red zone" of 32K, and if we allocate
// a new stack allocate 1MB of stack space.
//
// If we're already in bounds, however, just run the provided closure on our
// own stack
stacker::maybe_grow(32 * 1024, 1024 * 1024, || {
    // guaranteed to have at least 32K of stack
});

Functions

maybe_grow

Grows the call stack if necessary.

remaining_stack

Queries the amount of remaining stack as interpreted by this library.