[Soot-list] qustion about loop fusion

John Jorgensen jorgnsn at lcd.uregina.ca
Wed Mar 1 00:53:09 EST 2006


Jun Cau <caoj> writes:

    caoj> I use soot to do loop fusion.

    [ omitting java and jimple source for class A ]

    caoj> After it, I run "java A", it gives me the following
    caoj> error:

    caoj> Exception in thread "main" java.lang.VerifyError:
    caoj> (class: A, method: main signature:
    caoj> ([Ljava/lang/String;)V) Accessing value from
    caoj> uninitialized register 2

    caoj> Does anyone know what is wrong with my changed jimple
    caoj> codes? 

I don't think that the problem is in the jimple that you included
in your question. Not only can I not see any obvious difficulty,
but when I tried to create a file corresponding to your jimple
(attached below) and ran that through "soot -src-prej jimple",
soot generates an output class that runs correctly.

Since the problem is a verification error, and the JVM's verifier
performs its dataflow analysis on bytecode, 
you'll probably have more luck finding the problem by first
examining the bytecode in the output class file to see exactly
what bytecode instructions the verifier is complaining about, and
then working backward to determine how the transformations you are
performing might have generated the problematic bytecode.

More specifically, the VerifyError claims that local variable 2
might be read before it is assigned any value. So look at the
bytecode to see which instructions set and read local 2, then
figure out which jimple variables correspond to that local.

soot has options to dump its intermediate representations 
before and after each of its transformations, and
the control flow graphs produced at intermediate points in its
processing.  They may be of use in discovering where the
unverifiable transformations occur, though interpreting them
requires looking at the PackManager source to determine the order
in which transformations occur.  See the documentation for the
--dump-body and --dump-cfg options" for more information.


-------------- next part --------------
class A extends java.lang.Object
{

    void <init>()
    {
        A r0;

        r0 := @this: A;
        specialinvoke r0.<java.lang.Object: void <init>()>();
        return;
    }

    public static void main(java.lang.String[])
    {
        java.lang.String[] r0;
        int[] r1, r2;
        int i0, i1, $i2;
        java.io.PrintStream $r3;
        java.lang.StringBuilder $r4, $r5, $r6, $r7, $r8, $r9;
        java.lang.String $r10;

        r0 := @parameter0: java.lang.String[];
        r1 = newarray (int)[10];
        r2 = newarray (int)[11];
        i0 = 0;

     label0:
        if i0 >= 10 goto label3;

        r1[i0] = i0;

        $r3 = <java.lang.System: java.io.PrintStream out>;
        $r4 = new java.lang.StringBuilder;
        specialinvoke $r4.<java.lang.StringBuilder: void <init>()>();
        $r5 = virtualinvoke $r4.<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>("a[");
        $r6 = virtualinvoke $r5.<java.lang.StringBuilder: java.lang.StringBuilder append(int)>(i0);
        $r7 = virtualinvoke $r6.<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>("]=");
        $i2 = r1[i0];
        $r8 = virtualinvoke $r7.<java.lang.StringBuilder: java.lang.StringBuilder append(int)>($i2);
        $r9 = virtualinvoke $r8.<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>("\n");
        $r10 = virtualinvoke $r9.<java.lang.StringBuilder: java.lang.String toString()>();
        virtualinvoke $r3.<java.io.PrintStream: void println(java.lang.String)>($r10);

        i0 = i0 + 1;
        goto label0;

     label3:
        return;
    }
}


More information about the Soot-list mailing list