Home | History | Annotate | Download | only in manual
      1 <!doctype html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
      2 <html>
      3 <head>
      4 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
      5 <meta http-equiv="content-style-type" content="text/css">
      6 <link rel="stylesheet" type="text/css" href="style.css">
      7 <title>Optimizations</title>
      8 </head>
      9 <body>
     10 
     11 <h2>Optimizations</h2>
     12 
     13 The optimization step of ProGuard can be switched off with the
     14 <a href="usage.html#dontoptimize"><code>-dontoptimize</code></a> option. For
     15 more fine-grained control over individual optimizations, experts can use the
     16 <a href="usage.html#optimizations"><code>-optimizations</code></a> option,
     17 with a filter based on the optimization names listed below. The filter works
     18 like any <a href="usage.html#filters">filter</a> in ProGuard.
     19 <p>
     20 
     21 The following wildcards are supported:
     22 
     23 <table cellspacing="10">
     24 <tr><td valign="top"><code><b>?</b></code></td>
     25     <td>matches any single character in an optimization name.</td></tr>
     26 <tr><td valign="top"><code><b>*</b></code></td>
     27     <td>matches any part of an optimization name.</td></tr>
     28 </table>
     29 
     30 An optimization that is preceded by an exclamation mark '<b>!</b>' is
     31 <i>excluded</i> from further attempts to match with <i>subsequent</i>
     32 optimization names in the filter. Make sure to specify filters correctly,
     33 since they are not checked for potential typos.
     34 <p>
     35 
     36 For example,
     37 "<code>code/simplification/variable,code/simplification/arithmetic</code>"
     38 only performs the two specified peephole optimizations.
     39 <p>
     40 
     41 For example, "<code>!method/propagation/*</code>" performs all optimizations,
     42 except the ones that propagate values between methods.
     43 <p>
     44 
     45 For example,
     46 "<code>!code/simplification/advanced,code/simplification/*</code>" only
     47 performs all peephole optimizations.
     48 <p>
     49 Some optimizations necessarily imply other optimizations. These are then
     50 indicated. Note that the list is likely to change over time, as optimizations
     51 are added and reorganized.
     52 <p>
     53 
     54 <dl>
     55 <dt><code><b>class/marking/final</b></code></dt>
     56 <dd>Marks classes as final, whenever possible.</dd>
     57 
     58 <dt><code><b>class/merging/vertical</b></code></dt>
     59 <dd>Merges classes vertically in the class hierarchy, whenever possible.</dd>
     60 
     61 <dt><code><b>class/merging/horizontal</b></code></dt>
     62 <dd>Merges classes horizontally in the class hierarchy, whenever possible.</dd>
     63 
     64 <dt><div>(&rArr; <code>code/removal/advanced</code>)</div>
     65     <code><b>field/removal/writeonly</b></code></dt>
     66 <dd>Removes write-only fields.</dd>
     67 
     68 <dt><code><b>field/marking/private</b></code></dt>
     69 <dd>Marks fields as private, whenever possible.</dd>
     70 
     71 <dt><div>(&rArr; <code>code/simplification/advanced</code>)</div>
     72     <code><b>field/propagation/value</b></code></dt>
     73 <dd>Propagates the values of fields across methods.</dd>
     74 
     75 <dt><code><b>method/marking/private</b></code></dt>
     76 <dd>Marks methods as private, whenever possible (<i>devirtualization</i>).</dd>
     77 
     78 <dt><div>(&rArr; <code>code/removal/advanced</code>)</div>
     79     <code><b>method/marking/static</b></code></dt>
     80 <dd>Marks methods as static, whenever possible (<i>devirtualization</i>).</dd>
     81 
     82 <dt><code><b>method/marking/final</b></code></dt>
     83 <dd>Marks methods as final, whenever possible.</dd>
     84 
     85 <dt><div>(&rArr; <code>code/removal/advanced</code>)</div>
     86     <code><b>method/removal/parameter</b></code></dt>
     87 <dd>Removes unused method parameters.</dd>
     88 
     89 <dt><div>(&rArr; <code>code/simplification/advanced</code>)</div>
     90     <code><b>method/propagation/parameter</b></code></dt>
     91 <dd>Propagates the values of method parameters from method invocations to
     92     the invoked methods.</dd>
     93 
     94 <dt><div>(&rArr; <code>code/simplification/advanced</code>)</div>
     95     <code><b>method/propagation/returnvalue</b></code></dt>
     96 <dd>Propagates the values of method return values from methods to their
     97     invocations.</dd>
     98 
     99 <dt><code><b>method/inlining/short</b></code></dt>
    100 <dd>Inlines short methods.</dd>
    101 
    102 <dt><code><b>method/inlining/unique</b></code></dt>
    103 <dd>Inlines methods that are only called once.</dd>
    104 
    105 <dt><code><b>method/inlining/tailrecursion</b></code></dt>
    106 <dd>Simplifies tail recursion calls, whenever possible.</dd>
    107 
    108 <dt><code><b>code/merging</b></code></dt>
    109 <dd>Merges identical blocks of code by modifying branch targets.</dd>
    110 
    111 <dt><code><b>code/simplification/variable</b></code></dt>
    112 <dd>Performs peephole optimizations for variable loading and storing.</dd>
    113 
    114 <dt><code><b>code/simplification/arithmetic</b></code></dt>
    115 <dd>Performs peephole optimizations for arithmetic instructions.</dd>
    116 
    117 <dt><code><b>code/simplification/cast</b></code></dt>
    118 <dd>Performs peephole optimizations for casting operations.</dd>
    119 
    120 <dt><code><b>code/simplification/field</b></code></dt>
    121 <dd>Performs peephole optimizations for field loading and storing.</dd>
    122 
    123 <dt><div>(&rArr; <code>code/removal/simple</code>)</div>
    124     <code><b>code/simplification/branch</b></code></dt>
    125 <dd>Performs peephole optimizations for branch instructions.</dd>
    126 
    127 <dt><div>(<i>best used with</i> <code>code/removal/advanced</code>)</div>
    128     <code><b>code/simplification/advanced</b></code></dt>
    129 <dd>Simplifies code based on control flow analysis and data flow
    130     analysis.</dd>
    131 
    132 <dt><div>(&rArr; <code>code/removal/exception</code>)</div>
    133     <code><b>code/removal/advanced</b></code></dt>
    134 <dd>Removes dead code based on control flow analysis and data flow
    135     analysis.</dd>
    136 
    137 <dt><div>(&rArr; <code>code/removal/exception</code>)</div>
    138     <code><b>code/removal/simple</b></code></dt>
    139 <dd>Removes dead code based on a simple control flow analysis.</dd>
    140 
    141 <dt><code><b>code/removal/variable</b></code></dt>
    142 <dd>Removes unused variables from the local variable frame.</dd>
    143 
    144 <dt><code><b>code/removal/exception</b></code></dt>
    145 <dd>Removes exceptions with empty catch blocks.</dd>
    146 
    147 <dt><code><b>code/allocation/variable</b></code></dt>
    148 <dd>Optimizes variable allocation on the local variable frame.</dd>
    149 </dl>
    150 <p>
    151 
    152 <hr>
    153 <address>
    154 Copyright &copy; 2002-2009
    155 <a href="http://www.graphics.cornell.edu/~eric/">Eric Lafortune</a>.
    156 </address>
    157 </body>
    158 </html>
    159