Effect Analysis for Programs with Callbacks

  • Etienne Kneuss
  • Viktor Kuncak
  • Philippe Suter
Conference paper

DOI: 10.1007/978-3-642-54108-7_3

Volume 8164 of the book series Lecture Notes in Computer Science (LNCS)
Cite this paper as:
Kneuss E., Kuncak V., Suter P. (2014) Effect Analysis for Programs with Callbacks. In: Cohen E., Rybalchenko A. (eds) Verified Software: Theories, Tools, Experiments. VSTTE 2013. Lecture Notes in Computer Science, vol 8164. Springer, Berlin, Heidelberg

Abstract

We introduce a precise interprocedural effect analysis for programs with mutable state, dynamic object allocation, and dynamic dispatch. Our analysis is precise even in the presence of dynamic dispatch where the context-insensitive estimate on the number of targets is very large. This feature makes our analysis appropriate for programs that manipulate first-class functions (callbacks). We present a framework in which programs are enriched with special effect statements, and define the semantics of both program and effect statements as relations on states. Our framework defines a program composition operator that is sound with respect to relation composition. Computing the summary of a procedure then consists of composing all its program statements to produce a single effect statement. We propose a strategy for applying the composition operator in a way that balances precision and efficiency.

We instantiate this framework with a domain for tracking read and write effects, where relations on program states are abstracted as graphs. We implemented the analysis as a plugin for the Scala compiler. We analyzed the Scala standard library containing 58000 methods and classified them into several categories according to their effects. Our analysis proves that over one half of all methods are pure, identifies a number of conditionally pure methods, and computes summary graphs and regular expressions describing the side effects of non-pure methods.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Springer-Verlag Berlin Heidelberg 2014

Authors and Affiliations

  • Etienne Kneuss
    • 1
  • Viktor Kuncak
    • 1
  • Philippe Suter
    • 1
    • 2
  1. 1.École Polytechnique Fédérale de Lausanne (EPFL)Switzerland
  2. 2.IBM T.J. Watson Research CenterYorktown HeightsUSA