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
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
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)
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)
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)
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)
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)
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)
Crockford, D.: JavaScript: The Good Parts, 170 p. O’Reilly Media, Sebastopol (2008)
ECMAScript Language Specification, ECMA International, ECMA-262, 3rd edn. (December 1999), http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
Fisher, K.: Type Systems for Object-Oriented Programming Languages. PhD thesis, Standford University, Stanford CS Technical Report STAN-CS-TR-98-1602 (1996)
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)
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)
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)
Gifford, D., Lucassen, J.: Integrating functional and imperative programming. In: Proc. 1986 ACM Conf. on Lisp and Functional Programming, pp. 28–38 (1986)
Heidegger, P., Thiemann, P.: Recency types for scripting languages. Universität Freiburg (July 2009), http://proglang.informatik.uni-freiburg.de/JavaScript/appendix.pdf
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)
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)
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)
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
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)
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)
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)
Smith, F., Walker, D., Morrisett, J.G.: Alias types. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, pp. 366–381. Springer, Heidelberg (2000)
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)
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)
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)
Wright, A., Felleisen, M.: A syntactic approach to type soundness. Information and Computation 115(1), 38–94 (1994)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)