Skip to main content

Deriving Compilers and Virtual Machines for a Multi-level Language

  • Conference paper
Programming Languages and Systems (APLAS 2007)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 4807))

Included in the following conference series:

Abstract

We develop virtual machines and compilers for a multi-level language, which supports multi-stage specialization by composing program fragments with quotation mechanisms. We consider two styles of virtual machines—ones equipped with special instructions for code generation and ones without—and show that the latter kind can deal with, more easily, low-level code generation, which avoids the overhead of (run-time) compilation by manipulating instruction sequences, rather than source-level terms, as data. The virtual machines and accompanying compilers are derived by program transformation, which extends Ager et al.’s derivation of virtual machines from evaluators.

Supported in part by Grant-in-Aid for Scientific Research No. 19300007 from MEXT of Japan.

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

Access this chapter

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

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Nielson, F., Nielson, H.R.: Two-Level Functional Languages. Cambridge University Press, Cambridge (1992)

    MATH  Google Scholar 

  2. Glück, R., Jørgensen, J.: Efficient multi-level generating extensions for program specialization. In: Swierstra, S.D. (ed.) PLILP 1995. LNCS, vol. 982, pp. 259–278. Springer, Heidelberg (1995)

    Chapter  Google Scholar 

  3. Davies, R.: A temporal-logic approach to binding-time analysis. In: Proc. of IEEE LICS, pp. 184–195 (July 1996)

    Google Scholar 

  4. Wickline, P., Lee, P., Pfenning, F.: Run-time code generation and Modal-ML. In: Proc. of ACM PLDI, pp. 224–235 (1998)

    Google Scholar 

  5. Taha, W., Benaissa, Z.E.A., Sheard, T.: Multi-stage programming: Axiomatization and type-safety. In: Larsen, K.G., Skyum, S., Winskel, G. (eds.) ICALP 1998. LNCS, vol. 1443, pp. 918–929. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  6. Moggi, E., Taha, W., Benaissa, Z.E.A., Sheard, T.: An idealized MetaML: Simpler, and more expressive. In: Swierstra, S.D. (ed.) ESOP 1999 and ETAPS 1999. LNCS, vol. 1576, pp. 193–207. Springer, Heidelberg (1999)

    Chapter  Google Scholar 

  7. Taha, W., Sheard, T.: MetaML and multi-stage programming with explicit annotations. Theoretical Computer Science 248, 211–242 (2000)

    Article  MATH  Google Scholar 

  8. Davies, R., Pfenning, F.: A modal analysis of staged computation. Journal of the ACM 48(3), 555–604 (2001)

    Article  MathSciNet  Google Scholar 

  9. Taha, W., Nielsen, M.F.: Environment classifiers. In: Proc. of ACM POPL, pp. 26–37 (2003)

    Google Scholar 

  10. Calcagno, C., Moggi, E., Taha, W.: ML-like inference for classifiers. In: Schmidt, D. (ed.) ESOP 2004. LNCS, vol. 2986, pp. 79–93. Springer, Heidelberg (2004)

    Google Scholar 

  11. Yuse, Y., Igarashi, A.: A modal type system for multi-level generating extensions with persistent code. In: Proc. of ACM PPDP, pp. 201–212. ACM Press, New York (2006)

    Google Scholar 

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

    Article  Google Scholar 

  13. Masuhara, H., Yonezawa, A.: Run-time bytecode specialization: A portable approach to generating optimized specialized code. In: Danvy, O., Filinski, A. (eds.) PADO 2001. LNCS, vol. 2053, pp. 138–154. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  14. Consel, C., Lawall, J.L., Meur, A.F.L.: A tour of Tempo: A program specializer for the C language. Science of Computer Programming 52(1–3), 341–370 (2004)

    Article  MATH  MathSciNet  Google Scholar 

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

    Article  MATH  Google Scholar 

  16. Cousineau, G., Curien, P.L., Mauny, M.: The categorical abstract machine. Science of Computer Programming 8(2), 173–202 (1987)

    Article  MATH  MathSciNet  Google Scholar 

  17. Ager, M.S., Biernacki, D., Danvy, O., Midtgaard, J.: From interpreter to compiler and virtual machine: A functional derivation. Technical Report RS-03-14, BRICS (March 2003)

    Google Scholar 

  18. Ager, M.S., Biernacki, D., Danvy, O., Midtgaard, J.: A functional correspondence between evaluators and abstract machines. In: Proc. of ACM PPDP, pp. 8–19 (2003)

    Google Scholar 

  19. Grégoire, B., Leroy, X.: A compiled implementation of strong reduction. In: Proc. of ACM ICFP, pp. 235–246 (2002)

    Google Scholar 

  20. Kohlbecker, E., Friedman, D.P., Felleisen, M., Duba, B.: Hygienic macro expansion. In: Proc. of ACM LFP, pp. 151–161 (1986)

    Google Scholar 

  21. Reynolds, J.C.: Definitional interpreters for higher-order programming languages. Higher-Order Symbolic Computation 11(4), 363–397 (1998)

    Article  MATH  Google Scholar 

  22. Felleisen, M., Friedman, D.P.: Control operators, the SECD machine, and the λ-calculus. In: Proc. Formal Description of Prog. Concepts III, pp. 193–217 (1986)

    Google Scholar 

  23. Calcagno, C., Taha, W., Huang, L., Leroy, X.: Implementing multi-stage languages using ASTs, gensym, and reflection. In: Pfenning, F., Smaragdakis, Y. (eds.) GPCE 2003. LNCS, vol. 2830, pp. 57–76. Springer, Heidelberg (2003)

    Google Scholar 

  24. Leone, M., Lee, P.: Optimizing ML with run-time code generation. In: Proc. of ACM PLDI, pp. 137–148 (1996)

    Google Scholar 

  25. Marlet, R., Consel, C., Boinot, P.: Efficient incremental run-time specialization for free. In: Proc. of ACM PLDI, pp. 281–292 (1999)

    Google Scholar 

  26. Consel, C., Noël, F.: A general approach for run-time specialization and its application to C. In: Proc. of ACM POPL, pp. 145–156 (1996)

    Google Scholar 

  27. Krivine, J.L.: A call-by-name lambda-calculus machine. Available online, from http://www.pps.jussieu.fr/~krivine

  28. Ager, M.S., Danvy, O., Midtgaard, J.: A functional correspondence between call-by-need evaluators and lazy abstract machines. Information Processing Letters 90(5), 223–232 (2004)

    Article  MathSciNet  Google Scholar 

  29. Ager, M.S., Danvy, O., Midtgaard, J.: A functional correspondence between monadic evaluators and abstract machines for languages with computational effects. Theoretical Computer Science 342(1), 149–172 (2005)

    Article  MATH  MathSciNet  Google Scholar 

  30. Leroy, X.: The ZINC experiment: An economical implementation of the ML language. Technical Report 117, INRIA (1990)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Zhong Shao

Rights and permissions

Reprints and permissions

Copyright information

© 2007 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Igarashi, A., Iwaki, M. (2007). Deriving Compilers and Virtual Machines for a Multi-level Language. In: Shao, Z. (eds) Programming Languages and Systems. APLAS 2007. Lecture Notes in Computer Science, vol 4807. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-76637-7_14

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-76637-7_14

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-76636-0

  • Online ISBN: 978-3-540-76637-7

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics