From: bdemsky Date: Wed, 20 Oct 2010 07:49:03 +0000 (+0000) Subject: more changes...RCR wasn't usable until it was too late... X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=2f0d9d6fb0477593d2bcadc49e71d462a2f5d954;p=IRC.git more changes...RCR wasn't usable until it was too late... --- diff --git a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java index 2cc4119e..9ec6c2d6 100644 --- a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java +++ b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java @@ -85,6 +85,10 @@ public class OoOJavaAnalysis { return cp; } + public Set getNodesWithPlans() { + return codePlans.keySet(); + } + public OoOJavaAnalysis(State state, TypeUtil typeUtil, CallGraph callGraph, Liveness liveness, ArrayReferencees arrayReferencees) { diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index f38efb4c..9b261737 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -219,6 +219,9 @@ public class BuildCode { outmethodheader.println("#include \"psemaphore.h\""); outmethodheader.println("#include \"memPool.h\""); + if (state.RCR) + outmethodheader.println("#include \"rcr_runtime.h\""); + // spit out a global to inform all worker threads with // the maximum size is for any task record outmethodheader.println("extern int "+maxTaskRecSizeStr+";"); @@ -290,40 +293,12 @@ public class BuildCode { } catch (FileNotFoundException e) { System.out.println("Runtime Conflict Resolver could not create output file."); } + rcr.init(); } while(seseit.hasNext()){ FlatSESEEnterNode fsen = seseit.next(); initializeSESE( fsen ); - - //this code will culminate all conflicts into one master hashtable. - if(state.RCR && rcr != null) { - Analysis.OoOJava.ConflictGraph conflictGraph; - Hashtable> conflicts; - - System.out.println("-------"); - System.out.println(fsen); - System.out.println(fsen.getIsCallerSESEplaceholder()); - System.out.println(fsen.getParent()); - - if (fsen.getParent()!=null) { - conflictGraph = oooa.getConflictGraph(fsen.getParent()); - System.out.println("CG="+conflictGraph); - if (conflictGraph!=null) - System.out.println("Conflicts="+conflictGraph.getConflictEffectSet(fsen)); - } - - if(!fsen.getIsCallerSESEplaceholder() && fsen.getParent()!=null && - (conflictGraph = oooa.getConflictGraph(fsen.getParent())) != null && - (conflicts = conflictGraph.getConflictEffectSet(fsen)) != null) { - FlatMethod fm=fsen.getfmEnclosing(); - ReachGraph rg=oooa.getDisjointAnalysis().getReachGraph(fm.getMethod()); - if(rcr.cSideDebug) - rg.writeGraph("RCR_RG_SESE_DEBUG"); - - rcr.addToTraverseToDoList(fsen, rg, conflicts); - } - } } } @@ -693,6 +668,10 @@ public class BuildCode { outstructs.println("#include \"mlp_runtime.h\""); outstructs.println("#include \"psemaphore.h\""); } + if (state.RCR) { + outstructs.println("#include \"rcr_runtime.h\""); + } + /* Output #defines that the runtime uses to determine type * numbers for various objects it needs */ @@ -3125,22 +3104,7 @@ public class BuildCode { for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) { Analysis.OoOJava.WaitingElement waitingElement = (Analysis.OoOJava.WaitingElement) iterator.next(); - - if(state.RCR) { - Analysis.OoOJava.ConflictGraph conflictGraph = graph; - Hashtable> conflicts; - ReachGraph rg = oooa.getDisjointAnalysis().getReachGraph(currentSESE.getmdEnclosing()); - if(rcr.cSideDebug) { - rg.writeGraph("RCR_RG_STALLSITE_DEBUG"); - } - if((conflictGraph != null) && - (conflicts = graph.getConflictEffectSet(fn)) != null && - (rg != null)){ - rcr.addToTraverseToDoList(fn, waitingElement.getTempDesc(), rg, conflicts); - } - } - - if( waitingElement.getStatus() >= ConflictNode.COARSE ){ + if( waitingElement.getStatus() >= ConflictNode.COARSE ){ output.println(" rentry=mlpCreateREntry("+ waitingElement.getStatus()+ ", runningSESE);"); }else{ output.println(" rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+ ", runningSESE, (void*)&" +generateTemp(fm,waitingElement.getTempDesc(),lb)+ ");"); @@ -4273,7 +4237,7 @@ public class BuildCode { TempDescriptor td=invars.get(i); Set weset=seseWaitingQueue.getWaitingElementSet(td); int numqueues=weset.size(); - output.println(" seseToIssue->rcrRecords["+i+"]="+numqueues+";"); + output.println(" seseToIssue->rcrRecords["+i+"].flag="+numqueues+";"); output.println(" dispCount=0;"); for(Iterator wtit=weset.iterator();wtit.hasNext();) { Analysis.OoOJava.WaitingElement waitingElement=wtit.next(); @@ -4285,7 +4249,7 @@ public class BuildCode { output.println(" dispCount++;"); output.println(" }"); } - output.println(" if(!dispCount || !atomic_sub_and_test(dispCount,&(seseToIssue->rcrRecords["+i+"])))"); + output.println(" if(!dispCount || !atomic_sub_and_test(dispCount,&(seseToIssue->rcrRecords["+i+"].flag)))"); output.println(" localCount++;"); if (fsen.getDynamicInVarSet().contains(td)) { // dynamic in-var case diff --git a/Robust/src/IR/Flat/RuntimeConflictResolver.java b/Robust/src/IR/Flat/RuntimeConflictResolver.java index 0a584cde..f713124b 100644 --- a/Robust/src/IR/Flat/RuntimeConflictResolver.java +++ b/Robust/src/IR/Flat/RuntimeConflictResolver.java @@ -10,6 +10,8 @@ import java.util.Iterator; import java.util.Set; import java.util.Vector; import Analysis.Disjoint.*; +import Analysis.MLP.CodePlan; +import IR.Flat.*; import IR.TypeDescriptor; import Analysis.OoOJava.OoOJavaAnalysis; @@ -111,6 +113,71 @@ public class RuntimeConflictResolver { System.out.println("====================END LIST===================="); } } + + public void init() { + //Go through the SESE's + for(Iterator seseit=oooa.getAllSESEs().iterator();seseit.hasNext();) { + FlatSESEEnterNode fsen=seseit.next(); + Analysis.OoOJava.ConflictGraph conflictGraph; + Hashtable> conflicts; + System.out.println("-------"); + System.out.println(fsen); + System.out.println(fsen.getIsCallerSESEplaceholder()); + System.out.println(fsen.getParent()); + + if (fsen.getParent()!=null) { + conflictGraph = oooa.getConflictGraph(fsen.getParent()); + System.out.println("CG="+conflictGraph); + if (conflictGraph!=null) + System.out.println("Conflicts="+conflictGraph.getConflictEffectSet(fsen)); + } + + if(!fsen.getIsCallerSESEplaceholder() && fsen.getParent()!=null && + (conflictGraph = oooa.getConflictGraph(fsen.getParent())) != null && + (conflicts = conflictGraph.getConflictEffectSet(fsen)) != null) { + FlatMethod fm=fsen.getfmEnclosing(); + ReachGraph rg=oooa.getDisjointAnalysis().getReachGraph(fm.getMethod()); + if(cSideDebug) + rg.writeGraph("RCR_RG_SESE_DEBUG"); + + addToTraverseToDoList(fsen, rg, conflicts); + } + } + //Go through the stall sites + for(Iterator codeit=oooa.getNodesWithPlans().iterator();codeit.hasNext();) { + FlatNode fn=codeit.next(); + CodePlan cp=oooa.getCodePlan(fn); + FlatSESEEnterNode currentSESE=cp.getCurrentSESE(); + Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(currentSESE); + + if(graph!=null){ + Set seseLockSet = oooa.getLockMappings(graph); + Set waitingElementSet = + graph.getStallSiteWaitingElementSet(fn, seseLockSet); + + if(waitingElementSet.size()>0){ + for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) { + Analysis.OoOJava.WaitingElement waitingElement = (Analysis.OoOJava.WaitingElement) iterator.next(); + + Analysis.OoOJava.ConflictGraph conflictGraph = graph; + Hashtable> conflicts; + ReachGraph rg = oooa.getDisjointAnalysis().getReachGraph(currentSESE.getmdEnclosing()); + if(cSideDebug) { + rg.writeGraph("RCR_RG_STALLSITE_DEBUG"); + } + if((conflictGraph != null) && + (conflicts = graph.getConflictEffectSet(fn)) != null && + (rg != null)){ + addToTraverseToDoList(fn, waitingElement.getTempDesc(), rg, conflicts); + } + } + } + } + } + + buildEffectsLookupStructure(); + runAllTraversals(); + } /* * Basic Strategy: @@ -243,9 +310,6 @@ public class RuntimeConflictResolver { } public void close() { - buildEffectsLookupStructure(); - runAllTraverserals(); - //prints out all generated code for(TaintAndInternalHeapStructure ths: pendingPrintout) { printCMethod(ths.nodesInHeap, ths.t); @@ -278,7 +342,7 @@ public class RuntimeConflictResolver { enumerateHeaproots(); } - private void runAllTraverserals() { + private void runAllTraversals() { for(TraversalInfo t: toTraverse) { printDebug(javaDebug, "Running Traversal a traversal on " + t.f); @@ -320,12 +384,12 @@ public class RuntimeConflictResolver { Vector invars=fsen.getInVarsForDynamicCoarseConflictResolution(); for(int i=0;i"+tmp+", record", fsen)); + cFile.println(" " + this.getTraverserInvocation(tmp, "rec->"+tmp+", rec", fsen)); } cFile.println( " }"); cFile.println( " break;"); } - + cFile.println(" default:\n printf(\"Invalid SESE ID was passed in.\\n\");\n break;"); cFile.println(" }"); @@ -343,7 +407,7 @@ public class RuntimeConflictResolver { for(Taint t: doneTaints.keySet()) { cFile.println(" case " + doneTaints.get(t)+ ":"); if(t.isRBlockTaint()) { - cFile.println(" " + this.getTraverserInvocation(t.getVar(), "startingPtr, record", t.getSESE())); + cFile.println(" " + this.getTraverserInvocation(t.getVar(), "startingPtr, ("+t.getSESE().getSESErecordName()+" *)record", t.getSESE())); } else if (t.isStallSiteTaint()){ cFile.println(" " + this.getTraverserInvocation(t.getVar(), "startingPtr, record", t.getStallSite())); } else { @@ -563,8 +627,8 @@ public class RuntimeConflictResolver { */ private void printCMethod(Hashtable created, Taint taint) { - //This hash table keeps track of all the case statements generated. Although it may seem a bit much - //for its purpose, I think it may come in handy later down the road to do it this way. + //This hash table keeps track of all the case statements generated. Although it may seem a bit much + //for its purpose, I think it may come in handy later down the road to do it this way. //(i.e. what if we want to eliminate some cases? Or build filter for 1 case) String inVar = taint.getVar().getSafeSymbol(); String rBlock; @@ -584,15 +648,20 @@ public class RuntimeConflictResolver { for (ConcreteRuntimeObjNode node : created.values()) { printDebug(javaDebug, "Considering " + node.allocSite + " for traversal"); if (!cases.containsKey(node.allocSite) && qualifiesForCaseStatement(node)) { - printDebug(javaDebug, "+\t" + node.allocSite + " qualified for case statement"); addChecker(taint, node, cases, null, "ptr", 0); } } //IMPORTANT: remember to change getTraverserInvocation if you change the line below - String methodName = "void traverse___" + removeInvalidChars(inVar) + - removeInvalidChars(rBlock) + "___(void * InVar, SESEcommon *record)"; - + String methodName; + if (taint.isStallSiteTaint()) { + methodName= "void traverse___" + removeInvalidChars(inVar) + + removeInvalidChars(rBlock) + "___(void * InVar, SESEcommon *record)"; + } else { + methodName= "void traverse___" + removeInvalidChars(inVar) + + removeInvalidChars(rBlock) + "___(void * InVar, "+taint.getSESE().getSESErecordName() +" *record)"; + } + cFile.println(methodName + " {"); headerFile.println(methodName + ";"); @@ -602,14 +671,12 @@ public class RuntimeConflictResolver { if(cases.size() == 0) { cFile.println(" return; }"); - } - else { + } else { //clears queue and hashtable that keeps track of where we've been. cFile.println(clearQueue + ";\n" + resetVisitedHashTable + ";"); //Casts the ptr to a genericObjectStruct so we can get to the ptr->allocsite field. - cFile.println("struct ___Object___ * ptr = (struct ___Object___ *) InVar;\nif (InVar != NULL) {\n " + queryVistedHashtable - + "(ptr);\n do {"); + cFile.println("struct ___Object___ * ptr = (struct ___Object___ *) InVar;\nif (InVar != NULL) {\n " + queryVistedHashtable + "(ptr);\n do {"); cFile.println(" switch(ptr->allocsite) {"); @@ -682,13 +749,13 @@ public class RuntimeConflictResolver { assert heaprootNum != -1; int allocSiteID = connectedHRHash.get(taint).getWaitingQueueBucketNum(node); int traverserID = doneTaints.get(taint); - currCase.append(" rcr_WRITEBINCASE(allHashStructures["+heaprootNum+"],"+prefix+", record, "+index+")"); + currCase.append(" rcr_WRITEBINCASE(allHashStructures["+heaprootNum+"],"+prefix+", (SESEcommon *) record, "+index+")"); } else if (primConfRead||objConfRead) { int heaprootNum = connectedHRHash.get(taint).id; assert heaprootNum != -1; int allocSiteID = connectedHRHash.get(taint).getWaitingQueueBucketNum(node); int traverserID = doneTaints.get(taint); - currCase.append(" rcr_READBINCASE(allHashStructures["+heaprootNum+"],"+prefix+", record, "+index+")"); + currCase.append(" rcr_READBINCASE(allHashStructures["+heaprootNum+"],"+prefix+", (SESEcommon *) record, "+index+")"); } if(objConfRead) {