Hasty Briefsbeta

Bilingual

JSIR: A High-Level IR for JavaScript

4 hours ago
  • #Compiler
  • #Intermediate-Representation
  • #JavaScript
  • JSIR is a high-level intermediate representation (IR) for JavaScript, developed at Google, that preserves all AST information and supports lossless round-trip conversions between source code, AST, and JSIR.
  • It leverages MLIR regions for control flow representation and provides dataflow analysis capabilities, addressing the lack of IR-based tools in the JavaScript community which traditionally rely on ASTs.
  • Key use cases include decompilation from Hermes bytecode to JavaScript, deobfuscation using source-to-source transformations, and integration with tools like Babel and SWC for parsing.
  • Design goals include a public, stable IR definition that closely mirrors ESTree, capturing all source-level information to enable high-fidelity source-to-source transformations.
  • JSIR distinguishes between l-values and r-values explicitly in the IR, uses region-based control flow structures (e.g., if, while statements), and offers an improved dataflow analysis API over MLIR's built-in framework.
  • Potential future steps involve adopting more MLIR built-in functionalities, contributing region-based dataflow analysis improvements upstream, and addressing dependencies for possible integration into the MLIR codebase.