Lock Inference in the Presence of Large Libraries

  • Khilan Gudka
  • Tim Harris
  • Susan Eisenbach
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7313)


Atomic sections can be implemented using lock inference. For lock inference to be practically useful, it is crucial that large libraries be analysed. However, libraries are challenging for static analysis, due to their cyclomatic complexity.

Existing approaches either ignore libraries, require library implementers to annotate which locks to take or only consider accesses performed upto one level deep in library call chains. Thus, some library accesses may go unprotected, leading to atomicity violations that atomic sections are supposed to eliminate.

We present a lock inference approach for Java that analyses library methods in full. We achieve this by (i) formulating lock inference as an Interprocedural Distributive Environment dataflow problem, (ii) using a graph representation for summary information and (iii) applying a number of optimisations to our implementation to reduce space-time requirements and locks inferred. We demonstrate the scalability of our approach by analysing the entire GNU Classpath library comprising 122KLOC.


Memory Usage Large Library Path Expression Internal Object Cyclomatic Complexity 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Lomet, D.B.: Process structuring, synchronization, and recovery using atomic actions. SIGPLAN Not. (1977)Google Scholar
  2. 2.
    Grossman, D.: The transactional memory/garbage collection analogy. In: Proceedings of the 22nd Annual ACM SIGPLAN Conference on Object-Oriented Programming Systems and Applications (2007)Google Scholar
  3. 3.
    Cantrill, B., Bonwick, J.: Real-world concurrency. ACM Queue (2008)Google Scholar
  4. 4.
    Sutter, H.: The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software. Dr. Dobb’s Journal (2005)Google Scholar
  5. 5.
    Larus, J., Rajwar, R.: Transactional Memory (Synthesis Lectures on Computer Architecture). Morgan & Claypool Publishers (2007)Google Scholar
  6. 6.
    Rountev, A., Sharp, M., Xu, G.: IDE Dataflow Analysis in the Presence of Large Object-Oriented Libraries. In: Hendren, L. (ed.) CC 2008. LNCS, vol. 4959, pp. 53–68. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  7. 7.
    McCabe, T.: A complexity measure. IEEE Trans. on Soft. Eng. (1976)Google Scholar
  8. 8.
    Hicks, M., Foster, J.S., Pratikakis, P.: Lock inference for atomic sections. In: Proceedings of the First ACM SIGPLAN Workshop on Languages Compilers, and Hardware Support for Transactional Computing (TRANSACT) (2006)Google Scholar
  9. 9.
    Cherem, S., Chilimbi, T.M., Gulwani, S.: Inferring locks for atomic sections. In: PLDI (2008)Google Scholar
  10. 10.
    Emmi, M., Fischer, J.S., Jhala, R., Majumdar, R.: Lock allocation. In: POPL (2007)Google Scholar
  11. 11.
    Zhang, Y., Sreedhar, V.C., Zhu, W., Sarkar, V., Gao, G.R.: Minimum Lock Assignment: A Method for Exploiting Concurrency among Critical Sections. In: Amaral, J.N. (ed.) LCPC 2008. LNCS, vol. 5335, pp. 141–155. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  12. 12.
    McCloskey, B., Zhou, F., Gay, D., Brewer, E.: Autolocker: synchronization inference for atomic sections. ACM SIGPLAN Notices (2006)Google Scholar
  13. 13.
    Halpert, R.L., Pickett, C.J.F., Verbrugge, C.: Component-based lock allocation. In: PACT (2007)Google Scholar
  14. 14.
    Cunningham, D., Gudka, K., Eisenbach, S.: Keep Off the Grass: Locking the Right Path for Atomicity. In: Hendren, L. (ed.) CC 2008. LNCS, vol. 4959, pp. 276–290. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  15. 15.
    Sagiv, Reps, Horwitz: Precise Interprocedural Dataflow Analysis with Applications to Constant Propagation. TCS: Theoretical Computer Science 167 (1996)Google Scholar
  16. 16.
    Vallée-Rai, R., Co, P., Gagnon, E., Hendren, L.J., Lam, P., Sundaresan, V.: Soot - a java bytecode optimization framework. In: CASCON (1999)Google Scholar
  17. 17.
    Gray, J.N., Lorie, R.A., Putzolu, G.R.: Granularity of locks in a shared data base. In: VLDB 1975: Proceedings of the 1st International Conference on Very Large Data Bases (1975)Google Scholar
  18. 18.
    Chan, B., Abdelrahman, T.S.: Run-time support for the automatic parallelization of java programs. J. Supercomput. (2004)Google Scholar
  19. 19.
    Bodden, E., Sewe, A., Sinschek, J., Oueslati, H., Mezini, M.: Taming reflection: Aiding static analysis in the presence of reflection and custom class loaders. In: ICSE 2011: International Conference on Software Engineering (2011)Google Scholar
  20. 20.
    Lhotak, O.: Program Analysis Using Binary Decision Diagrams. PhD thesisGoogle Scholar
  21. 21.
    Gudka, K., Eisenbach, S.: Fast Multi-Level Locks for Java: A Preliminary Performance Evaluation. In: EC2 2010: Workshop on Exploiting Concurrency Efficiently and Correctly (2010)Google Scholar
  22. 22.
    Lea, D.: The java.util.concurrent synchronizer framework. Sci. Comput. Program (2005)Google Scholar
  23. 23.
    Goetz, B., Peierls, T., Bloch, J., Bowbeer, J., Holmes, D., Lea, D.: Java Concurrency in Practice. Addison-Wesley (2006)Google Scholar
  24. 24.
    Magee, J., Kramer, J.: Concurrency: state models & Java programs. Wiley, New York (2006)Google Scholar
  25. 25.
    Harris, T., Marlow, S., Peyton-Jones, S., Herlihy, M.: Composable memory transactions. In: Proceedings of the Tenth ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (2005)Google Scholar
  26. 26.
    Blackburn, S.M., et al.: The DaCapo benchmarks: Java benchmarking development and analysis. In: OOPSLA 2006: Proceedings of the 21st Annual ACM SIGPLAN Conference on Object-Oriented Programing, Systems, Languages, and Applications (2006)Google Scholar
  27. 27.
    Halpert, R.L.: Static lock allocation. Master’s thesis. McGill University (2008)Google Scholar
  28. 28.
    Naumovich, G., Avrunin, G.S.: A conservative data flow algorithm for detecting all pairs of statement that happen in parallel. In: SIGSOFT FSE (1998)Google Scholar
  29. 29.
    Sharir, M., Pnueli, A.: Two approaches to interprocedural data flow analysis. In: Program Flow Analysis: Theory and Applications (1981)Google Scholar
  30. 30.
    Khedker, U.P., Karkare, B.: Efficiency, Precision, Simplicity, and Generality in Interprocedural Data Flow Analysis: Resurrecting the Classical Call Strings Method. In: Hendren, L. (ed.) CC 2008. LNCS, vol. 4959, pp. 213–228. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  31. 31.
    Gulwani, S., Tiwari, A.: Computing Procedure Summaries for Interprocedural Analysis. In: De Nicola, R. (ed.) ESOP 2007. LNCS, vol. 4421, pp. 253–267. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  32. 32.
    Rountev, A.: Component-Level Dataflow Analysis. In: Heineman, G.T., Crnković, I., Schmidt, H.W., Stafford, J.A., Ren, X.-M., Wallnau, K. (eds.) CBSE 2005. LNCS, vol. 3489, pp. 82–89. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  33. 33.
    Whaley, J., Lam, M.S.: An Efficient Inclusion-Based Points-To Analysis for Strictly-Typed Languages. In: Hermenegildo, M.V., Puebla, G. (eds.) SAS 2002. LNCS, vol. 2477, pp. 180–195. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  34. 34.
    Choi, J., Gupta, M., Serrano, M., Sreedhar, V., Midkiff, S.: Escape analysis for Java. In: Proceedings of the 14th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (1999)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Khilan Gudka
    • 1
  • Tim Harris
    • 2
  • Susan Eisenbach
    • 1
  1. 1.Imperial College LondonUK
  2. 2.Microsoft Research CambridgeUK

Personalised recommendations