Skip to main content

Managing Dynamic Changes in Multi-stage Program Generation Systems

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2487))

Abstract

In a multi-stage program generation (MSPG) system, a stage-s program generates a stage-s + 1 program when the values of some variables are known. We call such variables program parameters for stage-s.

When program parameters for a stage change during runtime, all later-stage program objects that are generated directly or indirectly based on them need to be dynamically regenerated. We make two contributions. a) We explore a metaobject protocol called reflection across stages (RAS), which allows later-stage program objects to refer back to earlier-stage program objects they originated from. Intercessory procedures can be specified by the earlier-stage program objects to be executed at, e.g., execution of the later stage objects. b) We apply RAS to automating runtime program regeneration, so that affected later-stage programs are automatically regenerated after program parameters change.

In an initial experiment, RAS incurred an overhead of 10% when program parameters are invariant. The overhead of RAS plus regeneration is amortized to zero over1.5 executions of the generated program object.

This material is based upon work supported by the National Science Foundation under Grant Nos. 0086116, 0085773, and 9817773.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. A. Bawden. Quasiquotation in lisp. In Proc. of the 1999 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, pages 4–12, Jan. 1999.

    Google Scholar 

  2. A. Bawden and J. Rees. Syntatic closures. In Proc. of the 1988 ACM Symposium on Lisp and Functional Programming, pages 86–95, 1988.

    Google Scholar 

  3. C. Calcagno, W. Taha, L. Huang, and X. Leroy. A bytecode-compiled, type-safe, multi-stage language. draft, Nov. 2001.

    Google Scholar 

  4. P. Castro, P. Chiu, T. Kremenek, and R. Muntz. A probabilistic location service for wireless network environments. In Proc. of the 2001 Ubiquitous Computing Conference, pages 18–34, Sept. 2001.

    Google Scholar 

  5. W. Clinger and J. Rees. Macros that work. In Proc. of the 1991 ACM Conference on Principles of Programming Languages, pages 155–162, 1991.

    Google Scholar 

  6. C. Consel and F. Noël. A general approach for run-time specialization and its application to C. In Proc. of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 145–156, 1996.

    Google Scholar 

  7. F.-N. Demers and J. Malenfant. Reflection in logic, functional and object-oriented programming: a short comparative study. In Proc. of the IJCAI’95 Workshop on Reflection and Metalevel Architectures and their Applications in AI, pages 29–38, Aug. 1995.

    Google Scholar 

  8. J. des Rivières and B. C. Smith. The implementation of procedurally reflective languages. In Proc. of the 1984 ACM Symposium on LISP and functional programming, pages 331–347, 1984.

    Google Scholar 

  9. D. R. Engler, W. C. Hsieh, and M. F. Kaashoek. ‘C: A language for high-level, efficient, and machine-independent dynamic code generation. In Proc. of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 131–144, Jan. 1996.

    Google Scholar 

  10. S. Ganz, A. Sabry, and W. Taha. Macros as multi-stage computations: Type-safe, generative, binding macros in MacroML. In Proc. of the 25th ACM Symposium on Principles of Programming Languages, Sept. 2001.

    Google Scholar 

  11. R. Glück and J. Jörgensen. Efficient multi-level generating extensions for program specialization. In Programming Languages: Implementations, Logics and programs (PLILP’95), volume 982 of Lecture Notes in Computer Science, pages 259–278. Springer, 1995.

    Chapter  Google Scholar 

  12. B. Grant, M. Mock, M. Philipose, C. Chambers, and S. Eggers. Annotation-directed run-time specialization in C. In Proc. of the Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pages 163–178, June 1997.

    Google Scholar 

  13. B. Grant, M. Mock, M. Philipose, C. Chambers, and S. Eggers. DyC: An expressive annotation-directed dynamic compiler for C. Theoretical Computer Science, 248(1-2): 147–199, Oct. 2000.

    Google Scholar 

  14. B. Harrison and T. Sheard. Dynamically adaptable software with metacomputations in a staged language. In W. Taha, editor, Proc. of the Second International Workshop on Semantics, Applications, and Implementation of Program Generation (SAIG 2001), volume 2196 of Lecture Notes in Computer Science, pages 163–182. Springer, Sept. 2001.

    Chapter  Google Scholar 

  15. C. Huang and A. Darwiche. Inference in belief networks: A procedural guide. International J. of Approximate Reasoning, 15(3):225–263, Oct. 1996.

    Google Scholar 

  16. G. Kiczales, J. des Riviéres, and D. G. Bobrow. The Art of the Metaobject Protocol. The MIT Press, Cambridge, Massachusetts, 1991.

    Google Scholar 

  17. R. Marlet, C. Consel, and P. Boinot. Efficient incremental run-time specialization for free. In Proc. of the ACM SIGPLAN Conference on Programming language Design and Implementation, pages 281–292, 1999.

    Google Scholar 

  18. M. Mock, C. Chambers, and S. Eggers. Calpa: A tool for automating selective dynamic compilation. In Proc. of the 33rd ACM SIGMICRO Symposium on Microarchitecture, pages 202–291, 2000.

    Google Scholar 

  19. E. Moggi, W. Taha, Z. E.-A. Banaissa, and T. Sheard. An idealized MetaML: Simpler, and more expressive. In Proc. of the 1999 European Symposium on Programming, volume 1576 of, pages 193–207. Springer, Mar. 1999.

    Google Scholar 

  20. F. Nielson and H. R. Nielson. Two-Level Functional Languages. Cambridge Tracts in Theoretical Computer Science vol. 34. Cambridge University Press, 1992.

    Google Scholar 

  21. M. Poletto, W. C. Hsieh, D. R. Engler, and M. F. Kaashoek. ‘C and tcc: A language and compiler for dynamic code generation. ACM Transactions on Programming Languages and Systems, 21(2):324–369, March 1999.

    Google Scholar 

  22. M. Shields, T. Sheard, and S. P. Jones. Dynamic typing as staged type inference. In Proc. of the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 289–302, Jan. 1998.

    Google Scholar 

  23. B. C. Smith. Reflection and semantics in Lisp. In Proc. of the 11th annual ACM symposium on Principles of programming languages, pages 23–35, 1984.

    Google Scholar 

  24. W. Taha. Multi-Stage Programming: Its Theory and Applications. PhD thesis, Oregon Graduate Institute of Science and Technology, Nov. 1999.

    Google Scholar 

  25. W. Taha. A sound reduction semantics for untyped CBN multi-stage computation. In Proc. of the 2000 ACM SIGPLAN workshop on Partial evaluation and semantics-based program manipulation, pages 34–43, Jan. 2000.

    Google Scholar 

  26. W. Taha, Z.-E.-A. Benaissa, and T. Sheard. Multi-stage programming: Axiomatization and type safety. In Proc. of the 25th International Colloquium on Automata, Languages, and Programming, pages 918–929, July 1998.

    Google Scholar 

  27. W. Taha and T. Sheard. Multi-stage programming with explicit annotations. In Proc. of the 1997 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation, pages 203–217, June 1997.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2002 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Wang, Z., Muntz, R.R. (2002). Managing Dynamic Changes in Multi-stage Program Generation Systems. In: Batory, D., Consel, C., Taha, W. (eds) Generative Programming and Component Engineering. GPCE 2002. Lecture Notes in Computer Science, vol 2487. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45821-2_20

Download citation

  • DOI: https://doi.org/10.1007/3-540-45821-2_20

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-44284-4

  • Online ISBN: 978-3-540-45821-0

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics