Optimizations
The optimization step of ProGuard can be switched off with the
-dontoptimize
option. For
more fine-grained control over individual optimizations, experts can use the
-optimizations
option,
with a filter based on the optimization names listed below. The filter works
like any filter in ProGuard.
The following wildcards are supported:
? |
matches any single character in an optimization name. |
* |
matches any part of an optimization name. |
An optimization that is preceded by an exclamation mark '!' is
excluded from further attempts to match with subsequent
optimization names in the filter. Make sure to specify filters correctly,
since they are not checked for potential typos.
For example,
"code/simplification/variable,code/simplification/arithmetic
"
only performs the two specified peephole optimizations.
For example, "!method/propagation/*
" performs all optimizations,
except the ones that propagate values between methods.
For example,
"!code/simplification/advanced,code/simplification/*
" only
performs all peephole optimizations.
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.
class/marking/final
- Marks classes as final, whenever possible.
class/merging/vertical
- Merges classes vertically in the class hierarchy, whenever possible.
class/merging/horizontal
- Merges classes horizontally in the class hierarchy, whenever possible.
(⇒ code/removal/advanced
)
field/removal/writeonly
- Removes write-only fields.
field/marking/private
- Marks fields as private, whenever possible.
(⇒ code/simplification/advanced
)
field/propagation/value
- Propagates the values of fields across methods.
method/marking/private
- Marks methods as private, whenever possible (devirtualization).
(⇒ code/removal/advanced
)
method/marking/static
- Marks methods as static, whenever possible (devirtualization).
method/marking/final
- Marks methods as final, whenever possible.
(⇒ code/removal/advanced
)
method/removal/parameter
- Removes unused method parameters.
(⇒ code/simplification/advanced
)
method/propagation/parameter
- Propagates the values of method parameters from method invocations to
the invoked methods.
(⇒ code/simplification/advanced
)
method/propagation/returnvalue
- Propagates the values of method return values from methods to their
invocations.
method/inlining/short
- Inlines short methods.
method/inlining/unique
- Inlines methods that are only called once.
method/inlining/tailrecursion
- Simplifies tail recursion calls, whenever possible.
code/merging
- Merges identical blocks of code by modifying branch targets.
code/simplification/variable
- Performs peephole optimizations for variable loading and storing.
code/simplification/arithmetic
- Performs peephole optimizations for arithmetic instructions.
code/simplification/cast
- Performs peephole optimizations for casting operations.
code/simplification/field
- Performs peephole optimizations for field loading and storing.
(⇒ code/removal/simple
)
code/simplification/branch
- Performs peephole optimizations for branch instructions.
(best used with code/removal/advanced
)
code/simplification/advanced
- Simplifies code based on control flow analysis and data flow
analysis.
(⇒ code/removal/exception
)
code/removal/advanced
- Removes dead code based on control flow analysis and data flow
analysis.
(⇒ code/removal/exception
)
code/removal/simple
- Removes dead code based on a simple control flow analysis.
code/removal/variable
- Removes unused variables from the local variable frame.
code/removal/exception
- Removes exceptions with empty catch blocks.
code/allocation/variable
- Optimizes variable allocation on the local variable frame.
Copyright © 2002-2009
Eric Lafortune.