Add JStg IR

Closed doyougnu requested to merge doyougnu/ghc:wip/doyougnu/js/add-jstg into master

This MR is the next step on the path towards #22736, #22261 (specifically the GHCJS optimizer) and #22352 (closed).

We make progress towards these goals by splitting the current pipeline to add a new IR JStg that serves as the first target for StgToJS. We then write the RTS in JStg and and eventually compile to the original JExpr. In this way we split GHCJS's original design so that we can use JExpr and friends for lower level optimization passes, but write hand-crafted code in JStg.

An decent analogy is to think of JStg as Stg and JExpr as Cmm but for the JS backend. So that the pipeline this MR creates looks like this:

---- {stgToJStg code generator}
JStg <--{eDSL interpreter}-- eDSL
---- {jstgToJS code generator}
---- {Linker}
---- {Pretty-printer}
Raw JS


  • CI passes - [ ] update note in JStgToJS with pipeline visualization Wont do until we settle on an optimizer architecture. See #22736.
  • add guidance comments on type classes
  • fixup Prim module
  • rebase
  • squash
Edited by doyougnu

Merge request reports