Optimizing ML with run-time code generation

We describe the design and implementation of a compiler that automatically translates ordinary programs written in a subset of ML into code that generates native code at run time. Run-time code generation can make use of values and invariants that cannot be exploited at compile time, yielding code that is often superior to statically optimal code. But the cost of optimizing and generating code at run time can be prohibitive. We demonstrate how compile-time specialization can reduce the cost of run-time code generation by an order of magnitude without greatly affecting code quality. Several benchmark programs are examined, which exhibit an average cost of only six cycles per instruction generated at run time.

[1]  Markus Mock,et al.  Automatic Dynamic Compilation Support for Event Dispatching in Extensible Systems , 1998 .

[2]  Robert Harper,et al.  TIL: a type-directed optimizing compiler for ML , 1996, PLDI '96.

[3]  Brian N. Bershad,et al.  Fast, effective dynamic compilation , 1996, PLDI '96.

[4]  Peter Sestoft,et al.  Partial evaluation and automatic program generation , 1993, Prentice Hall international series in computer science.

[5]  Peter Lee,et al.  Lightweight Run-Time Code Generation , 1994, PEPM.

[6]  Walid Taha,et al.  Multi-stage programming with explicit annotations , 1997 .

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

[8]  Anders Bondorf,et al.  Automatic Autoprojection of Recursive Equations with Global Variables and Abstract Data Types , 1991, Sci. Comput. Program..

[9]  Ken Thompson,et al.  Programming Techniques: Regular expression search algorithm , 1968, Commun. ACM.

[10]  David Keppel,et al.  A portable interface for on-the-fly instruction space modification , 1991, ASPLOS IV.

[11]  Calton Pu,et al.  Optimistic incremental specialization: streamlining a commercial operating system , 1995, SOSP.

[12]  Frank Pfenning,et al.  A modal analysis of staged computation , 1996, POPL '96.

[13]  Robert Glück,et al.  Fast Binding-Time Analysis for Multi-Level Specialization , 1996, Ershov Memorial Conference.

[14]  Dawson R. Engler,et al.  DCG: an efficient, retargetable dynamic code generation system , 1994, ASPLOS VI.

[15]  Scott Draves,et al.  Compiler Generation for Interactive Graphics Using Intermediate Code , 1996, Dagstuhl Seminar on Partial Evaluation.

[16]  Peter Lee,et al.  Standard ML Signatures for a Protocol Stack , 1993 .

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

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

[19]  Rob Pike,et al.  Hardware/software trade‐offs for bitmap graphics on the blit , 1985, Softw. Pract. Exp..

[20]  T. Anderson,et al.  Eecient Software-based Fault Isolation , 1993 .

[21]  Susan J. Eggers,et al.  A case for runtime code generation , 1993 .

[22]  Robert L. Wainwright,et al.  A Study of Sparse Matrix Representations for Solving Linear Systems in a Functional Language , 1992, J. Funct. Program..

[23]  Flemming Nielson,et al.  Two-level functional languages , 1992, Cambridge tracts in theoretical computer science.

[24]  Henry Massalin,et al.  Synthesis: an efficient implementation of fundamental operating system services , 1992 .

[25]  Andrew W. Appel,et al.  Separate compilation for Standard ML , 1994, PLDI '94.

[26]  Jeffrey C. Mogul,et al.  The packer filter: an efficient mechanism for user-level network code , 1987, SOSP '87.

[27]  Dawson R. Engler,et al.  C: a language for high-level, efficient, and machine-independent dynamic code generation , 1995, POPL '96.

[28]  Calton Pu,et al.  Fast, optimized Sun RPC using automatic program specialization , 1998, Proceedings. 18th International Conference on Distributed Computing Systems (Cat. No.98CB36183).

[29]  Marc Feeley,et al.  Using Multilisp for solving constraint satisfaction problems: An application to nucleic acid 3D structure determination , 1994, LISP Symb. Comput..

[30]  Markus Mock,et al.  Annotation-directed run-time specialization in C , 1997 .

[31]  Dawson R. Engler,et al.  VCODE: a retargetable, extensible, very fast dynamic code generation system , 1996, PLDI '96.

[32]  Bell Telephone,et al.  Regular Expression Search Algorithm , 1968 .

[33]  Calton Pu,et al.  Threads and input/output in the synthesis kernal , 1989, SOSP '89.

[34]  David Keppel,et al.  Shade: a fast instruction-set simulator for execution profiling , 1994, SIGMETRICS.

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

[36]  Robert Glück,et al.  Efficient Multi-level Generating Extensions for Program Specialization , 1995, PLILP.

[37]  Peter Lee,et al.  Signatures for a network protocol stack: a systems application of Standard ML , 1994, LFP '94.

[38]  Charles Consel,et al.  A general approach for run-time specialization and its application to C , 1996, POPL '96.

[39]  Charles Consel,et al.  Safe Operating System Specialization: the RPC Case Study , 1996 .

[40]  Steven McCanne,et al.  The BSD Packet Filter: A New Architecture for User-level Packet Capture , 1993, USENIX Winter.

[41]  HölzleUrs,et al.  Type feedback vs. concrete type inference , 1995 .

[42]  Brian N. Bershad,et al.  Extensibility safety and performance in the SPIN operating system , 1995, SOSP.