Stack check elision for functions with small stack usage
Specifically, they maintain the invariant that the stack always has a small amount (a few hundred bytes) of free space. The code generator can then elide a stack check in cases where it can statically determine that the function's stack usage fits in this space.
As we will soon be able to include information determined during code generation in interface files, GHC may be able to do something similar:
- During code generation record an upper bound on each function's (transitive) stack usage (or nothing if no bound can be determined due to thunk evaluation) in its
IdInfo. This will be recorded in the interface file
- If during code generation we see that a function's stack usage is less than the reserved buffer then we can elide the stack check