[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to main content

Type Analysis for JavaScript

  • Conference paper
Static Analysis (SAS 2009)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 5673))

Included in the following conference series:

Abstract

JavaScript is the main scripting language for Web browsers, and it is essential to modern Web applications. Programmers have started using it for writing complex applications, but there is still little tool support available during development.

We present a static program analysis infrastructure that can infer detailed and sound type information for JavaScript programs using abstract interpretation. The analysis is designed to support the full language as defined in the ECMAScript standard, including its peculiar object model and all built-in functions. The analysis results can be used to detect common programming errors – or rather, prove their absence, and for producing type information for program comprehension.

Preliminary experiments conducted on real-life JavaScript code indicate that the approach is promising regarding analysis precision on small and medium size programs, which constitute the majority of JavaScript applications. With potential for further improvement, we propose the analysis as a foundation for building tools that can aid JavaScript programmers.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
£29.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
GBP 19.95
Price includes VAT (United Kingdom)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
GBP 35.99
Price includes VAT (United Kingdom)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
GBP 44.99
Price includes VAT (United Kingdom)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Similar content being viewed by others

References

  1. Adobe. JSEclipse, http://labs.adobe.com/technologies/jseclipse/

  2. Anderson, C., Giannini, P., Drossopoulou, S.: Towards type inference for JavaScript. In: Black, A.P. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 428–452. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  3. Balakrishnan, G., Reps, T.W.: Recency-abstraction for heap-allocated storage. In: Yi, K. (ed.) SAS 2006. LNCS, vol. 4134, pp. 221–239. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  4. Boyd, N., et al.: Rhino: JavaScript for Java, http://www.mozilla.org/rhino/

  5. Bush, W.R., Pincus, J.D., Sielaff, D.J.: A static analyzer for finding dynamic programming errors. Software: Practice and Experience 30(7), 775–802 (2000)

    MATH  Google Scholar 

  6. Cartwright, R., Fagan, M.: Soft typing. In: Proc. ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 1991 (June 1991)

    Google Scholar 

  7. Childs, B.: JavaScript development toolkit (JSDT) features (July 2008), http://live.eclipse.org/node/569

  8. Christensen, A.S., Møller, A., Schwartzbach, M.I.: Precise analysis of string expressions. In: Cousot, R. (ed.) SAS 2003. LNCS, vol. 2694, pp. 1–18. Springer, Heidelberg (2003)

    Chapter  Google Scholar 

  9. Cousot, P., Cousot, R.: Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In: Proc. 4th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1977, pp. 238–252 (1977)

    Google Scholar 

  10. Dolby, J.: Using static analysis for IDE’s for dynamic languages, 2005. In: The Eclipse Languages Symposium (2005)

    Google Scholar 

  11. ECMA. ECMAScript Language Specification, 3rd edn. ECMA-262

    Google Scholar 

  12. Engler, D.R., Chelf, B., Chou, A., Hallem, S.: Checking system rules using system-specific, programmer-written compiler extensions. In: 4th Symposium on Operating System Design and Implementation, OSDI 2000, USENIX (October 2000)

    Google Scholar 

  13. Fink, S., Dolby, J.: WALA – The T.J. Watson Libraries for Analysis, http://wala.sourceforge.net/

  14. Flanagan, C., Flatt, M., Krishnamurthi, S., Weirich, S., Felleisen, M.: Catching bugs in the web of program invariants. In: Proc. ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 1996, pp. 23–32 (1996)

    Google Scholar 

  15. Furr, M., (David) An, J-h., Foster, J.S., Hicks, M.: Static type inference for Ruby. In: Proc. 24th Annual ACM Symposium on Applied Computing, SAC 2009, Object Oriented Programming Languages and Systems Track (March 2009)

    Google Scholar 

  16. Graver, J.O., Johnson, R.E.: A type system for Smalltalk. In: Proc. 17th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1990, pp. 136–150 (1990)

    Google Scholar 

  17. Heidegger, P., Thiemann, P.: Recency types for dynamically-typed object-based languages. In: Proc. International Workshops on Foundations of Object-Oriented Languages, FOOL 2009 (January 2009)

    Google Scholar 

  18. Apple Inc. Squirrelfish bytecodes, http://webkit.org/specs/squirrelfish-3bytecode.html

  19. Jagannathan, S., Thiemann, P., Weeks, S., Wright, A.: Single and loving it: Must-alias analysis for higher-order languages. In: Proc. 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1998, pp. 329–341 (1998)

    Google Scholar 

  20. Jang, D., Choe, K.-M.: Points-to analysis for JavaScript. In: Proc. 24th Annual ACM Symposium on Applied Computing, SAC 2009, Programming Language Track (March 2009)

    Google Scholar 

  21. Kam, J.B., Ullman, J.D.: Monotone data flow analysis frameworks. Acta Informatica 7, 305–317 (1977)

    Article  MathSciNet  MATH  Google Scholar 

  22. Kromann-Larsen, R., Simonsen, R.: Statisk analyse af JavaScript: Indledende arbejde. Master’s thesis, Department of Computer Science, University of Aarhus (2007) (in Danish)

    Google Scholar 

  23. Lindahl, T., Sagonas, K.: Practical type inference based on success typings. In: Proc. 8th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming, PPDP 2006, pp. 167–178 (2006)

    Google Scholar 

  24. Marlow, S., Wadler, P.: A practical subtyping system for Erlang. In: Proc. 2nd ACM SIGPLAN International Conference on Functional Programming, ICFP 1997, pp. 136–149 (1997)

    Google Scholar 

  25. Sun Microsystems and Netscape Inc. Netscape and Sun announce Javascript(TM), the open, cross-platform object scripting language for enterprise networks and the internet (1995), http://sunsite.nus.sg/hotjava/pr951204-03.html

  26. Might, M., Shivers, O.: Improving flow analyses via ΓCFA: abstract garbage collection and counting. In: Proc. 11th ACM SIGPLAN International Conference on Functional Programming, ICFP 2006 (2006)

    Google Scholar 

  27. Nyström, S.-O.: A soft-typing system for Erlang. In: Proc. 2nd ACM SIGPLAN Erlang Workshop, ERLANG 2003, pp. 56–71 (2003)

    Google Scholar 

  28. Sagiv, S., Reps, T.W., Wilhelm, R.: Parametric shape analysis via 3-valued logic. ACM Transactions on Programming Languages and Systems 24(3), 217–298 (2002)

    Article  Google Scholar 

  29. Sharir, M., Pnueli, A.: Two approaches to interprocedural dataflow analysis. In: Program Flow Analysis: Theory and Applications, pp. 189–233. Prentice-Hall, Englewood Cliffs (1981)

    Google Scholar 

  30. Thiemann, P.: Towards a type system for analyzing JavaScript programs. In: Sagiv, M. (ed.) ESOP 2005. LNCS, vol. 3444, pp. 408–422. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  31. Wright, A.K., Cartwright, R.: A practical soft type system for Scheme. ACM Transactions on Programming Languages and Systems 19(1), 87–152 (1997)

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2009 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Jensen, S.H., Møller, A., Thiemann, P. (2009). Type Analysis for JavaScript. In: Palsberg, J., Su, Z. (eds) Static Analysis. SAS 2009. Lecture Notes in Computer Science, vol 5673. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-03237-0_17

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-03237-0_17

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-03236-3

  • Online ISBN: 978-3-642-03237-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics