Skip to content

Proof of concept: Translate STG into language with reified Haskell stack

Motivation

Eventually GHC would like to target platforms such as JavaScript or other managed runtimes where GHC does not get to control the byte-for-byte layout of the Haskell stack. GHC might also like to use high-level, type-safe LLVM instructions (like the "get element" family?) to access information on the Haskell stack. Reifying the Haskell stack is a translation that might reasonably be shared among those back ends and also the native back end (NCG).

Proposal

Implement a translation that takes STG as input and outputs an IR in which the Haskell stack is reified. Details not yet resolved:

  • What the output IR looks like
  • On what compilation path to test the first prototype

Note: Submitting issue based on conversation with many stakeholders on 14 Sep 2021: @bgamari @nrnrnr @angerman @AndreasK @TerrorJack @simonpj @hsyl20 @luite

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information