HORIZON HASKELLDocslts/ghc-9.14.xb2f3bfd2026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · b2f3bfd · 2026-10-11

Moduleghc-9.14.1GHC2021

GHC.JS.Opt.Simple

  • Simple optimizer for the JavaScript IR

    This is a simple optimizer for the JavaScript IR. It is intended to be the first optimization pass after generating the JavaScript IR.

  • Design

    The optimizer is invoked on the top-level JStat. It leaves the top-level scope alone, but traverses into each function body and optimizes it. Nested functions are mostly left alone, since they are uncommon in generated code.

    The optimizations are:

    • rename local variables to shorter names

    • remove unused variables

    • remove trivial assignments: x = x

    • "float" expressions without side effects:

    • var x = 1; var y = x + 1; -> var y = 1 + 1;

  • Limitations

    The simple optimization pass is intended to be fast and applicable to almost all generated JavaScript code. Limitations are:

    • optimization is disabled if an eval statement is encountered

    • variables declared in nested scopes are not renamed

  • 1 value
  • Packageghc-9.14.1
  • Exports1
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceSimple.hs