Skip to main content
QUICK REVIEW

[论文解读] Conditional Execution of Transpiler Passes Based on Per-Script Feature Detection

Rishipal Singh Bhatia|arXiv (Cornell University)|Mar 17, 2026
Logic, programming, and type systems被引用 0
一句话总结

该论文在 Google Closure Compiler 中提出一种选择性转译方法,跟踪每个脚本的语言特性以跳过不必要的 passes,在保持正确性的前提下减少构建时间和资源使用。

ABSTRACT

As the ECMAScript specification evolves, industrial-scale JavaScript compilers face the challenge of supporting modern language syntax while maintaining compatibility for diverse execution environments. Traditionally, compilers solve this by running transpilation passes in a monolithic pipeline, where the transpilation passes are chosen to execute strictly based on a target language level. This results in significant computational waste, as compilers perform expensive Abstract Syntax Tree (AST) traversals to lower features that may not exist in the actual input source code. We present a compiler improvement that conditionally executes transpiler passes based on accurately tracking and dynamically maintaining the exact set of language features present in the compilation unit throughout the transpilation process. It is implemented in the production Google Closure Compiler. By populating and maintaining a FeatureSet at every JavaScript script-level, it dynamically skips running unnecessary lowering passes. We detail the architectural safeguards -- including strategic pass ordering and dynamic validation of the transpiled code for feature-correctness. Evaluation of this improvement on large-scale production monorepos produced a considerable reduction in compilation time and saved compute and memory usage.

研究动机与目标

  • 通过考虑每个脚本实际使用的特性来提高减少转译工作量的动机。
  • 引入按脚本的 FeatureSet 来动态门控转译器的 passes。
  • 通过特征传播、验证和转译后检查等 safeguards 来确保正确性。
  • 在大型生产型单仓库中评估性能收益并证明正确性。

提出的方法

  • 在解析过程中在每个 SCRIPT 节点记录输入特征。
  • 将每个转译器 pass 映射到它所降低的特征。
  • 动态维护脚本级 FeatureSet,传播合成特征并执行 Transpiled-Away 集。
  • 设置门控:只有当一个 pass 处理脚本中存在且目标级别中不存在的特征时才运行该 pass。
  • 保持 safeguards:策略性的 pass 顺序、动态跟踪、AST 验证和转译后校验。

实验结果

研究问题

  • RQ1按脚本特征跟踪能否可靠地确定何时需要转译 passes?
  • RQ2选择性转译是否在不影响输出语义的前提下减少编译时间和资源使用?
  • RQ3防止特征泄漏或错误降低需要哪些架构性保障?
  • RQ4该方法在跨越不同 JavaScript 语言水平的大型生产单仓库中表现如何?

主要发现

MetricResult
Transpilation Time (Large Apps)50% Reduction
Mean Compilation Stage Latency12% Reduction
Redundant Transpiler Passes Skipped30% – 40%
Daily Production Executions≈ 900,000
  • 在评估 workload 中,大型应用的总转译时间约减少 50%。
  • Mean 编译阶段延迟下降约 12%。
  • 对典型 ES5 目标的应用,遗留模型中有 30%–40% 的转译器 passes 是冗余的。
  • 在评估环境中,日常生产编译约为 ≈ 900,000 次执行。
  • 选择性转译在输出等价性方面与遗留模型保持一致,如差分和代码大小测试所示。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。