1 <!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//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 <script type="text/javascript" language="JavaScript"> 9 <!-- 10 if (window.self==window.top) 11 window.top.location.replace("../index.html#"+window.location.pathname+window.location.hash); 12 else { 13 var hash="#"+window.location.pathname.replace(window.top.location.pathname.replace("index.html", ""), ""); 14 if (window.top.location.hash!=hash) 15 window.top.location.hash=hash; 16 } 17 //--> 18 </script> 19 </head> 20 <body> 21 22 <h2>Optimizations</h2> 23 24 The optimization step of ProGuard can be switched off with the 25 <a href="usage.html#dontoptimize"><code>-dontoptimize</code></a> option. For 26 more fine-grained control over individual optimizations, experts can use the 27 <a href="usage.html#optimizations"><code>-optimizations</code></a> option, 28 with a filter based on the optimization names listed below. The filter works 29 like any <a href="usage.html#filters">filter</a> in ProGuard. 30 <p> 31 32 The following wildcards are supported: 33 34 <table cellspacing="10"> 35 <tr><td valign="top"><code><b>?</b></code></td> 36 <td>matches any single character in an optimization name.</td></tr> 37 <tr><td valign="top"><code><b>*</b></code></td> 38 <td>matches any part of an optimization name.</td></tr> 39 </table> 40 41 An optimization that is preceded by an exclamation mark '<b>!</b>' is 42 <i>excluded</i> from further attempts to match with <i>subsequent</i> 43 optimization names in the filter. Make sure to specify filters correctly, 44 since they are not checked for potential typos. 45 <p> 46 47 For example, 48 "<code>code/simplification/variable,code/simplification/arithmetic</code>" 49 only performs the two specified peephole optimizations. 50 <p> 51 52 For example, "<code>!method/propagation/*</code>" performs all optimizations, 53 except the ones that propagate values between methods. 54 <p> 55 56 For example, 57 "<code>!code/simplification/advanced,code/simplification/*</code>" only 58 performs all peephole optimizations. 59 <p> 60 Some optimizations necessarily imply other optimizations. These are then 61 indicated. Note that the list is likely to change over time, as optimizations 62 are added and reorganized. 63 <p> 64 65 <dl> 66 <dt><code><b>class/marking/final</b></code></dt> 67 <dd>Marks classes as final, whenever possible.</dd> 68 69 <dt><code><b>class/merging/vertical</b></code></dt> 70 <dd>Merges classes vertically in the class hierarchy, whenever possible.</dd> 71 72 <dt><code><b>class/merging/horizontal</b></code></dt> 73 <dd>Merges classes horizontally in the class hierarchy, whenever possible.</dd> 74 75 <dt><div>(⇒ <code>code/removal/advanced</code>)</div> 76 <code><b>field/removal/writeonly</b></code></dt> 77 <dd>Removes write-only fields.</dd> 78 79 <dt><code><b>field/marking/private</b></code></dt> 80 <dd>Marks fields as private, whenever possible.</dd> 81 82 <dt><div>(⇒ <code>code/simplification/advanced</code>)</div> 83 <code><b>field/propagation/value</b></code></dt> 84 <dd>Propagates the values of fields across methods.</dd> 85 86 <dt><code><b>method/marking/private</b></code></dt> 87 <dd>Marks methods as private, whenever possible (<i>devirtualization</i>).</dd> 88 89 <dt><div>(⇒ <code>code/removal/advanced</code>)</div> 90 <code><b>method/marking/static</b></code></dt> 91 <dd>Marks methods as static, whenever possible (<i>devirtualization</i>).</dd> 92 93 <dt><code><b>method/marking/final</b></code></dt> 94 <dd>Marks methods as final, whenever possible.</dd> 95 96 <dt><div>(⇒ <code>code/removal/advanced</code>)</div> 97 <code><b>method/removal/parameter</b></code></dt> 98 <dd>Removes unused method parameters.</dd> 99 100 <dt><div>(⇒ <code>code/simplification/advanced</code>)</div> 101 <code><b>method/propagation/parameter</b></code></dt> 102 <dd>Propagates the values of method parameters from method invocations to 103 the invoked methods.</dd> 104 105 <dt><div>(⇒ <code>code/simplification/advanced</code>)</div> 106 <code><b>method/propagation/returnvalue</b></code></dt> 107 <dd>Propagates the values of method return values from methods to their 108 invocations.</dd> 109 110 <dt><code><b>method/inlining/short</b></code></dt> 111 <dd>Inlines short methods.</dd> 112 113 <dt><code><b>method/inlining/unique</b></code></dt> 114 <dd>Inlines methods that are only called once.</dd> 115 116 <dt><code><b>method/inlining/tailrecursion</b></code></dt> 117 <dd>Simplifies tail recursion calls, whenever possible.</dd> 118 119 <dt><code><b>code/merging</b></code></dt> 120 <dd>Merges identical blocks of code by modifying branch targets.</dd> 121 122 <dt><code><b>code/simplification/variable</b></code></dt> 123 <dd>Performs peephole optimizations for variable loading and storing.</dd> 124 125 <dt><code><b>code/simplification/arithmetic</b></code></dt> 126 <dd>Performs peephole optimizations for arithmetic instructions.</dd> 127 128 <dt><code><b>code/simplification/cast</b></code></dt> 129 <dd>Performs peephole optimizations for casting operations.</dd> 130 131 <dt><code><b>code/simplification/field</b></code></dt> 132 <dd>Performs peephole optimizations for field loading and storing.</dd> 133 134 <dt><div>(⇒ <code>code/removal/simple</code>)</div> 135 <code><b>code/simplification/branch</b></code></dt> 136 <dd>Performs peephole optimizations for branch instructions.</dd> 137 138 <dt><code><b>code/simplification/string</b></code></dt> 139 <dd>Performs peephole optimizations for constant strings.</dd> 140 141 <dt><div>(<i>best used with</i> <code>code/removal/advanced</code>)</div> 142 <code><b>code/simplification/advanced</b></code></dt> 143 <dd>Simplifies code based on control flow analysis and data flow 144 analysis.</dd> 145 146 <dt><div>(⇒ <code>code/removal/exception</code>)</div> 147 <code><b>code/removal/advanced</b></code></dt> 148 <dd>Removes dead code based on control flow analysis and data flow 149 analysis.</dd> 150 151 <dt><div>(⇒ <code>code/removal/exception</code>)</div> 152 <code><b>code/removal/simple</b></code></dt> 153 <dd>Removes dead code based on a simple control flow analysis.</dd> 154 155 <dt><code><b>code/removal/variable</b></code></dt> 156 <dd>Removes unused variables from the local variable frame.</dd> 157 158 <dt><code><b>code/removal/exception</b></code></dt> 159 <dd>Removes exceptions with empty try blocks.</dd> 160 161 <dt><code><b>code/allocation/variable</b></code></dt> 162 <dd>Optimizes variable allocation on the local variable frame.</dd> 163 </dl> 164 <p> 165 166 ProGuard also provides some unofficial settings to control optimizations, that 167 may disappear in future versions. These are Java system properties, which 168 can be set as JVM arguments (with <code>-D.....)</code>: 169 <dl> 170 <dt><code><b>maximum.inlined.code.length</b></code> (default = 8 bytes)</dt> 171 <dd>Specifies the maximum code length (expressed in bytes) of short methods 172 that are eligible to be inlined. Inlining methods that are too long may 173 unnecessarily inflate the code size.</dd> 174 175 <dt><code><b>maximum.resulting.code.length</b></code> (default = 8000 bytes 176 for JSE, 2000 bytes for JME)</dt> 177 <dd>Specifies the maximum resulting code length (expressed in bytes) allowed 178 when inlining methods. Many Java virtual machines do not apply just-in-time 179 compilation to methods that are too long, so it's important not to let them 180 grow too large.</dd> 181 182 <dt><code><b>optimize.conservatively</b></code> (default = unset)</dt> 183 <dd>Allows input code with ordinary instructions intentionally throwing 184 <code>NullPointerException</code>, 185 <code>ArrayIndexOutOfBoundsException</code>, or 186 <code>ClassCastException</code>, without any other useful purposes. By 187 default, ProGuard may just discard such seemingly useless instructions, 188 resulting in better optimization of most common code.</dd> 189 </dl> 190 191 <hr /> 192 <noscript><div><a target="_top" href="../index.html" class="button">Show menu</a></div></noscript> 193 <address> 194 Copyright © 2002-2013 195 <a target="other" href="http://www.lafortune.eu/">Eric Lafortune</a>. 196 </address> 197 </body> 198 </html> 199