allow Pointer to run for usual compilation modes... added a todo that points-to check...
authorjjenista <jjenista>
Fri, 20 May 2011 18:26:31 +0000 (18:26 +0000)
committerjjenista <jjenista>
Fri, 20 May 2011 18:26:31 +0000 (18:26 +0000)
Robust/src/Analysis/Pointer/Pointer.java
Robust/src/IR/Flat/BCXallocsiteObjectField.java

index 57f6181c183d0a681bfc0e50d74832239aaff95f..2bf65e115bc3c34bea0671b0b1cb57c236cb0c98 100644 (file)
@@ -469,6 +469,14 @@ nextdelta:
     case FKind.FlatCall:
       return processFlatCall(bblock, index, (FlatCall) node, delta, newgraph);
 
+    case FKind.FlatLiteralNode:
+      // jjenista - the heap analysis abstraction---when used to verify points-to
+      // analysis results against runtime pointers---will eventually need this to
+      // model that a flat literal node can result in a pointer to an implicitly
+      // allocated string.  For now it will pass through like Pointer used to, but
+      // the checks versus runtime pointers will fail for string literals.
+      return delta;
+
     default:
       throw new Error("Unrecognized node:"+node + " of kind " + node.kind());
     }
index 03312575ff52c065afba33f90756167ec94c2d0a..aa88cdf2d4a33394423dcac2e86b845c632a4dcf 100644 (file)
@@ -45,6 +45,15 @@ public class BCXallocsiteObjectField implements BuildCodeExtension {
     }
     assert strBytes != null;
   }
+
+
+  protected Integer getIDtoGen( Alloc a, int idWhenNull ) {
+    if( a == null ) {
+      return idWhenNull;
+    }
+    return a.getUniqueAllocSiteID();
+  }
+
   
   
   public void additionalClassObjectFields(PrintWriter outclassdefs) {
@@ -56,24 +65,18 @@ public class BCXallocsiteObjectField implements BuildCodeExtension {
 
     String argsAccess = "((struct "+cdString.getSafeSymbol()+
       " **)(((char *)& "+argsVar+"->___length___)+sizeof(int)))";
+
+    Integer argsAllocID     = getIDtoGen( heapAnalysis.getCmdLineArgsAlloc(),     -109 ); 
+    Integer argAllocID      = getIDtoGen( heapAnalysis.getCmdLineArgAlloc(),      -119 ); 
+    Integer argBytesAllocID = getIDtoGen( heapAnalysis.getCmdLineArgBytesAlloc(), -129 ); 
     
-    outmethod.println(argsVar+"->allocsite = "+
-                      heapAnalysis.getCmdLineArgsAlloc().getUniqueAllocSiteID()+
-                      ";"
-                      );
+    outmethod.println(argsVar+"->allocsite = "+argsAllocID+";");
     outmethod.println("{");
     outmethod.println("  int i;" );
     outmethod.println("  for( i = 0; i < "+argsVar+"->___length___; ++i ) {");    
-    outmethod.println("    "+argsAccess+"[i]->allocsite = "+
-                      heapAnalysis.getCmdLineArgAlloc().getUniqueAllocSiteID()+
-                      ";"
-                      );
-    outmethod.println("    "+argsAccess+"[i]->"+
-                      strBytes.getSafeSymbol()+
-                      "->allocsite = "+
-                      heapAnalysis.getCmdLineArgBytesAlloc().getUniqueAllocSiteID()+
-                      ";"
-                      );
+    outmethod.println("    "+argsAccess+"[i]->allocsite = "+argAllocID+";");
+    outmethod.println("    "+argsAccess+"[i]->"+strBytes.getSafeSymbol()+
+                      "->allocsite = "+argBytesAllocID+";");
     outmethod.println("  }");
     outmethod.println("}");
     outmethod.println("");
@@ -81,25 +84,21 @@ public class BCXallocsiteObjectField implements BuildCodeExtension {
 
 
   public void additionalCodeNewObject(PrintWriter outmethod, String dstVar, FlatNew flatNew) {
-    outmethod.println(dstVar+"->allocsite = "+
-                      heapAnalysis.getAllocationSiteFromFlatNew( flatNew ).getUniqueAllocSiteID()+
-                      ";"
-                      );
+
+    Integer allocID = getIDtoGen( heapAnalysis.getAllocationSiteFromFlatNew( flatNew ), -199 ); 
+
+    outmethod.println(dstVar+"->allocsite = "+allocID+";");
   }
 
 
   public void additionalCodeNewStringLiteral(PrintWriter output, String dstVar) {
-    output.println(dstVar+"->allocsite = "+
-                   heapAnalysis.getNewStringLiteralAlloc().getUniqueAllocSiteID()+
-                   ";"
-                   );    
-
-    output.println(dstVar+"->"+
-                   strBytes.getSafeSymbol()+
-                   "->allocsite = "+
-                   heapAnalysis.getNewStringLiteralBytesAlloc().getUniqueAllocSiteID()+
-                   ";"
-                   );
+
+    Integer stringAllocID      = getIDtoGen( heapAnalysis.getNewStringLiteralAlloc(),      -29 ); 
+    Integer stringBytesAllocID = getIDtoGen( heapAnalysis.getNewStringLiteralBytesAlloc(), -39 ); 
+
+    output.println(dstVar+"->allocsite = "+stringAllocID+";");    
+    output.println(dstVar+"->"+strBytes.getSafeSymbol()+
+                   "->allocsite = "+stringBytesAllocID+";");
   }