Refactor remainder bulk of code generation to use generator context

This will allow optimizations like merging multiple prolog/epilog emit
sequences in order to reduce the cost of probing code.