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
evalstatement is encounteredvariables declared in nested scopes are not renamed
- 1 value
- Packageghc-9.10.3
- Exports1
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceSimple.hs