Open
Description
Currently, HPhi
is just one of the many subclasses of HInstruction
, but it would be nice to have a stronger separation between phis and non-phis. Our current type hierarchy is insufficient to express some important invariants:
HPhi.next
, if it exists, is another phi. Currently, we cast when necessary.- Phis can only be added to/removed from a basic block in certain ways. (Corollary: certain nodes are known to be
HInstruction
s which are notHPhi
s.) Currently, we "enforce" this with assertions.
Likewise, it would be nice to have a clearer distinction between HInstructionList
and HPhiList
.
One hurdle is that the relevant features in the Dart system are not totally free:
- Some subclassing is okay, but we want to avoid virtual dispatch on hot APIs (e.g.
HInstruction.next
). This is why we castHPhi.next
rather than overriding. - Generics (and
covariant
members) incur parameter checks.
/cc @rakudrama - feel free to add other invariants/hurdles.