Modify rpoSortCfg to reduce memory usage in refcount-opts
commita8f0653d15cc635c7167ba9c36515a3ab06cab54
authorBrett Simmers <bsimmers@fb.com>
Fri, 12 Dec 2014 17:50:51 +0000 (12 09:50 -0800)
committerhhvm-bot <hhvm-bot@fb.com>
Fri, 12 Dec 2014 18:00:36 +0000 (12 10:00 -0800)
tree5db5cea2e9421b4af6b2ab34683a35372c2231db
parent7e3de0dd2a8666bccf07c4f597fc31728332bb7d
Modify rpoSortCfg to reduce memory usage in refcount-opts

Summary: The old order was specifically designed so exit blocks would appear
last in the RPO order, for optimal codegen. But codegen order is now decided by
vasm's rpo sort so this shouldn't affect it. Anyway, because we were visiting
exit blocks last, their in-states would sit around in a map waiting to be used
until we finished visitng the rest of the blocks. With this new order, we'll
visit exit blocks and then erase their in-state right after visiting the
predecessor. This means the max size of the state map is now O(1) on long
traces with lots of exits blocks, rather than O(nExits).

This exposed a refcount-opts issue where we were depending on the traversal
order to punt in units with unsupported instructions. I changed it to check for
that condition in a better way before even starting the optimization.

Reviewed By: @bertmaher

Differential Revision: D1734625
hphp/runtime/vm/jit/cfg.h
hphp/runtime/vm/jit/refcount-opts.cpp