Supporting unboxed tuples in the bytecode compiler

Ömer Sinan Ağacan omeragacan at
Mon Jul 25 10:14:39 UTC 2016


I was looking at the bytecode compiler to understand what's needed to support
unboxed tuples. It seems like if we generate bytecode after unarise it should be
very easy to support unboxed tuples, because after unarise we don't have any
unboxed tuple binders (all binders have UnaryType). So only places we see
unboxed tuples are:

    - Return positions. We just push contents of the tuple to the stack.

    - Case alternatives. The case expression in this case has to have this form:

        case e1 of
          (# bndr1, bndr2, ..., bndrN #) -> RHS

      All binders will have unary types again. We just bind ids in the
      environment to their stack locations and compile RHS.

I think that's it. We also get unboxed sums support for free when we do this
after unarise.

What do you think about compiling to bytecode from STG? Have you considered that
before? Would that be a problem for GHCi's debugger or any other features?

More information about the ghc-devs mailing list