Optimizing Java Bytecode Using the Soot Framework: Is It Feasible?

  • Raja Vallée-Rai
  • Etienne Gagnon
  • Laurie Hendren
  • Patrick Lam
  • Patrice Pominville
  • Vijay Sundaresan
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1781)


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.


Virtual Machine Basic Block Intermediate Representation Java Virtual Machine Store Instruction 
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.
    Ali-Reza Adl-Tabatabai, Michal Cierniak, Guei-Yuan Lueh, Vishesh M. Parikh, and James M. Stichnoth. Fast and effective code generation in a just-in-time Java compiler. ACM SIGPLAN Notices, 33(5):280–290, May 1998. 18CrossRefGoogle Scholar
  2. 2.
    Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman. Compilers Principles, Techniques and Tools. Addison-Wesley, 1986. 26, 30Google Scholar
  3. 3.
    Lars R. Clausen. A Java bytecode optimizer using side-effect analysis. Concurrency: Practice & Experience, 9(11):1031–1045, November 1997. 30CrossRefGoogle Scholar
  4. 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. 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. 6.
  7. 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. 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. 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. 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. 11.
    Jasmin: A Java Assembler Interface. 22
  12. 12.
  13. 13.
  14. 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
  15. 15.
    Martin Maierhofer and M. Anton Ertl. Local stack allocation. In Kai Koskimies, editor, Compiler Construction (CC’98), pages 189–203, Lisbon, 1998. Springer LNCS 1383. 32CrossRefGoogle Scholar
  16. 16.
    Steven S. Muchnick. Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997. 21Google Scholar
  17. 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. 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. 19.
    Tatiana Shpeisman and Mustafa Tikir. Generating Efficient Stack Code for Java. Technical report, University of Maryland, 1999. 32Google Scholar
  20. 20.
    Soot-a Java Optimization Framework. 19
  21. 21.
    4thpass SourceGuard. 32
  22. 22.
    SuperCede, Inc. SuperCede for Java. 32
  23. 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. 24.
    Tower Technology. Tower J. 32
  25. 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

Copyright information

© Springer-Verlag Berlin Heidelberg 2000

Authors and Affiliations

  • Raja Vallée-Rai
    • 1
  • Etienne Gagnon
    • 1
  • Laurie Hendren
    • 1
  • Patrick Lam
    • 1
  • Patrice Pominville
    • 1
  • Vijay Sundaresan
    • 1
  1. 1.Sable Research Group, School of Computer ScienceMcGill UniversityCanada

Personalised recommendations