[Soot-list] Prevent static array fill code getting pessimized to use aload+astore instead of dup?
Noam Postavsky
npostavs at users.sourceforge.net
Wed Jul 9 16:45:15 EDT 2014
public class StaticArray {
static byte[] array = {
'a', 'b', 'c'
};
}
javac compiles this into
static {};
Code:
0: iconst_3
1: newarray byte
3: dup
4: iconst_0
5: bipush 97
7: bastore
8: dup
9: iconst_1
10: bipush 98
12: bastore
...
After running get
java -jar \soot\soot-2.5.0.jar -O -cp . -pp StaticArray
the resulting class file uses aload+astore instead of dup:
static {};
Code:
0: iconst_3
1: newarray byte
3: astore_0
4: aload_0
5: iconst_0
6: bipush 97
8: bastore
9: aload_0
10: iconst_1
11: bipush 98
13: bastore
...
I want avoid this not only because it makes the code bigger (and
probably slower), but also because I'm trying to use soot with
JavaCard applets, and the JavaCard applet converter only allows
certain instructions to appear in the static class initializer; aload
and astore are not allowed.
I'm still trying to figure out how soot works, but if I understand
correctly, soot would need to "rediscover" the store+load -> dup
optimization since the original form of the input isn't saved. I tried
playing with the bb.lso phase options but it didn't seem to help. Any
suggestions?
More information about the Soot-list
mailing list