From c45ffec9b8a137a41d3f29cb5bcf1decbd32e419 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 19 Jun 2009 23:30:03 +0000 Subject: [PATCH] more code towards transaction optimizations --- .../Analysis/Locality/DelayComputation.java | 17 ++--- .../Analysis/Locality/LocalityAnalysis.java | 29 +------- Robust/src/IR/Flat/BuildCode.java | 72 ++++++++++++++++--- 3 files changed, 71 insertions(+), 47 deletions(-) diff --git a/Robust/src/Analysis/Locality/DelayComputation.java b/Robust/src/Analysis/Locality/DelayComputation.java index 8bc4713f..1f8852e6 100644 --- a/Robust/src/Analysis/Locality/DelayComputation.java +++ b/Robust/src/Analysis/Locality/DelayComputation.java @@ -382,19 +382,14 @@ public class DelayComputation { toanalyze.add(fn.getPrev(i)); }//end of while loop HashSet notreadyset=computeNotReadySet(lb, cannotdelay); - HashSet atomicset=new HashSet(); - for(Iterator fnit=fm.getNodeSet().iterator();fnit.hasNext();) { - FlatNode fn=fnit.next(); - boolean isatomic=atomictable.get(fn).intValue()>0; - if (isatomic) - atomicset.add(fn); - } - if (!atomicset.isEmpty()) { - atomicset.removeAll(notreadyset); - atomicset.removeAll(cannotdelay); + HashSet otherset=new HashSet(); + otherset.addAll(fm.getNodeSet()); + if (lb.getHasAtomic()) { + otherset.removeAll(notreadyset); + otherset.removeAll(cannotdelay); notreadymap.put(lb, notreadyset); cannotdelaymap.put(lb, cannotdelay); - othermap.put(lb, atomicset); + othermap.put(lb, otherset); } //We now have: diff --git a/Robust/src/Analysis/Locality/LocalityAnalysis.java b/Robust/src/Analysis/Locality/LocalityAnalysis.java index f86ada2c..9c53efeb 100644 --- a/Robust/src/Analysis/Locality/LocalityAnalysis.java +++ b/Robust/src/Analysis/Locality/LocalityAnalysis.java @@ -7,6 +7,7 @@ import IR.State; import IR.TypeUtil; import IR.MethodDescriptor; import IR.Flat.*; +import Analysis.Liveness; import IR.ClassDescriptor; public class LocalityAnalysis { @@ -1119,33 +1120,7 @@ public class LocalityAnalysis { } Hashtable> computeLiveTemps(FlatMethod fm) { - Hashtable> nodetotemps=new Hashtable>(); - - Set toprocess=fm.getNodeSet(); - - while(!toprocess.isEmpty()) { - FlatNode fn=toprocess.iterator().next(); - toprocess.remove(fn); - - List reads=Arrays.asList(fn.readsTemps()); - List writes=Arrays.asList(fn.writesTemps()); - - HashSet tempset=new HashSet(); - for(int i=0; i nodetolabel=assignLabels(first, stop); + Set storeset=null; + HashSet genset=null; + + if (state.DELAYCOMP) { + storeset=delaycomp.livecode(lb); + genset=new HashSet(); + if (firstpass) { + genset.addAll(delaycomp.getCannotDelay(lb)); + genset.addAll(delaycomp.getOther(lb)); + } else { + genset.addAll(delaycomp.getNotReady(lb)); + } + } + /* Do the actual code generation */ FlatNode current_node=null; HashSet tovisit=new HashSet(); @@ -1843,6 +1856,28 @@ public class BuildCode { FlatSESEEnterNode fsen = (FlatSESEEnterNode)current_node; generateFlatNode(fm, lb, current_node, output); nextnode=fsen.getFlatExit().getNext(0); + } else if (state.DELAYCOMP) { + if (genset.contains(current_node)) + generateFlatNode(fm, lb, current_node, output); + if (storeset.contains(current_node)) { + TempDescriptor wrtmp=current_node.writesTemps()[0]; + if (firstpass) { + //need to store value written by previous node + if (wrtmp.getType().isPtr()) { + output.println("STOREPTR("+generateTemp(fm, wrtmp,lb)+");"); + } else { + output.println("STORE"+wrtmp.getType().getSafeDescriptor()+"("+generateTemp(fm, wrtmp, lb)+");"); + } + } else { + //need to read value read by previous node + if (wrtmp.getType().isPtr()) { + output.println("RESTOREPTR("+generateTemp(fm, wrtmp,lb)+");"); + } else { + output.println("RESTORE"+wrtmp.getType().getSafeDescriptor()+"("+generateTemp(fm, wrtmp, lb)+");"); + } + } + } + nextnode=current_node.getNext(0); } else { output.print(" "); generateFlatNode(fm, lb, current_node, output); @@ -1855,8 +1890,25 @@ public class BuildCode { current_node=nextnode; } else if (current_node.numNext()==2) { /* Branch */ - output.print(" "); - generateFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output); + if (state.DELAYCOMP) { + if (firstpass) { + //need to record which way it should go + output.print(" "); + if (storeset.contains(current_node)) { + //need to store which way branch goes + generateStoreFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output); + } else + generateFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output); + } else { + if (storeset.contains(current_node)) { + //need to do branch + output.println("RESTOREANDBRANCH(L"+nodetolabel.get(current_node.getNext(1))+");"); + } + } + } else { + output.print(" "); + generateFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output); + } if (!visited.contains(current_node.getNext(1))) tovisit.add(current_node.getNext(1)); if (visited.contains(current_node.getNext(0))) { @@ -1868,11 +1920,11 @@ public class BuildCode { } } - /** This method assigns labels to FlatNodes */ protected Hashtable assignLabels(FlatNode first) { return assignLabels(first, null); } + protected Hashtable assignLabels(FlatNode first, FlatSESEExitNode last) { HashSet tovisit=new HashSet(); HashSet visited=new HashSet(); @@ -1937,9 +1989,7 @@ public class BuildCode { } protected void generateFlatNode(FlatMethod fm, LocalityBinding lb, FlatNode fn, PrintWriter output) { - switch(fn.kind()) { - case FKind.FlatAtomicEnterNode: generateFlatAtomicEnterNode(fm, lb, (FlatAtomicEnterNode) fn, output); break; @@ -3019,6 +3069,10 @@ public class BuildCode { } } + protected void generateStoreFlatCondBranch(FlatMethod fm, LocalityBinding lb, FlatCondBranch fcb, String label, PrintWriter output) { + output.println("STOREANDBRANCH(!"+generateTemp(fm, fcb.getTest(),lb)+", "+label+");"); + } + protected void generateFlatCondBranch(FlatMethod fm, LocalityBinding lb, FlatCondBranch fcb, String label, PrintWriter output) { output.println("if (!"+generateTemp(fm, fcb.getTest(),lb)+") goto "+label+";"); } -- 2.34.1