Move phase end rank handling out of the TokenAccumulator

We'd like to generalize the TokenAccumulator so that it can be used more
generically where async expansions are initiated in token transformers. One
example of such a transformer is the TemplateHandler.

This patch works towards this goal with several parts:

* Track down problematic callers with env.log

* Set the phaseEndRank in AccumChain.push, maybeSyncReturn,
  TemplateHandler._onEnd/._onChunk and a few other places.

Overall most, but not all, broken callers of TokenAccumulator are fixed by
this patch. Once we have fixed all callers we can remove the phaseEndRank
logic from TokenAccumulator.

Change-Id: I26b66fb53ad1b44df6ac60bc6783d46d2efbcf9b