1. processLookahead/BacktrackPosition created separate entry objects
for each glyph at each position (O(N^M) with N glyphs, M positions).
Now all glyphs at a position share one entry object.
2. cloneEntry, cloneTree, flattenEntry, and mergeTreeEntry could
infinitely recurse or duplicate work on shared/cyclic references.
Added visited/merged tracking maps to cache results.
Note that parsing CommitMono locks up the renderer for some time still
so there is still a performance issue here, this fixes the OOM though.
This was mostly defensive generated code since the codebase is
unfamiliar to me.
Fixes#5570