arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2403.02420cs.PL
收藏

Dr Wenowdis:利用类型信息特化动态语言 C 扩展

Dr Wenowdis: Specializing dynamic language C extensions using type information

Maxwell Bernstein, CF Bolz-Tereick

AI总结:

本文提出 typed methods 技术,通过为 C 扩展函数附加向后兼容的类型元数据,显著降低动态语言运行时中 C 扩展调用的开销,并在 PyPy 中验证了其有效性。

摘要:

基于 C 的解释器(如 CPython)大量使用 C“扩展”代码,这些代码对于静态分析工具和带有 JIT 编译器的更快速运行时(如 PyPy)来说是不透明的。不仅扩展本身不透明,动态语言类型与 C 类型之间的接口也会引入阻抗失配。我们假设频繁调用 C 扩展代码会引入显著且往往不必要的开销。我们通过引入一种简单的技术“typed methods”(类型化方法)来验证这一假设,该技术允许选定的 C 扩展函数以向后兼容的方式附加额外的元数据。这些额外元数据使 JIT 编译器(并且如我们所示,甚至解释器本身!)能够显著降低调用和返回开销。虽然我们已在 PyPy 中原型化了 typed methods,但我们推测同样的技术适用于更广泛的语言运行时,并且这些信息也可以被静态分析工具所消费。

英文摘要:

C-based interpreters such as CPython make extensive use of C "extension" code, which is opaque to static analysis tools and faster runtimes with JIT compilers, such as PyPy. Not only are the extensions opaque, but the interface between the dynamic language types and the C types can introduce impedance. We hypothesise that frequent calls to C extension code introduce significant overhead that is often unnecessary. We validate this hypothesis by introducing a simple technique, "typed methods", which allow selected C extension functions to have additional metadata attached to them in a backward-compatible way. This additional metadata makes it much easier for a JIT compiler (and as we show, even an interpreter!) to significantly reduce the call and return overhead. Although we have prototyped typed methods in PyPy, we suspect that the same technique is applicable to a wider variety of language runtimes and that the information can also be consumed by static analysis tooling.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑