[Soot-list] bug in shimple optimization?

Ingwar Wirjawan iwirjawan at gmail.com
Mon Jan 9 22:06:31 EST 2006


hi,

i was trying out SOOT( mainly shimple optimization), and possibly found a bug(?)

[18:52:46][16] $ more a/foo.java
package a;

public class foo
{
  public static int inc( int n )
  {
    return n+1;
  }
  public static void main( String [] args )
  {
    foo();
  }
  public static void foo()
  {
    int a = 0;
    while( true )
      a = inc( a );
  }
}
[18:52:56][17] $ javac a/foo.java
[18:53:12][18] $ java soot.Main -f jimple --via-shimple -O a.foo
Soot started on Mon Jan 09 18:53:32 PST 2006
Transforming a.foo...
Writing to sootOutput/a.foo.jimple
Soot finished on Mon Jan 09 18:53:34 PST 2006
Soot has run for 0 min. 1 sec.
[18:53:34][19] $ more sootOutput/a.foo.jimple
[...]
    public static void foo()
    {
     label0:
        staticinvoke <a.foo: int inc(int)>(0);
        goto label0;
    }
[...]

the produced output doesn't look correct, because the function inc's
parameter is always 0.

Note:
1. The bug seems to disappear when the function/block is more complicated.
2. If the function foo has parameter(s), it seems to give the correct output.
3. If there are other function calls (non-static), after "a = inc(a)",
that doesn't use the "a" variable, it produces the correct output. It
produces the wrong output, if it is a static function (doesn't use "a"
variable).

I am using jasminclass-2257 and sootclasses-2257.

Thanks,
Ingwar Wirjawan.


More information about the Soot-list mailing list