Skip to main content

Recency Types for Analyzing Scripting Languages

  • Conference paper

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

Abstract

With the current surge of scripting technologies, large programs are being built with dynamically typed languages. As these programs grow in size, semantics-based tools gain importance for detecting programming errors as well as for program understanding.

As a basis for such tools, we propose a descriptive type system for an imperative call-by-value lambda calculus with objects. The calculus models essential features of JavaScript, a widely used dynamically-typed language: first-class functions, objects as property maps, and prototypes.

Our type system infers precise singleton object types for recently allocated objects. These object types are handled flow-sensitively and change during the objects’ initialization phase. The notion of recency provides an automatic criterion to subsume these precise object types to summary object types, which are handled flow-insensitively. The criterion applies on a per-object basis. Thus, the type system identifies a generalized initialization phase for each object during which the change of its value is precisely reflected in the change of its type. Unlike with linear types, summary types may refer to singleton types and vice versa.

We prove the soundness of the type system and present a constraint-based inference algorithm. An implementation is available on the web.

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

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   109.99
Price excludes VAT (USA)
  • 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

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Altucher, R.Z., Landi, W.: An extended form of must alias analysis for dynamic allocation. In: Proc. 1995 ACM Symp. POPL, San Francisco, CA, USA, pp. 74–84. ACM Press, New York (January 1995)

    Google Scholar 

  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)

    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. Bono, V., Fisher, K.: An imperative, first-order calculus with object extension. In: Jul, E. (ed.) ECOOP 1998. LNCS, vol. 1445, pp. 462–497. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  5. Boyland, J., Noble, J., Retert, W.: Capabilities for sharing: A generalisation of uniqueness and read-only. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 2–27. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  6. Chase, D.R., Wegman, M., Zadeck, F.K.: Analysis of pointers and structures. In: Proc. PLDI 1990, White Plains NY, USA, pp. 296–310. ACM, New York (June 1990)

    Google Scholar 

  7. Crockford, D.: JavaScript: The Good Parts, 170 p. O’Reilly Media, Sebastopol (2008)

    Google Scholar 

  8. ECMAScript Language Specification, ECMA International, ECMA-262, 3rd edn. (December 1999), http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf

  9. Fisher, K.: Type Systems for Object-Oriented Programming Languages. PhD thesis, Standford University, Stanford CS Technical Report STAN-CS-TR-98-1602 (1996)

    Google Scholar 

  10. Flanagan, C., Sabry, A., Duba, B.F., Felleisen, M.: The essence of compiling with continuations. In: Proc. 1993 PLDI, Albuquerque, NM, USA, pp. 237–247 (June 1993)

    Google Scholar 

  11. Foster, J.S., Terauchi, T., Aiken, A.: Flow-sensitive type qualifiers. In: Proc. 2002 PLDI, Berlin, Germany, pp. 1–12. ACM Press, New York (June 2002)

    Chapter  Google Scholar 

  12. Fähndrich, M., Xia, S.: Establishing object invariants with delayed types. In: Proc. 22nd ACM Conf. OOPSLA, Montreal, QC, CA, pp. 337–350. ACM Press, New York (2007)

    Google Scholar 

  13. Gifford, D., Lucassen, J.: Integrating functional and imperative programming. In: Proc. 1986 ACM Conf. on Lisp and Functional Programming, pp. 28–38 (1986)

    Google Scholar 

  14. Heidegger, P., Thiemann, P.: Recency types for scripting languages. Universität Freiburg (July 2009), http://proglang.informatik.uni-freiburg.de/JavaScript/appendix.pdf

  15. Jagannathan, S., Thiemann, P., Weeks, S., Wright, A.: Single and loving it: Must-alias analysis for higher-order languages. In: Cardelli, L. (ed.) Proc. 25th ACM Symp. POPL, San Diego, CA, USA, pp. 329–341. ACM Press, New York (January 1998)

    Google Scholar 

  16. Jensen, S.H., Møller, A., Thiemann, P.: Type analysis for JavaScript. In: Palsberg, J., Su, Z. (eds.) SAS 2009. LNCS, vol. 5673, pp. 238–255. Springer, Heidelberg (2009)

    Chapter  Google Scholar 

  17. Jones, N.D., Muchnick, S.S.: Flow analysis and optimization of Lisp-like languages. In: Proc.  6th ACM Symp. POPL, pp. 244–256. ACM Press, New York (1979)

    Google Scholar 

  18. Kehrt, M., Aldrich, J.: A theory of linear objects. In: FOOL 2008, San Francisco, CA, USA (January 2008), http://fool08.kuis.kyoto-u.ac.jp/kehrt.pdf

  19. Lebresne, S., Richards, G., Östlund, J., Wrigstad, T., Vitek, J.: Understanding the dynamics of JavaScript. In: International Workshop on Script to Program Evolution (STOP), Genova, Italy (July 2009)

    Google Scholar 

  20. Might, M., Shivers, O.: Improving flow analyses via ΓCFA: Abstract garbage collection and counting. In: Lawall, J. (ed.) Proc. ICFP 2006, Portland, Oregon, USA, pp. 13–25. ACM Press, New York (September 2006)

    Chapter  Google Scholar 

  21. Qi, X., Myers, A.C.: Masked types for sound object initialization. In: Pierce, B. (ed.) Proc. 36th ACM Symp. POPL, Savannah, GA, USA, pp. 53–65. ACM Press, New York (January 2009)

    Google Scholar 

  22. Smith, F., Walker, D., Morrisett, J.G.: Alias types. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, pp. 366–381. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  23. 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)

    Google Scholar 

  24. Tobin-Hochstadt, S., Felleisen, M.: The design and implementation of typed scheme. In: Wadler, P. (ed.) Proc. 35th ACM Symp. POPL, San Francisco, CA, USA, pp. 395–406. ACM Press, New York (January 2008)

    Google Scholar 

  25. Walker, D., Morrisett, G.: Alias types for recursive data structures. In: Harper, R. (ed.) TIC 2000. LNCS, vol. 2071, pp. 177–206. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  26. Wright, A., Felleisen, M.: A syntactic approach to type soundness. Information and Computation 115(1), 38–94 (1994)

    Article  MATH  MathSciNet  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2010 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Heidegger, P., Thiemann, P. (2010). Recency Types for Analyzing Scripting Languages. In: D’Hondt, T. (eds) ECOOP 2010 – Object-Oriented Programming. ECOOP 2010. Lecture Notes in Computer Science, vol 6183. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-14107-2_10

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-14107-2_10

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-14106-5

  • Online ISBN: 978-3-642-14107-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics