From bd117b884e1caff9d8e80177b102d052f048c7b1 Mon Sep 17 00:00:00 2001
From: jjenista <jjenista>
Date: Tue, 22 Jun 2010 21:40:01 +0000
Subject: [PATCH] got the hooks in place to get taints for rblocks

---
 .../Analysis/Disjoint/DisjointAnalysis.java   | 12 ++++++
 .../src/Analysis/Disjoint/PointerMethod.java  |  2 +
 Robust/src/Analysis/Disjoint/ReachGraph.java  | 37 +++++++++++++++++++
 Robust/src/Analysis/Disjoint/Taint.java       |  2 +-
 Robust/src/IR/Flat/BuildFlat.java             |  8 ++--
 Robust/src/Tests/disjoint/taintTest1/makefile |  2 +-
 .../src/Tests/disjoint/taintTest1/test.java   | 18 +++++++--
 7 files changed, 71 insertions(+), 10 deletions(-)

diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java
index f40261fa..567d9e3c 100644
--- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java
+++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java
@@ -1112,6 +1112,18 @@ public class DisjointAnalysis {
       }
       break;
 
+    case FKind.FlatSESEEnterNode:
+      FlatSESEEnterNode sese = (FlatSESEEnterNode) fn;
+      rg.taintLiveTemps( sese,
+                         liveness.getLiveInTemps( fmContaining, fn ) 
+                         );
+      break;
+
+    case FKind.FlatSESEExitNode:
+      FlatSESEExitNode fsexn = (FlatSESEExitNode) fn;
+      rg.removeInContextTaints( fsexn.getFlatEnter() );
+      break;
+      
     case FKind.FlatCall: {
       Descriptor mdCaller;
       if( fmContaining.getMethod() != null ){
diff --git a/Robust/src/Analysis/Disjoint/PointerMethod.java b/Robust/src/Analysis/Disjoint/PointerMethod.java
index 372a0fca..396474d3 100644
--- a/Robust/src/Analysis/Disjoint/PointerMethod.java
+++ b/Robust/src/Analysis/Disjoint/PointerMethod.java
@@ -95,6 +95,8 @@ public class PointerMethod {
     case FKind.FlatCall:
     case FKind.FlatReturnNode:
     case FKind.FlatBackEdge:
+    case FKind.FlatSESEEnterNode:
+    case FKind.FlatSESEExitNode:
       return true;
     case FKind.FlatCastNode:
       FlatCastNode fcn=(FlatCastNode)fn;
diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java
index 2b554894..127ca159 100644
--- a/Robust/src/Analysis/Disjoint/ReachGraph.java
+++ b/Robust/src/Analysis/Disjoint/ReachGraph.java
@@ -1243,6 +1243,43 @@ public class ReachGraph {
   }
 
 
+  public void taintLiveTemps( FlatSESEEnterNode sese, 
+                              Set<TempDescriptor> liveTemps
+                              ) {
+
+    System.out.println( "At "+sese+" with: "+liveTemps );
+
+    Iterator<TempDescriptor> tdItr = liveTemps.iterator();
+    while( tdItr.hasNext() ) {
+      TempDescriptor td = tdItr.next();
+      VariableNode   vn = td2vn.get( td );
+
+      Iterator<RefEdge> reItr = vn.iteratorToReferencees();
+      while( reItr.hasNext() ) {
+        RefEdge re = reItr.next();
+
+        // these new sese (rblock) taints should
+        // have empty predicates so they never propagate
+        // out to callers
+        Taint t = Taint.factory( sese,
+                                 td,
+                                 re.getDst().getAllocSite(),
+                                 ExistPredSet.factory()
+                                 );
+
+        re.setTaints( Canonical.add( re.getTaints(),
+                                     t 
+                                     )
+                      );
+      }
+    }
+  }
+
+  public void removeInContextTaints( FlatSESEEnterNode sese ) {
+    
+  }
+
+
   // used in makeCalleeView below to decide if there is
   // already an appropriate out-of-context edge in a callee
   // view graph for merging, or null if a new one will be added
diff --git a/Robust/src/Analysis/Disjoint/Taint.java b/Robust/src/Analysis/Disjoint/Taint.java
index 06ac9a9d..440a33fa 100644
--- a/Robust/src/Analysis/Disjoint/Taint.java
+++ b/Robust/src/Analysis/Disjoint/Taint.java
@@ -130,7 +130,7 @@ public class Taint extends Canonical {
 
   public String toString() {
     return 
-      "("+sese.toPrettyString()+
+      "("+sese.getPrettyIdentifier()+
       "-"+insetVar+
       ", "+allocSite.toStringBrief()+
       "):"+preds;
diff --git a/Robust/src/IR/Flat/BuildFlat.java b/Robust/src/IR/Flat/BuildFlat.java
index a895190a..584e8767 100644
--- a/Robust/src/IR/Flat/BuildFlat.java
+++ b/Robust/src/IR/Flat/BuildFlat.java
@@ -163,7 +163,7 @@ public class BuildFlat {
       // that method at runtime
       FlatSESEEnterNode spliceSESE = null;
       FlatSESEExitNode  spliceExit = null;
-      if( state.MLP ) {
+      if( state.MLP || state.OOOJAVA ) {
 	if( currmd.equals( typeutil.getMain() ) ) {
 	  SESENode mainTree = new SESENode( "main" );
 	  spliceSESE = new FlatSESEEnterNode( mainTree );
@@ -216,7 +216,7 @@ public class BuildFlat {
       } else if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) {
 	FlatNode rnflat=null;
 	// splice implicit SESE exit after method body
-	if( state.MLP ) {
+	if( state.MLP || state.OOOJAVA ) {
 	  np.getEnd().addNext(spliceExit);
 	  rnflat=spliceReturn(spliceExit);
 	} else {
@@ -225,7 +225,7 @@ public class BuildFlat {
 	rnflat.addNext(fe);
       } else if (np.getEnd()!=null) {
 	// splice implicit SESE exit after method body
-	if( state.MLP ) {
+	if( state.MLP || state.OOOJAVA ) {
 	  FlatReturnNode rnflat=(FlatReturnNode)np.getEnd();
 	  np.getEnd().addNext(spliceExit);
 	  spliceExit.addNext(fe);
@@ -233,7 +233,7 @@ public class BuildFlat {
       }
 
       // splice an implicit SESE enter before method body
-      if( state.MLP ) {
+      if( state.MLP || state.OOOJAVA ) {
 	spliceSESE.addNext(fn);
 	fn=spliceSESE;	 
       }
diff --git a/Robust/src/Tests/disjoint/taintTest1/makefile b/Robust/src/Tests/disjoint/taintTest1/makefile
index af136378..2224b405 100644
--- a/Robust/src/Tests/disjoint/taintTest1/makefile
+++ b/Robust/src/Tests/disjoint/taintTest1/makefile
@@ -5,7 +5,7 @@ SOURCE_FILES=$(PROGRAM).java
 BUILDSCRIPT=~/research/Robust/src/buildscript
 
 
-BSFLAGS= -mainclass Test -justanalyze -disjoint -disjoint-k 2 -disjoint-write-dots final -enable-assertions
+BSFLAGS= -mainclass Test -justanalyze -ooojava -disjoint -disjoint-k 2 -disjoint-write-dots final -enable-assertions
 
 all: $(PROGRAM).bin
 
diff --git a/Robust/src/Tests/disjoint/taintTest1/test.java b/Robust/src/Tests/disjoint/taintTest1/test.java
index bae5a1a5..a8b37ef2 100644
--- a/Robust/src/Tests/disjoint/taintTest1/test.java
+++ b/Robust/src/Tests/disjoint/taintTest1/test.java
@@ -9,14 +9,24 @@ public class Test {
   static public void main( String[] args ) {
 
     Foo a = new Foo();
-    Foo b = new Foo();
+
+    rblock DU {
+      Foo b = new Foo();
+      Foo z = a.f;
+    }
+
     Foo c = new Foo();
     Foo d = new Foo();
-    giveParamNames( a, b, c );
+    
+    //doSomething( a, b, c );
   }
 
-  static void giveParamNames( Foo a, Foo b, Foo c ) {
-    Foo e = doStuff( a, b );
+  static void doSomething( Foo a, Foo b, Foo c ) {
+
+    rblock YO {
+      Foo e = doStuff( a, b );
+    }
+
     Foo f = doStuff( a, c );
   }   
 
-- 
2.34.1