From 9084969e24b064e799f845810b4a15e135dc6bf2 Mon Sep 17 00:00:00 2001 From: jjenista Date: Fri, 20 May 2011 18:26:31 +0000 Subject: [PATCH] allow Pointer to run for usual compilation modes... added a todo that points-to checks at runtime need some extra modeling for string literals added to Pointer before that system will work. --- Robust/src/Analysis/Pointer/Pointer.java | 8 +++ .../src/IR/Flat/BCXallocsiteObjectField.java | 57 +++++++++---------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index 57f6181c..2bf65e11 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -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()); } diff --git a/Robust/src/IR/Flat/BCXallocsiteObjectField.java b/Robust/src/IR/Flat/BCXallocsiteObjectField.java index 03312575..aa88cdf2 100644 --- a/Robust/src/IR/Flat/BCXallocsiteObjectField.java +++ b/Robust/src/IR/Flat/BCXallocsiteObjectField.java @@ -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+";"); } -- 2.34.1