Corpse Reviver:通过合同验证进行合理有效的逐步打字
Corpse Reviver: Sound and Efficient Gradual Typing via Contract Verification
摘要:
渐进类型化程序设计语言允许将静态类型增量添加到非类型化程序中。为了保持可靠性,语言在类型化和非类型化代码之间的边界处插入运行时检查。不幸的是,性能研究表明,这些检查的开销可能高得惊人,这让人们对声音渐进式输入的可行性产生了疑问。在本文中,我们表明,通过建立在现有的工作软合同验证,我们可以减少或消除这种开销。我们的关键见解是,虽然非类型化代码不能被渐进类型系统信任,但在优化渐进类型化程序时,没有必要只考虑最坏的情况。相反,我们静态分析的非类型化的部分逐渐类型化的程序,以证明几乎所有的动态检查暗示逐渐类型边界不能失败,并可以在编译时消除。我们的分析是模块化的,可以应用于程序的任何部分。我们评估了这种方法对现有的十几个渐进式程序以前表现出令人望而却步的性能开销--与$3.5\times$的中位数开销和高达$73.6\times$在最坏的情况下--和消除所有的开销在大多数情况下,在最坏的情况下,只有$1.6\times$开销的痛苦。
英文摘要:
Gradually-typed programming languages permit the incremental addition of static types to untyped programs. To remain sound, languages insert run-time checks at the boundaries between typed and untyped code. Unfortunately, performance studies have shown that the overhead of these checks can be disastrously high, calling into question the viability of sound gradual typing. In this paper, we show that by building on existing work on soft contract verification, we can reduce or eliminate this overhead. Our key insight is that while untyped code cannot be trusted by a gradual type system, there is no need to consider only the worst case when optimizing a gradually-typed program. Instead, we statically analyze the untyped portions of a gradually-typed program to prove that almost all of the dynamic checks implied by gradual type boundaries cannot fail, and can be eliminated at compile time. Our analysis is modular, and can be applied to any portion of a program. We evaluate this approach on a dozen existing gradually-typed programs previously shown to have prohibitive performance overhead---with a median overhead of $3.5\times$ and up to $73.6\times$ in the worst case---and eliminate all overhead in most cases, suffering only $1.6\times$ overhead in the worst case.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。