JSIR: A High-Level IR for JavaScript
This RFC introduces JSIR, a high-level IR for JavaScript:
JSIR is developed and deployed in production at Google for code analysis and transform use cases.
JSIR is open source here: GitHub - google/jsir: Next-generation JavaScript analysis tooling ยท GitHub .
Industry trend of building high-level language-specific IRs
The compiler industry is moving towards building high-level language-specific IRs. For example, the Rust and Swift compilers perform certain analyses on their high-level IRs before lowering down to LLVM. There are also a number of ongoing projects in this direction, such as Clang IR , Mojo , and Carbon .
Why do we need a high-level IR for JavaScript specifically? While much of JavaScript tooling relies on ASTs (like ESTree), complex analyses require a control flow graph (CFG) and dataflow analysis capabilities, which JSIR provides by using the MLIR framework.