Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/2508168.2508175acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Type refinement for static analysis of JavaScript

Published: 28 October 2013 Publication History

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.

References

[1]
Defensive JavaScript. http://www.defensivejs.com/. Accessed: 2013-06-05.
[2]
Emscripten. http://emscripten.org/. Accessed: 2013-06-05.
[3]
LINQ for JavaScript. http://linqjs.codeplex.com/. Accessed: 2013-06-05.
[4]
Octane JavaScript Benchmark. http://code.google.com/p/octane-benchmark/. Accessed: 2013-06-05.
[5]
Rhino Documentation. https://developer.mozilla.org/en-US/docs/Rhino. Accessed: 2013-06-05.
[6]
SunSpider JavaScript Benchmark. http://www.webkit.org/perf/sunspider/sunspider.html. Accessed: 2013-06-05.
[7]
T.J.Watson Libraries for Analysis (WALA). http://wala.sf.net. Accessed: 2013-06-05.
[8]
J.-h. D. An, A. Chaudhuri, J. S. Foster, and M. Hicks. Dynamic inference of static types for ruby. In ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), 2011.
[9]
C. Anderson, P. Giannini, and S. Drossopoulou. Towards type inference for JavaScript. In European Conference on Object-Oriented Programming (ECOOP), 2005.
[10]
G. Balakrishnan and T. Reps. Recency-abstraction for heap allocated storage. In Symposium on Static Analysis (SAS), 2006.
[11]
R. Chugh, P. M. Rondon, and R. Jhala. Nested refinements: a logic for duck typing. In ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), 2012.
[12]
P. Cousot and R. Cousot. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), 1977.
[13]
A. Feldthaus, T. D. Millstein, A. Møller, M. Schäfer, and F. Tip. Toolsupported refactoring for JavaScript. In ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2011.
[14]
T. Freeman and F. Pfenning. Refinement types for ML. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 1991.
[15]
M. Furr, J.-h. D. An, J. S. Foster, and M. Hicks. Static type inference for ruby. In ACM symposium on Applied Computing, 2009.
[16]
M. Gorbovitski, Y. A. Liu, S. D. Stoller, T. Rothamel, and T. K. Tekle. Alias analysis for optimization of dynamic languages. In Symposium on Dynamic Languages (DLS), 2010.
[17]
S. Guarnieri and B. Livshits. GATEKEEPER: mostly static enforcement of security and reliability policies for JavaScript code. In USENIX security symposium (SSYM), 2009.
[18]
S. Guarnieri, M. Pistoia, O. Tripp, J. Dolby, S. Teilhet, and R. Berg. Saving the world wide web from vulnerable javascript. In International Symposium on Software Testing and Analysis (ISSTA), 2011.
[19]
A. Guha, S. Krishnamurthi, and T. Jim. Static analysis for ajax intrusion detection. In International World Wide Web Conference (WWW), 2009.
[20]
A. Guha, C. Saftoiu, and S. Krishnamurthi. Typing local control and state using flow analysis. In European Symposium on Programming (ESOP), 2011.
[21]
B. Hackett and S. Guo. Fast and precise hybrid type inference for javascript. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 2012.
[22]
P. Heidegger and P. Thiemann. Recency Types for Analyzing Scripting Languages. In European Conference on Object-Oriented Programming, 2010.
[23]
D. Jang and K.-M. Choe. Points-to analysis for javascript. In ACM symposium on Applied Computing (SAC), 2009.
[24]
S. H. Jensen, A. Møller, and P. Thiemann. Type Analysis for JavaScript. In Symposium on Static Analysis (SAS), 2009.
[25]
G. A. Kildall. A unified approach to global program optimization. In ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), 1973.
[26]
H. Lee, S. Won, J. Jin, J. Cho, and S. Ryu. Safe: Formal specification and implementation of a scalable analysis framework for ecmascript. In International Workshop on Foundations of Object-Oriented Languages (FOOL), 2012.
[27]
F. Logozzo and H. Venter. RATA: rapid atomic type analysis by abstract interpretation -- application to JavaScript optimization. In Joint European conference on Theory and Practice of Software, international conference on Compiler Construction (CC/ETAPS), 2010.
[28]
F. Pluquet, A. Marot, and R. Wuyts. Fast type reconstruction for dynamically typed programming languages. In Symposium on Dynamic Languages (DLS), 2009.
[29]
H. G. Rice. Classes of Recursively Enumerable Sets and Their Decision Problems. Transactions of the American Mathematical Society, 74(2), 1953.
[30]
M. Sridharan, J. Dolby, S. Chandra, M. Schäfer, and F. Tip. Correlation tracking for points-to analysis of javascript. In European Conference on Object-Oriented Programming (ECOOP), 2012.
[31]
S. Tobin-Hochstadt and M. Felleisen. The design and implementation of typed scheme. In ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), 2008.
[32]
S. Tobin-Hochstadt and M. Felleisen. Logical types for untyped languages. In ACM SIGPLAN International Conference on Functional programming (ICFP), 2010.
[33]
T. Zhao. Polymorphic type inference for scripting languages with object extensions. In Symposium on Dynamic Languages (DLS), 2011.

Cited By

View all
  • (2024)The Linguistics of ProgrammingProceedings of the 2024 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software10.1145/3689492.3689806(162-182)Online publication date: 17-Oct-2024
  • (2019)Reasonably-most-general clients for JavaScript library analysisProceedings of the 41st International Conference on Software Engineering10.1109/ICSE.2019.00026(83-93)Online publication date: 25-May-2019
  • (2017)Analysis of JavaScript ProgramsACM Computing Surveys10.1145/310674150:4(1-34)Online publication date: 25-Aug-2017
  • Show More Cited By

Index Terms

  1. Type refinement for static analysis of JavaScript

      Recommendations

      Comments

      Information & Contributors

      Information

      Published In

      cover image ACM Conferences
      DLS '13: Proceedings of the 9th symposium on Dynamic languages
      October 2013
      118 pages
      ISBN:9781450324335
      DOI:10.1145/2508168
      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Sponsors

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      Published: 28 October 2013

      Permissions

      Request permissions for this article.

      Check for updates

      Author Tags

      1. javascript
      2. static analysis
      3. type-error analysis

      Qualifiers

      • Research-article

      Conference

      SPLASH '13
      Sponsor:

      Acceptance Rates

      DLS '13 Paper Acceptance Rate 9 of 22 submissions, 41%;
      Overall Acceptance Rate 32 of 77 submissions, 42%

      Upcoming Conference

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)13
      • Downloads (Last 6 weeks)0
      Reflects downloads up to 13 Jan 2025

      Other Metrics

      Citations

      Cited By

      View all
      • (2024)The Linguistics of ProgrammingProceedings of the 2024 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software10.1145/3689492.3689806(162-182)Online publication date: 17-Oct-2024
      • (2019)Reasonably-most-general clients for JavaScript library analysisProceedings of the 41st International Conference on Software Engineering10.1109/ICSE.2019.00026(83-93)Online publication date: 25-May-2019
      • (2017)Analysis of JavaScript ProgramsACM Computing Surveys10.1145/310674150:4(1-34)Online publication date: 25-Aug-2017
      • (2017)A Brief Survey of Related WorkString Analysis for Software Verification and Security10.1007/978-3-319-68670-7_11(155-164)Online publication date: 13-Dec-2017
      • (2016)Semantic subtyping for imperative object-oriented languagesACM SIGPLAN Notices10.1145/3022671.298399251:10(568-587)Online publication date: 19-Oct-2016
      • (2016)Semantic subtyping for imperative object-oriented languagesProceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications10.1145/2983990.2983992(568-587)Online publication date: 19-Oct-2016
      • (2015)Static analysis of event-driven Node.js JavaScript applicationsACM SIGPLAN Notices10.1145/2858965.281427250:10(505-519)Online publication date: 23-Oct-2015
      • (2015)Static analysis of event-driven Node.js JavaScript applicationsProceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications10.1145/2814270.2814272(505-519)Online publication date: 23-Oct-2015
      • (2015)Desynchronized Multi-State Abstractions for Open Programs in Dynamic LanguagesProceedings of the 24th European Symposium on Programming on Programming Languages and Systems - Volume 903210.1007/978-3-662-46669-8_20(483-509)Online publication date: 11-Apr-2015
      • (2014)Determinacy in static analysis for jQueryACM SIGPLAN Notices10.1145/2714064.266021449:10(17-31)Online publication date: 15-Oct-2014
      • Show More Cited By

      View Options

      Login options

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Media

      Figures

      Other

      Tables

      Share

      Share

      Share this Publication link

      Share on social media