Patrick Lam (firstname.lastname@example.org)
March 23, 2000
This tutorial describes the use of Soot as an optimization tool. After completing this tutorial, the user will be able to use Soot to optimize classfiles and whole applications.
Soot is able to optimize individual classfiles. Some of the transformations which can be carried out on individual classfiles include: common subexpression elimination, partial redundency elimination, copy propagation, constant propagation and folding, conditional branch folding, dead assignment elimination, unreachable code elimination, unconditional branch folding, and unused local elimination.
In order to optimize the Hello example from the previous tutorial, we issue the command:
> java soot.Main -O Hello Transforming Hello...
Soot will then leave a new, improved Hello.class file in the sootOutput directory. For this class, the improvement after Sootification is not so obvious. Soot does, however, eliminate unused locals. Try adding an unused local to Hello and giving this command:
> java soot.Main -O -f jimple Hello Transforming Hello...
You should see that the unused local is no longer present.
Any number of classfiles can be specified to Soot in this mode, as long as they are in the CLASSPATH.
Unfortunately, our current optimizations with -O tend to have little effect on the program execution time.
Soot provides the -app switch to make it work on all the class files in an applicaion. When this switch is present, the user specifies the main classfile, and Soot will load all needed classes.
Soot has a whole-program mode in which allows it to carry out whole-program transformations; for instance, method inlining requires the whole program to correctly resolve virtual method calls.
To specify that Soot should do whole-program optimizations (-W), as well as single-class optimizations, use the command:
> java soot.Main --app -W Hello Transforming Hello...
Soot will write out all classes except those in the java.*, javax.* and sun.* packages.
The default behaviour of -W is to statically inline methods. Soot is also capable of static method binding; use
> java soot.Main --app -p wjop.smb on -p wjop.si off -W -O Hello
This type of optimization has produced significant speedups on some benchmarks.
This document was generated using the LaTeX2HTML translator Version 2008 (1.71)
Copyright © 1993, 1994, 1995, 1996,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html optimizer -split 0 -nonavigation -dir ./
The translation was initiated by Eric Bodden on 2012-01-22