This diff implements code generation for continuation arguments as proposed in #16098 . For
mask/... which are defined in the
runtime-system there is no mechanism for inlining them. This often leads
to otherwise unnecessary allocations of closures.
See also #17760 (closed)
This patch introduces the notion of continuation arguments to code generation, including:
- A way to control CorePrep to not ANFize certain primops. That is,
leaving arguments of the form
State# s -> (# State# s, a #)in defined positions.
CoreToStghow to translate these to STG by extending STG language. Namely the
- Inline primops and continuation in code generation.
This patch happily inlines
... I64[Sp - 24] = PicBaseReg + stg_catch_frame_info; I64[Sp - 16] = %MO_UU_Conv_W32_W64(I32[I64[BaseReg + 872] + 28]); I64[Sp - 8] = PicBaseReg + (Test.someHandler_closure+2); ...
- ... call to runtime system
- ... allocation
- ... copying of free variables
Currently this is implemented only for catch# primop. Once we agree to merge this I will bring in the rest.
P.S. Also StgCse and Unarise are broken for continuation arguments. I will fix that in the coming days.
Note that this was originally authored by Alex Biehl. I am simply posting a rebased version of his patch (Phab:D4647).