“I think it's really cool that Haoran Xu and Fredrik Kjolstad's copy-and-patch technique[0]”
Copy-and-Patch Compilation: A fast compilation algorithm for high-level languages and bytecode
拼接预编译机器码模板的极速编译技术,代码质量也不错
论文提出 copy-and-patch:把大量预先生成的二进制实现变体(stencil,带有待填空位)拼接并回填,从而把高级语言或字节码快速降为机器码。基于它实现了面向元编程的 C 类语言编译器和 WebAssembly 编译器:在 TPC-H 上生成代码比 LLVM -O0 快两个数量级,生成的代码比解释执行快一个数量级、比 LLVM -O0 快 14%;WebAssembly 编译比 Chrome 的 Liftoff 快 4.9 到 6.5 倍。
HN 上的人把它当作在“编译速度与代码质量”之间取得最佳折中的简单 JIT 方案来推荐,常在讨论 WebAssembly、JIT 和查询编译时被提到。
HN 书评
推荐在前,同类按时间 · 每篇最多保留 20 条,统计用全部提及“However, there are some good comparisons done by a third party in this paper:”
“The author also worked on the Copy-and-Patch Compilation paper[1]”
“Link to the HTML version for those who need it and to help spread the knowledge of the wonderful arxiv ar5iv tool: Copy-and-Patch Compilation”
“Once I get this working I plan on seeing how well they do with Copy-and-Patch Compilation[2]”
“I think the _copy-and-patch_ approach [0] is probably the best compromise here.”
- Copy-and-Patch: Fast JIT Compilation for SQL, WebAssembly, and Others ↗sillycross · 2021-09-16 · 30 分
- Copy-and-Patch: Fast compilation for high-level languages and bytecode (2020) ↗tosh · 2024-06-02 · 182 分