22 releases (7 breaking)
Uses new Rust 2024
| new 0.8.0-pre.10 | Nov 26, 2025 |
|---|---|
| 0.8.0-pre.8 | Jul 24, 2025 |
| 0.4.0 | Mar 9, 2025 |
| 0.3.1 | Dec 29, 2024 |
#1988 in Web programming
Used in portal-jsc-swc-opt-ssa
570KB
11K
SLoC
Static Single Assignment (SSA) form intermediate representation.
This crate provides an SSA form representation for JavaScript/ECMAScript code, which is a lower-level IR than TAC (Three-Address Code) that enforces stronger invariants for optimization.
Static Single Assignment Form
In SSA form:
- Each variable is assigned exactly once (static single assignment)
- Variables are versioned when they would be reassigned in non-SSA form
- Control flow merges use block parameters instead of φ-functions
- Enables more powerful dataflow analysis and optimizations
Block Parameters Instead of Phi Nodes
This SSA representation uses block parameters instead of traditional φ-functions. Basic blocks take parameters just like functions, and predecessors pass arguments when jumping to them. This approach:
- Makes SSA construction and transformation easier to reason about
- Avoids edge cases that occur with φ-nodes (e.g., critical edges)
- Provides a cleaner representation for optimization passes
- Naturally handles multiple values being merged at the same point
For example, instead of:
block:
x = φ(x1 from pred1, x2 from pred2)
We use:
block(x): // x is a block parameter
...
pred1:
jump block(x1) // pass x1 as argument
pred2:
jump block(x2) // pass x2 as argument
Key Types
SFunc: A function in SSA formSCfg: The SSA control flow graphSBlock: A basic block with parameters (replacing φ-functions)SValue: An SSA value (operation, parameter, load, store, etc.)SValueW: A wrapper aroundSValuefor arena storageSTerm: Block terminator with target blocks and argumentsSTarget: A jump target (block + arguments for its parameters)
Conversion from TAC
The primary entry point is converting from TAC to SSA form. This involves:
- Identifying variables that need versioning
- Creating block parameters at control flow merges (instead of φ-functions)
- Threading SSA values through the control flow graph
- Converting assignments to SSA form
- Passing appropriate arguments when jumping to blocks
Modules
Dependencies
~20–33MB
~502K SLoC