[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug in generating variable names
First the good news:
I just ran the test again with the fix and it works.
The third steps generates correct jimple code now.
Thanks, Patrick. Furthermore, it reaches a fixed point
(step 4 does not change the code anymore).
Now let's take a critical look at the quality of the
optimized jimple code (IMHO this is much more
important for a tool like soot than processing speed -
that can always be optimized later).
I took a step back and looked at the original .java
code. The labeled block corresponds to the body of
this inner loop:
int len = middle - bottom;
int i;
for (i = 0; i < len; i++)
{
tem = argv[bottom + i];
argv[bottom + i] = argv[top - (middle - bottom) +
i];
argv[top - (middle - bottom) + i] = tem;
}
top -= len;
Now, if I were to hand-optimize this, the java code
would look like:
int len = top - middle;
int i;
for (i = bottom; i < middle; i++)
{
tem = argv[i];
argv[i] = argv[len + i];
argv[len + i] = tem;
}
top = len + bottom;
Then, the jimple code for the loop body would be:
label1:
r2 = r1[$cseTmp1];
$cseTmp2 = $cseTmp0 + i4;
$r3 = r1[$cseTmp2];
r1[$cseTmp1] = $r3;
r1[$cseTmp2] = r2;
i4 = i4 + 1;
instead of the current (after three passes)
label1:
$cseTmp1 = i0 + i4;
r2 = r1[$cseTmp1];
$cseTmp0 = i2 - $cseTmp3;
$cseTmp2 = $cseTmp0 + i4;
$r3 = r1[$cseTmp2];
r1[$cseTmp1] = $r3;
r1[$cseTmp2] = r2;
i4 = i4 + 1;
This looks like something soot should be able to do,
what do you think ?
Florin
--- Florin Mateoc <fmateoc@yahoo.com> wrote:
>
> Here is an example of what was happening in soot
> 1.2.1
> and 1.2.2, from gnu.getopt.Getopt.jimple, in the
> method protected void exchange(java.lang.String[])
>
> The "optimized" jimple representation after a
> translation from .class to .jimple looks like:
>
> label1:
> $cseTmp1 = i0 + i4;
> r2 = r1[$cseTmp1];
> $i10 = i2 - $cseTmp3;
> $i11 = $i10 + i4;
> $r3 = r1[$i11];
> r1[$cseTmp1] = $r3;
> $i13 = i2 - $cseTmp3;
> $i14 = $i13 + i4;
> r1[$i14] = r2;
> i4 = i4 + 1;
>
>
> When run a second time (reading the previous .jimple
> and outputting .jimple) we get:
>
> label1:
> $cseTmp1 = i0 + i4;
> r2 = r1[$cseTmp1];
> $cseTmp0 = i2 - $cseTmp3;
> $i11 = $cseTmp0 + i4;
> $r3 = r1[$i11];
> r1[$cseTmp1] = $r3;
> $i14 = $cseTmp0 + i4;
> r1[$i14] = r2;
> i4 = i4 + 1;
>
> When run a third time:
>
>
> label1:
> $cseTmp1 = i0 + i4;
> r2 = r1[$cseTmp1];
> $cseTmp0 = i2 - $cseTmp3;
> $cseTmp0 = $cseTmp0 + i4;
> $r3 = r1[$cseTmp0];
> r1[$cseTmp1] = $r3;
> r1[$cseTmp0] = r2;
> i4 = i4 + 1;
>
>
> In the third case we have an additional
> subexpression
> elimination, but also a manifestation of the bug
> that
> started this thread, where what was previously $i11
> (and $i14) was renamed to $cseTmp0 (already in use).
> As you can see, this was not harmless.
>
> Results from running with the new code will follow
> shortly
>
> Florin
>
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/