HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleghc-9.10.3GHC2021

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.10.3
  • Exports1
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceSimple.hs