changes.
authoryeom <yeom>
Tue, 7 Aug 2012 01:19:59 +0000 (01:19 +0000)
committeryeom <yeom>
Tue, 7 Aug 2012 01:19:59 +0000 (01:19 +0000)
Robust/src/Analysis/SSJava/FlowDownCheck.java
Robust/src/Analysis/SSJava/LocationInference.java
Robust/src/Benchmarks/SSJava/MP3Decoder/LayerIIIDecoder.java
Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java

index f466b0edbe8abaedb2c3931d54a883e8d0007e5f..85b36731c909080f71cf361ad6e092edd00b47cb 100644 (file)
@@ -1162,11 +1162,10 @@ public class FlowDownCheck {
   private void checkCalleeConstraints(MethodDescriptor md, SymbolTable nametable,
       MethodInvokeNode min, CompositeLocation callerBaseLoc, CompositeLocation constraint) {
 
-    // System.out.println("checkCalleeConstraints=" + min.printNode(0));
-
     MethodDescriptor calleemd = min.getMethod();
 
     MethodLattice<String> calleeLattice = ssjava.getMethodLattice(calleemd);
+
     CompositeLocation calleeThisLoc =
         new CompositeLocation(new Location(calleemd, calleeLattice.getThisLoc()));
 
@@ -1179,7 +1178,8 @@ public class FlowDownCheck {
 
       // setup caller args set
       // first, add caller's base(this) location
-      callerArgList.add(callerBaseLoc);
+      if (!calleemd.isStatic())
+        callerArgList.add(callerBaseLoc);
       // second, add caller's arguments
       for (int i = 0; i < min.numArgs(); i++) {
         ExpressionNode en = min.getArg(i);
@@ -1191,7 +1191,8 @@ public class FlowDownCheck {
 
       // setup callee params set
       // first, add callee's this location
-      calleeParamList.add(calleeThisLoc);
+      if (!calleemd.isStatic())
+        calleeParamList.add(calleeThisLoc);
       // second, add callee's parameters
       for (int i = 0; i < calleemd.numParameters(); i++) {
         VarDescriptor calleevd = (VarDescriptor) calleemd.getParameter(i);
@@ -1499,26 +1500,28 @@ public class FlowDownCheck {
       }
     }
 
+    Set<CompositeLocation> inputGLB = new HashSet<CompositeLocation>();
     if (left instanceof ArrayAccessNode) {
       ArrayAccessNode aan = (ArrayAccessNode) left;
-      left = aan.getExpression();
+      CompositeLocation indexLoc =
+          checkLocationFromExpressionNode(md, nametable, aan.getIndex(), loc, constraint, false);
+      inputGLB.add(indexLoc);
     }
 
     loc = checkLocationFromExpressionNode(md, nametable, left, loc, constraint, false);
-    // System.out.println("### checkLocationFromFieldAccessNode=" +
-    // fan.printNode(0));
-    // System.out.println("### left=" + left.printNode(0));
 
     if (!left.getType().isPrimitive()) {
 
-      if (fd.getSymbol().equals("length")) {
+      if (!fd.getSymbol().equals("length")) {
         // array.length access, return the location of the array
-        return loc;
+        Location fieldLoc = getFieldLocation(fd);
+        loc.addLocation(fieldLoc);
       }
 
-      Location fieldLoc = getFieldLocation(fd);
-      loc.addLocation(fieldLoc);
     }
+
+    inputGLB.add(loc);
+    loc = CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(md.getClassDesc(), fan));
     return loc;
   }
 
index 7d7ad44ed3e7a60f4c9981c4fb71a77e229f970a..64aa39ad1a3cc5883e09c3af9ab2d8d7e4fbc6c2 100644 (file)
@@ -1039,7 +1039,6 @@ public class LocationInference {
           if (isCompositeLocation(inNodeInferLoc)) {
             // need to make sure that newLocSymbol is lower than the infernode
             // location in the field lattice
-
             addRelation(methodLattice, methodInfo, inNodeInferLoc, inferLocation);
 
           }
@@ -1065,13 +1064,14 @@ public class LocationInference {
             continue;
           }
 
-          
-          CompositeLocation outNodeInferLoc= generateInferredCompositeLocation(methodInfo, flowGraph.getLocationTuple(localOutNode));
+          CompositeLocation outNodeInferLoc =
+              generateInferredCompositeLocation(methodInfo,
+                  flowGraph.getLocationTuple(localOutNode));
 
           if (isCompositeLocation(outNodeInferLoc)) {
             // need to make sure that newLocSymbol is higher than the infernode
             // location
-            
+
             addRelation(methodLattice, methodInfo, inferLocation, outNodeInferLoc);
 
           }
@@ -1117,8 +1117,6 @@ public class LocationInference {
     // return;
     // }
     Set<String> cycleElementSet = lattice.getPossibleCycleElements(higher, lower);
-    System.out.println("#Check cycle=" + lower + " < " + higher);
-    System.out.println("#cycleElementSet=" + cycleElementSet);
 
     boolean hasNonPrimitiveElement = false;
     for (Iterator iterator = cycleElementSet.iterator(); iterator.hasNext();) {
@@ -1132,6 +1130,8 @@ public class LocationInference {
     }
 
     if (hasNonPrimitiveElement) {
+      System.out.println("#Check cycle= " + lower + " < " + higher + "     cycleElementSet="
+          + cycleElementSet);
       // if there is non-primitive element in the cycle, no way to merge cyclic
       // elements into the shared location
       throw new CyclicFlowException();
@@ -1517,7 +1517,7 @@ public class LocationInference {
     case Kind.FieldAccessNode:
       flowTuple =
           analyzeFlowFieldAccessNode(md, nametable, (FieldAccessNode) en, nodeSet, base,
-              implicitFlowTupleSet);
+              implicitFlowTupleSet, isLHS);
       if (flowTuple != null) {
         nodeSet.addTuple(flowTuple);
       }
@@ -1918,7 +1918,7 @@ public class LocationInference {
 
   private NTuple<Descriptor> analyzeFlowFieldAccessNode(MethodDescriptor md, SymbolTable nametable,
       FieldAccessNode fan, NodeTupleSet nodeSet, NTuple<Descriptor> base,
-      NodeTupleSet implicitFlowTupleSet) {
+      NodeTupleSet implicitFlowTupleSet, boolean isLHS) {
 
     ExpressionNode left = fan.getExpression();
     TypeDescriptor ltd = left.getType();
@@ -1938,12 +1938,15 @@ public class LocationInference {
     }
 
     if (left instanceof ArrayAccessNode) {
+
       ArrayAccessNode aan = (ArrayAccessNode) left;
       left = aan.getExpression();
+      analyzeFlowExpressionNode(md, nametable, aan.getIndex(), nodeSet, base, implicitFlowTupleSet,
+          isLHS);
     }
     // fanNodeSet
     base =
-        analyzeFlowExpressionNode(md, nametable, left, nodeSet, base, implicitFlowTupleSet, false);
+        analyzeFlowExpressionNode(md, nametable, left, nodeSet, base, implicitFlowTupleSet, isLHS);
     if (base == null) {
       // in this case, field is TOP location
       return null;
@@ -1951,9 +1954,8 @@ public class LocationInference {
 
       if (!left.getType().isPrimitive()) {
 
-        if (fd.getSymbol().equals("length")) {
+        if (!fd.getSymbol().equals("length")) {
           // array.length access, just have the location of the array
-        } else {
           base.add(fd);
         }
 
@@ -2036,6 +2038,15 @@ public class LocationInference {
         addFlowGraphEdge(md, tuple, tuple);
       }
 
+      // creates edges from implicitFlowTupleSet to LHS
+      for (Iterator<NTuple<Descriptor>> iter = implicitFlowTupleSet.iterator(); iter.hasNext();) {
+        NTuple<Descriptor> fromTuple = iter.next();
+        for (Iterator<NTuple<Descriptor>> iter2 = nodeSetLHS.iterator(); iter2.hasNext();) {
+          NTuple<Descriptor> toTuple = iter2.next();
+          addFlowGraphEdge(md, fromTuple, toTuple);
+        }
+      }
+
     }
 
   }
index 52fdb3d4534d2b1fec54d4571569e78606f22a90..c6766010d0d06857a79406da4712d1d859f4e09d 100644 (file)
@@ -56,7 +56,7 @@ final class LayerIIIDecoder implements FrameDecoder {
 
   // MDM: removed, as this wasn't being used.
   // private float CheckSumOut1d = 0.0f;
-  @LOC("SI1")
+  @LOC("IS1D")
   private int CheckSumHuff = 0;
   @LOC("IS1D")
   private int[] is_1d;
@@ -1106,10 +1106,10 @@ final class LayerIIIDecoder implements FrameDecoder {
   private void huffman_decode(@LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int part2_start_local,
       @LOC("THIS,LayerIIIDecoder.CH0") int ch, @LOC("THIS,LayerIIIDecoder.CH0") int gr) {
 
-    @LOC("RE") int x[] = new int[1];
-    @LOC("RE") int y[] = new int[1];
-    @LOC("RE") int v[] = new int[1];
-    @LOC("RE") int w[] = new int[1];
+    @LOC("THIS,LayerIIIDecoder.IS1D") int x[] = new int[1];
+    @LOC("THIS,LayerIIIDecoder.IS1D") int y[] = new int[1];
+    @LOC("THIS,LayerIIIDecoder.IS1D") int v[] = new int[1];
+    @LOC("THIS,LayerIIIDecoder.IS1D") int w[] = new int[1];
 
     @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int part2_3_end =
         part2_start_local + si.ch[ch].gr[gr].part2_3_length;
index ae59051bd203779f7c3c609cceb90712823dae91..895f95fd1cdd96d435d1d0974f47f583cdaf46ba 100644 (file)
@@ -506,13 +506,14 @@ final class huffcodetab {
    * Do the huffman-decoding. note! for counta,countb -the 4 bit value is\r
    * returned in y, discard x.\r
    */\r
-  @LATTICE("OUT<V1,THIS<V1,V1<V,V<IN,IN<C,C*,V*,THISLOC=THIS,GLOBALLOC=IN")\r
+//  @LATTICE("OUT<V1, THIS<V1,V1<V,V<IN,IN<C,C*,V*,THISLOC=THIS,GLOBALLOC=IN")\r
+  @LATTICE("OUT<THIS, THIS<V1,V1<V,V<IN,IN<C,C*,V*,THISLOC=THIS,GLOBALLOC=IN")\r
   @RETURNLOC("OUT,BitReserve.BIT")\r
   @PCLOC("OUT,BitReserve.BIT")\r
   public static int huffman_decoder(@LOC("THIS,LayerIIIDecoder.SI2") int htIdx,\r
       @LOC("OUT,BitReserve.BIT") int[] x, @LOC("OUT,BitReserve.BIT") int[] y,\r
       @LOC("OUT,BitReserve.BIT") int[] v, @LOC("OUT,BitReserve.BIT") int[] w,\r
-      @LOC("OUT") BitReserve br) {\r
+      @LOC("V1") BitReserve br) {\r
     // array of all huffcodtable headers\r
     // 0..31 Huffman code table 0..31\r
     // 32,33 count1-tables\r