Guard pages instead of Heap/Stack limit checks in Cmm
Recently I have debugged a small program and I saw that there are a lot of Heap/Stack limit checks on function entrances (https://ghc.haskell.org/trac/ghc/browser/ghc/rts/HeapStackCheck.cmm). This is not cheap and introduce more branch mispredictions and instructions. What you think if we use guard OS pages (that trigger exceptions when someone try to read/write on them) around Stack and Heap? Stack and Heap sizes should be aligned on page size (usually 4K) and with sizes that fits 4K pages. We could handle such exceptions so we could do GC if needed. This trick is usually found in some memory managers for finding out-of-bounds bugs.