Use a uniform return convention in bytecode for unary results
This MR fixes #22958 (closed) and supersedes !10040 (closed). It solves the problem in a more decisive way by unifying the RETURN
/PUSH_ALTS
and RETURN_UNLIFTED
/PUSH_ALTS_UNLIFTED
instructions (as I suggested in #22958 (comment 484895)). The new instructions are named RETURN
/PUSH_ALTS
, but they are indexed by ArgRep
like RETURN_UNLIFTED
/PUSH_ALTS_UNLIFTED
were.
This unification meaningfully simplifies parts of the bytecode compiler. Prior to this change, the bytecode compiler attempted to treat unlifted types quite differently from lifted types, but this is a fundamentally sketchy proposition: native code does not make these distinctions, and it required hacks like treating algebraic unlifted types like lifted types. The new design avoids all of these special cases by handling lifted and unlifted types mostly the same way, the only difference being whether or not values of the type are entered when they are returned.
The change also simplifies and clarifies parts of the bytecode interpreter. Rather than making a lifted/unlifted distinction, it now makes a pointer/nonpointer distinction, which is the right one to be making at the level of the RTS. (Levity is not really an RTS concern.)
I have left !10040 (closed) open in case it is preferable to backport to 9.6, since it is a smaller patch. But this MR is still quite small, and it is otherwise a better patch in every way.