Effect Analysis for Programs with Callbacks

  • Etienne Kneuss
  • Viktor Kuncak
  • Philippe Suter
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8164)

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.

References

  1. 1.
    Banerjee, A., Naumann, D.A.: State based ownership, reentrance, and encapsulation. In: Gao, X.-X. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 387–411. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  2. 2.
    Barnett, M., DeLine, R., Fähndrich, M., Leino, K.R.M., Schulte, W.: Verification of object-oriented programs with invariants. J. Object Technology 3(6), 27–56 (2004)CrossRefGoogle Scholar
  3. 3.
    Berdine, J., Cook, B., Ishtiaq, S.: SLAyer: Memory safety for systems-level code. In: Gopalakrishnan, G., Qadeer, S. (eds.) CAV 2011. LNCS, vol. 6806, pp. 178–183. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  4. 4.
    Boyapati, C., Liskov, B., Shrira, L.: Ownership types for object encapsulation. In: POPL, pp. 213–223 (2003)Google Scholar
  5. 5.
    Cavalcanti, A., Naumann, D.A.: Forward simulation for data refinement of classes. In: Eriksson, L.-H., Lindsay, P.A. (eds.) FME 2002. LNCS, vol. 2391, pp. 471–490. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  6. 6.
    Chase, D.R., Wegman, M.N., Zadeck, F.K.: Analysis of pointers and structures. In: PLDI, pp. 296–310 (1990)Google Scholar
  7. 7.
    Clarke, D., Drossopoulou, S.: Ownership, encapsulation and the disjointness of type and effect. In: OOPSLA (2002)Google Scholar
  8. 8.
    Cooper, K.D., Kennedy, K.: Interprocedural side-effect analysis in linear time. In: PLDI, pp. 57–66 (1988)Google Scholar
  9. 9.
    Cousot, P., Cousot, R.: Modular static program analysis. In: Nigel Horspool, R. (ed.) CC 2002. LNCS, vol. 2304, pp. 159–178. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  10. 10.
    Deutsch, A.: A storeless model of aliasing and its abstractions using finite representations of right-regular equivalence relations. In: Proc. Int. Conf. Computer Languages, Oakland, California, pp. 2–13 (1992)Google Scholar
  11. 11.
    Dinsdale-Young, T., Dodds, M., Gardner, P., Parkinson, M.J., Vafeiadis, V.: Concurrent abstract predicates. In: D’Hondt, T. (ed.) ECOOP 2010. LNCS, vol. 6183, pp. 504–528. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  12. 12.
    Fähndrich, M., Leino, K.R.M.: Heap monotonic typestates. In: Aliasing, Confinement and Ownership in object-oriented programming (IWACO) (2003)Google Scholar
  13. 13.
    Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns. Addison-Wesley, Reading (1994)Google Scholar
  14. 14.
    Jensen, S.H., Møller, A., Thiemann, P.: Interprocedural analysis with lazy propagation. In: Cousot, R., Martel, M. (eds.) SAS 2010. LNCS, vol. 6337, pp. 320–339. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  15. 15.
    Jifeng, H., Hoare, C.A.R., Sanders, J.W.: Data refinement refined. In: Robinet, B., Wilhelm, R. (eds.) ESOP 1986. LNCS, vol. 213, pp. 187–196. Springer, Heidelberg (1986)CrossRefGoogle Scholar
  16. 16.
    Jouvelot, P., Gifford, D.K.: Algebraic reconstruction of types and effects. In: POPL, pp. 303–310 (1991)Google Scholar
  17. 17.
    Larus, J.R., Hilfinger, P.N.: Detecting conflicts between structure accesses. In: Proc. ACM PLDI, Atlanta, GA (June 1988)Google Scholar
  18. 18.
    Madhavan, R., Ramalingam, G., Vaswani, K.: Purity analysis: An abstract interpretation formulation. In: Yahav, E. (ed.) Static Analysis. LNCS, vol. 6887, pp. 7–24. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  19. 19.
    Madhavan, R., Ramalingam, G., Vaswani, K.: Modular heap analysis for higher-order programs. In: Miné, A., Schmidt, D. (eds.) SAS 2012. LNCS, vol. 7460, pp. 370–387. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  20. 20.
    Might, M., Smaragdakis, Y., Horn, D.V.: Resolving and exploiting the k-CFA paradox: illuminating functional vs. object-oriented program analysis. In: PLDI, pp. 305–315 (2010)Google Scholar
  21. 21.
    Milanova, A., Rountev, A., Ryder, B.G.: Parameterized object sensitivity for points-to and side-effect analyses for java. In: ISSTA, pp. 1–11 (2002)Google Scholar
  22. 22.
    Nordio, M., Calcagno, C., Meyer, B., Müller, P., Tschannen, J.: Reasoning about function objects. In: Vitek, J. (ed.) TOOLS 2010. LNCS, vol. 6141, pp. 79–96. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  23. 23.
    Parkinson, M.J., Summers, A.J.: The relationship between separation logic and implicit dynamic frames. In: Barthe, G. (ed.) ESOP 2011. LNCS, vol. 6602, pp. 439–458. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  24. 24.
    de Roever, W.P., Engelhardt, K.: Data Refinement: Model-oriented proof methods and their comparison. Cambridge University Press (1998)Google Scholar
  25. 25.
    Rountev, A.: Precise identification of side-effect-free methods in java. In: ICSM, pp. 82–91 (2004)Google Scholar
  26. 26.
    Rytz, L., Odersky, M., Haller, P.: Lightweight polymorphic effects. In: Noble, J. (ed.) ECOOP 2012. LNCS, vol. 7313, pp. 258–282. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  27. 27.
    Sălcianu, A., Rinard, M.: Purity and side effect analysis for Java programs. In: Cousot, R. (ed.) VMCAI 2005. LNCS, vol. 3385, pp. 199–215. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  28. 28.
    Salcianu, A.D.: Pointer Analysis for Java Programs: Novel Techniques and Applications. Ph.D. thesis, Massachusetts Institute of Technology (2006)Google Scholar
  29. 29.
    Shivers, O.: Control-flow analysis in scheme. In: PLDI, pp. 164–174 (1988)Google Scholar
  30. 30.
    Smans, J., Jacobs, B., Piessens, F.: Implicit dynamic frames: Combining dynamic frames and separation logic. In: Drossopoulou, S. (ed.) ECOOP 2009. LNCS, vol. 5653, pp. 148–172. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  31. 31.
    Tkachuk, O., Dwyer, M.B.: Adapting side effects analysis for modular program model checking. In: ESEC / SIGSOFT FSE, pp. 188–197 (2003)Google Scholar
  32. 32.
    Whaley, J., Rinard, M.: Compositional pointer and escape analysis for Java programs. In: Proc. 14th Annual ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications, Denver (November 1999)Google Scholar
  33. 33.
    Yorsh, G., Yahav, E., Chandra, S.: Generating precise and concise procedure summaries. In: POPL, pp. 221–234. ACM (2008)Google Scholar

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

Personalised recommendations