From 9e5f005202221b45bc2b17cd8454bbb8e99d96e4 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Sun, 28 Jun 2009 08:17:30 +0000 Subject: [PATCH] changes --- .../Analysis/Locality/DelayComputation.java | 102 ++++++++++-------- Robust/src/IR/Flat/BuildCode.java | 2 +- 2 files changed, 59 insertions(+), 45 deletions(-) diff --git a/Robust/src/Analysis/Locality/DelayComputation.java b/Robust/src/Analysis/Locality/DelayComputation.java index 058d336e..ec812588 100644 --- a/Robust/src/Analysis/Locality/DelayComputation.java +++ b/Robust/src/Analysis/Locality/DelayComputation.java @@ -155,7 +155,7 @@ public class DelayComputation { return liveinto; } - //This method computes which temps are live out of the second part + //This method computes which temps are live out of the second part public Set liveoutvirtualread(LocalityBinding lb, FlatAtomicEnterNode faen) { MethodDescriptor md=lb.getMethod(); FlatMethod fm=state.getMethodFlat(md); @@ -187,7 +187,7 @@ public class DelayComputation { FlatNode fn2=fnit2.next(); if (secondpart.contains(fn2)) { insidenode=true; - } else { + } else if (!atomicnodes.contains(fn2)) { outsidenode=true; } if (outsidenode&&insidenode) { @@ -248,15 +248,57 @@ public class DelayComputation { public Set livecode(LocalityBinding lb) { if (!othermap.containsKey(lb)) return null; - HashSet delayedset=notreadymap.get(lb); MethodDescriptor md=lb.getMethod(); FlatMethod fm=state.getMethodFlat(md); + + HashSet delayedset=notreadymap.get(lb); + HashSet otherset=othermap.get(lb); + HashSet cannotdelayset=cannotdelaymap.get(lb); + Hashtable> livemap=Liveness.computeLiveTemps(fm); + Hashtable>> reachingdefsmap=ReachingDefs.computeReachingDefs(fm, livemap); + HashSet unionset=new HashSet(delayedset); + Hashtable>> map=new Hashtable>>(); + HashSet livenodes=new HashSet(); + + for(Iterator fnit=fm.getNodeSet().iterator();fnit.hasNext();) { + FlatNode fn=fnit.next(); + if (fn.kind()==FKind.FlatAtomicExitNode) { + Set livetemps=livemap.get(fn); + Hashtable> tempmap=reachingdefsmap.get(fn); + for(Iterator tmpit=livetemps.iterator();tmpit.hasNext();) { + TempDescriptor tmp=tmpit.next(); + Set fnset=tempmap.get(tmp); + boolean inpart1=false; + boolean inpart2=false; + for(Iterator fnit2=fnset.iterator();fnit2.hasNext();) { + FlatNode fn2=fnit2.next(); + if (delayedset.contains(fn2)) { + inpart2=true; + if (inpart1) + break; + } else if (otherset.contains(fn2)||cannotdelayset.contains(fn2)) { + inpart1=true; + if (inpart2) + break; + } + } + if (inpart1&&inpart2) { + for(Iterator fnit2=fnset.iterator();fnit2.hasNext();) { + FlatNode fn2=fnit2.next(); + if (otherset.contains(fn2)||cannotdelayset.contains(fn2)) { + unionset.add(fn2); + livenodes.add(fn2); + } + } + } + } + } + } + HashSet toanalyze=new HashSet(); toanalyze.add(fm); - - HashSet livenodes=new HashSet(); while(!toanalyze.isEmpty()) { FlatNode fn=toanalyze.iterator().next(); @@ -292,8 +334,10 @@ public class DelayComputation { TempDescriptor readset[]=fn.readsTemps(); for(int i=0;i1) { //We have a conditional branch...need to handle this carefully - Set set0=getNext(fn, 0, delayedset, lb, locality); - Set set1=getNext(fn, 1, delayedset, lb, locality); + Set set0=getNext(fn, 0, unionset, lb, locality, false); + Set set1=getNext(fn, 1, unionset, lb, locality, false); if (!set0.equals(set1)||set0.size()>1) { //This branch is important--need to remember how it goes livenodes.add(fn); + unionset.add(fn); } } } @@ -330,41 +375,8 @@ public class DelayComputation { } return livenodes; } - - - public static Set getBranchNodes(FlatNode fn, int i, Set delayset, LocalityBinding lb, LocalityAnalysis locality) { - FlatNode fnnext=fn.getNext(i); - Hashtable atomictable=locality.getAtomic(lb); - - HashSet reachable=new HashSet(); - - if (delayset.contains(fnnext)||atomictable.get(fnnext).intValue()==0) { - reachable.add(fnnext); - return reachable; - } - - Stack nodes=new Stack(); - HashSet visited=new HashSet(); - nodes.push(fnnext); - visited.add(fn);//don't go back to the start node - - while(!nodes.isEmpty()) { - FlatNode fn2=nodes.pop(); - if (visited.contains(fn2)) - continue; - visited.add(fn2); - for (int j=0;j getNext(FlatNode fn, int i, Set delayset, LocalityBinding lb, LocalityAnalysis locality) { + public static Set getNext(FlatNode fn, int i, Set delayset, LocalityBinding lb, LocalityAnalysis locality, boolean contpastnode) { Hashtable atomictable=locality.getAtomic(lb); FlatNode fnnext=fn.getNext(i); HashSet reachable=new HashSet(); @@ -376,6 +388,8 @@ public class DelayComputation { Stack nodes=new Stack(); HashSet visited=new HashSet(); nodes.push(fnnext); + if (contpastnode) + visited.add(fn); while(!nodes.isEmpty()) { FlatNode fn2=nodes.pop(); @@ -477,8 +491,8 @@ public class DelayComputation { //Delay branches if possible if (fn.kind()==FKind.FlatCondBranch) { - Set leftset=getBranchNodes(fn, 0, cannotdelay, lb, locality); - Set rightset=getBranchNodes(fn, 1, cannotdelay, lb, locality); + Set leftset=getNext(fn, 0, cannotdelay, lb, locality,true); + Set rightset=getNext(fn, 1, cannotdelay, lb, locality,true); if (leftset.size()>0&&rightset.size()>0&& !leftset.equals(rightset)||leftset.size()>1) isnodelay=true; diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 41343cd2..e8728ef6 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -2043,7 +2043,7 @@ public class BuildCode { } } if (computeside) { - Set leftset=DelayComputation.getBranchNodes(current_node, 0, unionset, lb,locality); + Set leftset=DelayComputation.getNext(current_node, 0, unionset, lb,locality, true); int branch=0; if (leftset.size()==0) branch=1; -- 2.34.1