设置所有止损点:JavaScript的执行控制
Putting in All the Stops: Execution Control for JavaScript
摘要:
大量的编译器产生了JavaScript,使程序员能够在Web上使用多种语言,重用现有代码,甚至使用Web IDE。不幸的是,大多数编译器继承了浏览器的折衷执行模型,因此长时间运行的程序会冻结浏览器标签,无限循环会使IDE崩溃,等等。少数避免这些问题的编译器性能很差,很难设计。本文介绍了Stopify,一个源到源的编译器,扩展JavaScript的调试抽象和阻塞操作,并很容易与现有的编译器集成。我们将Stopify应用于10种程序设计语言,并开发了一个支持停止、单步执行、断点和长时间运行计算的Web IDE。对于九种语言,Stopify不需要或只需少量的编译器更改。对于八个,我们的IDE是第一个提供这些功能的IDE。我们的两个主题语言具有类似功能的编译器。Stopify的性能与这些编译器相比具有竞争力,它使它们变得非常简单。Stopify的抽象依赖于一级延续,它通过将JavaScript编译为JavaScript来提供。我们还确定了编译器隐式使用的JavaScript的子语言,并利用这些来提高性能。最后,Stopify需要反复中断和恢复程序执行。我们使用基于采样的技术来估计程序的速度,优于其他系统。
英文摘要:
Scores of compilers produce JavaScript, enabling programmers to use many languages on the Web, reuse existing code, and even use Web IDEs. Unfortunately, most compilers inherit the browser's compromised execution model, so long-running programs freeze the browser tab, infinite loops crash IDEs, and so on. The few compilers that avoid these problems suffer poor performance and are difficult to engineer. This paper presents Stopify, a source-to-source compiler that extends JavaScript with debugging abstractions and blocking operations, and easily integrates with existing compilers. We apply Stopify to 10 programming languages and develop a Web IDE that supports stopping, single-stepping, breakpointing, and long-running computations. For nine languages, Stopify requires no or trivial compiler changes. For eight, our IDE is the first that provides these features. Two of our subject languages have compilers with similar features. Stopify's performance is competitive with these compilers and it makes them dramatically simpler. Stopify's abstractions rely on first-class continuations, which it provides by compiling JavaScript to JavaScript. We also identify sub-languages of JavaScript that compilers implicitly use, and exploit these to improve performance. Finally, Stopify needs to repeatedly interrupt and resume program execution. We use a sampling-based technique to estimate program speed that outperforms other systems.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。