The popularity and wide adoption of JavaScript both at the client and server side makes its code analysis more important than ever before. Most of the algorithms for vulnerability analysis, coding issue detection, or type inference rely on the call graph representation of the underlying program. Despite some obvious advantages of dynamic analysis, static algorithms should also be considered for call graph construction as they do not require extensive test beds for programs and their costly execution and tracing. In this paper, we systematically compare five widely adopted static algorithms - implemented by the npm call graph, IBM WALA, Google Closure Compiler, Approximate Call Graph, and Type Analyzer for JavaScript tools - for building JavaScript call graphs on 26 WebKit SunSpider benchmark programs and 6 real-world Node.js modules. We provide a performance analysis as well as a quantitative and qualitative evaluation of the results. We found that there was a relatively large intersection of the found call edges among the algorithms, which proved to be 100 precise. However, most of the tools found edges that were missed by all others. ACG had the highest precision followed immediately by TAJS, but ACG found significantly more call edges. As for the combination of tools, ACG and TAJS together covered 99% of the found true edges by all algorithms, while maintaining a precision as high as 98%. Only two of the tools were able to analyze up-to-date multi-file Node.js modules due to incomplete language features support. They agreed on almost 60% of the call edges, but each of them found valid edges that the other missed.
翻译:JavaScript在客户端和服务器端的广泛流行和采用使其代码分析比以往任何时候都更加重要。大多数用于漏洞分析、编码问题检测或类型推断的算法都依赖于底层程序的调用图表示。尽管动态分析具有一些明显优势,但在构建调用图时也应考虑静态算法,因为它们不需要为程序提供广泛的测试套件及其昂贵的执行和追踪。本文系统比较了五种广泛采用的静态算法——由npm call graph、IBM WALA、Google Closure Compiler、Approximate Call Graph和Type Analyzer for JavaScript工具实现——在26个WebKit SunSpider基准程序和6个真实世界Node.js模块上构建JavaScript调用图。我们提供了性能分析以及对结果的定量和定性评估。我们发现各算法找到的调用边存在相对较大的交集,这些交集被证明100%精确。然而,大多数工具都发现了被其他所有工具遗漏的边。ACG的精确度最高,紧随其后的是TAJS,但ACG找到了显著更多的调用边。在工具组合方面,ACG和TAJS共同覆盖了所有算法找到的真实边的99%,同时保持了高达98%的精确度。由于对语言特性支持不完整,只有两个工具能够分析最新的多文件Node.js模块。它们在近60%的调用边上达成一致,但每个工具都找到了另一个工具遗漏的有效边。