Assessing the Overhead of ML Exceptions by Selective CPS Transformation

ML's exception handling makes it possible to describe exceptional execution flows conveniently, but it also forms a performance bottleneck. Our goal is to reduce this overhead by source-level transformation. To this end, we transform source programs into continuation-passing style (CPS), replacing handle and raise expressions by continuation-catching and throwing expressions, respectively. CPS-transforming every expression, however, introduces a new cost. We therefore use an exception analysis to transform expressions selectively: if an expression is statically determined to involve exceptions then it is CPS-transformed; otherwise, it is left in direct style. In this article, we formalize this selective CPS transformation, prove its correctness, and present early experimental data indicating its effect on ML programs.

[1]  Olivier Danvy,et al.  Representing Control: a Study of the CPS Transformation , 1992, Mathematical Structures in Computer Science.

[2]  Andrew W. Appel,et al.  Compiling with Continuations , 1991 .

[3]  Zhe Yang Encoding Types in ML-like Languages (Preliminary Version) , 1998 .

[4]  Suresh Jagannathan,et al.  Flow-directed inlining , 1996, PLDI '96.

[5]  Peter Lee,et al.  Safe-for-Space Threads in Standard ML , 1998, High. Order Symb. Comput..

[6]  Theis Rauhe,et al.  Optimal time-space trade-offs for sorting , 1998, Proceedings 39th Annual Symposium on Foundations of Computer Science (Cat. No.98CB36280).

[7]  Mitchell Wand,et al.  Selective Thunkification , 1994, SAS.

[8]  Peter Bro Miltersen,et al.  Lower Bounds for Dynamic Algebraic Problems , 1998, Inf. Comput..

[9]  Matthias Felleisen,et al.  The calculi of lambda-nu-cs conversion: a syntactic theory of control and state in imperative higher-order programming languages , 1987 .

[10]  Olivier Danvy,et al.  Thunks and the λ-calculus , 1997, Journal of Functional Programming.

[11]  Olivier Danvy,et al.  CPS-transformation after strictness analysis , 1992, LOPL.

[12]  David A. McAllester,et al.  Linear-time subtransitive control flow analysis , 1997, PLDI '97.

[13]  Kwangkeun Yi,et al.  Towards a Cost-Effective Estimation of Uncaught Exceptions in SML Programs , 1997, SAS.

[14]  Sandeep Sen,et al.  The Hardness of Speeding-up Knapsack , 1998 .

[15]  Gordon D. Plotkin,et al.  Call-by-Name, Call-by-Value and the lambda-Calculus , 1975, Theor. Comput. Sci..

[16]  Olivier Danvy,et al.  On the Transformation between Direct and Continuation Semantics , 1993, MFPS.

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

[18]  P. S. Thiagarajan,et al.  Distributed Versions of Linear Time Temporal Logic: A Trace Perspective , 1998 .

[19]  Peter Sestoft,et al.  Replacing function parameters by global variables , 1989, FPCA.

[20]  Kim Sunesen,et al.  Further Results on Partial Order Equivalences on Infinite Systems , 1998 .

[21]  Stephen Alstrup,et al.  Marked Ancestor Problems (Preliminary Version) , 1998 .

[22]  Peter Bro Miltersen,et al.  Lower Bounds for Dynamic Algebraic Problems , 1998 .

[23]  Olivier Danvy,et al.  Compiling Actions by Partial Evaluation, Revisited , 1998 .

[24]  Eddy Bevers,et al.  CPS transformation after binding-time analysis , 1995 .

[25]  P. S. Thiagarajan,et al.  Distributed Versions of Linear Time Temporal Logic: A Trace Perspective , 1996, Petri Nets.