Type refinement for static analysis of JavaScript

  • Authors:
  • Vineeth Kashyap;John Sarracino;John Wagner;Ben Wiedermann;Ben Hardekopf

  • Affiliations:
  • University of California Santa Barbara, Santa Barbara, California, USA;Harvey Mudd College, Claremont, California, USA;University of California Santa Barbara, Santa Barbara, California, USA;Harvey Mudd College, Claremont, California, USA;University of California Santa Barbara, Santa Barbara, California, USA

  • Venue:
  • Proceedings of the 9th symposium on Dynamic languages
  • Year:
  • 2013

Quantified Score

Hi-index 0.00

Visualization

Abstract

Static analysis of JavaScript has proven useful for a variety of purposes, including optimization, error checking, security auditing, program refactoring, and more. We propose a technique called type refinement that can improve the precision of such static analyses for JavaScript without any discernible performance impact. Refinement is a known technique that uses the conditions in branch guards to refine the analysis information propagated along each branch path. The key insight of this paper is to recognize that JavaScript semantics include many implicit conditional checks on types, and that performing type refinement on these implicit checks provides significant benefit for analysis precision. To demonstrate the effectiveness of type refinement, we implement a static analysis tool for reporting potential type-errors in JavaScript programs. We provide an extensive empirical evaluation of type refinement using a benchmark suite containing a variety of JavaScript application domains, ranging from the standard performance benchmark suites (Sunspider and Octane), to open-source JavaScript applications, to machine-generated JavaScript via Emscripten. We show that type refinement can significantly improve analysis precision by up to 86% without affecting the performance of the analysis.