Concrete type inference: delivering object-oriented applications

Polymorphism in object-oriented languages, while increasing expressive power and reusability of code, sacrifices manifest concrete type information. In turn, application delivery suffers: lacking concrete type information, it is impossible to compile as efficiently, to check as thoroughly, and to eliminate dead code as effectively. The delivery problem exists for dynamically-typed languages like Smalltalk and, since type-declarations should be abstract, for statically-typed languages like C++. We have designed, implemented, and evaluated an algorithm, the cartesian product algorithm, that can infer concrete types of object-oriented programs. It applies the cartesian product to break the analysis of each polymorphic send into a case analysis; each case represents a monomorphic combination of actual arguments and can be analyzed precisely. The cartesian product algorithm improves precision and efficiency over previous algorithms and deals directly with inheritance, rather than relying on a preprocessor to expand it away. Our implementation handles most of the dynamically-typed Self language, including dynamically-dispatched messages, dynamic and multiple inheritance, lexically-scoped blocks, and non-local returns, although it supports the reflective features of Self only partially. Using the inferred concrete types, a compiler can statically bind and inline message sends, a browser can follow control-flow through message sends, an extractor can identify the essential objects for an application and discard the rest, and a checker can statically guarantee the absence of message-not-understood errors. Collaborating with other researchers, we have implemented proof-of-concept versions of these type-based application delivery tools. Measurements indicate that type inference performs well. For example, on a 167 MHz UltraSPARC our type inferencer can analyze the DeltaBlue constraint solver in 10 seconds (DeltaBlue consists of 500 lines of source code and uses an additional 900 lines from libraries). Subsequently, our extractor takes 4 seconds to produce a shrink-wrapped DeltaBlue application comprising 350 Kb, a 96% size reduction over the original 10 Mb image. Moreover, the inferred types enable static compilation of Self program, while sustaining performance comparable to that of Holzle's state-of-the-art dynamic Self compiler. Thus, concrete type inference enables delivery of object-oriented applications.

[1]  Giuseppe Castagna,et al.  Covariance and contravariance: conflict without a cause , 1995, TOPL.

[2]  Jong-Deok Choi,et al.  Efficient flow-sensitive interprocedural computation of pointer-induced aliases and side effects , 1993, POPL '93.

[3]  Jens Palsberg,et al.  Object-oriented type systems , 1994, Wiley professional computing.

[4]  Robert Cartwright,et al.  Soft typing , 2004, SIGP.

[5]  Mark N. Wegman,et al.  Efficiently computing static single assignment form and the control dependence graph , 1991, TOPL.

[6]  Mads Tofte,et al.  Type Inference for Polymorphic References , 1990, Inf. Comput..

[7]  Carl G. Ponder,et al.  Polymorphism considered harmful , 1994 .

[8]  Jeffrey D. Ullman,et al.  A general scheme for the automatic inference of variable types , 1978, POPL.

[9]  R. Nigel Horspool,et al.  Compile-Time Analysis of Object-Oriented Programs , 1992, CC.

[10]  Alexander Aiken,et al.  Soft typing with conditional types , 1994, POPL '94.

[11]  Michael A. Harrison,et al.  Accurate static estimators for program optimization , 1994, PLDI '94.

[12]  Ralph E. Johnson,et al.  A type system for Smalltalk , 1989, POPL '90.

[13]  J. Boreczky Building common Lisp applications with reasonable performance , 1993, LUV '93.

[14]  Andrew A. Chien,et al.  Precise concrete type inference for object-oriented languages , 1994, OOPSLA 1994.

[15]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[16]  William R. Cook,et al.  A Proposal for Making Eiffel Type-Safe , 1989, Comput. J..

[17]  Neil D. Jones,et al.  Binding time optimization in programming languages: Some thoughts toward the design of an ideal language , 1976, POPL.

[18]  Patrick Cousot,et al.  Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints , 1977, POPL.

[19]  Mark N. Wegman,et al.  Constant propagation with conditional branches , 1985, POPL.

[20]  Christopher W. Fraser,et al.  Integrating code generation and optimization , 1986, SIGPLAN '86.

[21]  Monica S. Lam,et al.  Efficient context-sensitive pointer analysis for C programs , 1995, PLDI '95.

[22]  L. Peter Deutsch The Past, Present and Future of Smalltalk , 1989, ECOOP.

[23]  Didier Rémy,et al.  Type checking records and variants in a natural extension of ML , 1989, POPL '89.

[24]  Leon J. Osterweil,et al.  Data Flow Analysis in Software Reliability , 1976, CSUR.

[25]  Olin Shivers,et al.  Control-flow analysis of higher-order languages of taming lambda , 1991 .

[26]  Bjørn N. Freeman-Benson,et al.  Multi‐way versus one‐way constraints in user interfaces: Experience with the deltablue algorithm , 1993, Softw. Pract. Exp..

[27]  Norman Wilde,et al.  Maintenance support for object oriented programs , 1991, Proceedings. Conference on Software Maintenance 1991.

[28]  Amitabh Srivastava,et al.  Unreachable procedures in object-oriented programming , 1992, LOPL.

[29]  David Ungar,et al.  Sifting out the gold: delivering compact applications from an exploratory object-oriented programming environment , 1994, OOPSLA 1994.

[30]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

[31]  David M. Ungar Annotating objects for transport to other worlds , 1995, OOPSLA.

[32]  Mario Südholt,et al.  On Interprocedural Data Flow Analysis for Object Oriented Languages , 1992, CC.

[33]  Alan Borning,et al.  Classes versus Prototypes in Object-Oriented Languages , 1986, FJCC.

[34]  Stefan M. Freudenberger,et al.  Phase Ordering of Register Allocation and Instruction Scheduling , 1991, Code Generation.

[35]  Andrew A. Chien,et al.  Type Directed Cloning for Object-Oriented Programs , 1995, LCPC.

[36]  L. Peter Deutsch,et al.  Efficient implementation of the smalltalk-80 system , 1984, POPL.

[37]  Urs Hölzle,et al.  Type feedback vs. concrete type inference: a comparison of optimization techniques for object-oriented languages , 1995, OOPSLA.

[38]  Craig Chambers,et al.  Object-Oriented Multi-Methods in Cecil , 1992, ECOOP.

[39]  Ole Agesen The Cartesian Product Algorithm: Simple and Precise Type Inference Of Parametric Polymorphism , 1995, ECOOP.

[40]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

[41]  Urs Hölzle,et al.  Adaptive optimization for self: reconciling high performance with exploratory programming , 1994 .

[42]  Ole Lehrmann Madsen,et al.  Object-oriented programming in the BETA programming language , 1993 .

[43]  Norihisa Suzuki,et al.  Inferring types in Smalltalk , 1981, POPL '81.

[44]  Peter Wegner,et al.  Dimensions of object-based language design , 1987, OOPSLA '87.

[45]  Gilad Bracha,et al.  Strongtalk: typechecking Smalltalk in a production environment , 1993, OOPSLA '93.

[46]  Jens Palsberg,et al.  Making Type Inference Practical , 1992, ECOOP.

[47]  Daniel H. H. Ingalls A simple technique for handling multiple polymorphism , 1986, OOPSLA 1986.

[48]  Randall B. Smith,et al.  Self: The power of simplicity , 1987, OOPSLA 1987.

[49]  Jens Palsberg,et al.  Object-oriented type inference , 1991, OOPSLA 1991.

[50]  Mitchell Wand,et al.  Type inference for record concatenation and multiple inheritance , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[51]  Jerzy Tiuryn,et al.  Type Inference Problems: A Survey , 1990, MFCS.

[52]  K. J. Lienberherr Formulations and benefits of the law of demeter , 1989 .

[53]  Craig Chambers,et al.  The design and implementation of the self compiler, an optimizing compiler for object-oriented programming languages , 1992 .

[54]  Harry G. Mairson,et al.  Unification and ML-Type Reconstruction , 1991, Computational Logic - Essays in Honor of Alan Robinson.

[55]  Ole Lehrmann Madsen,et al.  Virtual classes: a powerful mechanism in object-oriented programming , 1989, OOPSLA 1989.

[56]  Brian W. Kernighan,et al.  The C Programming Language , 1978 .

[57]  Thomas G. Szymanski,et al.  A fast algorithm for computing longest common subsequences , 1977, CACM.

[58]  Neil D. Jones,et al.  Program flow analysis - theory and applications , 1981, Prentice Hall software series.

[59]  簡聰富,et al.  物件導向軟體之架構(Object-Oriented Software Construction)探討 , 1989 .

[60]  Ralph E. Johnson,et al.  Type-checking Smalltalk , 1986, OOPLSA '86.

[61]  Charles Consel,et al.  Polyvariant binding-time analysis for applicative languages , 1993, PEPM '93.

[62]  Ole Lehrmann Madsen,et al.  Strong typing of object-oriented languages revisited , 1990, OOPSLA/ECOOP '90.

[63]  John C. Reynolds,et al.  The discoveries of continuations , 1993, LISP Symb. Comput..

[64]  Andrew P. Black,et al.  Object structure in the Emerald system , 1986, OOPSLA 1986.

[65]  Ralph E. Johnson,et al.  Using static single assignment form in a code optimizer , 1992, LOPL.

[66]  Ken Kennedy,et al.  Procedure cloning , 1992, Proceedings of the 1992 International Conference on Computer Languages.

[67]  Barbara G. Ryder,et al.  Static Type Determination and Aliasing for C , 1990 .

[68]  Richard M. Karp,et al.  Turing award lecture , 1985, ACM '85.

[69]  Andrew A. Chien,et al.  Obtaining sequential efficiency for concurrent object-oriented languages , 1995, POPL '95.

[70]  Andreas V. Hense Polymorphic type inference for a simple object oriented programming language with state , 1990 .

[71]  Jens Palsberg,et al.  Analysis of Objects with Dynamic and Multiple Inheritance , 1993 .

[72]  Thomas W. Reps,et al.  Precise interprocedural dataflow analysis via graph reachability , 1995, POPL '95.

[73]  Craig Chambers,et al.  An efficient implementation of SELF, a dynamically-typed object-oriented language based on prototypes , 1991 .

[74]  Mary Lou Soffa,et al.  Efficient computation of interprocedural definition-use chains , 1994, TOPL.

[75]  Urs Hölzle,et al.  Optimizing dynamically-dispatched calls with run-time type feedback , 1994, PLDI '94.

[76]  Craig Schaffert,et al.  An introduction to Trellis/Owl , 1986, OOPSLA 1986.

[77]  Ben Wegbreit,et al.  Property extraction in well-founded property sets , 1975, IEEE Transactions on Software Engineering.

[78]  Norihisa Suzuki,et al.  Creating efficient systems for object-oriented languages , 1984, POPL '84.

[79]  R. Hindley The Principal Type-Scheme of an Object in Combinatory Logic , 1969 .

[80]  Pavel Curtis Constrained qualification in polymorphic type analysis , 1990 .

[81]  A. Barnard,et al.  From types to dataflow - code analysis for an object-oriented language , 1993, Technical report series.

[82]  Jens Palsberg,et al.  Type inference of SELF: Analysis of objects with dynamic and multiple inheritance , 1995, Softw. Pract. Exp..

[83]  Kim B. Bruce Safe type checking in a statically-typed object-oriented programming language , 1993, POPL '93.

[84]  Jens Palsberg,et al.  Polyvariant Analysis of the Untyped Lambda Calculus , 1992 .

[85]  Dharma P. Agrawal,et al.  An Improved Type-Inference Algorithm to Expose Parallelism in Object-Oriented Programs , 1996 .

[86]  Olin Shivers,et al.  Data-flow analysis and type recovery in Scheme , 1990 .

[87]  Daniel G. Bobrow,et al.  CommonLoops: Merging Lisp and Object-Oriented Programming , 1986, OOPSLA.

[88]  Ole Agesen Constraint-Based Type Inference and Parametric Polymorphism , 1994, SAS.

[89]  Justin O. Graver,et al.  TS: an optimizing compiler for smalltalk , 1988, OOPSLA 1988.

[90]  David Robson,et al.  Smalltalk-80: The Language and Its Implementation , 1983 .

[91]  Ivan Moore,et al.  Babel - A Translator from Smalltalk into CLOS , 1994 .

[92]  Adi Shamir,et al.  A method for obtaining digital signatures and public-key cryptosystems , 1978, CACM.

[93]  Justin O. Graver,et al.  Type checking and type inference for object-oriented programming languages , 1989 .

[94]  Luca Cardelli,et al.  A Semantics of Multiple Inheritance , 1984, Information and Computation.

[95]  Randall B. Smith,et al.  Programming as an Experience: The Inspiration for Self , 1995, ECOOP.

[96]  Alan Borning,et al.  A type declaration and inference system for smalltalk , 1982, POPL '82.

[97]  Dhananjay M. Dhamdhere,et al.  A generalized theory of bit vector data flow analysis , 1994, TOPL.

[98]  Neil D. Jones,et al.  Program Flow Analysis: Theory and Application , 1981 .

[99]  Norman Wilde,et al.  Maintaining object-oriented software , 1993, IEEE Software.

[100]  Andrew A. Chien,et al.  The concert system--compiler and runtime support for efficient, fine-grained concurrent object-oriented programs , 1993 .