winapi has this feature which allows to mostly remove bound checks from compression algorithms,
so I made a class which supposedly makes it easier to use.
The idea is that instead of explicit checks in the code, like if( p>=buf+bufsize) on each memory write,
we can use hardware support (it has almost zero overhead when bound check is never triggered).
"Guard page" is like normal memory, but triggers the SEH handler on first access, where buf.flag is set.
Well, it made my code a bit slower, but that's because I had to add memcpy for copying
from guard_buf to actual output buffer.
Branch prediction and __builtin_expect are pretty cool, too.
But for a less optimized codec completely removing all bound checks should be helpful, right?
For example, as an alternative, lzma has a special version of decoder ( "LzmaDec_TryDummy" ),
which runs at the end of buffer to do bound checks.
> Do you know of any comparable features on other operating systems?