[Soot-list] A question about using a subset of optimizaitons
directly on bytecode
David Beaumont
dbeaumont at google.com
Sat Aug 2 10:52:09 EDT 2008
Hi,
I have been playing with soot to do some bytecode optimization but
was wondering how easy it would be to using a few of the optimizations
on bytecode directly, rather than going via the main command line
tool.
Basically I am generating some bytecode and would like to pass _some_
of the methods through a specific set of Jimple optimizations.
Ideally I'd be looking to write a filter that takes in a byte[] of the
method's bytecode and returns the optimized bytecode. I believe that
the optimizations I am looking to perform can be made safe to be
performed on a per-method basis (with reference to other classes via
the soot classpath).
Basically some of the code I am generating will contain bytecode equivalent to:
if (false && someCondition) {
unreachableCode();
}
or
if (someConstant < biggerConstant) {
unreachableCode();
}
And I would like to detect and remove the unreachable code sequences.
Basically I think I want to apply:
* jop.cpf - constant propagation
"false && x"
-->
"false"
* jop.cbf - constant branchfolding
if (false) {
unreachableCode();
}
-->
goto x;
unreachableCode();
x:
* jop.uce1 - unreachable code elimination
goto x;
unreachableCode();
x:
-->
goto x;
x:
* jop.ubf1 - unconditional branch folding
goto x;
x:
-->
<nothing>
But only to a known subset of methods and a subset of classes (this
has to be as faster as possible).
Many thanks in advance for any help or advice,
David
--
David Beaumont :: Mobile Software Engineer :: Google
Google UK Ltd, Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Tel +44-20-7031-3000 :: Fax +44-20-7031-3001
More information about the Soot-list
mailing list