按年被提到
20202024 · 3 次2026
编程语言与编译器›编译器与运行时优化·arXiv:2011.13127 · cs.PL

Copy-and-Patch Compilation: A fast compilation algorithm for high-level languages and bytecode

Copy-and-Patch 编译:面向高级语言和字节码的快速编译算法
Haoran Xu, Fredrik Kjolstad · 2020

拼接预编译机器码模板的极速编译技术,代码质量也不错

开始阅读 ↗PDFalphaXiv 讨论
被推荐 · 8 人首次 2021-09-16 · 最近 2025-09-26
8不同的人
7活跃月份
7讨论串
26被引(OpenAlex)

论文提出 copy-and-patch:把大量预先生成的二进制实现变体(stencil,带有待填空位)拼接并回填,从而把高级语言或字节码快速降为机器码。基于它实现了面向元编程的 C 类语言编译器和 WebAssembly 编译器:在 TPC-H 上生成代码比 LLVM -O0 快两个数量级,生成的代码比解释执行快一个数量级、比 LLVM -O0 快 14%;WebAssembly 编译比 Chrome 的 Liftoff 快 4.9 到 6.5 倍。

HN 为什么提它

HN 上的人把它当作在“编译速度与代码质量”之间取得最佳折中的简单 JIT 方案来推荐,常在讨论 WebAssembly、JIT 和查询编译时被提到。

方法难度 4 / 5约 50 分钟经得起时间
读之前最好知道
1编译器基础与代码生成
2JIT 编译
3重定位(relocation)与机器码
4LLVM 与 WebAssembly 基础

HN 书评

推荐在前,同类按时间 · 每篇最多保留 20 条,统计用全部提及
推荐vanderZwan · 2024-01

“I think it's really cool that Haoran Xu and Fredrik Kjolstad's copy-and-patch technique[0]”

称 Xu 和 Kjolstad 的 copy-and-patch 技术很酷
Python 3.13 Gets a JIT原评论 ↗
引用cfallin · 2022-09

“However, there are some good comparisons done by a third party in this paper:”

指出第三方在这篇论文中对 Wasmtime 与 V8 等做了不错的比较
Wasmtime 1.0原评论 ↗
引用fsfod · 2022-11

“The author also worked on the Copy-and-Patch Compilation paper[1]”

提到作者也做过 Copy-and-Patch 编译这篇论文
Building the fastest Lua interpreter automatically原评论 ↗
引用alserio · 2024-06

“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”

贴出 HTML 版本,并推广 arxiv 的 ar5iv 工具
Copy-and-Patch: Fast compilation for high-level languages and bytecode (2020)原评论 ↗
引用UncleEntity · 2025-04

“Once I get this working I plan on seeing how well they do with Copy-and-Patch Compilation[2]”

打算在跑通后看 Claude 能否实现这种快速编译技术
Co-designing a sparse music codec with ChatGPT o3原评论 ↗
引用darkamaul · 2025-09

“I think the _copy-and-patch_ approach [0] is probably the best compromise here.”

认为 copy-and-patch 是这里最好的折中,用简单 JIT 接近原生速度
Writing Memory Safe JIT Compilers原评论 ↗
被提交为 story · 2 次