[Soot-list] extra temp variables in jimple code

Linghui Luo linghui.luo at uni-paderborn.de
Thu Aug 24 05:53:03 EDT 2017


Hallo Jack,

As you can see in the jimple code there is an assignment
        tmp$15916637 = (java.awt.Graphics) tmp$713250488;
which means that these two references points to the same object.

Soot creates jimple a few steps:
the first step is to produce typeless jimple from java byte code.
After generating typeless jimple code, it splits the variables according to definition-use chains.
Renaming the reference as in the jimple code can prevent local variables being reused to different types.
Since in typeless jimple code bad assignment can cause type conflicts as in the following example:
o=”hello”;
string=o;
o=1;
int=o;
In this typeless example the variable o is used as both a string and a int.
In your jave code 2nd line defines g and 3rd line uses g as parameter, so renaming happens.

Best,
Linghui
Von: Soot-list [mailto:soot-list-bounces at CS.McGill.CA] Im Auftrag von Jack Traror
Gesendet: Donnerstag, 24. August 2017 10:46
An: soot-list at CS.McGill.CA
Betreff: [Soot-list] extra temp variables in jimple code


Hello

In the jimple code which is in the end of this message, tmp$713250488 represents the variable g defined at the 2nd line in the following test case. However, this variable changes to tmp$15916637 at the 3rd line. Why is that happening?


@Test

public void testBarcodeIsDrawnAtOriginForZeroZeroDraw() throws Exception {

BarcodeMock barcode = new BarcodeMock("12345");

GraphicsMock g = new GraphicsMock();// 2nd line

barcode.paintComponent(g); // 3rd line

assertEquals(0, (int) g.getModifiedBounds().getX());

assertEquals(0, (int) g.getModifiedBounds().getY());

}

protected void paintComponent(java.awt.Graphics g) {

super.paintComponent(g);

Insets insets = getInsets();

try {

draw((Graphics2D) g, insets.left, insets.top);

} catch (OutputException e) {

// Don't draw anything

}

}


class GraphicsMock extends java.awt.Graphics2D {

...

}


public void testBarcodeIsDrawnAtOriginForZeroZeroDraw() throws java.lang.Exception
    {
        net.sourceforge.barbecue.BarcodeTest this;
        java.awt.Rectangle $r2, $r3;
        double $d0, $d1;
        int $i0, $i1;
        net.sourceforge.barbecue.BarcodeTest$BarcodeMock tmp$1950524369;
        net.sourceforge.barbecue.GraphicsMock tmp$713250488;
        java.awt.Graphics tmp$15916637;

        this := @this: net.sourceforge.barbecue.BarcodeTest;

        tmp$1950524369 = new net.sourceforge.barbecue.BarcodeTest$BarcodeMock;

        specialinvoke tmp$1950524369.<net.sourceforge.barbecue.BarcodeTest$BarcodeMock: void <init>(net.sourceforge.barbecue.BarcodeTest,java.lang.String)>(this, "12345");

        tmp$713250488 = new net.sourceforge.barbecue.GraphicsMock;

        specialinvoke tmp$713250488.<net.sourceforge.barbecue.GraphicsMock: void <init>()>();

        tmp$15916637 = (java.awt.Graphics) tmp$713250488;

        virtualinvoke tmp$1950524369.<net.sourceforge.barbecue.BarcodeTest$BarcodeMock: void paintComponent(java.awt.Graphics)>(tmp$15916637);

        $r2 = virtualinvoke tmp$713250488.<net.sourceforge.barbecue.GraphicsMock: java.awt.Rectangle getModifiedBounds()>();

        $d0 = virtualinvoke $r2.<java.awt.Rectangle: double getX()>();

        $i0 = (int) $d0;

        staticinvoke <net.sourceforge.barbecue.BarcodeTest: void assertEquals(int,int)>(0, $i0);

        $r3 = virtualinvoke tmp$713250488.<net.sourceforge.barbecue.GraphicsMock: java.awt.Rectangle getModifiedBounds()>();

        $d1 = virtualinvoke $r3.<java.awt.Rectangle: double getY()>();

        $i1 = (int) $d1;

        staticinvoke <net.sourceforge.barbecue.BarcodeTest: void assertEquals(int,int)>(0, $i1);

        return;
    }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20170824/3523643e/attachment-0001.html>


More information about the Soot-list mailing list