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

异步JavaScript程序的静态分析

Static Analysis for Asynchronous JavaScript Programs

Thodoris Sotiropoulos, Benjamin Livshits

摘要:

异步已经成为JavaScript的一个固有元素,作为提高现代Web应用程序的可伸缩性和性能的一种努力。为此,JavaScript为程序员提供了用于开发执行异步计算的代码的各种构造和特征,包括但不限于定时器、承诺和非阻塞I/O。然而,由XML强加的数据流是隐式的,并且并不总是被开发人员很好地理解,他们将许多与XML相关的错误引入到他们的程序中。更糟糕的是,很少有工具和技术可用于分析和推理此类异步应用程序。在这项工作中,我们解决这个问题,设计和实现的第一个静态分析计划能够处理几乎所有的异步原语的JavaScript的ECMAScript规范的第7版。具体来说,我们引入了回调图,一种用于捕获异步代码之间的数据流的表示。我们利用回调图设计一个更精确的分析,尊重不同的异步函数之间的执行顺序。我们用一种新颖的上下文敏感性风格来参数化我们的分析,并且我们最终得到了用于构建回调图的多种分析变体。我们在一组手写和真实世界的JavaScript程序上进行了大量的实验。我们的研究结果表明,我们的分析可以应用到中等规模的程序,平均达到79%的精度。研究结果进一步表明,分析灵敏度是有益的,为绝大多数的基准。具体来说,它能够将精度提高28.5%,同时在不牺牲性能的情况下平均达到88%的精度。

英文摘要:

Asynchrony has become an inherent element of JavaScript, as an effort to improve the scalability and performance of modern web applications. To this end, JavaScript provides programmers with a wide range of constructs and features for developing code that performs asynchronous computations, including but not limited to timers, promises, and non-blocking I/O. However, the data flow imposed by asynchrony is implicit, and not always well-understood by the developers who introduce many asynchrony-related bugs to their programs. Worse, there are few tools and techniques available for analyzing and reasoning about such asynchronous applications. In this work, we address this issue by designing and implementing one of the first static analysis schemes capable of dealing with almost all the asynchronous primitives of JavaScript up to the 7th edition of the ECMAScript specification. Specifically, we introduce the callback graph, a representation for capturing data flow between asynchronous code. We exploit the callback graph for designing a more precise analysis that respects the execution order between different asynchronous functions. We parameterize our analysis with one novel context-sensitivity flavor, and we end up with multiple analysis variations for building callback graph. We performed a number of experiments on a set of hand-written and real-world JavaScript programs. Our results show that our analysis can be applied to medium-sized programs achieving 79% precision on average. The findings further suggest that analysis sensitivity is beneficial for the vast majority of the benchmarks. Specifically, it is able to improve precision by up to 28.5%, while it achieves an 88% precision on average without highly sacrificing performance.

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

↑