[Soot-list] So many Nop instructions and lables in BAF

pingzixiami pingzixiami at gmail.com
Tue Apr 27 23:38:22 EDT 2010


Hi Eric, When I tried to convert the java source code to BAF form using Eclipse and Soot plugin, I found there were so many nop instructions and labels used in the produced file. The source code snippet is :
public String codeDemo(int someInt){
     int[] array = new int[5];
     
     if(someInt > 10){
     array[0] = num1;
     System.out.println("Num1 Assigned");
     } else if(someInt > 5){
     someInt = someInt + 10 * num2;
     }
     
     someInt = array[0];
     
     return "End";
    }

and the BAF code is :
    public java.lang.String codeDemo(int)
    {
        word this, someInt, array;
        this := @this: Test;
        someInt := @parameter0: int;
     label0:
        push 5;
     label1:
        newarray;
     label2:
        store.r array;
     label3:
        load.i someInt;
     label4:
        push 10;
     label5:
        ifcmpgt.i label7;
     label6:
        goto label17;
     label7:
        nop;
     label8:
        load.r array;
     label9:
        push 0;
     label10:
        load.r this;
     label11:
        fieldget <Test: int num1>;
     label12:
        arraywrite.i;
     label13:
        staticget <java.lang.System: java.io.PrintStream out>;
     label14:
        push "Num1 Assigned";
     label15:
        virtualinvoke <java.io.PrintStream: void println(java.lang.String)>;
     label16:
        goto label31;
     label17:
        nop;
     label18:
        load.i someInt;
     label19:
        push 5;
     label20:
        ifcmpgt.i label22;
     label21:
        goto label30;
     label22:
        nop;
     label23:
        load.i someInt;
     label24:
        push 10;
     label25:
        load.r this;
     label26:
        fieldget <Test: int num2>;
     label27:
        mul.i;
     label28:
        add.i;
     label29:
        store.i someInt;
     label30:
        nop;
     label31:
        nop;
     label32:
        load.r array;
     label33:
        push 0;
     label34:
        arrayread.i;
     label35:
        store.i someInt;
     label36:
        push "End";
     label37:
        return.r;
    }
Why extra nops are added in BAF form while I found no corresponding nops in java bytecode. Furthermore, are so many lables neccessary in the produced file, I think they are distracting hence reduces readability.
Thanks!
2010-04-28 



Palmer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100428/49407fe8/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: girl_002.gif
Type: image/gif
Size: 1920 bytes
Desc: not available
Url : http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100428/49407fe8/attachment-0001.gif 


More information about the Soot-list mailing list