Properly mark things as on stack in variable scope

Because of the reordering (and because there were lingering bugs here in
the first place), we need to guard places properly with on stack guards
when allocation might happen.

This is also in the spin loop for getting and setting a local, because a
heap tuple might be allocated that could have caused a gc. We put the
guard inside the loop though, so we don't have to setup the on stack
guard for the common case of not having to spin loop here.