blob: 9c20571b8ff9dc41e31080d25d9cbaf5b2c2215d [file] [log] [blame]
<!doctype html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="content-style-type" content="text/css">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Optimizations</title>
</head>
<body>
<h2>Optimizations</h2>
The optimization step of ProGuard can be switched off with the
<a href="usage.html#dontoptimize"><code>-dontoptimize</code></a> option. For
more fine-grained control over individual optimizations, experts can use the
<a href="usage.html#optimizations"><code>-optimizations</code></a> option,
with a filter based on the optimization names listed below. The filter works
like any <a href="usage.html#filters">filter</a> in ProGuard.
<p>
The following wildcards are supported:
<table cellspacing="10">
<tr><td valign="top"><code><b>?</b></code></td>
<td>matches any single character in an optimization name.</td></tr>
<tr><td valign="top"><code><b>*</b></code></td>
<td>matches any part of an optimization name.</td></tr>
</table>
An optimization that is preceded by an exclamation mark '<b>!</b>' is
<i>excluded</i> from further attempts to match with <i>subsequent</i>
optimization names in the filter. Make sure to specify filters correctly,
since they are not checked for potential typos.
<p>
For example,
"<code>code/simplification/variable,code/simplification/arithmetic</code>"
only performs the two specified peephole optimizations.
<p>
For example, "<code>!method/propagation/*</code>" performs all optimizations,
except the ones that propagate values between methods.
<p>
For example,
"<code>!code/simplification/advanced,code/simplification/*</code>" only
performs all peephole optimizations.
<p>
Some optimizations necessarily imply other optimizations. These are then
indicated. Note that the list is likely to change over time, as optimizations
are added and reorganized.
<p>
<dl>
<dt><code><b>class/marking/final</b></code></dt>
<dd>Marks classes as final, whenever possible.</dd>
<dt><code><b>class/merging/vertical</b></code></dt>
<dd>Merges classes vertically in the class hierarchy, whenever possible.</dd>
<dt><code><b>class/merging/horizontal</b></code></dt>
<dd>Merges classes horizontally in the class hierarchy, whenever possible.</dd>
<dt><div>(&rArr; <code>code/removal/advanced</code>)</div>
<code><b>field/removal/writeonly</b></code></dt>
<dd>Removes write-only fields.</dd>
<dt><code><b>field/marking/private</b></code></dt>
<dd>Marks fields as private, whenever possible.</dd>
<dt><div>(&rArr; <code>code/simplification/advanced</code>)</div>
<code><b>field/propagation/value</b></code></dt>
<dd>Propagates the values of fields across methods.</dd>
<dt><code><b>method/marking/private</b></code></dt>
<dd>Marks methods as private, whenever possible (<i>devirtualization</i>).</dd>
<dt><div>(&rArr; <code>code/removal/advanced</code>)</div>
<code><b>method/marking/static</b></code></dt>
<dd>Marks methods as static, whenever possible (<i>devirtualization</i>).</dd>
<dt><code><b>method/marking/final</b></code></dt>
<dd>Marks methods as final, whenever possible.</dd>
<dt><div>(&rArr; <code>code/removal/advanced</code>)</div>
<code><b>method/removal/parameter</b></code></dt>
<dd>Removes unused method parameters.</dd>
<dt><div>(&rArr; <code>code/simplification/advanced</code>)</div>
<code><b>method/propagation/parameter</b></code></dt>
<dd>Propagates the values of method parameters from method invocations to
the invoked methods.</dd>
<dt><div>(&rArr; <code>code/simplification/advanced</code>)</div>
<code><b>method/propagation/returnvalue</b></code></dt>
<dd>Propagates the values of method return values from methods to their
invocations.</dd>
<dt><code><b>method/inlining/short</b></code></dt>
<dd>Inlines short methods.</dd>
<dt><code><b>method/inlining/unique</b></code></dt>
<dd>Inlines methods that are only called once.</dd>
<dt><code><b>method/inlining/tailrecursion</b></code></dt>
<dd>Simplifies tail recursion calls, whenever possible.</dd>
<dt><code><b>code/merging</b></code></dt>
<dd>Merges identical blocks of code by modifying branch targets.</dd>
<dt><code><b>code/simplification/variable</b></code></dt>
<dd>Performs peephole optimizations for variable loading and storing.</dd>
<dt><code><b>code/simplification/arithmetic</b></code></dt>
<dd>Performs peephole optimizations for arithmetic instructions.</dd>
<dt><code><b>code/simplification/cast</b></code></dt>
<dd>Performs peephole optimizations for casting operations.</dd>
<dt><code><b>code/simplification/field</b></code></dt>
<dd>Performs peephole optimizations for field loading and storing.</dd>
<dt><div>(&rArr; <code>code/removal/simple</code>)</div>
<code><b>code/simplification/branch</b></code></dt>
<dd>Performs peephole optimizations for branch instructions.</dd>
<dt><div>(<i>best used with</i> <code>code/removal/advanced</code>)</div>
<code><b>code/simplification/advanced</b></code></dt>
<dd>Simplifies code based on control flow analysis and data flow
analysis.</dd>
<dt><div>(&rArr; <code>code/removal/exception</code>)</div>
<code><b>code/removal/advanced</b></code></dt>
<dd>Removes dead code based on control flow analysis and data flow
analysis.</dd>
<dt><div>(&rArr; <code>code/removal/exception</code>)</div>
<code><b>code/removal/simple</b></code></dt>
<dd>Removes dead code based on a simple control flow analysis.</dd>
<dt><code><b>code/removal/variable</b></code></dt>
<dd>Removes unused variables from the local variable frame.</dd>
<dt><code><b>code/removal/exception</b></code></dt>
<dd>Removes exceptions with empty catch blocks.</dd>
<dt><code><b>code/allocation/variable</b></code></dt>
<dd>Optimizes variable allocation on the local variable frame.</dd>
</dl>
<p>
<hr>
<address>
Copyright &copy; 2002-2009
<a href="http://www.graphics.cornell.edu/~eric/">Eric Lafortune</a>.
</address>
</body>
</html>