optimizations
authorbdemsky <bdemsky>
Fri, 26 Jun 2009 06:28:27 +0000 (06:28 +0000)
committerbdemsky <bdemsky>
Fri, 26 Jun 2009 06:28:27 +0000 (06:28 +0000)
Robust/src/Analysis/Locality/LocalityAnalysis.java
Robust/src/Analysis/Locality/LocalityBinding.java

index 7ceab573346b2d5d729f49348157b5c86b77a8aa..abd14d8ed26aba8fa9df1f2d7bb9ec872f532564 100644 (file)
@@ -1,5 +1,6 @@
 package Analysis.Locality;
 
+import Analysis.Liveness;
 import java.util.*;
 import Analysis.CallGraph.CallGraph;
 import IR.SymbolTable;
@@ -297,6 +298,7 @@ public class LocalityAnalysis {
     FlatMethod fm=state.getMethodFlat(md);
     HashSet<FlatNode> tovisit=new HashSet<FlatNode>();
     tovisit.add(fm.getNext(0));
+
     {
       // Build table for initial node
       Hashtable<TempDescriptor,Integer> table=new Hashtable<TempDescriptor,Integer>();
@@ -314,9 +316,12 @@ public class LocalityAnalysis {
       }
     }
 
+    Hashtable<FlatNode, Set<TempDescriptor>> livemap=Liveness.computeLiveTemps(fm);
+    
     while(!tovisit.isEmpty()) {
       FlatNode fn=tovisit.iterator().next();
       tovisit.remove(fn);
+      Set<TempDescriptor> liveset=livemap.get(fn);
       Hashtable<TempDescriptor, Integer> currtable=new Hashtable<TempDescriptor, Integer>();
       int atomicstate=0;
       for(int i=0; i<fn.numPrev(); i++) {
@@ -329,6 +334,8 @@ public class LocalityAnalysis {
        Hashtable<TempDescriptor, Integer> prevtable=temptable.get(prevnode);
        for(Iterator<TempDescriptor> tempit=prevtable.keySet().iterator(); tempit.hasNext();) {
          TempDescriptor temp=tempit.next();
+         if (!liveset.contains(temp))
+           continue;
          Integer tmpint=prevtable.get(temp);
          Integer oldint=currtable.containsKey(temp) ? currtable.get(temp) : STMEITHER;
          Integer newint=mergestm(tmpint, oldint);
@@ -512,6 +519,7 @@ public class LocalityAnalysis {
 
        lb.setParent(currlb);
        lbtovisit.add(lb);
+       System.out.println("New lb:"+lb);
        discovered.put(lb, lb);
        if (!classtolb.containsKey(lb.getMethod().getClassDesc()))
          classtolb.put(lb.getMethod().getClassDesc(), new HashSet<LocalityBinding>());
@@ -531,7 +539,7 @@ public class LocalityAnalysis {
        calldep.put(currlb, new HashSet<LocalityBinding>());
       calldep.get(currlb).add(lb);
     }
-    if (fc.getReturnTemp()!=null) {
+    if (fc.getReturnTemp()!=null&&fc.getReturnTemp().getType().isPtr()) {
       currtable.put(fc.getReturnTemp(), currreturnval);
     }
   }
@@ -539,18 +547,15 @@ public class LocalityAnalysis {
   void processFieldNodeSTM(LocalityBinding lb, FlatFieldNode ffn, Hashtable<TempDescriptor, Integer> currtable) {
     Integer type=currtable.get(ffn.getSrc());
     TempDescriptor dst=ffn.getDst();
+    if (!ffn.getDst().getType().isPtr())
+      return;
+
     if (type.equals(SCRATCH)) {
       currtable.put(dst,SCRATCH);
     } else if (type.equals(NORMAL)) {
-      if (ffn.getField().getType().isPrimitive()&&!ffn.getField().getType().isArray())
-       currtable.put(dst, SCRATCH);         // primitives are local
-      else
-       currtable.put(dst, NORMAL);
+      currtable.put(dst, NORMAL);
     } else if (type.equals(STMEITHER)) {
-      if (ffn.getField().getType().isPrimitive()&&!ffn.getField().getType().isArray())
-       currtable.put(dst, SCRATCH);         // primitives are local
-      else
-       currtable.put(dst, STMEITHER);
+      currtable.put(dst, STMEITHER);
     } else if (type.equals(STMCONFLICT)) {
       throw new Error("Access to object that could be either normal or scratch in context:\n"+ffn+"  "+lb.getExplanation());
     }
index 52dc14907c3628e1f3c86331fcaba89eae4f9678..58545066864ca07ed11bb46fdbbee668adb0c84a 100644 (file)
@@ -105,7 +105,7 @@ public class LocalityBinding {
       else if (isglobal[i].equals(LocalityAnalysis.CONFLICT))
        st+="conflict ";
       else
-       st+="["+isglobalthis+"]";
+       st+="["+isglobal[i]+"]";
     return st;
   }
 
@@ -158,7 +158,7 @@ public class LocalityBinding {
       return b==null;
     } else if (b==null) {
       //a is not null
-      return false;
+      return a==null;
     } else return a.equals(b);
   }