From: jjenista Date: Thu, 3 Feb 2011 22:15:00 +0000 (+0000) Subject: This is a compile-stable update of OoOJava code, there are almost certainly bugs... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=92e3e49e7d7ad0d6a32f80743b0d22ede1c625b2;p=IRC.git This is a compile-stable update of OoOJava code, there are almost certainly bugs lurking... --- diff --git a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java index 71051fef..e7abf1b8 100644 --- a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java +++ b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java @@ -117,11 +117,11 @@ public class OoOJavaAnalysis { } - public OoOJavaAnalysis(State state, - TypeUtil typeUtil, - CallGraph callGraph, - Liveness liveness, - ArrayReferencees arrayReferencees) { + public OoOJavaAnalysis( State state, + TypeUtil typeUtil, + CallGraph callGraph, + Liveness liveness, + ArrayReferencees arrayReferencees ) { double timeStartAnalysis = (double) System.nanoTime(); @@ -212,40 +212,9 @@ public class OoOJavaAnalysis { notAvailableForward(fm); } - // 7th pass, make conflict graph - // conflict graph is maintained by each parent sese, - // where its' own stall sites and children may appear - Set allSESEs=rblockRel.getAllSESEs(); - for (Iterator iterator = allSESEs.iterator(); iterator.hasNext();) { - - FlatSESEEnterNode parent = (FlatSESEEnterNode) iterator.next(); - if (!parent.getIsLeafSESE()) { - - EffectsAnalysis effectsAnalysis = disjointAnalysisTaints.getEffectsAnalysis(); - ConflictGraph conflictGraph = sese2conflictGraph.get(parent); - if (conflictGraph == null) { - conflictGraph = new ConflictGraph(state); - } - - Set children = parent.getChildren(); - for (Iterator iterator2 = children.iterator(); iterator2.hasNext();) { - FlatSESEEnterNode child = (FlatSESEEnterNode) iterator2.next(); - Hashtable> taint2Effects = effectsAnalysis.get(child); - conflictGraph.addLiveIn(taint2Effects); - sese2conflictGraph.put(parent, conflictGraph); - } - } - } - - Iterator descItr = descriptorsToAnalyze.iterator(); - while (descItr.hasNext()) { - Descriptor d = (Descriptor) descItr.next(); - FlatMethod fm = state.getMethodFlat(d); - if (fm != null) { - makeConflictGraph(fm); - } - } - + // 7th pass, start conflict graphs where a parent's graph has a + // node for possibly conflicting children and its own stall sites + startConflictGraphs(); // 8th pass, calculate all possible conflicts without using // reachability info and identify set of FlatNew that next @@ -253,7 +222,6 @@ public class OoOJavaAnalysis { Set sitesToFlag = new HashSet(); calculateConflicts(sitesToFlag, false); - if (!state.RCR) { // 9th pass, ask disjoint analysis to compute reachability // for objects that may cause heap conflicts so the most @@ -269,7 +237,8 @@ public class OoOJavaAnalysis { calculateConflicts(null, true); } - // 11th pass, compiling locks + // 11th pass, compiling memory Qs! The name "lock" is a legacy + // term for the heap dependence queue, or memQ as the runtime calls it synthesizeLocks(); // 12th pass, compute a plan for code injections @@ -1133,138 +1102,148 @@ public class OoOJavaAnalysis { } - private void makeConflictGraph(FlatMethod fm) { + private void startConflictGraphs() { + + // first, for each task, consider whether it has any children, and if + // effects analysis says they should be a conflict node in the that + // parent's conflict graph + Set allSESEs = rblockRel.getAllSESEs(); + for( Iterator iterator = allSESEs.iterator(); iterator.hasNext(); ) { + + FlatSESEEnterNode parent = (FlatSESEEnterNode) iterator.next(); + if( parent.getIsLeafSESE() ) { + continue; + } + + EffectsAnalysis effectsAnalysis = disjointAnalysisTaints.getEffectsAnalysis(); + ConflictGraph conflictGraph = sese2conflictGraph.get( parent ); + assert conflictGraph == null; + //if (conflictGraph == null) { + conflictGraph = new ConflictGraph( state ); + //} + + Set children = parent.getChildren(); + for( Iterator iterator2 = children.iterator(); iterator2.hasNext(); ) { + FlatSESEEnterNode child = (FlatSESEEnterNode) iterator2.next(); + Hashtable> taint2Effects = effectsAnalysis.get( child ); + conflictGraph.addLiveIn( taint2Effects ); + } + + sese2conflictGraph.put( parent, conflictGraph ); + } + + // then traverse all methods looking for potential stall sites, and + // add those stall sites as nodes in any task's conflict graph that + // might be executing at the point of the stall site + Iterator descItr = descriptorsToAnalyze.iterator(); + while( descItr.hasNext() ) { + MethodDescriptor md = descItr.next(); + FlatMethod fm = state.getMethodFlat( md ); + if( fm != null ) { + addStallSitesToConflictGraphs( fm ); + } + } + } + + private void addStallSitesToConflictGraphs( FlatMethod fm ) { Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add(fm); + flatNodesToVisit.add( fm ); Set visited = new HashSet(); - while (!flatNodesToVisit.isEmpty()) { + while( !flatNodesToVisit.isEmpty() ) { FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove(fn); - visited.add(fn); + flatNodesToVisit.remove( fn ); + visited.add( fn ); Set currentSESEs = rblockRel.getPossibleExecutingRBlocks( fn ); - conflictGraph_nodeAction(fn, currentSESEs); + conflictGraph_nodeAction( fn, currentSESEs ); // schedule forward nodes for analysis - for (int i = 0; i < fn.numNext(); i++) { - FlatNode nn = fn.getNext(i); - if (!visited.contains(nn)) { - flatNodesToVisit.add(nn); + for( int i = 0; i < fn.numNext(); i++ ) { + FlatNode nn = fn.getNext( i ); + if( !visited.contains( nn ) ) { + flatNodesToVisit.add( nn ); } } - } - } - private void conflictGraph_nodeAction(FlatNode fn, - Set currentSESEs - ) { - ConflictGraph conflictGraph; - TempDescriptor lhs; - TempDescriptor rhs; - + private void conflictGraph_nodeAction( FlatNode fn, + Set currentSESEs + ) { + EffectsAnalysis effectsAnalysis = disjointAnalysisTaints.getEffectsAnalysis(); + Hashtable> taint2Effects = effectsAnalysis.get( fn ); - switch (fn.kind()) { + // repeat the process of adding a stall site to a conflict graph + // for each task that might be executing at a possible stall site + Iterator seseItr = currentSESEs.iterator(); + while( seseItr.hasNext() ) { + FlatSESEEnterNode currentSESE = seseItr.next(); - case FKind.FlatFieldNode: - case FKind.FlatElementNode: { + ConflictGraph conflictGraph = sese2conflictGraph.get( currentSESE ); + assert conflictGraph != null; + //if (conflictGraph == null) { + // conflictGraph = new ConflictGraph(state); + //} - if (fn instanceof FlatFieldNode) { - FlatFieldNode ffn = (FlatFieldNode) fn; - rhs = ffn.getSrc(); - } else { - FlatElementNode fen = (FlatElementNode) fn; - rhs = fen.getSrc(); - } + TempDescriptor lhs; + TempDescriptor rhs; + + switch( fn.kind() ) { - for( Iterator itr = currentSESEs.iterator(); - itr.hasNext(); - ) { - FlatSESEEnterNode currentSESE = itr.next(); - conflictGraph = sese2conflictGraph.get(currentSESE); - if (conflictGraph == null) { - conflictGraph = new ConflictGraph(state); - } + case FKind.FlatFieldNode: + case FKind.FlatElementNode: { - // add stall site - Hashtable> taint2Effects = effectsAnalysis.get(fn); - conflictGraph.addStallSite(taint2Effects, rhs); - - if (conflictGraph.id2cn.size() > 0) { - sese2conflictGraph.put(currentSESE, conflictGraph); + if( fn instanceof FlatFieldNode ) { + FlatFieldNode ffn = (FlatFieldNode) fn; + rhs = ffn.getSrc(); + } else { + FlatElementNode fen = (FlatElementNode) fn; + rhs = fen.getSrc(); } - } - } break; + conflictGraph.addStallSite( taint2Effects, rhs ); + } break; - case FKind.FlatSetFieldNode: - case FKind.FlatSetElementNode: { - if (fn instanceof FlatSetFieldNode) { - FlatSetFieldNode fsfn = (FlatSetFieldNode) fn; - lhs = fsfn.getDst(); - rhs = fsfn.getSrc(); - } else { - FlatSetElementNode fsen = (FlatSetElementNode) fn; - lhs = fsen.getDst(); - rhs = fsen.getSrc(); - } - - for( Iterator itr = currentSESEs.iterator(); - itr.hasNext(); - ) { - FlatSESEEnterNode currentSESE = itr.next(); - - conflictGraph = sese2conflictGraph.get(currentSESE); - if (conflictGraph == null) { - conflictGraph = new ConflictGraph(state); - } + case FKind.FlatSetFieldNode: + case FKind.FlatSetElementNode: { - Hashtable> taint2Effects = effectsAnalysis.get(fn); - conflictGraph.addStallSite(taint2Effects, rhs); - conflictGraph.addStallSite(taint2Effects, lhs); - - if (conflictGraph.id2cn.size() > 0) { - sese2conflictGraph.put(currentSESE, conflictGraph); + if( fn instanceof FlatSetFieldNode ) { + FlatSetFieldNode fsfn = (FlatSetFieldNode) fn; + lhs = fsfn.getDst(); + rhs = fsfn.getSrc(); + } else { + FlatSetElementNode fsen = (FlatSetElementNode) fn; + lhs = fsen.getDst(); + rhs = fsen.getSrc(); } - } - } break; + conflictGraph.addStallSite( taint2Effects, rhs ); + conflictGraph.addStallSite( taint2Effects, lhs ); + } break; - case FKind.FlatCall: { - FlatCall fc = (FlatCall) fn; - lhs = fc.getThis(); - for( Iterator itr = currentSESEs.iterator(); - itr.hasNext(); - ) { - FlatSESEEnterNode currentSESE = itr.next(); + case FKind.FlatCall: { + FlatCall fc = (FlatCall) fn; + lhs = fc.getThis(); - conflictGraph = sese2conflictGraph.get(currentSESE); - if (conflictGraph == null) { - conflictGraph = new ConflictGraph(state); - } - - // collects effects of stall site and generates stall site node - Hashtable> taint2Effects = effectsAnalysis.get(fn); + conflictGraph.addStallSite( taint2Effects, lhs ); + } break; - conflictGraph.addStallSite(taint2Effects, lhs); - if (conflictGraph.id2cn.size() > 0) { - sese2conflictGraph.put(currentSESE, conflictGraph); - } } - } break; - + + if( conflictGraph.id2cn.size() > 0 ) { + sese2conflictGraph.put( currentSESE, conflictGraph ); + } } } @@ -1307,7 +1286,10 @@ public class OoOJavaAnalysis { } } + private void synthesizeLocks() { + // for every conflict graph, generate a set of memory queues + // (called SESELock in this code!) to cover the graph Set> graphEntrySet = sese2conflictGraph.entrySet(); for (Iterator iterator = graphEntrySet.iterator(); iterator.hasNext();) { Entry graphEntry = (Entry) iterator.next(); @@ -1624,6 +1606,10 @@ public class OoOJavaAnalysis { return rblockRel.getCallerProxySESE(); } + public Set getPossibleExecutingRBlocks( FlatNode fn ) { + return rblockRel.getPossibleExecutingRBlocks( fn ); + } + public void writeReports(String timeReport) throws java.io.IOException { diff --git a/Robust/src/IR/Flat/BuildOoOJavaCode.java b/Robust/src/IR/Flat/BuildOoOJavaCode.java index cf27765e..a8d73348 100644 --- a/Robust/src/IR/Flat/BuildOoOJavaCode.java +++ b/Robust/src/IR/Flat/BuildOoOJavaCode.java @@ -275,6 +275,7 @@ public class BuildOoOJavaCode extends BuildCode { // eom - set up related allocation sites's waiting queues // TODO: we have to do a table-based thing here... + // jjenista, I THINK WE LOSE THIS ALTOGETHER! /* FlatSESEEnterNode callerSESEplaceholder = (FlatSESEEnterNode) fm.getNext( 0 ); if(callerSESEplaceholder!= oooa.getMainSESE()){ @@ -1020,63 +1021,80 @@ public class BuildOoOJavaCode extends BuildCode { output.println(" "+dynVar+"_srcSESE = NULL;"); } + - // eom - handling stall site - // TODO, this is an iterate over situation - ConflictGraph graph = oooa.getConflictGraph( currentSESE ); - if( graph != null ) { - Set seseLockSet = oooa.getLockMappings( graph ); + // handling stall site, consider that one of several tasks might be + // executing, so create a switch on task ID, because waiting elements + // generated by this stall site should be inserted into possibly a + // different memory queue index, depending on which task type it is + output.println(" // potential stall site "); + output.println(" switch( runningSESE->classID ) {"); + + // create a case for each class of task that might be executing + Iterator taskItr = oooa.getPossibleExecutingRBlocks( fn ).iterator(); + while( taskItr.hasNext() ) { + FlatSESEEnterNode parent = taskItr.next(); + ConflictGraph graph = oooa.getConflictGraph( parent ); + + if( graph == null ) { + continue; + } + + Set seseLockSet = oooa.getLockMappings( graph ); Set waitingElementSet = graph.getStallSiteWaitingElementSet( fn, seseLockSet ); - - if (waitingElementSet.size() > 0) { - if (state.RCR) { - stallMEMRCR(fm, fn, waitingElementSet, output); - } else { - output.println("// stall on parent's stall sites "); - output.println(" {"); - output.println(" REntry* rentry;"); + + if( waitingElementSet.size() == 0 ) { + continue; + } + + output.println(" case "+parent.getIdentifier()+": {"); + + if( state.RCR ) { + stallMEMRCR(fm, fn, waitingElementSet, output); + } else { + + output.println(" REntry* rentry;"); - for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) { - WaitingElement waitingElement = - (WaitingElement) iterator.next(); - if (waitingElement.getStatus() >= ConflictNode.COARSE) { - output.println(" rentry=mlpCreateREntry(runningSESE->memoryQueueArray[" - + waitingElement.getQueueID() + "]," + waitingElement.getStatus() - + ", runningSESE);"); - } else { - output.println(" rentry=mlpCreateFineREntry(runningSESE->memoryQueueArray[" - + waitingElement.getQueueID() + "]," + waitingElement.getStatus() - + ", runningSESE, (void*)&" - + generateTemp(fm, waitingElement.getTempDesc(), lb) + ");"); - } - output.println(" rentry->parentStallSem=&runningSESEstallSem;"); - output.println(" psem_reset( &runningSESEstallSem);"); - output.println(" rentry->tag=runningSESEstallSem.tag;"); - output.println(" rentry->queue=runningSESE->memoryQueueArray[" - + waitingElement.getQueueID() + "];"); - output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray[" - + waitingElement.getQueueID() + "],rentry)==NOTREADY){"); - if (state.COREPROF) { - output.println("#ifdef CP_EVENTID_TASKSTALLMEM"); - output - .println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );"); - output.println("#endif"); - } + for( Iterator iterator = waitingElementSet.iterator(); iterator.hasNext(); ) { + WaitingElement waitingElement = (WaitingElement) iterator.next(); + + if (waitingElement.getStatus() >= ConflictNode.COARSE) { + output.println(" rentry=mlpCreateREntry(runningSESE->memoryQueueArray[" + + waitingElement.getQueueID() + "]," + waitingElement.getStatus() + + ", runningSESE);"); + } else { + output.println(" rentry=mlpCreateFineREntry(runningSESE->memoryQueueArray[" + + waitingElement.getQueueID() + "]," + waitingElement.getStatus() + + ", runningSESE, (void*)&" + + generateTemp(fm, waitingElement.getTempDesc(), lb) + ");"); + } + output.println(" rentry->parentStallSem=&runningSESEstallSem;"); + output.println(" psem_reset( &runningSESEstallSem);"); + output.println(" rentry->tag=runningSESEstallSem.tag;"); + output.println(" rentry->queue=runningSESE->memoryQueueArray[" + + waitingElement.getQueueID() + "];"); + output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray[" + + waitingElement.getQueueID() + "],rentry)==NOTREADY){"); + if (state.COREPROF) { + output.println("#ifdef CP_EVENTID_TASKSTALLMEM"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );"); + output.println("#endif"); + } - output.println(" psem_take( &runningSESEstallSem, (struct garbagelist *)&___locals___ );"); + output.println(" psem_take( &runningSESEstallSem, (struct garbagelist *)&___locals___ );"); - if (state.COREPROF) { - output.println("#ifdef CP_EVENTID_TASKSTALLMEM"); - output - .println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );"); - output.println("#endif"); - } - output.println(" } "); + if (state.COREPROF) { + output.println("#ifdef CP_EVENTID_TASKSTALLMEM"); + output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );"); + output.println("#endif"); } - output.println(" }"); + output.println(" } "); } + } + output.println(" } break; // end case "+parent.getIdentifier()); } + output.println(" } // end stall site switch"); } } @@ -1105,7 +1123,7 @@ public class BuildOoOJavaCode extends BuildCode { assert !fsen.getIsCallerProxySESE(); - output.println(" {"); + output.println(" { // issue new task instance"); if( state.COREPROF ) { output.println("#ifdef CP_EVENTID_TASKDISPATCH"); @@ -1315,157 +1333,185 @@ public class BuildOoOJavaCode extends BuildCode { // maintain pointers for finding dynamic SESE - // instances from static names - // TODO: what to do here?! - /* - SESEandAgePair pairNewest = new SESEandAgePair( fsen, 0 ); - SESEandAgePair pairOldest = new SESEandAgePair( fsen, fsen.getOldestAgeToTrack() ); - if( fsen.getParent() != null && - fsen.getParent().getNeededStaticNames().contains( pairNewest ) - ) { - output.println(" {"); - output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" ); - output.println(" SESEcommon* oldest = "+pairOldest+";"); - output.println("#endif // OOO_DISABLE_TASKMEMPOOL" ); + // instances from static names, do a shuffle as instances age + // and also release references that have become too old + if( !fsen.getIsMainSESE() ) { - for( int i = fsen.getOldestAgeToTrack(); i > 0; --i ) { - SESEandAgePair pair1 = new SESEandAgePair( fsen, i ); - SESEandAgePair pair2 = new SESEandAgePair( fsen, i-1 ); - output.println(" "+pair1+" = "+pair2+";"); - } - output.println(" "+pairNewest+" = &(seseToIssue->common);"); + FlatSESEEnterNode currentSESE = fsen.getLocalParent(); - // no need to add a reference to whatever is the newest record, because - // we initialized seseToIssue->refCount to *2* - // but release a reference to whatever was the oldest BEFORE the shift - output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" ); - output.println(" if( oldest != NULL ) {"); - output.println(" RELEASE_REFERENCE_TO( oldest );"); - output.println(" }"); - output.println("#endif // OOO_DISABLE_TASKMEMPOOL" ); - output.println(" }"); + ContextTaskNames contextTaskNames; + if( currentSESE.getIsCallerProxySESE() ) { + contextTaskNames = oooa.getContextTaskNames( oooa.getContainingFlatMethod( fsen ) ); + } else { + contextTaskNames = oooa.getContextTaskNames( currentSESE ); + } + + SESEandAgePair pairNewest = new SESEandAgePair( fsen, 0 ); + SESEandAgePair pairOldest = new SESEandAgePair( fsen, fsen.getOldestAgeToTrack() ); + if( contextTaskNames.getNeededStaticNames().contains( pairNewest ) ) { + output.println(" {"); + output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" ); + output.println(" SESEcommon* oldest = "+pairOldest+";"); + output.println("#endif // OOO_DISABLE_TASKMEMPOOL" ); + + for( int i = fsen.getOldestAgeToTrack(); i > 0; --i ) { + SESEandAgePair pair1 = new SESEandAgePair( fsen, i ); + SESEandAgePair pair2 = new SESEandAgePair( fsen, i-1 ); + output.println(" "+pair1+" = "+pair2+";"); + } + output.println(" "+pairNewest+" = &(seseToIssue->common);"); + + // no need to add a reference to whatever is the newest record, because + // we initialized seseToIssue->refCount to *2* + // but release a reference to whatever was the oldest BEFORE the shift + output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" ); + output.println(" if( oldest != NULL ) {"); + output.println(" RELEASE_REFERENCE_TO( oldest );"); + output.println(" }"); + output.println("#endif // OOO_DISABLE_TASKMEMPOOL" ); + output.println(" }"); + } } - */ + } + + + ////////////////////// + // count up memory conflict dependencies, + /////////////////////// + if( !fsen.getIsMainSESE() ) { + if( state.COREPROF ) { output.println("#ifdef CP_EVENTID_PREPAREMEMQ"); output.println(" CP_LOGEVENT( CP_EVENTID_PREPAREMEMQ, CP_EVENTTYPE_BEGIN );"); output.println("#endif"); } - - //////////////// - // count up memory conflict dependencies, if(state.RCR) { dispatchMEMRC(fm, lb, fsen, output); } else { - // NEED TO FIX IT, TODO - // assumes that there is only one parent, but it is possible that - // currentSESE has more than one so we need to generate - // conditional case for each parent case - assert fsen.getParents().size()>0; - FlatSESEEnterNode parent = fsen.getParents().iterator().next(); - ConflictGraph graph = oooa.getConflictGraph(parent); - if (graph != null && graph.hasConflictEdge()) { + + // there may be several task types that can get to this + // program point (issue this new task) so create a switch + // based on task ID, each type of task has a different index + // scheme for its memory queue's, and the cases here drop the + // new task instance in the right bucket + + output.println(" // add new task instance to current task's memory queues if needed "); + output.println(" switch( runningSESE->classID ) {"); + + // create a case for each class of task that might be executing + Iterator taskItr = oooa.getPossibleExecutingRBlocks( fsen ).iterator(); + while( taskItr.hasNext() ) { + FlatSESEEnterNode parent = taskItr.next(); + ConflictGraph graph = oooa.getConflictGraph( parent ); + + if( graph == null || !graph.hasConflictEdge() ) { + continue; + } + Set seseLockSet = oooa.getLockMappings(graph); - output.println(); - output.println(" //add memory queue element"); - SESEWaitingQueue seseWaitingQueue= + + SESEWaitingQueue seseWaitingQueue = graph.getWaitingElementSetBySESEID(fsen.getIdentifier(), seseLockSet); - if(seseWaitingQueue.getWaitingElementSize()>0) { - output.println(" {"); - output.println(" REntry* rentry=NULL;"); - output.println(" INTPTR* pointer=NULL;"); - output.println(" seseToIssue->common.rentryIdx=0;"); - - Set queueIDSet=seseWaitingQueue.getQueueIDSet(); - for (Iterator iterator = queueIDSet.iterator(); iterator.hasNext();) { - Integer key = (Integer) iterator.next(); - int queueID=key.intValue(); - Set waitingQueueSet = - seseWaitingQueue.getWaitingElementSet(queueID); - int enqueueType=seseWaitingQueue.getType(queueID); - if(enqueueType==SESEWaitingQueue.EXCEPTION) { - output.println(" INITIALIZEBUF(runningSESE->memoryQueueArray[" + queueID+ "]);"); - } - for (Iterator iterator2 = waitingQueueSet.iterator(); iterator2.hasNext();) { - WaitingElement waitingElement - = (WaitingElement) iterator2.next(); - if (waitingElement.getStatus() >= ConflictNode.COARSE) { - output.println(" rentry=mlpCreateREntry(runningSESE->memoryQueueArray["+ queueID+ "]," + + if( seseWaitingQueue.getWaitingElementSize() == 0 ) { + continue; + } + + output.println(" case "+parent.getIdentifier()+": {"); + output.println(" REntry* rentry=NULL;"); + output.println(" INTPTR* pointer=NULL;"); + output.println(" seseToIssue->common.rentryIdx=0;"); + + Set queueIDSet=seseWaitingQueue.getQueueIDSet(); + for (Iterator iterator = queueIDSet.iterator(); iterator.hasNext();) { + Integer key = (Integer) iterator.next(); + int queueID=key.intValue(); + Set waitingQueueSet = + seseWaitingQueue.getWaitingElementSet(queueID); + int enqueueType=seseWaitingQueue.getType(queueID); + if(enqueueType==SESEWaitingQueue.EXCEPTION) { + output.println(" INITIALIZEBUF(runningSESE->memoryQueueArray[" + queueID+ "]);"); + } + for (Iterator iterator2 = waitingQueueSet.iterator(); iterator2.hasNext();) { + WaitingElement waitingElement + = (WaitingElement) iterator2.next(); + if (waitingElement.getStatus() >= ConflictNode.COARSE) { + output.println(" rentry=mlpCreateREntry(runningSESE->memoryQueueArray["+ queueID+ "]," + + waitingElement.getStatus() + + ", &(seseToIssue->common));"); + } else { + TempDescriptor td = waitingElement.getTempDesc(); + // decide whether waiting element is dynamic or static + if (fsen.getDynamicInVarSet().contains(td)) { + // dynamic in-var case + output.println(" pointer=seseToIssue->" + + waitingElement.getDynID() + + "_srcSESE+seseToIssue->" + + waitingElement.getDynID() + + "_srcOffset;"); + output.println(" rentry=mlpCreateFineREntry(runningSESE->memoryQueueArray["+ queueID+ "]," + waitingElement.getStatus() - + ", &(seseToIssue->common));"); - } else { - TempDescriptor td = waitingElement.getTempDesc(); - // decide whether waiting element is dynamic or static - if (fsen.getDynamicInVarSet().contains(td)) { - // dynamic in-var case - output.println(" pointer=seseToIssue->" - + waitingElement.getDynID() - + "_srcSESE+seseToIssue->" - + waitingElement.getDynID() - + "_srcOffset;"); - output.println(" rentry=mlpCreateFineREntry(runningSESE->memoryQueueArray["+ queueID+ "]," - + waitingElement.getStatus() - + ", &(seseToIssue->common), pointer );"); - } else if (fsen.getStaticInVarSet().contains(td)) { - // static in-var case - VariableSourceToken vst = fsen.getStaticInVarSrc(td); - if (vst != null) { + + ", &(seseToIssue->common), pointer );"); + } else if (fsen.getStaticInVarSet().contains(td)) { + // static in-var case + VariableSourceToken vst = fsen.getStaticInVarSrc(td); + if (vst != null) { - String srcId = "SESE_" + vst.getSESE().getPrettyIdentifier() - + vst.getSESE().getIdentifier() - + "_" + vst.getAge(); - output.println(" pointer=(void*)&seseToIssue->" - + srcId - + "->" - + waitingElement - .getDynID() - + ";"); - output.println(" rentry=mlpCreateFineREntry(runningSESE->memoryQueueArray["+ queueID+ "]," - + waitingElement.getStatus() - + ", &(seseToIssue->common), pointer );"); - } - } else { + String srcId = "SESE_" + vst.getSESE().getPrettyIdentifier() + + vst.getSESE().getIdentifier() + + "_" + vst.getAge(); + output.println(" pointer=(void*)&seseToIssue->" + + srcId + + "->" + + waitingElement + .getDynID() + + ";"); output.println(" rentry=mlpCreateFineREntry(runningSESE->memoryQueueArray["+ queueID+ "]," + waitingElement.getStatus() - + ", &(seseToIssue->common), (void*)&seseToIssue->" - + waitingElement.getDynID() - + ");"); + + ", &(seseToIssue->common), pointer );"); } + } else { + output.println(" rentry=mlpCreateFineREntry(runningSESE->memoryQueueArray["+ queueID+ "]," + + waitingElement.getStatus() + + ", &(seseToIssue->common), (void*)&seseToIssue->" + + waitingElement.getDynID() + + ");"); } - output.println(" rentry->queue=runningSESE->memoryQueueArray[" - + waitingElement.getQueueID() - + "];"); + } + output.println(" rentry->queue=runningSESE->memoryQueueArray[" + + waitingElement.getQueueID() + + "];"); - if(enqueueType==SESEWaitingQueue.NORMAL){ - output.println(" seseToIssue->common.rentryArray[seseToIssue->common.rentryIdx++]=rentry;"); - output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray[" - + waitingElement.getQueueID() - + "],rentry)==NOTREADY) {"); - output.println(" localCount++;"); - output.println(" }"); - } else { - output.println(" ADDRENTRYTOBUF(runningSESE->memoryQueueArray[" + waitingElement.getQueueID() + "],rentry);"); - } + if(enqueueType==SESEWaitingQueue.NORMAL){ + output.println(" seseToIssue->common.rentryArray[seseToIssue->common.rentryIdx++]=rentry;"); + output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray[" + + waitingElement.getQueueID() + + "],rentry)==NOTREADY) {"); + output.println(" localCount++;"); + output.println(" }"); + } else { + output.println(" ADDRENTRYTOBUF(runningSESE->memoryQueueArray[" + waitingElement.getQueueID() + "],rentry);"); } - if(enqueueType!=SESEWaitingQueue.NORMAL){ - output.println(" localCount+=RESOLVEBUF(runningSESE->memoryQueueArray[" - + queueID+ "],&seseToIssue->common);"); - } } - output.println(" }"); + if(enqueueType!=SESEWaitingQueue.NORMAL){ + output.println(" localCount+=RESOLVEBUF(runningSESE->memoryQueueArray[" + + queueID+ "],&seseToIssue->common);"); + } } - output.println(); + output.println(" } break; // end case "+parent.getIdentifier()); + output.println(); } + output.println(" } // end stall site switch"); + } + + if( state.COREPROF ) { + output.println("#ifdef CP_EVENTID_PREPAREMEMQ"); + output.println(" CP_LOGEVENT( CP_EVENTID_PREPAREMEMQ, CP_EVENTTYPE_END );"); + output.println("#endif"); } } - if( state.COREPROF ) { - output.println("#ifdef CP_EVENTID_PREPAREMEMQ"); - output.println(" CP_LOGEVENT( CP_EVENTID_PREPAREMEMQ, CP_EVENTTYPE_END );"); - output.println("#endif"); - } - // Enqueue Task Record if (state.RCR) { if( fsen != oooa.getMainSESE() && fsen.getInVarsForDynamicCoarseConflictResolution().size()>0){ @@ -1486,8 +1532,7 @@ public class BuildOoOJavaCode extends BuildCode { output.println("#endif"); } - output.println(" }"); - + output.println(" } // end task issue"); } @@ -1499,6 +1544,9 @@ public class BuildOoOJavaCode extends BuildCode { // assumes that there is only one parent, but it is possible that // currentSESE has more than one so we need to generate // conditional case for each parent case + + assert false; // FIX THIS TO UNDERSTAND NO PLACEHOLDER TASKS!!! + assert fsen.getParents().size()>0; FlatSESEEnterNode parent = fsen.getParents().iterator().next(); ConflictGraph graph = oooa.getConflictGraph(parent); @@ -1768,22 +1816,32 @@ public class BuildOoOJavaCode extends BuildCode { // non-null var of these types output.println(" // releasing static SESEs"); output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" ); - // TODO - //Iterator pItr = fsen.getNeededStaticNames().iterator(); - //while( pItr.hasNext() ) { - // SESEandAgePair pair = pItr.next(); - // output.println(" if( "+pair+" != NULL ) {"); - // output.println(" RELEASE_REFERENCE_TO( "+pair+" );"); - // output.println(" }"); - //} - //output.println(" // releasing dynamic variable sources"); - //Iterator dynSrcItr = fsen.getDynamicVarSet().iterator(); - //while( dynSrcItr.hasNext() ) { - // TempDescriptor dynSrcVar = dynSrcItr.next(); - // output.println(" if( "+dynSrcVar+"_srcSESE != NULL ) {"); - // output.println(" RELEASE_REFERENCE_TO( "+dynSrcVar+"_srcSESE );"); - // output.println(" }"); - //} + + FlatSESEEnterNode currentSESE = fsen.getLocalParent(); + + ContextTaskNames contextTaskNames; + if( currentSESE.getIsCallerProxySESE() ) { + contextTaskNames = oooa.getContextTaskNames( oooa.getContainingFlatMethod( fsen ) ); + } else { + contextTaskNames = oooa.getContextTaskNames( currentSESE ); + } + + Iterator pItr = contextTaskNames.getNeededStaticNames().iterator(); + while( pItr.hasNext() ) { + SESEandAgePair pair = pItr.next(); + output.println(" if( "+pair+" != NULL ) {"); + output.println(" RELEASE_REFERENCE_TO( "+pair+" );"); + output.println(" }"); + } + output.println(" // releasing dynamic variable sources"); + Iterator dynSrcItr = contextTaskNames.getDynamicVarSet().iterator(); + while( dynSrcItr.hasNext() ) { + TempDescriptor dynSrcVar = dynSrcItr.next(); + output.println(" if( "+dynSrcVar+"_srcSESE != NULL ) {"); + output.println(" RELEASE_REFERENCE_TO( "+dynSrcVar+"_srcSESE );"); + output.println(" }"); + } + // destroy this task's mempool if it is not a leaf task if( !fsen.getIsLeafSESE() ) { output.println(" pooldestroy( runningSESE->taskRecordMemPool );");