Optimizing Java Bytecode Using the Soot Framework: Is It Feasible?
This paper presents Soot, a framework for optimizing Java™ bytecode. The framework is implemented in Java and supports three intermediate representations for representing Java bytecode: Baf, a streamlined representation of Java’s stack-based bytecode; Jimple, a typed three-address intermediate representation suitable for optimization; and Grimp, an aggregated version of Jimple.
Our approach to class file optimization is to first convert the stack-based bytecode into Jimple, a three-address form more amenable to traditional program optimization, and then convert the optimized Jimple back to bytecode.
In order to demonstrate that our approach is feasible, we present experimental results showing the effects of processing class files through our framework. In particular, we study the techniques necessary to effectively translate Jimple back to bytecode, without losing performance. Finally, we demonstrate that class file optimization can be quite effective by showing the results of some basic optimizations using our framework. Our experiments were done on ten benchmarks, including seven SPECjvm98 benchmarks, and were executed on five different Java virtual machine implementations.
KeywordsVirtual Machine Basic Block Intermediate Representation Java Virtual Machine Store Instruction
- 2.Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman. Compilers Principles, Techniques and Tools. Addison-Wesley, 1986. 26, 30Google Scholar
- 4.Geoff A. Cohen, Jeffrey S. Chase, and David L. Kaminsky. Automatic program transformation with JOIE. In Proceedings of the USENIX 1998 Annual Technical Conference, pages 167–178, Berkeley, USA, June 15–19 1998. USENIX Association. 31Google Scholar
- 5.Ron Cytron, Jeanne Ferrante, Barry K. Rosen, Mark K. Wegman, and F. Kenneth Zadeck. An efficient method of computing static single assignment form. In 16th Annual ACM Symposium on Principles of Programming Languages, pages 25–35, 1989. 22Google Scholar
- 6.DashOPro. http://www.preemptive.com/products.html. 32
- 7.Jeffrey Dean, Greg DeFouw, David Grove, Vassily Litvinov, and Craig Chambers. VORTEX: An optimizing compiler for object-oriented languages. In Proceedings OOPSLA’ 96 Conference on Object-Oriented Programming Systems, Languages, and Applications, volume 31 of ACM SIGPLAN Notices, pages 83–100. ACM, October 1996. 32Google Scholar
- 8.Jeffrey Dean, David Grove, and Craig Chambers. Optimization of object-oriented programs using static class hierarchy analysis. In Walter G. Olthoff, editor, ECOOP’95-Object-Oriented Programming, 9th European Conference, volume 952 of Lecture Notes in Computer Science, pages 77–101, Åarhus, Denmark, 7–11 August 1995. Springer. 30Google Scholar
- 9.Étienne Gagnon and Laurie Hendren. Intra-procedural Inference of Static Types for Java Bytecode. Sable Technical Report 1999-1, Sable Research Group, McGill University, March 1999. 22Google Scholar
- 10.Robert Fitzgerald, Todd B. Knoblock, Erik Ruf, Bjarne Steensgaard, and David Tarditi. Marmot: an Optimizing Compiler for Java. Microsoft technical report, Microsoft Research, October 1998. 32Google Scholar
- 11.Jasmin: A Java Assembler Interface. http://www.cat.nyu.edu/meyer/jasmin/. 22
- 12.JavaClass. http://www.inf.fu-berlin.de/dahm/JavaClass/. 31
- 13.Compaq JTrek. http://www.digital.com/java/download/jtrek. 31
- 14.Han Bok Lee and Benjamin G. Zorn. A Tool for Instrumenting Java Bytecodes. In The USENIX Symposium on Internet Technologies and Systems, pages 73–82, 1997. 31Google Scholar
- 16.Steven S. Muchnick. Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997. 21Google Scholar
- 17.Gilles Muller, Bárbara Moura, Fabrice Bellard, and Charles Consel. Harissa: A flexible and efficient Java environment mixing bytecode and compiled code. In Proceedings of the 3rd Conference on Object-Oriented Technologies and Systems, pages 1–20, Berkeley, June 16–20 1997. Usenix Association. 18, 21, 22, 32Google Scholar
- 18.Todd A. Proebsting, Gregg Townsend, Patrick Bridges, John H. Hartman, Tim Newsham, and Scott A. Watterson. Toba: Java for applications: A way ahead of time (WAT) compiler. In Proceedings of the 3rd Conference on Object-Oriented Technologies and Systems, pages 41–54, Berkeley, June 16–20 1997. Usenix Association. 18, 21, 22, 32Google Scholar
- 19.Tatiana Shpeisman and Mustafa Tikir. Generating Efficient Stack Code for Java. Technical report, University of Maryland, 1999. 32Google Scholar
- 20.Soot-a Java Optimization Framework. http://www.sable.mcgill.ca/soot/. 19
- 21.4thpass SourceGuard. http://www.4thpass.com/sourceguard/. 32
- 22.SuperCede, Inc. SuperCede for Java. http://www.supercede.com/. 32
- 23.Frank Tip, Chris Laffra, Peter F. Sweeney, and David Streeter. Practical Experience with an Application Extractor for Java. IBM Research Report RC 21451, IBM Research, 1999. 30, 32Google Scholar
- 24.Tower Technology. Tower J. http://www.twr.com/. 32
- 25.Raja Vallée-Rai and Laurie J. Hendren. Jimple: Simplifying Java Bytecode for Analyses and Transformations. Sable Technical Report 1998-4, Sable Research Group, McGill University, July 1998. 20Google Scholar