Generational behavior for the garbage collector

Same as #5227 but living in this repo & squashed.

It looks like we might be able to use `__builtin_ffs` for MinGW (see https://bugs.freedesktop.org/show_bug.cgi?id=30277), but that won't help for MSVC. We could maybe grab musl's implementation http://git.musl-libc.org/cgit/musl/tree/src/misc/ffs.c - I'm still trying to find `atomic.h` and the definition of `a_ctz_l` though.