From: stephey Date: Tue, 17 Aug 2010 06:55:33 +0000 (+0000) Subject: Changed the way conflict flags are propagated (fixed infinite loops, for reals this... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9f503a92ae9aa6d6a996dd5c82a51cb2ddad553a;p=IRC.git Changed the way conflict flags are propagated (fixed infinite loops, for reals this time). Removed extraneous code. Added tentative stallsite code. --- diff --git a/Robust/src/IR/Flat/RuntimeConflictResolver.java b/Robust/src/IR/Flat/RuntimeConflictResolver.java index 9d003e1f..229acb00 100644 --- a/Robust/src/IR/Flat/RuntimeConflictResolver.java +++ b/Robust/src/IR/Flat/RuntimeConflictResolver.java @@ -25,7 +25,7 @@ import IR.TypeDescriptor; * 3) Call void close() */ public class RuntimeConflictResolver { - private static final boolean debug = true; + private static final boolean debug = false; private PrintWriter cFile; private PrintWriter headerFile; @@ -110,6 +110,36 @@ public class RuntimeConflictResolver { return "traverse___" + invar.getSafeSymbol().replaceAll(" ", "") + sese.getPrettyIdentifier().replaceAll(" ", "") + "___("+varString+");"; } + + public void traverseStallSite( + FlatSESEEnterNode rblock, + TempDescriptor invar, + Hashtable> effects, + Hashtable> conflicts, + ReachGraph rg) { + + + TypeDescriptor type = invar.getType(); + if(type == null || type.isPrimitive()) { + return; + } + + //created stores nodes with specific alloc sites that have been traversed while building + //internal data structure. It is later traversed sequentially to find inset variables and + //build output code. + Hashtable created = new Hashtable(); + VariableNode varNode = rg.getVariableNodeNoMutation(invar); + Hashtable effectsLookupTable; + + effectsLookupTable = generateEffectsLookupTable(rblock, varNode, effects, conflicts); + createConcreteGraph(effectsLookupTable, created, varNode); + + if (!created.isEmpty()) { + rblock.addInVarForDynamicCoarseConflictResolution(invar); + printCMethods(created, invar.getSafeSymbol(), rblock.getPrettyIdentifier()); + } + + } public void close() { // Adds Extra supporting methods @@ -123,7 +153,6 @@ public class RuntimeConflictResolver { headerFile.close(); } - //TODO it appears that using the optimize flags screws with the invar naming. private void createConcreteGraph( Hashtable table, Hashtable created, @@ -252,7 +281,7 @@ public class RuntimeConflictResolver { if (currEffects == null || currEffects.isEmpty()) return; - //Handle Objects + //Handle Objects (and primitive conflict flag propagation) if(currEffects.hasObjectEffects()) { while(edges.hasNext()) { RefEdge edge = edges.next(); @@ -279,14 +308,21 @@ public class RuntimeConflictResolver { propogateObjConflictFlag(child); } + //If isNewChild, flag propagation will be handled at recursive call if (effectsForGivenField.hasReadEffect && isNewChild) { + child.addReachableParent(curr); createHelper(child, childHRN.iteratorToReferencees(), created, table); } + else { + if(child.decendantsPrimConflict || child.hasPrimativeConflicts()) { + propogatePrimConflictFlag(curr); + } + } } } } - //Handle primitives + //Handles primitives if(currEffects.hasPrimativeConflicts()) { curr.conflictingPrimitiveFields = currEffects.primativeConflictingFields; propogatePrimConflictFlag(curr); @@ -294,25 +330,21 @@ public class RuntimeConflictResolver { } // This will propagate the conflict up the data structure. - private void propogateObjConflictFlag(ConcreteRuntimeObjNode in) { - ConcreteRuntimeObjNode node = in; - while(node.lastReferencer != null) { - node.lastReferencer.decendantsObjConflict = true; - if(!node.parentsThatWillLeadToConflicts.add(node.lastReferencer) && - node.lastReferencer.isInsetVar) - break; - node = node.lastReferencer; + private void propogateObjConflictFlag(ConcreteRuntimeObjNode curr) { + for(ConcreteRuntimeObjNode referencer: curr.parentsWithReadToNode) { + if(curr.parentsThatWillLeadToConflicts.add(referencer)) { + referencer.decendantsObjConflict = true; + propogateObjConflictFlag(referencer); + } } } - private void propogatePrimConflictFlag(ConcreteRuntimeObjNode in) { - ConcreteRuntimeObjNode node = in; - while(node.lastReferencer != null) { - node.lastReferencer.decendantsPrimConflict = true; - if(!node.parentsThatWillLeadToConflicts.add(node.lastReferencer) && - node.lastReferencer.isInsetVar) - break; - node = node.lastReferencer; + private void propogatePrimConflictFlag(ConcreteRuntimeObjNode curr) { + for(ConcreteRuntimeObjNode referencer: curr.parentsWithReadToNode) { + if(curr.parentsThatWillLeadToConflicts.add(referencer)) { + referencer.decendantsPrimConflict = true; + propogatePrimConflictFlag(referencer); + } } } @@ -340,8 +372,6 @@ public class RuntimeConflictResolver { if (!cases.containsKey(node.allocSite) && (node.getNumOfReachableParents() != 1 || node.isInsetVar) && (node.decendantsConflict() || node.hasPrimativeConflicts())) { - //resets the lastReferncer if we're dealing with an insetVar - node.lastReferencer = null; addChecker(node, cases, null, "ptr", 0); } } @@ -571,41 +601,6 @@ public class RuntimeConflictResolver { return hasReadConflict || hasWriteConflict || hasStrongUpdateConflict; } } - -// private class EffectPair { -// Effect originalEffect; -// int type; -// boolean conflict; -// -// public EffectPair(Effect e, boolean conflict) { -// originalEffect = e; -// type = e.getType(); -// this.conflict = conflict; -// } -// -// public int hashCode() { -// return originalEffect.hashCode(); -// } -// -// public boolean equals(Object o) { -// if (o == null) -// return false; -// -// if (!(o instanceof EffectPair)) -// return false; -// -// EffectPair other = (EffectPair) o; -// -// return (other.originalEffect.getAffectedAllocSite().equals( -// originalEffect.getAffectedAllocSite()) && other.originalEffect.getField().equals( -// originalEffect.getField())); -// } -// -// public String toString() -// { -// return originalEffect.toString(); -// } -// } //This will keep track of a reference private class ObjRef { @@ -639,8 +634,8 @@ public class RuntimeConflictResolver { private class ConcreteRuntimeObjNode { ArrayList objectRefs; ArrayList conflictingPrimitiveFields; + HashSet parentsWithReadToNode; HashSet parentsThatWillLeadToConflicts; - ConcreteRuntimeObjNode lastReferencer; boolean decendantsPrimConflict; boolean decendantsObjConflict; boolean isInsetVar; @@ -649,14 +644,18 @@ public class RuntimeConflictResolver { public ConcreteRuntimeObjNode(HeapRegionNode me, boolean isInVar) { objectRefs = new ArrayList(); + conflictingPrimitiveFields = null; parentsThatWillLeadToConflicts = new HashSet(); - lastReferencer = null; + parentsWithReadToNode = new HashSet(); allocSite = me.getAllocSite(); original = me; isInsetVar = isInVar; decendantsPrimConflict = false; decendantsObjConflict = false; - conflictingPrimitiveFields = null; + } + + public void addReachableParent(ConcreteRuntimeObjNode curr) { + parentsWithReadToNode.add(curr); } @Override @@ -687,7 +686,6 @@ public class RuntimeConflictResolver { } public void addObjChild(String field, ConcreteRuntimeObjNode child, CombinedObjEffects ce) { - child.lastReferencer = this; ObjRef ref = new ObjRef(field, child, ce); objectRefs.add(ref); }