Skip to main content

A Self-certifying Compilation Framework for WebAssembly

  • Conference paper
  • First Online:
Verification, Model Checking, and Abstract Interpretation (VMCAI 2021)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 12597))

Abstract

A self-certifying compiler is designed to generate a correctness proof for each optimization performed during compilation. The generated proofs are checked automatically by an independent proof validator. The outcome is formally verified compilation, achieved without formally verifying the compiler. This paper describes the design and implementation of a self-certifying compilation framework for WebAssembly, a new intermediate language supported by all major browsers.

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

Notes

  1. 1.

    The implementation is available as open source at https://github.com/nokia/web-assembly-self-certifying-compilation-framework.

  2. 2.

    The full specification is at https://webassembly.github.io/spec/.

  3. 3.

    https://github.com/WebAssembly/spec.

  4. 4.

    The formal statements follow Dijkstra-Scholten convention [9], where \([\varphi ]\) indicates that the expression \(\varphi \) is valid. We use \(d(X,Y,\ldots )\) to abbreviate \((d(X),d(Y),\ldots )\).

  5. 5.

    The full correspondence for edge \(e_3\) is that \(K,G,M=K',G',M'\) (stack, global, and main memories are identical) and that \(L[0]=L'[0]\), \(L[1]=L'[3]\), and \(L[2]=L'[5]\).

  6. 6.

    Excluding comments. Measured with cloc: https://github.com/AlDanial/cloc.

  7. 7.

    https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm.

References

  1. Barrett, C.W., Fang, Y., Goldberg, B., Hu, Y., Pnueli, A., Zuck, L.D.: TVOC: a translation validator for optimizing compilers. In: CAV, pp. 291–295 (2005)

    Google Scholar 

  2. Barthe, G., Demange, D., Pichardie, D.: Formal verification of an SSA-based middle-end for CompCert. ACM Trans. Program. Lang. Syst. 36(1), 4 (2014)

    Article  Google Scholar 

  3. Benton, N.: Simple relational correctness proofs for static analyses and program transformations. In: POPL, pp. 14–25 (2004)

    Google Scholar 

  4. Bevier, W.R., Hunt, W.A., Moore, J.S., Young, W.D.: An approach to systems verification. J. Autom. Reasoning 5(4), 411–428 (1989)

    Article  Google Scholar 

  5. Blum, M., Kannan, S.: Designing programs that check their work. J. ACM 42(1), 269–291 (1995)

    Article  Google Scholar 

  6. Churchill, B.R., Padon, O., Sharma, R., Aiken, A.: Semantic program alignment for equivalence checking. In: PLDI, pp. 1027–1040 (2019)

    Google Scholar 

  7. Cytron, R., Ferrante, J., Rosen, B.K., Wegman, M.N., Zadeck, F.K.: Efficiently computing static single assignment form and the control dependence graph. ACM Trans. Program. Lang. Syst. 13(4), 451–490 (1991)

    Article  Google Scholar 

  8. Dahiya, M., Bansal, S.: Modeling undefined behaviour semantics for checking equivalence across compiler optimizations. In: HVC, pp. 19–34 (2017)

    Google Scholar 

  9. Dijkstra, E.W., Scholten, C.S.: Predicate calculus and program semantics. In: Texts and Monographs in Computer Science, Springer, New York (1990). https://doi.org/10.1007/978-1-4612-3228-5

  10. Fedyukovich, G., Gurfinkel, A., Sharygina, N.: Automated discovery of simulation between programs. In: Davis, M., Fehnker, A., McIver, A., Voronkov, A. (eds.) LPAR 2015. LNCS, vol. 9450, pp. 606–621. Springer, Heidelberg (2015). https://doi.org/10.1007/978-3-662-48899-7_42

    Chapter  Google Scholar 

  11. Gjomemo, R., Namjoshi, K.S., Phung, P.H., Venkatakrishnan, V.N., Zuck, L.D.: From verification to optimizations. In: D’Souza, D., Lal, A., Larsen, K.G. (eds.) VMCAI 2015. LNCS, vol. 8931, pp. 300–317. Springer, Heidelberg (2015). https://doi.org/10.1007/978-3-662-46081-8_17

    Chapter  MATH  Google Scholar 

  12. Godlin, B., Strichman, O.: Regression verification. In: Proceedings of the 46th Design Automation Conference, DAC 2009, San Francisco, CA, USA, July 26–31, 2009, pp. 466–471 (2009)

    Google Scholar 

  13. Godlin, B., Strichman, O.: Regression verification: proving the equivalence of similar programs. Softw. Test., Verif. Reliab. 23(3), 241–258 (2013)

    Google Scholar 

  14. Haas, A., et al.: Bringing the web up to speed with WebAssembly. In: PLDI, pp. 185–200 (2017)

    Google Scholar 

  15. Jourdan, J., Pottier, F., Leroy, X.: Validating LR(1) parsers. In: ESOP, pp. 397–416 (2012)

    Google Scholar 

  16. Kang, J., Kim, Y., et al.: Crellvm: verified credible compilation for LLVM. In: PLDI, pp. 631–645 (2018)

    Google Scholar 

  17. Lahiri, S.K., Hawblitzel, C., Kawaguchi, M., Rebêlo, H.: SYMDIFF: a language-agnostic semantic diff tool for imperative programs. In: CAV, pp. 712–717 (2012)

    Google Scholar 

  18. Leroy, X.: Formal certification of a compiler back-end or: programming a compiler with a proof assistant. In: POPL, pp. 42–54. ACM (2006)

    Google Scholar 

  19. Leroy, X.: Formal verification of a realistic compiler. Commun. ACM 52(7), 107–115 (2009)

    Article  Google Scholar 

  20. Marinov, D.: Credible Compilation. Master’s thesis, Massachusetts Institute of Technology (2000)

    Google Scholar 

  21. McCarthy, J., Painter, J.: Correctness of a compiler for arithmetic expressions, pp. 33–41. American Mathematical Society (1967)

    Google Scholar 

  22. de Moura, L., Bjørner, N.: Z3: an efficient SMT solver. In: Ramakrishnan, C.R., Rehof, J. (eds.) TACAS 2008. LNCS, vol. 4963, pp. 337–340. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-78800-3_24

    Chapter  Google Scholar 

  23. Namjoshi, K.S.: Certifying model checkers. In: CAV, pp. 2–13 (2001)

    Google Scholar 

  24. Namjoshi, K.S.: Witnessing an SSA transformation. In: VeriSure Workshop, CAV (2014). https://kedar-namjoshi.github.io/papers/Namjoshi-VeriSure-CAV-2014.pdf

  25. Namjoshi, K.S., Singhania, N.: Loopy: Programmable and formally verified loop transformations. In: SAS, pp. 383–402 (2016)

    Google Scholar 

  26. Namjoshi, K.S., Tagliabue, G., Zuck, L.D.: A witnessing compiler: a proof of concept. In: RV, pp. 340–345 (2013)

    Google Scholar 

  27. Namjoshi, K.S., Zuck, L.D.: Witnessing program transformations. In: Logozzo, F., Fähndrich, M. (eds.) SAS 2013. LNCS, vol. 7935, pp. 304–323. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-38856-9_17

    Chapter  Google Scholar 

  28. Necula, G.: Translation validation of an optimizing compiler. In: (PLDI) 2000, pp. 83–95 (2000)

    Google Scholar 

  29. Peled, D.A., Pnueli, A., Zuck, L.D.: From falsification to verification. In: FSTTCS, pp. 292–304 (2001)

    Google Scholar 

  30. Pnueli, A., Shtrichman, O., Siegel, M.: The code validation tool (CVT)- automatic verification of a compilation process. Software Tools Technol. Transfer 2(2), 192–201 (1998)

    Article  Google Scholar 

  31. Rinard, M.: Credible Compilation. Tech. Rep. MIT-LCS-TR-776, MIT (1999)

    Google Scholar 

  32. Samet, H.: Automatically proving the correctness of translations involving optimized code - research sponsored by Advanced Research Projects Agency, ARPA order no. 2494. Ph.D. thesis, Stanford University (1975)

    Google Scholar 

  33. Strichman, O., Veitsman, M.: Regression verification for unbalanced recursive functions. In: Fitzgerald, J., Heitmeyer, C., Gnesi, S., Philippou, A. (eds.) FM 2016. LNCS, vol. 9995, pp. 645–658. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-48989-6_39

    Chapter  Google Scholar 

  34. Zaks, A., Pnueli, A.: Program analysis for compiler validation. In: PASTE, pp. 1–7 (2008)

    Google Scholar 

  35. Zhang, L., Malik, S.: Validating SAT solvers using an independent resolution-based checker: practical implementations and other applications. In: DATE, pp. 10880–10885 (2003)

    Google Scholar 

  36. Zhao, J., Nagarakatte, S., Martin, M.M.K., Zdancewic, S.: Formal verification of SSA-based optimizations for LLVM. In: PLDI 2013, pp. 175–186 (2013)

    Google Scholar 

  37. Zuck, L.D., Pnueli, A., Goldberg, B., Barrett, C.W., Fang, Y., Hu, Y.: Translation and run-time validation of loop transformations. Formal Methods Syst. Des. 27(3), 335–360 (2005)

    Article  Google Scholar 

Download references

Acknowledgments

This material is based upon work supported by the National Science Foundation under Grant CCF-1563393. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Kedar S. Namjoshi .

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

Namjoshi, K.S., Xue, A. (2021). A Self-certifying Compilation Framework for WebAssembly. In: Henglein, F., Shoham, S., Vizel, Y. (eds) Verification, Model Checking, and Abstract Interpretation. VMCAI 2021. Lecture Notes in Computer Science(), vol 12597. Springer, Cham. https://doi.org/10.1007/978-3-030-67067-2_7

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-67067-2_7

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-67066-5

  • Online ISBN: 978-3-030-67067-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics