[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newmultiarrays in Spark



The following one-line fix should fix the bug. It will be included in
future releases of Soot.

Ondrej

Index: src/soot/jimple/spark/builder/StandardParms.java
===================================================================
--- src/soot/jimple/spark/builder/StandardParms.java    (revision 1120)
+++ src/soot/jimple/spark/builder/StandardParms.java    (working copy)
@@ -363,6 +363,7 @@
         AllocNode prevAn = pag.makeAllocNode(
             new Pair( nmae, new Integer( type.numDimensions ) ), type, currentMethod );
         VarNode prevVn = pag.makeVarNode( prevAn, prevAn.getType(), currentMethod );
+        addEdge( prevAn, prevVn );
         setResult( prevAn );
         while( true ) {
             Type t = type.getElementType();

On Sat, Jul 12, 2003 at 11:05:12PM -0500, Manoj Plakal wrote:
> 
> Hello Soot-ers,
> 
> For the following test program,
> in method foo(), Spark computes
> the points-to set of the incoming
> multiarray-typed parameter r0 (using
> Jimple names) correctly:
>   "AllocNode 1 Pair newmultiarray (int)[5][4],2 in method <ArrayTest: void main(java.lang.String[])>,"
> 
> But the temporary local r1 has no
> points-to information computed.
> 
> I took a look at spark/builder/StandardParms
> and put in some printlns in caseNewMultiArrayExpr
> and saw that AllocNodes are indeed being created 
> for both the 2-D multiarray and its 1-D sub-array:
> 
>   AllocNode 1 Pair newmultiarray (int)[5][4],2 in method <ArrayTest: void main(java.lang.String[])>,
> 
>   AllocNode 2 Pair newmultiarray (int)[5][4],1 in method <ArrayTest: void main(java.lang.String[])>,
> 
> And these seem to be linked in correctly
> into the PAG.
> 
> So why doesn't Spark then use the assignment
> r1 = r0[1] to compute that r1 will point 
> to the second AllocNode?
> 
> Thanks,
> Manoj
> 
> 
> -------------------------------------
> 
> Java source:
> 
> class ArrayTest
> {
>   public static void main(String[] args)
>   {
>     int[][] ia;
>     ia = new int[5][4];
>     foo(ia);
>   }
> 
>   static void foo(int[][] ja)
>   {
>      ja[1][3] = -2;
>   }
> 
> }
> 
> -------------------------------------
> 
> Jimple output:
> 
> class ArrayTest extends java.lang.Object
> {
> 
>     void <init>()
>     {
>         ArrayTest r0;
> 
>         r0 := @this: ArrayTest;
> 6
>         specialinvoke r0.<java.lang.Object: void <init>()>();
>         return;
>     }
> 
>     public static void main(java.lang.String[])
>     {
>         java.lang.String[] r0;
>         int[][] r1;
> 
>         r0 := @parameter0: java.lang.String[];
> 6
>         r1 = newmultiarray (int)[5][4];
>         staticinvoke <ArrayTest: void foo(int[][])>(r1);
>         return;
>     }
> 
>     static void foo(int[][])
>     {
>         int[][] r0;
>         int[] $r1;
> 
>         r0 := @parameter0: int[][];
> 6
>         $r1 = r0[1];
>         $r1[3] = -2;
>         return;
>     }
> }
> 
> -------------------------------------