A Comprehensive Approach to Array Bounds Check Elimination for Java

  • Feng Qian
  • Laurie Hendren
  • Clark Verbrugge
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2304)


This paper reports on a comprehensive approach to eliminating array bounds checks in Java. Our approach is based upon three analyses. The first analysis is a flow-sensitive intraprocedural analysis called variable constraint analysis (VCA). This analysis builds a small constraint graph for each important point in a method, and then uses the information encoded in the graph to infer the relationship between array index expressions and the bounds of the array. Using VCA as the base analysis, we also show how two further analyses can improve the results of VCA. Array field analysis is applied on each class and provides information about some arrays stored in fields, while rectangular array analysis is an interprocedural analysis to approximate the shape of arrays, and is useful for finding rectangular (non-ragged) arrays.

We have implemented all three analyses using the Soot bytecode optimization/ annotation framework and we transmit the results of the analysis to virtual machines using class file attributes. We have modified the Kaffe JIT, and IBM’s High Performance Compiler for Java (HPCJ) to make use of these attributes, and we demonstrate significant speedups.


Virtual Machine Basic Block Live Local Constraint Graph Program Point 
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.


  1. 1.
    R. Bodik, R. Gupta, and V. Sarkar. ABCD: Eliminating Array Bounds Checks on Demand. In Proceedings of the ACM SIGPLAN’ 00 Conference on Programming Language Design and Implementation(PLDI), pages 321–333, Vancouver, BC, Canada, June 2000.Google Scholar
  2. 2.
    M. Cierniak and W. Li. Optimizing Java bytecodes. Concurrency, Practice and Experience, 9(6):427–444, 1997.CrossRefGoogle Scholar
  3. 3.
    T. H. Cormen, C. E. Leiserson, and R. L. Rivest. Introduction to Algorithms. McGraw-Hill and MIT Press, 1990.Google Scholar
  4. 4.
    R. Gupta. A fresh look at optimizing array bound checking. In Proceedings of the ACM SIGPLAN’ 90 Conference on Programming Language Design and Implementation, pages 272–282, White Plains, NY, June 1990.Google Scholar
  5. 5.
    R. Gupta. Optimizing array bound checks using flow analysis. ACM Letters on Programming Languages and Systems, 2(1–4):135–150, 1993.CrossRefGoogle Scholar
  6. 6.
    S. Hoxey, F. Karim, B. Hay, and H. Warren, editors. The PowerPC Compiler Writer’s Guide. IBM Microelectronics Division, 1986.Google Scholar
  7. 7.
    V. Markstein, J. Cocke, and P. Markstein. Optimization of range checking. Proceedings of the SIGPLAN’82 Symposium on Compiler Construction, pages 114–119, June 1982.Google Scholar
  8. 8.
    S. S. Muchnick. Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997.Google Scholar
  9. 9.
    P. Pominville, F. Qian, R. Vallee-Rai, L. Hendren, and C. Verbrugge. A framework for optimizing java using attributes. In Proceedings of Compiler Construction, 2001, pages 334–554, 2001.Google Scholar
  10. 10.
    R. Shaham. Automatic removal of array memory leaks in Java. Master’s thesis, Tel-Aviv University, Tel-Aviv, Israel, September 1999. Available at
  11. 11.
    R. Shaham, E. K. Kolodner, and M. Sagiv. Automatic removal of array memory leaks in java. In D. A. Watt, editor, Compiler Construction, 9th International Conference, volume 1781 of Lecture Notes in Computer Science, pages 50–66, Berlin, Germany, March 2000. Springer.CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2002

Authors and Affiliations

  • Feng Qian
    • 1
  • Laurie Hendren
    • 1
  • Clark Verbrugge
    • 1
  1. 1.School of Computer ScienceMcGill UniversityUSA

Personalised recommendations