more changes...
authorbdemsky <bdemsky>
Fri, 28 Jan 2011 08:13:04 +0000 (08:13 +0000)
committerbdemsky <bdemsky>
Fri, 28 Jan 2011 08:13:04 +0000 (08:13 +0000)
Robust/src/Analysis/Pointer/Pointer.java
Robust/src/IR/State.java
Robust/src/Main/Main.java

index a1269846b198f0d0794f5b8493efa3140c715d55..e1abdda684580495e56cb2991375188fe93a48d6 100644 (file)
@@ -13,6 +13,7 @@ public class Pointer {
   TypeUtil typeUtil;
   AllocFactory allocFactory;
   LinkedList<Delta> toprocess;
+  TempDescriptor returntmp;
 
   public Pointer(State state, TypeUtil typeUtil) {
     this.state=state;
@@ -22,6 +23,8 @@ public class Pointer {
     this.typeUtil=typeUtil;
     this.allocFactory=new AllocFactory(state, typeUtil);
     this.toprocess=new LinkedList<Delta>();
+    ClassDescriptor stringcd=typeUtil.getClass(TypeUtil.ObjectClass);
+    this.returntmp=new TempDescriptor("RETURNVAL", stringcd);
   }
 
   public BasicBlock getBBlock(FlatMethod fm) {
@@ -45,7 +48,7 @@ public class Pointer {
     return delta;
   }
 
-  void doAnalysis() {
+  public void doAnalysis() {
     toprocess.add(buildInitialContext());
 
     while(!toprocess.isEmpty()) {
@@ -67,11 +70,11 @@ public class Pointer {
        nodeGraph=graphMap.get(currNode);
        delta=processNode(currNode, delta, nodeGraph);
       }
-      generateFinalDelta(delta, nodeGraph);
+      generateFinalDelta(bblock, delta, nodeGraph);
     }    
   }
 
-  void generateFinalDelta(Delta delta, Graph graph) {
+  void generateFinalDelta(BBlock bblock, Delta delta, Graph graph) {
     Delta newDelta=new Delta(null, false);
     if (delta.getInit()) {
       //First compute the set of temps
@@ -145,8 +148,7 @@ public class Pointer {
     /* Now we need to propagate newdelta */
     if (!newDelta.heapedgeadd.isEmpty()||!newDelta.heapedgeremove.isEmpty()||!newDelta.varedgeadd.isEmpty()) {
       /* We have a delta to propagate */
-      BBlock curr=delta.getBlock();
-      Vector<BBlock> blockvector=curr.next();
+      Vector<BBlock> blockvector=bblock.next();
       for(int i=0;i<blockvector.size();i++) {
        if (i==0) {
          newDelta.setBlock(blockvector.get(i));
@@ -155,7 +157,6 @@ public class Pointer {
          toprocess.add(newDelta.diffBlock(blockvector.get(i)));
        }
       }
-
     }
   }
 
@@ -168,15 +169,15 @@ public class Pointer {
       return processFieldElementNode(node, delta, newgraph);
     case FKind.FlatCastNode:
     case FKind.FlatOpNode:
+    case FKind.FlatReturnNode:
       return processCopyNode(node, delta, newgraph);
     case FKind.FlatSetFieldNode:
     case FKind.FlatSetElementNode:
       return processSetFieldElementNode(node, delta, newgraph);
     case FKind.FlatMethod:
-    case FKind.FlatCall:
-    case FKind.FlatReturnNode:
     case FKind.FlatExit:
-
+      return processFlatNop(node, delta, newgraph);
+    case FKind.FlatCall:
     case FKind.FlatSESEEnterNode:
     case FKind.FlatSESEExitNode:
       throw new Error("Unimplemented node:"+node);
@@ -309,6 +310,10 @@ public class Pointer {
       FlatOpNode fon=(FlatOpNode) node;
       src=fon.getLeft();
       dst=fon.getDest();
+    } else if (node.kind()==FKind.FlatReturnNode) {
+      FlatReturnNode frn=(FlatReturnNode)node;
+      src=frn.getReturnTemp();
+      dst=returntmp;
     } else {
       FlatCastNode fcn=(FlatCastNode) node;
       src=fcn.getSrc();
@@ -429,6 +434,11 @@ public class Pointer {
     }
   }
 
+  Delta processFlatNop(FlatNode node, Delta delta, Graph graph) {
+    applyDiffs(graph, delta);
+    return delta;
+  }
+
   Delta processNewNode(FlatNew node, Delta delta, Graph graph) {
     AllocNode summary=allocFactory.getAllocNode(node, true);
     AllocNode single=allocFactory.getAllocNode(node, false);
index c4a5e2b2a6b64e8b96e3e117c2259b5bc6a69bff..8b61997a271c6541d845f312d01466c083ba3881 100644 (file)
@@ -48,6 +48,7 @@ public class State {
 
   /** Boolean flag which indicates whether compiler is compiling a task-based
    * program. */
+  public boolean POINTER=false;
   public boolean COREPROF=false;
   public boolean WEBINTERFACE=false;
   public boolean MINIMIZE=false;
index 764e606d95f42c23753e4b53e991c76d125fd199..4ace49de756f88cd139d0bf73e591562b38b11c5 100644 (file)
@@ -48,6 +48,7 @@ import Analysis.OoOJava.OoOJavaAnalysis;
 import Analysis.Loops.*;
 import Analysis.Liveness;
 import Analysis.ArrayReferencees;
+import Analysis.Pointer.Pointer;
 import IR.MethodDescriptor;
 import IR.Flat.FlatMethod;
 import Interface.*;
@@ -170,11 +171,10 @@ public class Main {
        state.OWNERSHIPDEBUGCALLER=args[++i];
       } else if (option.equals("-owndebugcallcount")) {
        state.OWNERSHIPDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
-      }
-
-      else if (option.equals("-disjoint"))
+      } else if (option.equals("-pointer")) {
+       state.POINTER=true;
+      else if (option.equals("-disjoint"))
        state.DISJOINT=true;
-
       else if (option.equals("-disjoint-k")) {
        state.DISJOINTALLOCDEPTH=Integer.parseInt(args[++i]);
 
@@ -452,6 +452,10 @@ public class Main {
        }
       }
     }
+    if (state.POINTER) {
+      Pointer pointgraph=new Pointer(state, tu);
+      pointgraph.doAnalysis();
+    }
 
 
     if (state.OPTIMIZE) {