Make GC collections work when threads are in generators

The previous code assumed that there was only one stack per
thread, which could be examined by looking at the current registers.
Generators complicate that, since we switch to a separate stack.
We still need to scan the original, main stack, which means that
we need to add some bookkeeping code that remembers what the main
stack was, even as we swap to and from generators.