From f0fcce027ecb3096ea8539f8c06bea4834d15afb Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 27 Jul 2007 08:17:52 +0000 Subject: [PATCH] fix bugs --- .../Analysis/Locality/LocalityAnalysis.java | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/Robust/src/Analysis/Locality/LocalityAnalysis.java b/Robust/src/Analysis/Locality/LocalityAnalysis.java index 455ebe8e..b6c5c6f6 100644 --- a/Robust/src/Analysis/Locality/LocalityAnalysis.java +++ b/Robust/src/Analysis/Locality/LocalityAnalysis.java @@ -15,9 +15,10 @@ import IR.Flat.*; public class LocalityAnalysis { State state; - Stack tovisit; + Stack lbtovisit; Hashtable discovered; - Hashtable dependence; + Hashtable> dependence; + CallGraph callgraph; TypeUtil typeutil; public static final Integer LOCAL=new Integer(0); @@ -26,10 +27,11 @@ public class LocalityAnalysis { public static final Integer CONFLICT=new Integer(3); public LocalityAnalysis(State state, CallGraph callgraph, TypeUtil typeutil) { + this.typeutil=typeutil; this.state=state; this.discovered=new Hashtable(); - this.dependence=new Hashtable(); - this.tovisit=new Stack(); + this.dependence=new Hashtable>(); + this.lbtovisit=new Stack(); this.callgraph=callgraph; doAnalysis(); } @@ -40,18 +42,26 @@ public class LocalityAnalysis { private void computeLocalityBindings() { LocalityBinding lbmain=new LocalityBinding(typeutil.getMain(), false); - tovisit.add(lbmain); + lbmain.setGlobal(0, LOCAL); + lbtovisit.add(lbmain); discovered.put(lbmain, lbmain); - while(!tovisit.empty()) { - LocalityBinding lb=(LocalityBinding) tovisit.pop(); + while(!lbtovisit.empty()) { + LocalityBinding lb=(LocalityBinding) lbtovisit.pop(); + Integer returnglobal=lb.getGlobalReturn(); MethodDescriptor md=lb.getMethod(); Hashtable> temptable=new Hashtable>(); Hashtable atomictable=new Hashtable(); computeCallsFlags(md, lb, temptable, atomictable); + if (!md.isStatic()&&!returnglobal.equals(lb.getGlobalReturn())) { + //return type is more precise now + //rerun everything that call us + lbtovisit.addAll(dependence.get(lb)); + } } } + public void computeCallsFlags(MethodDescriptor md, LocalityBinding lb, Hashtable> temptable, Hashtable atomictable) { FlatMethod fm=state.getMethodFlat(md); HashSet tovisit=new HashSet(); @@ -61,15 +71,20 @@ public class LocalityAnalysis { Hashtable table=new Hashtable(); temptable.put(fm, table); atomictable.put(fm, lb.isAtomic()?1:0); - for(int i=0;i currtable=new Hashtable(); int atomicstate=0; for(int i=0;i tempit=prevtable.keySet().iterator();tempit.hasNext();) { TempDescriptor temp=tempit.next(); Integer tmpint=prevtable.get(temp); - Integer oldint=currtable.containsKey(temp)?currtable.get(temp):null; + Integer oldint=currtable.containsKey(temp)?currtable.get(temp):EITHER; Integer newint=merge(tmpint, oldint); currtable.put(temp, newint); } @@ -169,7 +184,7 @@ public class LocalityAnalysis { MethodDescriptor nodemd=fc.getMethod(); Set methodset=fc.getThis()==null?callgraph.getMethods(nodemd): callgraph.getMethods(nodemd, fc.getThis().getType()); - Integer currreturnval=null; + Integer currreturnval=EITHER; //Start off with the either value for(Iterator methodit=methodset.iterator();methodit.hasNext();) { MethodDescriptor md=(MethodDescriptor) methodit.next(); LocalityBinding lb=new LocalityBinding(md, isatomic); @@ -179,6 +194,8 @@ public class LocalityAnalysis { } if (fc.getThis()!=null) { Integer thistype=currtable.get(fc.getThis()); + if (thistype==null) + thistype=EITHER; if(thistype.equals(CONFLICT)) throw new Error("Using type that can be either local or global in context:\n"+currlb.getExplanation()); if(thistype.equals(GLOBAL)&&!isatomic) @@ -190,15 +207,19 @@ public class LocalityAnalysis { if (!discovered.containsKey(lb)) { lb.setGlobalReturn(EITHER); lb.setParent(currlb); - tovisit.add(lb); + lbtovisit.add(lb); discovered.put(lb, lb); } else lb=discovered.get(lb); Integer returnval=lb.getGlobalReturn(); currreturnval=merge(returnval, currreturnval); - dependence.put(md, currlb.getMethod()); + if (!dependence.containsKey(lb)) + dependence.put(lb, new HashSet()); + dependence.get(lb).add(currlb); + } + if (fc.getReturnTemp()!=null) { + currtable.put(fc.getReturnTemp(), currreturnval); } - currtable.put(fc.getReturnTemp(), currreturnval); } void processFieldNode(LocalityBinding lb, FlatFieldNode ffn, boolean transaction, Hashtable currtable) { -- 2.34.1