Skip to main content

Towards Demonstrably Correct Compilation of Java Byte Code

  • Conference paper
Formal Methods for Components and Objects (FMCO 2008)

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

Included in the following conference series:

Abstract

In this paper we investigate the feasibility of a demonstrably correct compiler for Java bytecode. We first examine the suitability of adapting the existing high assurance compiler DeCCo for the Pascal-like language PASP, based on a Z formalisation of the compiler manually transcribed to Prolog. During the investigation we have uncovered several problematic issues and argue that these can be avoided by formally deriving the code of the compiler from the formal specification, rather than manually transcribing it. We have conducted a case study, developing a compiler for a subset of Java bytecode to an idealised RISC processor using the B-method. We show that refinement is a natural way to model compilation and that the B-method can in principle be used to develop a demonstrably correct compiler. In particular, the tool support for B turned out to be extremely valuable: animation, automated refinement checking, and proof each uncovered a series of mistakes.

This work has been supported by AWE plc. within the JASP project.

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. Pnueli, E.S.A., Siegel, M.: Translation validation. In: Steffen, B. (ed.) TACAS 1998. LNCS, vol. 1384, p. 151. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  2. Abrial, J.-R.: The B-Book. Cambridge University Press, Cambridge (1996)

    Book  MATH  Google Scholar 

  3. Abrial, J.-R., Schuman, S.A., Meyer, B.: Specification language. In: McKeag, R.M., Macnaghten, A.M. (eds.) On the Construction of Programs: An Advanced Course, pp. 343–410. Cambridge University Press, Cambridge (1980)

    Google Scholar 

  4. Aho, A.V., Lam, M.S., Sethi, R., Ullman, J.D.: Compilers. Principles, Techniques, and Tools, 2nd edn. Addison-Wesley, Reading (2007)

    MATH  Google Scholar 

  5. Albert, E., Arenas, P., Genaim, S., Puebla, G., Zanardini, D.: Cost analysis of java bytecode. In: De Nicola, R. (ed.) ESOP 2007. LNCS, vol. 4421, pp. 157–172. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  6. Albert, E., Genaim, S., Gómez-Zamalloa, M.: Heap space analysis for java bytecode. In: Morrisett, G., Sagiv, M. (eds.) ISMM, pp. 105–116. ACM Press, New York (2007)

    Chapter  Google Scholar 

  7. Albert, E., Gómez-Zamalloa, M., Hubert, L., Puebla, G.: Verification of java bytecode using analysis and transformation of logic programs. In: Hanus, M. (ed.) PADL 2007. LNCS, vol. 4354, pp. 124–139. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  8. Apt, K.R., Marchiori, E.: Reasoning about Prolog programs: from modes through types to assertions. Formal Aspects of Computing 6(6A), 743–765 (1994)

    Article  MATH  Google Scholar 

  9. Börger, E.: Abstract State Machines. Springer, Heidelberg (2003)

    Book  MATH  Google Scholar 

  10. Bowen, J.P.: Formal Specification and Documentation using Z. International Thomson Computer Press (1996)

    Google Scholar 

  11. Buckley, A.: Jsr-000202 JavaTM class file specification update evaluation 1.0 final release. Technical report (December 2006), http://jcp.org/en/jsr/detail?id=202

  12. ClearSy, Aix-en-Provence, France. B4Free: Tool and Manuals (2006), http://www.b4free.com

  13. Cousot, P., Cousot, R.: Abstract interpretation: A unified lattice model for static analysis of programs by construction of approximation of fixed points. In: Proceedings of the 4th ACM Symposium on Principles of Programming Languages, Los Angeles, pp. 238–252. ACM Press, New York (1977)

    Google Scholar 

  14. Dold, A., Gaul, T., Vialard, V., Zimmermann, W.: Asm-based mechanized verification of compiler back-ends. In: Workshop on Abstract State Machines, pp. 50–67 (1998)

    Google Scholar 

  15. Dold, A., Vialard, V.: Formal verification of a compiler back-end generic checker program. In: Bjørner, D., Broy, M., Zamulin, A.V. (eds.) PSI 1999. LNCS, vol. 1755, pp. 470–480. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  16. Dold, A., von Henke, F.W., Goerigk, W.: A completely verified realistic bootstrap compiler. Int. J. Found. Comput. Sci. 14(4), 659 (2003)

    Article  MathSciNet  MATH  Google Scholar 

  17. Eichberg, M., Kahl, M., Saha, D., Mezini, M., Ostermann, K.: Automatic incrementalization of prolog based static analyses. In: Hanus, M. (ed.) PADL 2007. LNCS, vol. 4354, pp. 109–123. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  18. Evans, N., Ifill, W.: Hardware verification and beyond: Using B at AWE. In: Julliand, J., Kouchnarenko, O. (eds.) B 2007. LNCS, vol. 4355, pp. 260–261. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  19. Gómez-Zamalloa, M., Albert, E., Puebla, G.: Improving the decompilation of java bytecode to prolog by partial evaluation. Electr. Notes Theor. Comput. Sci. 190(1), 85–101 (2007)

    Article  Google Scholar 

  20. Klein, G., Nipkow, T.: A machine-checked model for a Java-like language, virtual machine and compiler. ACM Trans. Prog. Lang. Syst. 28(4), 619–695 (2006)

    Article  Google Scholar 

  21. Klose, K., Ostermann, K., Leuschel, M.: Partial evaluation of pointcuts. In: Hanus, M. (ed.) PADL 2007. LNCS, vol. 4354, pp. 320–334. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  22. Leonard, E.I., Heitmeyer, C.L.: Program synthesis from formal requirements specifications using apts. Higher-Order and Symbolic Computation 16(1-2), 63–92 (2003)

    Article  MATH  Google Scholar 

  23. Leroy, X.: Formal certification of a compiler back-end, or: programming a compiler with a proof assistant. In: 33rd symposium Principles of Programming Languages, pp. 42–54. ACM Press, New York (2006)

    Google Scholar 

  24. Leroy, X., Blazy, S.: Formal verification of a C-like memory model and its uses for verifying program transformations. Journal of Automated Reasoning 41(1), 1–31 (2008)

    Article  MathSciNet  MATH  Google Scholar 

  25. Leuschel, M.: Towards demonstrably correct compilation of java byte code. Technical report, Institut für Informaitk, Universität Düsseldorf (2009), http://www.stups.uni-duesseldorf.de/~leuschel/publication.php

  26. McCarthy, J., Painter, J.: Correctness of a compiler for arithmetic expressions. Technical report, MIT AI Lab Memo (1967)

    Google Scholar 

  27. Nettleton, C., Ifill, W., Marsh, C.: Towards a demonstrably-correct Ada compiler. In: Srivastava, A., Baird III, L.C. (eds.) SIGAda, pp. 89–96. ACM, New York (2007)

    Chapter  Google Scholar 

  28. Paige, R.: Viewing a program transformation system at work. In: Rodríguez-Artalejo, M., Levi, G. (eds.) ALP 1994. LNCS, vol. 850, p. 5. Springer, Heidelberg (1994)

    Chapter  Google Scholar 

  29. Pichardie, D.: Bicolano – Byte Code Language in Coq. Summary appears in Mobius Deliverable 3.1 (2006), http://mobius.inria.fr/bicolano

  30. Plagge, D., Leuschel, M.: Validating Z Specifications using the ProB Animator and Model Checker. In: Davies, J., Gibbons, J. (eds.) IFM 2007. LNCS, vol. 4591, pp. 480–500. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  31. Rideau, L., Serpette, B.P., Leroy, X.: Tilting at windmills with Coq: formal verification of a compilation algorithm for parallel moves. Journal of Automated Reasoning 40(4), 307–326 (2008)

    Article  MathSciNet  MATH  Google Scholar 

  32. Schmidt, D.: Denotational Semantics: a Methodology for Language Development. W.C. Brown Publishers (1986)

    Google Scholar 

  33. Smaus, J.-G., Hill, P.M., King, A.: Mode analysis domains for typed logic programs. In: Bossi, A. (ed.) LOPSTR 1999. LNCS, vol. 1817, pp. 82–101. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  34. Smith, J., Nair, R.: Virtual Machines: Versatile Platforms for Systems and Processes. Morgan Kaufmann, San Francisco (2005)

    MATH  Google Scholar 

  35. Sorensen, I.: A mathematical AMN state based description of the ASP. Technical report, AWE (1998)

    Google Scholar 

  36. Spivey, J.M.: The Z Notation: A Reference Manual, 2nd edn. Prentice Hall International Series in Computer Science (1992)

    Google Scholar 

  37. Stärk, R.F., Schmid, J., Börger, E.: Java and the Java Virtual Machine. Springer, Heidelberg (2001)

    Book  MATH  Google Scholar 

  38. Stepney, S., Nabney, I.T.: The DeCCo project papers I-VI. Technical Report YCS-2002-358 – YCS-2002-363, Department of Computer Science, University of York (June 2003)

    Google Scholar 

  39. Tristan, J.-B., Leroy, X.: Formal verification of translation validators: A case study on instruction scheduling optimizations. In: 35th symposium Principles of Programming Languages, pp. 17–27. ACM Press, New York (2008)

    Google Scholar 

  40. Wang, Q., Gupta, G., Leuschel, M.: Towards provably correct code generation via horn logical continuation semantics. In: Hermenegildo, M.V., Cabeza, D. (eds.) PADL 2004. LNCS, vol. 3350, pp. 98–112. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2009 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Leuschel, M. (2009). Towards Demonstrably Correct Compilation of Java Byte Code. In: de Boer, F.S., Bonsangue, M.M., Madelaine, E. (eds) Formal Methods for Components and Objects. FMCO 2008. Lecture Notes in Computer Science, vol 5751. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-04167-9_7

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-04167-9_7

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-04166-2

  • Online ISBN: 978-3-642-04167-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics