From: bdemsky Date: Thu, 10 Jan 2008 06:55:11 +0000 (+0000) Subject: more code X-Git-Tag: preEdgeChange~313 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=41b4760d6a5c32cb70e4c3b0a7bcebbda15c8760;p=IRC.git more code --- diff --git a/Robust/src/Analysis/TaskStateAnalysis/ObjWrapper.java b/Robust/src/Analysis/TaskStateAnalysis/ObjWrapper.java index 913b45b7..e2a9e99b 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/ObjWrapper.java +++ b/Robust/src/Analysis/TaskStateAnalysis/ObjWrapper.java @@ -5,15 +5,20 @@ import IR.Flat.*; import java.util.*; public class ObjWrapper implements Wrapper{ - Flagstate initfs; + FlagState initfs; HashSet fs; HashSet tags; public ObjWrapper(FlagState fs) { this.initfs=fs; this.fs=new HashSet(); - this.fs.add(fs); tags=new HashSet(); } + public ObjWrapper() { + this.fs=new HashSet(); + this.tags=new HashSet(); + } + + } diff --git a/Robust/src/Analysis/TaskStateAnalysis/TagState.java b/Robust/src/Analysis/TaskStateAnalysis/TagState.java index b2f4d4d1..925ed818 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/TagState.java +++ b/Robust/src/Analysis/TaskStateAnalysis/TagState.java @@ -24,6 +24,23 @@ public class TagState extends GraphNode { return tag; } + public TagState[] clearFS(FlagState fs) { + int num=0; + if (flags.containsKey(fs)) + num=flags.get(fs).intValue(); + if (num>0) + num--; + + TagState ts=new TagState(tag); + ts.flags.putAll(flags); + ts.flags.put(fs, new Integer(num)); + + if ((num+1)==KLIMIT) + return new TagState[] {ts, this}; + else + return new TagState[] {ts}; + } + public TagState[] addnewFS(FlagState fs) { int num=0; if (flags.containsKey(fs)) diff --git a/Robust/src/Analysis/TaskStateAnalysis/TagWrapper.java b/Robust/src/Analysis/TaskStateAnalysis/TagWrapper.java index 1cdad2c2..9e20521f 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/TagWrapper.java +++ b/Robust/src/Analysis/TaskStateAnalysis/TagWrapper.java @@ -6,11 +6,11 @@ import java.util.*; public class TagWrapper implements Wrapper { TagState initts; - Vector ts; + HashSet ts; public TagWrapper(TagState ts) { this.initts=ts; - this.ts=new Vector(); + this.ts=new HashSet(); this.ts.addAll(ts); } diff --git a/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java b/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java index f8e2e54b..4fd84f6d 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java +++ b/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java @@ -110,51 +110,175 @@ public class TaskTagAnalysis { if (obj instanceof TagWrapper) continue; ObjWrapper prevobj=(ObjWrapper)obj; - if (table.containsKey(tmp)) { + if (!table.containsKey(tmp)) { //merge tag states - ObjWrapper newobj=new ObjWrapper(prevobj.fs); + ObjWrapper newobj=new ObjWrapper(); + newobj.initfs=prevobj.initfs; table.put(tmp, newobj); } ObjWrapper currobj=(ObjWrapper) table.get(tmp); - for(int j=0;j tagit=prevobj.tags.iterator();tagit.hasNext();) { + TagWrapper tprev=tagit.next(); + TagWrapper t=tagtable.get(tprev); + currobj.tags.add(t); + } + for(Iterator flagit=prevobj.fs.iterator();flagit.hasNext();) { + FlagState fs=flagit.nexT(); + currobj.fs.add(fs); } } } return table; } - private void processFlatFlag(FlatFlagActionNode fn, Hashtable table) { + private void processFlatFlag(FlatFlagActionNode fn, Hashtable table) { + if (fn.getTaskType()==FlatFlagActionNode.PRE) { + throw new Error("Unsupported"); + } else if (fn.getTaskType()==FlatFlagActionNode.TASKEXIT) { + evalTaskExitNode(fn, table); + + } else if (fn.getTaskType()==FlatFlagActionNode.NEW) { + } + } + + private void setFlag(ObjWrapper ow, FlagDescriptor fd, boolean value) { + HashSet newstate=new HashSet(); + Hastable flagmap=new Hashtable(); + for(Iterator flagit=ow.fs.iterator();flagit.hasNext();) { + FlagState fs=flagit.next(); + FlagState fsnew=canonical(fs.setFlag(fd, value)); + newstate.add(fsnew); + flagmap.put(fs, fsnew); + } + + for(Iterator tagit=ow.tags.iterator();tagit.hasNext();) { + TagWrapper tw=tagit.next(); + HashSet newstates=new HashSet(); + for(Iterator tgit=tw.ts.iterator();tgit.hasNext();) { + TagState ts=tgit.next(); + for(Iterator flagit=ts.flags.keySet();flagit.hasNext();) { + FlagState fs=flagit.next(); + if (flagmap.containsKey(fs)) { + if (flagmap.get(fs).equals(fs)) { + newstates.add(ts); + } else { + TagState tsarray[]=ts.clearFS(fs); + //Can do strong update here because these + //must be parameter objects...therefore + //all possible aliasing relationships are + //explored + for(int i=0;i table) { + private void setTag(ObjWrapper ow, TagWrapper tw, boolean value) { + + + } + + private void evalTaskExitNode(FlatFlagActionNode fn, Hashtable table) { + //Process clears first + for(Iterator it_ttp=ffan.getTempTagPairs();it_ttp.hasNext();) { + TempTagPair ttp=(TempTagPair)it_ttp.next(); + TempDescriptor tmp=ttp.getTemp(); + TempDescriptor tagtmp=ttp.getTagTemp(); + TagWrapper tagw=(TagWrapper)table.get(tagtmp) + boolean newtagstate=fn.getTagChange(ttp); + ObjWrapper ow=(ObjWrapper)table.get(tmp); + if (!newtagstate) + setTag(ow, tagw, newtagstate); + } + + //Process sets next + for(Iterator it_ttp=ffan.getTempTagPairs();it_ttp.hasNext();) { + TempTagPair ttp=(TempTagPair)it_ttp.next(); + TempDescriptor tmp=ttp.getTemp(); + TempDescriptor tagtmp=ttp.getTagTemp(); + TagWrapper tagw=(TagWrapper)table.get(tagtmp) + boolean newtagstate=fn.getTagChange(ttp); + ObjWrapper ow=(ObjWrapper)table.get(tmp); + if (newtagstate) + setTag(ow, tagw, newtagstate); + } + + //Do the flags last + for(Iterator it_tfp=fn.getTempFlagPairs();it_tfp.hasNext();) { + TempFlagPair tfp=it_tfp.next(); + TempDescriptor tmp=tfp.getTemp(); + FlagDescriptor fd=tfp.getFlag(); + boolean newflagstate=fn.getFlagChange(tfp); + ObjWrapper ow=(ObjWrapper)table.get(tmp); + setFlag(ow, fd, newflagstate); + } + } + + private void processFlatTag(FlatTagDeclaration fn, Hashtable table) { + TempDescriptor tmp=fn.getDst(); + if (table.containsKey(tmp)) { + recordtagchange(table.get(tmp)); + } + TagDescriptor tag=fn.getTag(); + TagState ts=canonical(new TagState(tag)); + TagWrapper tw=new TagWrapper(ts); + tw.initts=null; + table.put(tmp, tw); + } + + private void processFlatCall(FlatCall fc, Hashtable table) { //Do nothing for now } - private void processFlatReturnNode(FlatReturnNode fr, Hashtable table) { + private void processFlatReturnNode(FlatReturnNode fr, Hashtable table) { } private boolean equivalent(Hashtable table1, Hashtable table2) { Hashtable emap=new Hashtable; + + if (table1.keySet().size()!=table2.keySet().size()) + return false; + for(Iterator tmpit=table1.keySet().iterator();tmpit.hasNext();) { TempDescriptor tmp=tmpit.next(); if (table2.containsKey(tmp)) { emap.put(table1.get(tmp), table2.get(tmp)); } else return false; } - for(Iterator tmpit=table2.keySet().iterator();tmpit.hasNext();) { + + for(Iterator tmpit=table1.keySet().iterator();tmpit.hasNext();) { TempDescriptor tmp=tmpit.next(); - if (table1.containsKey(tmp)) { - emap.put(table1.get(tmp), table2.get(tmp)); - } else return false; + Wrapper w1=table1.get(tmp); + Wrapper w2=table2.get(tmp); + if (w1 instanceof TagWrapper) { + TagWrapper t1=(TagWrapper)w1; + TagWrapper t2=(TagWrapper)w2; + if (!t1.ts.equals(t2.ts)) + return false; + + } else { + ObjWrapper t1=(ObjWrapper)w1; + ObjWrapper t2=(ObjWrapper)w2; + if (!t1.fs.equals(t2.fs)) + return false; + if (t1.tags.size()!=t2.tags.size()) + return false; + for(Iterator twit=t1.tags.iterator();twit.hasNext();) { + TagWrapper tw1=twit.next(); + if (!t2.tags.contains(emap.get(tw1))) + return false; + } + } } - - for - + return true; } private void doAnalysis(TaskBinding tb) { @@ -174,6 +298,9 @@ public class TaskTagAnalysis { case FKind.FlatFlagActionNode: processFlatFlag((FlatFlagActionNode)fn, table); break; + case FKind.FlatTagDeclaration: + processFlatTag((FlatTagDeclaration)fn, table); + break; case FKind.FlatCall: processFlatCall((FlatCall)fn, table); break;