Moduleghc-9.10.3GHC2021
GHC.JS.Optimizer
Domain and Purpose
GHC.JS.Optimizer is a shallow embedding of a peephole optimizer. That is, this module defines transformations over the JavaScript IR in
GHC.JS.Syntax, transforming the IR forms from inefficient, or non-idiomatic, JavaScript to more efficient and idiomatic JavaScript. The optimizer is written in continuation passing style so optimizations compose.Architecture of the optimizer
The design is that each optimization pattern matches on the head of a
block by pattern matching onto the head of the stream of nodes in the
JavaScript IR. If an optimization gets a successful match then it performs
whatever rewrite is necessary and then calls the loop continuation. This
ensures that the result of the optimization is subject to the same
optimization, and the rest of the optimizations. If there is no match
then the optimization should call the next continuation to pass the
stream to the next optimization in the optimization chain. We then define
the last "optimization" to be tailLoop which selects the next block of
code to optimize and begin the optimization pipeline again.
- 1 value
- Packageghc-9.10.3
- Exports1
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceOptimizer.hs