Skip to main content

A Formal Semantics of the GraalVM Intermediate Representation

  • Conference paper
  • First Online:
Automated Technology for Verification and Analysis (ATVA 2021)

Abstract

The optimization phase of a compiler is responsible for transforming an intermediate representation (IR) of a program into a more efficient form. Modern optimizers, such as that used in the GraalVM compiler, use an IR consisting of a sophisticated graph data structure that combines data flow and control flow into the one structure. As part of a wider project on the verification of optimization passes of GraalVM, this paper describes a semantics for its IR within Isabelle/HOL. The semantics consists of a big-step operational semantics for data nodes (which are represented in a graph-based static single assignment (SSA) form) and a small-step operational semantics for handling control flow including heap-based reads and writes, exceptions, and method calls. We have proved a suite of canonicalization optimizations and conditional elimination optimizations with respect to the semantics.

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 64.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 84.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

Similar content being viewed by others

Notes

  1. 1.

    A more abstract representation would be better but using natural numbers allows us to utilise Isabelle code generation facilities.

  2. 2.

    https://github.com/dacapobench/dacapobench.

  3. 3.

    In Isabelle/HOL “\(S \Rightarrow T\)” is the type of a function from S to T.

  4. 4.

    All theories are available at https://github.com/uqcyber/veriopt-releases/tree/atva2021.

  5. 5.

    The operation for allocating a new object could nondeterministically choose any unused object reference, but we have made it a deterministic function that allocates the next location to facilitate the use of Isabelle code generation facilities.

References

  1. Böhme, S., Moskal, M.: Heaps and data structures: a challenge for automated provers. In: Bjørner, N., Sofronie-Stokkermans, V. (eds.) CADE 2011. LNCS (LNAI), vol. 6803, pp. 177–191. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-22438-6_15

    Chapter  MATH  Google Scholar 

  2. Click, C.: Global code motion/global value numbering. In: PLDI 1995, pp. 246–257. ACM Press (1995). https://doi.org/10.1145/207110.207154

  3. Click, C., Cooper, K.D.: Combining analyses, combining optimizations. TOPLAS 17(2), 181–196 (1995). https://doi.org/10.1145/201059.201061

    Article  Google Scholar 

  4. Demange, D., Fernández de Retana, Y., Pichardie, D.: Semantic reasoning about the sea of nodes. In: CC 2018, pp. 163–173. ACM, New York (2018). https://doi.org/10.1145/3178372.3179503

  5. Duboscq, G., et al.: An intermediate representation for speculative optimizations in a dynamic compiler. In: VMIL 2013, pp. 1–10 (2013)

    Google Scholar 

  6. Ferrante, J., Ottenstein, K.J., Warren, J.D.: The program dependence graph and its use in optimization. ACM TOPLAS 9(3), 319–349 (1987). https://doi.org/10.1145/24039.24041

    Article  MATH  Google Scholar 

  7. Kumar, R., Myreen, M.O., Norrish, M., Owens, S.: CakeML: a verified implementation of ML. In: POPL 2014, pp. 179–191. ACM Press, January 2014. https://doi.org/10.1145/2535838.2535841

  8. Lattner, C., Adve, V.: LLVM: a compilation framework for lifelong program analysis & transformation. In: CGO 2004, pp. 75–86. IEEE Computer Society (2004)

    Google Scholar 

  9. Leroy, X., Blazy, S., Kästner, D., Schommer, B., Pister, M., Ferdinand, C.: CompCert - a formally verified optimizing compiler. In: ERTS 2016. SEE, Toulouse, January 2016. https://hal.inria.fr/hal-01238879

  10. Li, L., Gunter, E.L.: K-LLVM: a relatively complete semantics of LLVM IR. In: Hirschfeld, R., Pape, T. (eds.) ECOOP 2020, vol. 166, pp. 7:1–7:29. Dagstuhl, Germany (2020). https://doi.org/10.4230/LIPIcs.ECOOP.2020.7

  11. Lindholm, T., Yellin, F., Bracha, G., Buckley, A.: The Java virtual machine specification, February 2013. https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html. Chapter 4. The class File Format

  12. Lochbihler, A.: Mechanising a type-safe model of multithreaded Java with a verified compiler. J. Autom. Reason. 63(1), 243–332 (2018)

    Article  MathSciNet  Google Scholar 

  13. Nipkow, T., Paulson, L.C., Wenzel, M.: Isabelle/HOL: A Proof Assistant for Higher-Order Logic. LNCS, vol. 2283. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45949-9

    Book  MATH  Google Scholar 

  14. Oracle: GraalVM: Run programs faster anywhere (2020). https://github.com/oracle/graal

  15. Zhao, J., Nagarakatte, S., Martin, M.M., Zdancewic, S.: Formalizing the LLVM intermediate representation for verified program transformations. In: POPL 2012, pp. 427–440. ACM, New York (2012). https://doi.org/10.1145/2103656.2103709

Download references

Acknowledgements

Mark Utting’s position and Brae Webb’s scholarship are both funded in part by a gift from Oracle Labs. Thanks especially to Cristina Cifuentes, Paddy Krishnan and Andrew Craik from Oracle Labs Brisbane for their helpful feedback, and to the Oracle GraalVM compiler team for answering questions. Thanks to Chris Seaton for helping us extend the SeaFoam IR visualization tool to output the graph in Isabelle syntax. Thanks also to Kristian Thomassen for his work on the semantics of \(\phi \)-nodes and Sadra Bayat Tork who investigated IR graph invariants in the GraalVM compiler.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Brae J. Webb .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Webb, B.J., Utting, M., Hayes, I.J. (2021). A Formal Semantics of the GraalVM Intermediate Representation. In: Hou, Z., Ganesh, V. (eds) Automated Technology for Verification and Analysis. ATVA 2021. Lecture Notes in Computer Science(), vol 12971. Springer, Cham. https://doi.org/10.1007/978-3-030-88885-5_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-88885-5_8

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-88884-8

  • Online ISBN: 978-3-030-88885-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics