more changes
authorbdemsky <bdemsky>
Fri, 11 Jan 2008 06:49:49 +0000 (06:49 +0000)
committerbdemsky <bdemsky>
Fri, 11 Jan 2008 06:49:49 +0000 (06:49 +0000)
Robust/src/Analysis/TaskStateAnalysis/TagState.java
Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java
Robust/src/Util/GraphNode.java

index 91b505ec76b2e286e08af546e293552008c06413..4cc8fba25507da8fbdb7580d187bbefd854a5ca7 100644 (file)
@@ -13,12 +13,9 @@ public class TagState extends GraphNode {
     public static final int KLIMIT=2;
     public HashSet<TaskDescriptor> sourceset;
 
-    public TagState() {
-       this(null);
-    }
-
     public TagState(ClassDescriptor cd) {
-       this(null);
+       this.flags=new Hashtable<FlagState, Integer>();
+       this.sourceset=new HashSet<TaskDescriptor>();
        this.cd=cd;
     }
 
@@ -29,13 +26,17 @@ public class TagState extends GraphNode {
     public TagState(TagDescriptor tag) {
        this.tag=tag;
        this.flags=new Hashtable<FlagState, Integer>();
-       this.sourceset=new HashSet,TaskDescriptor>();
+       this.sourceset=new HashSet<TaskDescriptor>();
     }
 
     public TagDescriptor getTag() {
        return tag;
     }
 
+    public ClassDescriptor getClassDesc() {
+       return cd;
+    }
+
     public TagState[] clearFS(FlagState fs) {
        int num=0;
        if (flags.containsKey(fs))
index 78a230f086a89ca968dee297ed7ed406856f9850..27893fcc1c6f12ba70a9e603b3392289cfd45531 100644 (file)
@@ -16,7 +16,7 @@ public class TaskTagAnalysis {
     HashSet<TagState> discovered;
     Hashtable<TaskDescriptor, TaskQueue> tasktable;
     Hashtable<TagDescriptor, Set<TagState>> tsresults;
-    Hashtable<ClassDescriptor, Set<FlagState>> fsresults;
+    Hashtable<ClassDescriptor, Set<TagState>> fsresults;
 
 
     /** 
@@ -32,7 +32,7 @@ public class TaskTagAnalysis {
        this.discovered=new HashSet<TagState>();
        this.tasktable=new Hashtable<TaskDescriptor, TaskQueue>();
        this.tsresults=new Hashtable<TagDescriptor, Set<TagState>>();
-       this.fsresults=new Hashtable<ClassDescriptor, Set<FlagState>>();
+       this.fsresults=new Hashtable<ClassDescriptor, Set<TagState>>();
        
 
        for(Iterator taskit=state.getTaskSymbolTable().getDescriptorsIterator();taskit.hasNext();) {
@@ -140,13 +140,13 @@ public class TaskTagAnalysis {
        return table;
     }
 
-    private void processFlatFlag(FlatFlagActionNode fn, Hashtable<TempDescriptor, Wrapper> table) {
+    private void processFlatFlag(FlatFlagActionNode fn, Hashtable<TempDescriptor, Wrapper> table, TaskDescriptor td) {
        if (fn.getTaskType()==FlatFlagActionNode.PRE) {
            throw new Error("Unsupported");
        } else if (fn.getTaskType()==FlatFlagActionNode.TASKEXIT) {
            evalTaskExitNode(fn, table);
        } else if (fn.getTaskType()==FlatFlagActionNode.NEWOBJECT) {
-           evalNewNode(fn, table);
+           evalNewNode(fn, table, td);
        }
     }
 
@@ -354,12 +354,13 @@ public class TaskTagAnalysis {
                throw new Error("Can't clear tag in newly allocated object");
        }
        for(Iterator<FlagState> fsit=ow.fs.iterator();fsit.hasNext();) {
-           FlagState fs2=fsit.ext();
+           FlagState fs2=fsit.next();
            fs2.addAllocatingTask(td);
-           TagState ts2=new TagState(fs2.getClassDesc());
+           TagState ts2=new TagState(fs2.getClassDescriptor());
            ts2.addFS(fs2);
            ts2=canonical(ts2);
            ts2.addSource(td);
+           addresult(fs2.getClassDescriptor(), ts2);
            if (!discovered.contains(ts2)) {
                discovered.add(ts2);
                toprocess.add(ts2);
@@ -385,25 +386,58 @@ public class TaskTagAnalysis {
        tsresults.get(td).add(ts);
     }
 
+    private void addresult(ClassDescriptor cd, TagState ts) {
+       if (!fsresults.containsKey(cd))
+           fsresults.put(cd, new HashSet<TagState>());
+       fsresults.get(cd).add(ts);
+    }
+
     public void recordtagchange(TagWrapper tw, TaskDescriptor td) {
-       assert(tw.initts==null);
+       TagState init=tw.initts;
        for(Iterator<TagState> tsit=tw.ts.iterator(); tsit.hasNext();) {
            TagState ts=tsit.next();
-           ts.addSource(td);
-           addresult(ts.getTag(), ts);
+           if (init==null) {
+               ts.addSource(td);
+           } else {
+               TagEdge te=new TagEdge(ts, td);
+               if (!init.containsEdge(te)) {
+                   init.addEdge(te);
+               }
+           }
+           if (ts.getTag()!=null)
+               addresult(ts.getTag(), ts);
+           else
+               addresult(ts.getClassDesc(), ts);
            if (!discovered.contains(ts)) {
                discovered.add(ts);
                toprocess.add(ts);
            }
        }
     }
-    
+
+    private void recordobj(ObjWrapper ow, TaskDescriptor td) {
+       for(Iterator<TagWrapper> twit=ow.tags.iterator();twit.hasNext();) {
+           TagWrapper tw=twit.next();
+           recordtagchange(tw, td);
+       }
+    }
+
     private void processFlatCall(FlatCall fc, Hashtable<TempDescriptor, Wrapper> table) {
        //Do nothing for now
     }
     
     private void processFlatReturnNode(FlatReturnNode fr, Hashtable<TempDescriptor, Wrapper> table, TaskDescriptor td) {
-
+       for(Iterator<TempDescriptor> tmpit=table.keySet().iterator();tmpit.hasNext();) {
+           TempDescriptor tmp=tmpit.next();
+           Wrapper w=table.get(tmp);
+           if (w instanceof TagWrapper) {
+               TagWrapper tw=(TagWrapper)w;
+               recordtagchange(tw, td);
+           } else {
+               ObjWrapper ow=(ObjWrapper)w;
+               recordobj(ow, td);
+           }
+       }
     }
 
     private boolean equivalent(Hashtable<TempDescriptor, Wrapper> table1, Hashtable<TempDescriptor, Wrapper> table2) {
@@ -461,7 +495,7 @@ public class TaskTagAnalysis {
            Hashtable<TempDescriptor, Wrapper> table=computeInitialState(wtable, fn);
            switch(fn.kind()) {
            case FKind.FlatFlagActionNode:
-               processFlatFlag((FlatFlagActionNode)fn, table);
+               processFlatFlag((FlatFlagActionNode)fn, table, td);
                break;
            case FKind.FlatTagDeclaration:
                processFlatTag((FlatTagDeclaration)fn, table, td);
@@ -557,7 +591,7 @@ public class TaskTagAnalysis {
        FlagState fsstartup=(new FlagState(startupobject)).setFlag(fd,true);
        fsstartup.setAsSourceNode();
        fsstartup=canonical(fsstartup);
-       TagState ts=new TagState();
+       TagState ts=new TagState(startupobject);
        TagState[] tsarray=ts.addFS(fsstartup);
        return canonical(tsarray[0]);
     }
index 424dfc65de82c96a4a618886046a7a3ef00d67a7..0028af76b49646746e8ca253b3e91eda8f9df4f9 100755 (executable)
@@ -99,9 +99,9 @@ public class GraphNode {
        return "";
     }
     
-       public String getName(){
-               return "";
-       }
+    public String getName(){
+       return "";
+    }
 
     public NodeStatus getStatus() {
         return this.status;
@@ -146,6 +146,10 @@ public class GraphNode {
        tonode.inedges.addElement(newedge);
     }
 
+    public boolean containsEdge(Edge e) {
+       return edges.contains(e);
+    }
+
     public void addEdge(Vector v) {
        for (Iterator it = v.iterator(); it.hasNext();)
            addEdge((Edge)it.next());