A Comprehensive Approach to Array Bounds Check Elimination for Java
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.
KeywordsVirtual Machine Basic Block Live Local Constraint Graph Program Point
- 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
- 3.T. H. Cormen, C. E. Leiserson, and R. L. Rivest. Introduction to Algorithms. McGraw-Hill and MIT Press, 1990.Google Scholar
- 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
- 6.S. Hoxey, F. Karim, B. Hay, and H. Warren, editors. The PowerPC Compiler Writer’s Guide. IBM Microelectronics Division, 1986.Google Scholar
- 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.S. S. Muchnick. Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997.Google Scholar
- 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.R. Shaham. Automatic removal of array memory leaks in Java. Master’s thesis, Tel-Aviv University, Tel-Aviv, Israel, September 1999. Available at http://www.math.tau.ac.il/rans/thesis.zip.