A general approach for run-time specialization and its application to C

Specializing programs with respect to run-time invariants is an optimization technique that has shown to improve the performance of programs substantially. It allows a program to adapt to execution contexts that are valid for a limited time.Run-time specialization is being actively investigated in a variety of areas. For example, recently, major operating system research projects have been focusing on run-time specialization as a means to obtain efficiency from highly extensible and parameterized systems.This paper describes a general approach to run-time specialization. For a given program and a declaration of its run-time invariants, it automatically produces source templates at compile time, and transforms them so that they can be processed by a standard compiler. At run time, only minor operations need to be performed: selecting and copying templates, filling holes with run-time values, and relocating jump targets. As a consequence, run-time specialization is performed very efficiently and thus does not require the specialized code to be executed many times before its cost is amortized.Our approach improves on previous work in that: (1) templates are automatically produced from the source program and its invariants, (2) the approach is not machine dependent, (3) it is formally defined and proved correct, (4) it is efficient, as shown by our implementation for the C language.

[1]  Olivier Danvy,et al.  Tutorial notes on partial evaluation , 1993, POPL '93.

[2]  Jacques Noyé,et al.  A Uniform Approach for Compile-Time and Run-Time Specialization , 1996, Dagstuhl Seminar on Partial Evaluation.

[3]  Siau-Cheng Khoo,et al.  On-line & O(cid:11)-line Partial Evaluation: Semantic Speci(cid:12)cations and Correctness Proofs (cid:3) , 1993 .

[4]  Olivier Danvy,et al.  From Interpreting to Compiling Binding Times , 1990, ESOP.

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

[6]  Christopher W. Fraser,et al.  A code generation interface for ANSI C , 1991, Softw. Pract. Exp..

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

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

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

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

[11]  Calton Pu,et al.  The Synthesis Kernel , 1988, Comput. Syst..

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

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

[14]  Emin Gün Sirer,et al.  SPIN: an extensible microkernel for application-specific operating system services , 1994, EW 6.

[15]  Larry L. Peterson,et al.  Scout: a communications-oriented operating system , 1995, Proceedings 5th Workshop on Hot Topics in Operating Systems (HotOS-V).