import java.util.Map.Entry;
import Analysis.OwnershipAnalysis.HeapRegionNode;
+import Analysis.OwnershipAnalysis.OwnershipGraph;
+import Analysis.OwnershipAnalysis.ReachabilitySet;
+import Analysis.OwnershipAnalysis.TokenTuple;
import IR.Flat.FlatMethod;
import IR.Flat.FlatSESEEnterNode;
import IR.Flat.TempDescriptor;
public class ConflictGraph {
-
+
static private int uniqueCliqueIDcount = 100;
public Hashtable<String, ConflictNode> id2cn;
+ private OwnershipGraph og;
- public ConflictGraph() {
+ public ConflictGraph(OwnershipGraph og) {
id2cn = new Hashtable<String, ConflictNode>();
+ this.og = og;
}
-
- public boolean hasConflictEdge(){
-
- Set<String> keySet=id2cn.keySet();
+
+ public boolean hasConflictEdge() {
+
+ Set<String> keySet = id2cn.keySet();
for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
String key = (String) iterator.next();
- ConflictNode node=id2cn.get(key);
- if(node.getEdgeSet().size()>0){
+ ConflictNode node = id2cn.get(key);
+ if (node.getEdgeSet().size() > 0) {
return true;
}
- }
+ }
return false;
}
}
}
- private boolean isWriteConflicts(StallSiteNode nodeA, LiveInNode nodeB) {
-
- boolean result = false;
- StallSite stallSite = nodeA.getStallSite();
-
- Set<SESEEffectsKey> writeEffectsSet = nodeB.getWriteEffectsSet();
- Set<SESEEffectsKey> readEffectsSet = nodeB.getReadEffectsSet();
-
- if (writeEffectsSet != null) {
- Iterator<SESEEffectsKey> writeIter = writeEffectsSet.iterator();
- while (writeIter.hasNext()) {
- SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIter
- .next();
- String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
- String writeFieldName = seseEffectsKey.getFieldDescriptor();
-
- if(writeFieldName.length()>0){
- HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
- for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
- .hasNext();) {
- HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
- if (stallHRN.getGloballyUniqueIdentifier().equals(
- writeHeapRegionID)) {
-
- // check whether there are read or write effects of
- // stall sites
-
- HashSet<Effect> effectSet = stallSite.getEffectSet();
- for (Iterator iterator2 = effectSet.iterator(); iterator2
- .hasNext();) {
- Effect effect = (Effect) iterator2.next();
- String stallEffectfieldName = effect.getField();
-
- if (stallEffectfieldName.equals(writeFieldName)) {
- result = result | true;
- }
- }
-
- }
- }
- }else{
- // no field name
-
- HashSet<Effect> effectSet = stallSite.getEffectSet();
- for (Iterator iterator2 = effectSet.iterator(); iterator2
- .hasNext();) {
- Effect effect = (Effect) iterator2.next();
- String stallEffectfieldName = effect.getField();
-
- if (stallEffectfieldName.length()==0 && nodeB.getTempDescriptor().equals(nodeA.getStallSite().getTdA())) {
- result = result | true;
- }
- }
-
- }
-
- }
-
- }
-
- if (readEffectsSet != null) {
- Iterator<SESEEffectsKey> readIter = readEffectsSet.iterator();
- while (readIter.hasNext()) {
-
- SESEEffectsKey seseEffectsKey = (SESEEffectsKey) readIter
- .next();
- String readHeapRegionID = seseEffectsKey.getHRNUniqueId();
- String readFieldName = seseEffectsKey.getFieldDescriptor();
-
- if(readFieldName.length()>0){
- HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
- for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
- .hasNext();) {
- HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
- if (stallHRN.getGloballyUniqueIdentifier().equals(
- readHeapRegionID)) {
-
- HashSet<Effect> effectSet = stallSite.getEffectSet();
- for (Iterator iterator2 = effectSet.iterator(); iterator2
- .hasNext();) {
- Effect effect = (Effect) iterator2.next();
- String stallEffectfieldName = effect.getField();
-
- if (effect.getEffectType().equals(
- StallSite.WRITE_EFFECT)) {
- if (stallEffectfieldName.equals(readFieldName)) {
- result = result | true;
- }
- }
-
- }
-
- }
-
- }
- }else{
- //no field
- HashSet<Effect> effectSet = stallSite.getEffectSet();
- for (Iterator iterator2 = effectSet.iterator(); iterator2
- .hasNext();) {
- Effect effect = (Effect) iterator2.next();
- String stallEffectfieldName = effect.getField();
-
- if (effect.getEffectType().equals(
- StallSite.WRITE_EFFECT)) {
- if (stallEffectfieldName.length()==0 && nodeB.getTempDescriptor().equals(nodeA.getStallSite().getTdA())) {
- result = result | true;
- }
- }
-
- }
- }
-
-
- }
-
- }
-
- return result;
- }
-
- private int determineWriteConflictsType(LiveInNode liveInNodeA,
- LiveInNode liveInNodeB) {
-
- if(liveInNodeA.getSESEIdentifier()==liveInNodeB.getSESEIdentifier()){
- return ConflictEdge.NON_WRITE_CONFLICT;
- }
-
- Set<HeapRegionNode> liveInHrnSetA = liveInNodeA.getHRNSet();
- Set<HeapRegionNode> liveInHrnSetB = liveInNodeB.getHRNSet();
-
- boolean isPointingToSameRegion = compareHRNSet(liveInHrnSetA,
- liveInHrnSetB);
-
- boolean isSharingReachability = false;
-
- Set<Set> liveInNodeReachabilitySetA = liveInNodeA.getReachabilitySet();
- Set<Set> liveInNodeReachabilitySetB = liveInNodeB.getReachabilitySet();
-
- Set<GloballyUniqueTokenTuple> overlappedReachableRegionSet = calculateOverlappedReachableRegion(
- liveInNodeReachabilitySetA, liveInNodeReachabilitySetB);
- if (overlappedReachableRegionSet.size() > 0) {
- isSharingReachability = true;
- }
-
- if (isPointingToSameRegion && isSharingReachability) {
- // two node share same reachability and points to same region, then
- // it is fine grain conflicts
- return ConflictEdge.FINE_GRAIN_EDGE;
- } else if (isSharingReachability) {
- // two node share same reachability but points to different region,
- // then it is coarse grain conflicts
-// System.out.println("##coarse:");
-// System.out.println(liveInNodeA.getSESEIdentifier()+" <-> "+liveInNodeB.getSESEIdentifier());
-// System.out.println(liveInNodeA.getID()+" <-> "+liveInNodeB.getID());
-// System.out.println("--");
- return ConflictEdge.COARSE_GRAIN_EDGE;
- } else {
- // otherwise, it is not write conflicts
- return ConflictEdge.NON_WRITE_CONFLICT;
- }
-
- }
-
private boolean compareHRNSet(Set<HeapRegionNode> setA,
Set<HeapRegionNode> setB) {
-
- for (Iterator iterator = setA.iterator(); iterator.hasNext();) {
- HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next();
- String gID = heapRegionNode.getGloballyUniqueIdentifier();
- boolean found = false;
- for (Iterator iterator2 = setB.iterator(); iterator2.hasNext();) {
- HeapRegionNode heapRegionNode2 = (HeapRegionNode) iterator2
- .next();
- if (heapRegionNode2.getGloballyUniqueIdentifier().equals(gID)) {
- found = true;
- }
- }
- if (!found) {
- return false;
- }
- }
- return true;
- }
-
- private int determineWriteConflictsType(StallSiteNode stallNode,
- LiveInNode liveInNode) {
-
- Set<HeapRegionNode> stallHrnSet = stallNode.getHRNSet();
- Set<HeapRegionNode> liveInHrnSet = liveInNode.getHRNSet();
-
- boolean isPointingToSameRegion = compareHRNSet(stallHrnSet,
- liveInHrnSet);
-
- boolean isSharingReachability = false;
-
- Set<Set> stallNodeReachabilitySet = stallNode.getReachabilitySet();
- Set<Set> liveInNodeReachabilitySet = liveInNode.getReachabilitySet();
-
- Set<GloballyUniqueTokenTuple> overlappedReachableRegionSet = calculateOverlappedReachableRegion(
- stallNodeReachabilitySet, liveInNodeReachabilitySet);
- if (overlappedReachableRegionSet.size() > 0) {
- isSharingReachability = true;
- }
-
- if (isPointingToSameRegion && isSharingReachability) {
- // two node share same reachability and points to same region, then
- // it is fine grain conflicts
- return ConflictEdge.FINE_GRAIN_EDGE;
- } else if (isSharingReachability) {
- // two node share same reachability but points to different region,
- // then it is coarse grain conflicts
- return ConflictEdge.COARSE_GRAIN_EDGE;
- } else {
- // otherwise, it is not write conflicts
- return ConflictEdge.NON_WRITE_CONFLICT;
- }
-
- }
-
- private boolean hasStrongUpdate(SESEEffectsKey writeEffect,
- Set<SESEEffectsKey> strongUpdateSet) {
-
- if(strongUpdateSet!=null){
- Iterator<SESEEffectsKey> strongUpdateIter = strongUpdateSet.iterator();
- while (strongUpdateIter.hasNext()) {
- SESEEffectsKey strongEffect = (SESEEffectsKey) strongUpdateIter
- .next();
-
- if (strongEffect.getHRNUniqueId().equals(
- writeEffect.getHRNUniqueId())
- && strongEffect.getFieldDescriptor().equals(
- writeEffect.getFieldDescriptor())) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- private boolean isWriteConflicts(LiveInNode nodeA, LiveInNode nodeB) {
-
- Set<SESEEffectsKey> readEffectsSetA = nodeA.getReadEffectsSet();
- Set<SESEEffectsKey> writeEffectsSetA = nodeA.getWriteEffectsSet();
- Set<SESEEffectsKey> strongUpdateSetA = nodeA.getStrongUpdateSet();
-
- Set<SESEEffectsKey> readEffectsSetB = nodeB.getReadEffectsSet();
- Set<SESEEffectsKey> writeEffectsSetB = nodeB.getWriteEffectsSet();
- Set<SESEEffectsKey> strongUpdateSetB = nodeB.getStrongUpdateSet();
-
- boolean result=false;
- /*
- System.out.println("nodeA="+nodeA);
- System.out.println("readEffectsSetA="+readEffectsSetA);
- System.out.println("writeEffectsSetA="+writeEffectsSetA);
- System.out.println("strongUpdateSetA="+strongUpdateSetA);
- System.out.println("nodeB="+nodeB);
- System.out.println("readEffectsSetB="+readEffectsSetB);
- System.out.println("writeEffectsSetB="+writeEffectsSetB);
- System.out.println("strongUpdateSetB="+strongUpdateSetB);
- System.out.println("--");
- */
-
- // if node A has write effects on reading/writing regions of node B
- if (writeEffectsSetA != null) {
- Iterator<SESEEffectsKey> writeIterA = writeEffectsSetA.iterator();
- while (writeIterA.hasNext()) {
- SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterA
- .next();
-
-// if (!hasStrongUpdate(seseEffectsKey, strongUpdateSetA)) {
-
- String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
- String writeFieldName = seseEffectsKey.getFieldDescriptor();
-
- if (readEffectsSetB != null) {
-
- if(writeFieldName.length()>0){
- Iterator<SESEEffectsKey> readIterB = readEffectsSetB
- .iterator();
- while (readIterB.hasNext()) {
- SESEEffectsKey readingEffect = (SESEEffectsKey) readIterB
- .next();
-
- if (readingEffect.getHRNUniqueId().equals(
- writeHeapRegionID)
- && readingEffect.getFieldDescriptor()
- .equals(writeFieldName)) {
- result = result | true;
- }
- }
- }else{
- //no field name
- Iterator<SESEEffectsKey> readIterB = readEffectsSetB
- .iterator();
- while (readIterB.hasNext()) {
- SESEEffectsKey readingEffect = (SESEEffectsKey) readIterB
- .next();
-
- if (readingEffect.getFieldDescriptor().length()==0 && nodeA.getTempDescriptor().equals(nodeB.getTempDescriptor())) {
- result = result | true;
- }
- }
-
- }
-
- }
-
- if (writeEffectsSetB != null) {
- Iterator<SESEEffectsKey> writeIterB = writeEffectsSetB
- .iterator();
- while (writeIterB.hasNext()) {
- SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterB
- .next();
-
- if(writeFieldName.length()>0){
- if (writingEffect.getHRNUniqueId().equals(
- writeHeapRegionID)
- && writingEffect.getFieldDescriptor()
- .equals(writeFieldName)) {
- result = result | true;
- }
- }else{
- //no field
- if (writingEffect.getFieldDescriptor().length()==0 && nodeA.getTempDescriptor().equals(nodeB.getTempDescriptor())) {
- result = result | true;
- }
- }
-
-
- }
- }
-
-// } // end of if(hasStrong)
-
- }
- }
-
- // if node B has write effects on reading regions of node A
- if (writeEffectsSetB != null) {
- Iterator<SESEEffectsKey> writeIterB = writeEffectsSetB.iterator();
- while (writeIterB.hasNext()) {
- SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterB
- .next();
-
- //if (!hasStrongUpdate(seseEffectsKey, strongUpdateSetB)) {
-
- String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
- String writeFieldName = seseEffectsKey.getFieldDescriptor();
-
- if (readEffectsSetA != null) {
- Iterator<SESEEffectsKey> readIterA = readEffectsSetA
- .iterator();
- while (readIterA.hasNext()) {
- SESEEffectsKey readingEffect = (SESEEffectsKey) readIterA
- .next();
-
- if(writeFieldName.length()>0){
- if (readingEffect.getHRNUniqueId().equals(
- writeHeapRegionID)
- && readingEffect.getFieldDescriptor()
- .equals(writeFieldName)) {
- result = result | true;
- }
- }else{
- if (readingEffect.getFieldDescriptor().length()==0 && nodeA.getTempDescriptor().equals(nodeB.getTempDescriptor())) {
- result = result | true;
- }
- }
-
- }
- }
-
- if (writeEffectsSetA != null) {
- Iterator<SESEEffectsKey> writeIterA = writeEffectsSetA
- .iterator();
- while (writeIterA.hasNext()) {
- SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterA
- .next();
-
- if(writeFieldName.length()>0){
- if (writingEffect.getHRNUniqueId().equals(
- writeHeapRegionID)
- && writingEffect.getFieldDescriptor()
- .equals(writeFieldName)) {
- result = result | true;
- }
- }else{
- if (writingEffect.getFieldDescriptor().length()==0 && nodeA.getTempDescriptor().equals(nodeB.getTempDescriptor())) {
- result = result | true;
- }
- }
-
- }
- }
- //} // if(hasStrong)
-
- }
- }
- return result;
- }
-
- private boolean isSelfConflicted(LiveInNode liveInNode) {
-
- int strongUpdateCount = 0;
-
- if (liveInNode.getWriteEffectsSet() != null
- && liveInNode.getWriteEffectsSet().size() > 0) {
-
- Set<SESEEffectsKey> strongUpdateSet = liveInNode
- .getStrongUpdateSet();
-
- Iterator<SESEEffectsKey> writeIter = liveInNode
- .getWriteEffectsSet().iterator();
- while (writeIter.hasNext()) {
- SESEEffectsKey writeEffect = (SESEEffectsKey) writeIter.next();
- if (hasStrongUpdate(writeEffect, strongUpdateSet)) {
- strongUpdateCount++;
- }
-
- if(writeEffect.isStrong()){
- return false;
- }
- }
-
-
- if (liveInNode.getWriteEffectsSet().size() == strongUpdateCount) {
- return false;
- }else{
- return true;
- }
-
- }
-
- return false;
- }
-
- private boolean isSCC(LiveInNode liveInNode){
-
- Set<HeapRegionNode> liveInHrnSet = liveInNode.getHRNSet();
-// for (Iterator iterator = liveInHrnSet.iterator(); iterator.hasNext();) {
-// HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next();
-// System.out.println("hrn="+heapRegionNode.getGloballyUniqueIdentifier());
-// }
-
- Set<Set> liveInNodeReachabilitySet = liveInNode.getReachabilitySet();
- Set<GloballyUniqueTokenTuple> overlappedReachableRegionSet = calculateOverlappedReachableRegion(liveInNodeReachabilitySet,liveInNodeReachabilitySet);
-
- if(liveInHrnSet.size()>1){
- if(overlappedReachableRegionSet.size()>0){
- return true;
- }
- }
-
- return false;
- }
-
- public void analyzePossibleConflicts(Set<String> analyzedIDSet,
- ConflictNode currentNode) {
-
- // compare with all nodes
-
- // examine the case where self-edge exists
- if (currentNode instanceof LiveInNode) {
- LiveInNode liveInNode = (LiveInNode) currentNode;
-// if (liveInNode.getWriteEffectsSet() != null
-// && liveInNode.getWriteEffectsSet().size() > 0) {
-// addConflictEdge(ConflictEdge.FINE_GRAIN_EDGE, currentNode,
-// currentNode);
-// }
- if(isSCC(liveInNode)){
- addConflictEdge(ConflictEdge.COARSE_GRAIN_EDGE, currentNode,
- currentNode);
- }else if(isSelfConflicted(liveInNode)){
- addConflictEdge(ConflictEdge.FINE_GRAIN_EDGE, currentNode,
- currentNode);
- }
-
- }
-
- Set<Entry<String, ConflictNode>> set = id2cn.entrySet();
- for (Iterator iterator = set.iterator(); iterator.hasNext();) {
- Entry<String, ConflictNode> entry = (Entry<String, ConflictNode>) iterator
- .next();
-
- String entryNodeID = entry.getKey();
- ConflictNode entryNode = entry.getValue();
-
- if ((!currentNode.getID().equals(entryNodeID))
- && !(analyzedIDSet.contains(currentNode.getID()
- + entryNodeID) || analyzedIDSet
- .contains(entryNodeID + currentNode.getID()))) {
-
- if (currentNode instanceof StallSiteNode
- && entryNode instanceof LiveInNode) {
- if (isWriteConflicts((StallSiteNode) currentNode,
- (LiveInNode) entryNode)) {
- int conflictType = determineWriteConflictsType(
- (StallSiteNode) currentNode,
- (LiveInNode) entryNode);
- if (conflictType > 0) {
- addConflictEdge(conflictType, currentNode,
- entryNode);
- }
- }
- analyzedIDSet.add(currentNode.getID() + entryNodeID);
-
- } else if (currentNode instanceof LiveInNode
- && entryNode instanceof LiveInNode) {
- if (isWriteConflicts((LiveInNode) currentNode,
- (LiveInNode) entryNode)) {
-
- int conflictType = determineWriteConflictsType(
- (LiveInNode) currentNode,
- (LiveInNode) entryNode);
- if (conflictType > 0) {
- addConflictEdge(conflictType, currentNode,
- entryNode);
- }
- }
- analyzedIDSet.add(currentNode.getID() + entryNodeID);
- }
-
- }
-
- }
-
- }
-
- public boolean containsTokenTuple(Set<GloballyUniqueTokenTuple> overlapSet,
- String uniqueID) {
-
- for (Iterator iterator = overlapSet.iterator(); iterator.hasNext();) {
- GloballyUniqueTokenTuple globallyUniqueTokenTuple = (GloballyUniqueTokenTuple) iterator
- .next();
- if (globallyUniqueTokenTuple.getID().equals(uniqueID)) {
- return true;
- }
- }
-
- return false;
-
- }
-
- private Set<GloballyUniqueTokenTuple> calculateOverlappedReachableRegion(
- Set<Set> setA, Set<Set> setB) {
-
- Set<GloballyUniqueTokenTuple> returnSet = new HashSet<GloballyUniqueTokenTuple>();
-
- for (Iterator iterator2 = setA.iterator(); iterator2.hasNext();) {
- Set tokenTupleSetA = (Set) iterator2.next();
-
- for (Iterator iterator3 = setB.iterator(); iterator3.hasNext();) {
- Set tokenTupleSetB = (Set) iterator3.next();
-
- if (tokenTupleSetA.equals(tokenTupleSetB)) {
- // reachability states are overlapped
- Iterator ttsIter = tokenTupleSetA.iterator();
- while (ttsIter.hasNext()) {
- GloballyUniqueTokenTuple tt = (GloballyUniqueTokenTuple) ttsIter
- .next();
- returnSet.add(tt);
- }
+
+ for (Iterator iterator = setA.iterator(); iterator.hasNext();) {
+ HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next();
+ String gID = heapRegionNode.getGloballyUniqueIdentifier();
+ boolean found = false;
+ for (Iterator iterator2 = setB.iterator(); iterator2.hasNext();) {
+ HeapRegionNode heapRegionNode2 = (HeapRegionNode) iterator2
+ .next();
+ if (heapRegionNode2.getGloballyUniqueIdentifier().equals(gID)) {
+ found = true;
}
}
+ if (!found) {
+ return false;
+ }
}
- return returnSet;
+ return true;
}
public String addStallNode(TempDescriptor td, FlatMethod fm,
public void addConflictEdge(int type, ConflictNode nodeU, ConflictNode nodeV) {
- // if there are two edges between the same node pair, coarse has a priority
- HashSet<ConflictEdge> set=nodeU.getEdgeSet();
- ConflictEdge toBeRemoved=null;
+ // if there are two edges between the same node pair, coarse has a
+ // priority
+ HashSet<ConflictEdge> set = nodeU.getEdgeSet();
+ ConflictEdge toBeRemoved = null;
for (Iterator iterator = set.iterator(); iterator.hasNext();) {
ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
-
- if((conflictEdge.getVertexU().equals(nodeU) && conflictEdge.getVertexV().equals(nodeV)) ||
- (conflictEdge.getVertexU().equals(nodeV) && conflictEdge.getVertexV().equals(nodeU))
- ){
- if(conflictEdge.getType()==ConflictEdge.FINE_GRAIN_EDGE && type==ConflictEdge.COARSE_GRAIN_EDGE){
- toBeRemoved=conflictEdge;
+
+ if ((conflictEdge.getVertexU().equals(nodeU) && conflictEdge
+ .getVertexV().equals(nodeV))
+ || (conflictEdge.getVertexU().equals(nodeV) && conflictEdge
+ .getVertexV().equals(nodeU))) {
+ if (conflictEdge.getType() == ConflictEdge.FINE_GRAIN_EDGE
+ && type == ConflictEdge.COARSE_GRAIN_EDGE) {
+ toBeRemoved = conflictEdge;
break;
- }else if(conflictEdge.getType()==ConflictEdge.COARSE_GRAIN_EDGE && type==ConflictEdge.FINE_GRAIN_EDGE){
- //ignore
+ } else if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE
+ && type == ConflictEdge.FINE_GRAIN_EDGE) {
+ // ignore
return;
}
}
}
-
- if(toBeRemoved!=null){
+
+ if (toBeRemoved != null) {
nodeU.getEdgeSet().remove(toBeRemoved);
nodeV.getEdgeSet().remove(toBeRemoved);
}
-
-
+
ConflictEdge newEdge = new ConflictEdge(nodeU, nodeV, type);
nodeU.addEdge(newEdge);
nodeV.addEdge(newEdge);
}
- public HashSet<LiveInNode> getLiveInNodeSet() {
- HashSet<LiveInNode> resultSet = new HashSet<LiveInNode>();
-
- Set<String> keySet = id2cn.keySet();
- for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
- String key = (String) iterator.next();
- ConflictNode node = id2cn.get(key);
-
- if (node instanceof LiveInNode) {
- resultSet.add((LiveInNode) node);
- }
- }
-
- return resultSet;
- }
-
public Set<WaitingElement> getStallSiteWaitingElementSet(
ParentChildConflictsMap conflictsMap, HashSet<SESELock> seseLockSet) {
HashSet<WaitingElement> waitingElementSet = new HashSet<WaitingElement>();
Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
Collection<StallSite> stallSites = conflictsMap.getStallMap().values();
-
+
for (Iterator iterator = stallSites.iterator(); iterator.hasNext();) {
StallSite stallSite = (StallSite) iterator.next();
ConflictEdge conflictEdge = (ConflictEdge) iter2
.next();
- for (Iterator<SESELock> seseLockIter = seseLockSet
- .iterator(); seseLockIter.hasNext();) {
- SESELock seseLock = seseLockIter.next();
- if (seseLock.containsConflictNode(stallSiteNode) && seseLock.containsConflictEdge(conflictEdge)) {
- WaitingElement newElement = new WaitingElement();
- newElement.setWaitingID(seseLock
- .getID());
- if(isFineElement(newElement.getStatus())){
- newElement.setDynID(node.getTempDescriptor().toString());
- }
- newElement.setStatus(seseLock.getNodeType(stallSiteNode));
- waitingElementSet.add(newElement);
+ for (Iterator<SESELock> seseLockIter = seseLockSet
+ .iterator(); seseLockIter.hasNext();) {
+ SESELock seseLock = seseLockIter.next();
+ if (seseLock
+ .containsConflictNode(stallSiteNode)
+ && seseLock
+ .containsConflictEdge(conflictEdge)) {
+ WaitingElement newElement = new WaitingElement();
+ newElement.setWaitingID(seseLock.getID());
+ if (isFineElement(newElement.getStatus())) {
+ newElement
+ .setDynID(node
+ .getTempDescriptor()
+ .toString());
}
+ newElement.setStatus(seseLock
+ .getNodeType(stallSiteNode));
+ waitingElementSet.add(newElement);
}
+ }
}
}
}
return waitingElementSet;
}
- public Set<Integer> getConnectedConflictNodeSet(
- ParentChildConflictsMap conflictsMap) {
-
- HashSet<Integer> nodeIDSet = new HashSet<Integer>();
-
- Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
-
- Collection<StallSite> stallSites = conflictsMap.getStallMap().values();
- for (Iterator iterator = stallSites.iterator(); iterator.hasNext();) {
- StallSite stallSite = (StallSite) iterator.next();
- Iterator<Entry<String, ConflictNode>> i = s.iterator();
- while (i.hasNext()) {
- Entry<String, ConflictNode> entry = i.next();
- ConflictNode node = entry.getValue();
-
- if (node instanceof StallSiteNode) {
- StallSiteNode stallSiteNode = (StallSiteNode) node;
- if (stallSiteNode.getStallSite().equals(stallSite)) {
- HashSet<ConflictEdge> edgeSet = stallSiteNode
- .getEdgeSet();
- for (Iterator iter2 = edgeSet.iterator(); iter2
- .hasNext();) {
- ConflictEdge conflictEdge = (ConflictEdge) iter2
- .next();
- nodeIDSet
- .addAll(getConnectedConflictNode(conflictEdge));
- }
- }
- }
- }
- }
-
- return nodeIDSet;
-
- }
-
- private Set<Integer> getConnectedConflictNode(ConflictEdge conflictEdge) {
-
- HashSet<Integer> nodeIDSet = new HashSet<Integer>();
-
- if (conflictEdge.getVertexU() instanceof LiveInNode) {
- LiveInNode lin = (LiveInNode) conflictEdge.getVertexU();
- nodeIDSet.add(new Integer(lin.getSESEIdentifier()));
- }
- if (conflictEdge.getVertexV() instanceof LiveInNode) {
- LiveInNode lin = (LiveInNode) conflictEdge.getVertexV();
- nodeIDSet.add(new Integer(lin.getSESEIdentifier()));
- }
-
- return nodeIDSet;
- }
-
private Set<Integer> getConnectedConflictNode(ConflictEdge conflictEdge,
int seseID) {
.next();
for (Iterator<SESELock> seseLockIter = seseLockSet
- .iterator(); seseLockIter.hasNext();) {
- SESELock seseLock = seseLockIter.next();
- if (seseLock.containsConflictNode(liveInNode) && seseLock.containsConflictEdge(conflictEdge)) {
- WaitingElement newElement = new WaitingElement();
- newElement.setWaitingID(seseLock.getID());
- newElement.setStatus(seseLock.getNodeType(liveInNode));
- if(isFineElement(newElement.getStatus())){
- // for fine waiting element, set temp descriptor to handle unresolved pointer case.
- newElement.setDynID(node.getTempDescriptor().toString());
- newElement.setTempDesc(node.getTempDescriptor());
- }
- if(!waitingElementSet.contains(newElement)){
- waitingElementSet.add(newElement);
- }
-
+ .iterator(); seseLockIter.hasNext();) {
+ SESELock seseLock = seseLockIter.next();
+ if (seseLock.containsConflictNode(liveInNode)
+ && seseLock
+ .containsConflictEdge(conflictEdge)) {
+ WaitingElement newElement = new WaitingElement();
+ newElement.setWaitingID(seseLock.getID());
+ newElement.setStatus(seseLock
+ .getNodeType(liveInNode));
+ if (isFineElement(newElement.getStatus())) {
+ newElement.setDynID(node
+ .getTempDescriptor().toString());
+ newElement.setTempDesc(node.getTempDescriptor());
+ }
+ if (!waitingElementSet.contains(newElement)) {
+ waitingElementSet.add(newElement);
+ }
+
}
}
}
return waitingElementSet;
}
-
+
public boolean isFineElement(int type) {
if (type == ConflictNode.FINE_READ || type == ConflictNode.FINE_WRITE
|| type == ConflictNode.PARENT_READ
}
}
- public Set<Long> getAllocationSiteIDSetBySESEID(int seseID) {
- // deprecated
- HashSet<Long> allocSiteIDSet = new HashSet<Long>();
+ public HashSet<ConflictEdge> getEdgeSet() {
+
+ HashSet<ConflictEdge> returnSet = new HashSet<ConflictEdge>();
+
+ Collection<ConflictNode> nodes = id2cn.values();
+ for (Iterator iterator = nodes.iterator(); iterator.hasNext();) {
+ ConflictNode conflictNode = (ConflictNode) iterator.next();
+ returnSet.addAll(conflictNode.getEdgeSet());
+ }
+
+ return returnSet;
+ }
+
+ public void writeGraph(String graphName, boolean filter)
+ throws java.io.IOException {
+
+ graphName = graphName.replaceAll("[\\W]", "");
+
+ BufferedWriter bw = new BufferedWriter(new FileWriter(graphName
+ + ".dot"));
+ bw.write("graph " + graphName + " {\n");
+ HashSet<HeapRegionNode> visited = new HashSet<HeapRegionNode>();
+ // then visit every heap region node
Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
Iterator<Entry<String, ConflictNode>> i = s.iterator();
+ HashSet<ConflictEdge> addedSet = new HashSet<ConflictEdge>();
+
while (i.hasNext()) {
Entry<String, ConflictNode> entry = i.next();
ConflictNode node = entry.getValue();
- if (node instanceof LiveInNode) {
- LiveInNode liveInNode = (LiveInNode) node;
- if (liveInNode.getSESEIdentifier() == seseID) {
- HashSet<ConflictEdge> edgeSet = liveInNode.getEdgeSet();
- for (Iterator iterator = edgeSet.iterator(); iterator
- .hasNext();) {
- ConflictEdge conflictEdge = (ConflictEdge) iterator
+ if (filter) {
+ if (node.getID().startsWith("___dst")
+ || node.getID().startsWith("___srctmp")
+ || node.getID().startsWith("___neverused")
+ || node.getID().startsWith("___temp")) {
+
+ continue;
+ }
+ }
+
+ String attributes = "[";
+
+ attributes += "label=\"ID" + node.getID() + "\\n";
+
+ if (node instanceof StallSiteNode) {
+ attributes += "STALL SITE" + "\\n" + "\"]";
+ } else {
+ attributes += "LIVE-IN" + "\\n" + "\"]";
+ }
+ bw.write(entry.getKey() + attributes + ";\n");
+
+ HashSet<ConflictEdge> edgeSet = node.getEdgeSet();
+ for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
+ ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
+
+ ConflictNode u = conflictEdge.getVertexU();
+ ConflictNode v = conflictEdge.getVertexV();
+
+ if (filter) {
+ String uID = u.getID();
+ String vID = v.getID();
+ if (uID.startsWith("___dst") || uID.startsWith("___srctmp")
+ || uID.startsWith("___neverused")
+ || uID.startsWith("___temp")
+ || vID.startsWith("___dst")
+ || vID.startsWith("___srctmp")
+ || vID.startsWith("___neverused")
+ || vID.startsWith("___temp")) {
+ continue;
+ }
+ }
+
+ if (!addedSet.contains(conflictEdge)) {
+ bw.write(" " + u.getID() + "--" + v.getID() + "[label="
+ + conflictEdge.toGraphEdgeString()
+ + ",decorate];\n");
+ addedSet.add(conflictEdge);
+ }
+
+ }
+ }
+
+ bw.write(" graphTitle[label=\"" + graphName + "\",shape=box];\n");
+
+ bw.write("}\n");
+ bw.close();
+
+ }
+
+ private int calculateConflictType(StallSiteNode nodeA, LiveInNode nodeB) {
+
+ StallSite stallSite = nodeA.getStallSite();
+ Set<SESEEffectsKey> writeEffectsSet = nodeB.getWriteEffectsSet();
+ Set<SESEEffectsKey> readEffectsSet = nodeB.getReadEffectsSet();
+
+ int conflictType = 0;
+
+ if (writeEffectsSet != null) {
+ Iterator<SESEEffectsKey> writeIter = writeEffectsSet.iterator();
+ while (writeIter.hasNext()) {
+ SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIter
+ .next();
+ String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
+ String writeFieldName = seseEffectsKey.getFieldDescriptor();
+
+ HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
+ for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
+ .hasNext();) {
+ HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
+ if (stallHRN.getGloballyUniqueIdentifier().equals(
+ writeHeapRegionID)) {
+ // check whether there are read or write effects of
+ // stall sites
+ HashSet<Effect> effectSet = stallSite.getEffectSet();
+ for (Iterator iterator2 = effectSet.iterator(); iterator2
+ .hasNext();) {
+ Effect effect = (Effect) iterator2.next();
+ String stallEffectfieldName = effect.getField();
+
+ if (stallEffectfieldName.equals(writeFieldName)) {
+ int newType = determineConflictType(nodeA,
+ effect, nodeB, seseEffectsKey);
+ if (newType > conflictType) {
+ // coarse-grain conflict overrides
+ // fine-grain conflict
+ conflictType = newType;
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+
+ if (readEffectsSet != null) {
+ Iterator<SESEEffectsKey> readIter = readEffectsSet.iterator();
+ while (readIter.hasNext()) {
+ SESEEffectsKey seseEffectsKey = (SESEEffectsKey) readIter
+ .next();
+ String readHeapRegionID = seseEffectsKey.getHRNUniqueId();
+ String readFieldName = seseEffectsKey.getFieldDescriptor();
+
+ HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
+ for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
+ .hasNext();) {
+ HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
+ if (stallHRN.getGloballyUniqueIdentifier().equals(
+ readHeapRegionID)) {
+
+ HashSet<Effect> effectSet = stallSite.getEffectSet();
+ for (Iterator iterator2 = effectSet.iterator(); iterator2
+ .hasNext();) {
+ Effect effect = (Effect) iterator2.next();
+ String stallEffectfieldName = effect.getField();
+
+ if (effect.getEffectType().equals(
+ StallSite.WRITE_EFFECT)) {
+ if (stallEffectfieldName.equals(readFieldName)) {
+ int newType = determineConflictType(nodeA,
+ effect, nodeB, seseEffectsKey);
+ if (newType > conflictType) {
+ // coarse-grain conflict overrides
+ // fine-grain conflict
+ conflictType = newType;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+//System.out.println("%%%%%%%%%%%%%% RETURN conflictType="+conflictType);
+ return conflictType;
+ }
+
+ private int calculateConflictType(LiveInNode nodeA, LiveInNode nodeB) {
+
+ Set<SESEEffectsKey> readEffectsSetA = nodeA.getReadEffectsSet();
+ Set<SESEEffectsKey> writeEffectsSetA = nodeA.getWriteEffectsSet();
+ Set<SESEEffectsKey> strongUpdateSetA = nodeA.getStrongUpdateSet();
+
+ Set<SESEEffectsKey> readEffectsSetB = nodeB.getReadEffectsSet();
+ Set<SESEEffectsKey> writeEffectsSetB = nodeB.getWriteEffectsSet();
+ Set<SESEEffectsKey> strongUpdateSetB = nodeB.getStrongUpdateSet();
+
+ int conflictType = 0;
+
+ // if node A has write effects on reading/writing regions of node B
+ if (writeEffectsSetA != null) {
+ Iterator<SESEEffectsKey> writeIterA = writeEffectsSetA.iterator();
+ while (writeIterA.hasNext()) {
+ SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterA
+ .next();
+ String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
+ String writeFieldName = seseEffectsKey.getFieldDescriptor();
+
+ if (readEffectsSetB != null) {
+
+ Iterator<SESEEffectsKey> readIterB = readEffectsSetB
+ .iterator();
+ while (readIterB.hasNext()) {
+ SESEEffectsKey readingEffect = (SESEEffectsKey) readIterB
.next();
- //
- getConnectedConflictNode(conflictEdge, seseID);
- //
- if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE) {
- allocSiteIDSet
- .addAll(getHRNIdentifierSet(conflictEdge
- .getVertexU()));
- allocSiteIDSet
- .addAll(getHRNIdentifierSet(conflictEdge
- .getVertexV()));
- } else {// it is fine-grain edge
- allocSiteIDSet.addAll(getHRNIdentifierSet(node));
+
+ if (readingEffect.getHRNUniqueId().equals(
+ writeHeapRegionID)
+ && readingEffect.getFieldDescriptor().equals(
+ writeFieldName)) {
+ int newType = determineConflictType(nodeA,
+ seseEffectsKey, nodeB, readingEffect);
+ if (newType > conflictType) {
+ // coarse-grain conflict overrides fine-grain
+ // conflict
+ conflictType = newType;
+ }
}
}
}
- }
- }
- return allocSiteIDSet;
+ if (writeEffectsSetB != null) {
+ Iterator<SESEEffectsKey> writeIterB = writeEffectsSetB
+ .iterator();
+ while (writeIterB.hasNext()) {
+ SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterB
+ .next();
- }
+ if (writingEffect.getHRNUniqueId().equals(
+ writeHeapRegionID)
+ && writingEffect.getFieldDescriptor().equals(
+ writeFieldName)) {
+ int newType = determineConflictType(nodeA,
+ seseEffectsKey, nodeB, writingEffect);
+ if (newType > conflictType) {
+ // coarse-grain conflict overrides fine-grain
+ // conflict
+ conflictType = newType;
+ }
+ }
- public Set<Long> getAllocationSiteIDSetofStallSite() {
+ }
+ }
- HashSet<Long> allocSiteIDSet = new HashSet<Long>();
+ }
+ }
- Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
- Iterator<Entry<String, ConflictNode>> i = s.iterator();
+ // if node B has write effects on reading regions of node A
+ if (writeEffectsSetB != null) {
+ Iterator<SESEEffectsKey> writeIterB = writeEffectsSetB.iterator();
+ while (writeIterB.hasNext()) {
+ SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterB
+ .next();
- while (i.hasNext()) {
+ // if (!hasStrongUpdate(seseEffectsKey, strongUpdateSetB)) {
- Entry<String, ConflictNode> entry = i.next();
- ConflictNode node = entry.getValue();
+ String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
+ String writeFieldName = seseEffectsKey.getFieldDescriptor();
- if (node instanceof StallSiteNode) {
- allocSiteIDSet.addAll(getHRNIdentifierSet(node));
- }
+ if (readEffectsSetA != null) {
+ Iterator<SESEEffectsKey> readIterA = readEffectsSetA
+ .iterator();
+ while (readIterA.hasNext()) {
+ SESEEffectsKey readingEffect = (SESEEffectsKey) readIterA
+ .next();
- }
+ if (readingEffect.getHRNUniqueId().equals(
+ writeHeapRegionID)
+ && readingEffect.getFieldDescriptor().equals(
+ writeFieldName)) {
+ int newType = determineConflictType(nodeA,
+ readingEffect, nodeB, seseEffectsKey);
+ if (newType > conflictType) {
+ // coarse-grain conflict overrides fine-grain
+ // conflict
+ conflictType = newType;
+ }
+ }
- return allocSiteIDSet;
+ }
+ }
- }
+ if (writeEffectsSetA != null) {
+ Iterator<SESEEffectsKey> writeIterA = writeEffectsSetA
+ .iterator();
+ while (writeIterA.hasNext()) {
+ SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterA
+ .next();
- public Set<Long> getAllocationSiteIDSet() {
+ if (writingEffect.getHRNUniqueId().equals(
+ writeHeapRegionID)
+ && writingEffect.getFieldDescriptor().equals(
+ writeFieldName)) {
+ int newType = determineConflictType(nodeA,
+ writingEffect, nodeB, seseEffectsKey);
+ if (newType > conflictType) {
+ // coarse-grain conflict overrides fine-grain
+ // conflict
+ conflictType = newType;
+ }
+ }
- HashSet<Long> allocSiteIDSet = new HashSet<Long>();
+ }
+ }
- Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
- Iterator<Entry<String, ConflictNode>> i = s.iterator();
+ }
+ }
+ return conflictType;
+ }
- while (i.hasNext()) {
- Entry<String, ConflictNode> entry = i.next();
- ConflictNode node = entry.getValue();
+ private Set<HeapRegionNode> getSameHeapRoot(Set<HeapRegionNode> setA,
+ Set<HeapRegionNode> setB) {
- HashSet<ConflictEdge> edgeSet = node.getEdgeSet();
- for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
- ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
- if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE) {
- allocSiteIDSet.addAll(getHRNIdentifierSet(conflictEdge
- .getVertexU()));
- allocSiteIDSet.addAll(getHRNIdentifierSet(conflictEdge
- .getVertexV()));
- } else {// it is fine-grain edge
- allocSiteIDSet.addAll(getHRNIdentifierSet(node));
+ Set<HeapRegionNode> retSet = new HashSet<HeapRegionNode>();
+
+ if (compareHRNSet(setA, setB)) {
+ for (Iterator iterator = setA.iterator(); iterator.hasNext();) {
+ HeapRegionNode heapRegionNode = (HeapRegionNode) iterator
+ .next();
+ String gID = heapRegionNode.getGloballyUniqueIdentifier();
+ boolean found = false;
+ for (Iterator iterator2 = setB.iterator(); iterator2.hasNext();) {
+ HeapRegionNode heapRegionNode2 = (HeapRegionNode) iterator2
+ .next();
+ if (heapRegionNode2.getGloballyUniqueIdentifier().equals(
+ gID)) {
+ retSet.add(heapRegionNode2);
+ }
}
}
-
}
- return allocSiteIDSet;
+ return retSet;
}
+
+ private boolean isReachableFrom(HeapRegionNode root1, HeapRegionNode root2,
+ ReachabilitySet rset) {
+
+ boolean reachable=false;
+
+ TokenTuple h1 = new TokenTuple(root1.getID(), !root1.isSingleObject(),
+ TokenTuple.ARITY_ONE).makeCanonical();
+
+ TokenTuple h1plus = new TokenTuple(root1.getID(), !root1
+ .isSingleObject(), TokenTuple.ARITY_ONEORMORE).makeCanonical();
+
+ TokenTuple h1star = new TokenTuple(root1.getID(), !root1
+ .isSingleObject(), TokenTuple.ARITY_ZEROORMORE).makeCanonical();
+
+ TokenTuple h2 = new TokenTuple(root2.getID(), !root2.isSingleObject(),
+ TokenTuple.ARITY_ONE).makeCanonical();
+
+ TokenTuple h2plus = new TokenTuple(root2.getID(), !root2
+ .isSingleObject(), TokenTuple.ARITY_ONEORMORE).makeCanonical();
+
+ TokenTuple h2star = new TokenTuple(root2.getID(), !root2
+ .isSingleObject(), TokenTuple.ARITY_ZEROORMORE).makeCanonical();
+
+ // only do this one if they are different tokens
+ if( h1 != h2 &&
+ rset.containsTupleSetWithBoth(h1, h2) ) {
+ reachable = true;
+ }
+ if( rset.containsTupleSetWithBoth(h1plus, h2) ) {
+ reachable = true;
+ }
+ if( rset.containsTupleSetWithBoth(h1star, h2) ) {
+ reachable = true;
+ }
+ if( rset.containsTupleSetWithBoth(h1, h2plus) ) {
+ reachable = true;
+ }
+ if( rset.containsTupleSetWithBoth(h1plus, h2plus) ) {
+ reachable = true;
+ }
+ if( rset.containsTupleSetWithBoth(h1star, h2plus) ) {
+ reachable = true;
+ }
+ if( rset.containsTupleSetWithBoth(h1, h2star) ) {
+ reachable = true;
+ }
+ if( rset.containsTupleSetWithBoth(h1plus, h2star) ) {
+ reachable = true;
+ }
+ if( rset.containsTupleSetWithBoth(h1star, h2star) ) {
+ reachable = true;
+ }
+
+ return reachable;
- private HashSet<Integer> getAllocSet(ConflictNode node) {
-
- HashSet<Integer> returnSet = new HashSet<Integer>();
-
- if (node instanceof StallSiteNode) {
- StallSiteNode stallSiteNode = (StallSiteNode) node;
- Set<HeapRegionNode> hrnSet = stallSiteNode.getHRNSet();
- for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
- HeapRegionNode hrn = (HeapRegionNode) iterator.next();
- // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
- if (hrn.getAllocationSite() != null) {
- returnSet.add(new Integer(hrn.getAllocationSite().getID()));
+ }
+
+ private int determineConflictType(StallSiteNode stallSiteNodeA,
+ Effect effect, LiveInNode liveInNodeB,
+ SESEEffectsKey effectB) {
+
+ Set<HeapRegionNode> liveInHrnSetA = stallSiteNodeA.getStallSite().getHRNSet();
+ Set<HeapRegionNode> liveInHrnSetB = liveInNodeB.getHRNSet();
+
+ // check whether alloc site is reached from both heap roots
+ boolean isDisjoint=true;
+ HeapRegionNode effectHrn=og.gid2hrn.get(effectB.getHRNUniqueId());
+ if(effectHrn.isSingleObject()){
+ for (Iterator iterator = liveInHrnSetA.iterator(); iterator.hasNext();) {
+ HeapRegionNode r1 = (HeapRegionNode) iterator.next();
+ for (Iterator iterator2 = liveInHrnSetB.iterator(); iterator2.hasNext();) {
+ HeapRegionNode r2 = (HeapRegionNode) iterator2.next();
+ r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier());
+ r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier());
+ if(isReachableFrom(r1,r2,effectB.getRSet())){
+ isDisjoint=false;
+ }
}
}
- } else {
- LiveInNode liveInNode = (LiveInNode) node;
- Set<HeapRegionNode> hrnSet = liveInNode.getHRNSet();
- for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
- HeapRegionNode hrn = (HeapRegionNode) iterator.next();
- // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
- if (hrn.getAllocationSite() != null) {
- returnSet.add(new Integer(hrn.getAllocationSite().getID()));
- }else{
- returnSet.add(new Integer(hrn.getID()));
- }
+ if(isDisjoint){
+ return ConflictEdge.NON_WRITE_CONFLICT;
}
}
+
+ /*
+ HeapRegionNode r1=liveInHrnSetA.iterator().next();
+ HeapRegionNode r2=liveInHrnSetB.iterator().next();
+
+ r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier());
+ r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier());
+
+ System.out.println("r1="+r1);
+ System.out.println("r2="+r2);
+ System.out.println("effectB="+effectB.getRSet());
+ System.out.println("###STALL calculateConflictType2");
+ if(!isReachableFrom(r1,r2,effectB.getRSet())){
+ System.out.println("###STALL calculateConflictType3");
+ return ConflictEdge.NON_WRITE_CONFLICT;
+ }
+ */
+ Set<HeapRegionNode> entryHRNSet = getSameHeapRoot(liveInHrnSetA,
+ liveInHrnSetB);
+ if (entryHRNSet.size() == 0) {
+ return ConflictEdge.COARSE_GRAIN_EDGE;
+ }
- return returnSet;
- }
-
- private HashSet<Long> getHRNIdentifierSet(ConflictNode node) {
+ for (Iterator iterator = entryHRNSet.iterator(); iterator.hasNext();) {
+ HeapRegionNode hrn = (HeapRegionNode) iterator.next();
- HashSet<Long> returnSet = new HashSet<Long>();
+ String entryIdentifier = hrn.getGloballyUniqueIdentifier();
+ HeapRegionNode entryHRN = og.gid2hrn.get(entryIdentifier);
- if (node instanceof StallSiteNode) {
- StallSiteNode stallSiteNode = (StallSiteNode) node;
- Set<HeapRegionNode> hrnSet = stallSiteNode.getHRNSet();
- for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
- HeapRegionNode hrn = (HeapRegionNode) iterator.next();
- // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
- returnSet
- .add(new Long(hrn.getGloballyUniqueIntegerIdentifier()));
- }
- } else {
- LiveInNode liveInNode = (LiveInNode) node;
- Set<HeapRegionNode> hrnSet = liveInNode.getHRNSet();
- for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
- HeapRegionNode hrn = (HeapRegionNode) iterator.next();
- // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
- returnSet
- .add(new Long(hrn.getGloballyUniqueIntegerIdentifier()));
+ TokenTuple h1 = new TokenTuple(entryHRN.getID(), !entryHRN
+ .isSingleObject(), TokenTuple.ARITY_ONE).makeCanonical();
+
+ TokenTuple h1star = new TokenTuple(entryHRN.getID(), true,
+ TokenTuple.ARITY_ONEORMORE).makeCanonical();
+
+ if (effectB.getRSet().containsTuple(h1star)) {
+ return ConflictEdge.COARSE_GRAIN_EDGE;
+ }else if (effectB.getRSet().containsTuple(h1)) {
+ // rechability states contain heap root with arity 1
+ return ConflictEdge.FINE_GRAIN_EDGE;
}
}
-
- return returnSet;
-
+ return ConflictEdge.NON_WRITE_CONFLICT;
}
- public HashSet<ConflictEdge> getEdgeSet() {
+ private int determineConflictType(LiveInNode liveInNodeA,
+ SESEEffectsKey effectA, LiveInNode liveInNodeB,
+ SESEEffectsKey effectB) {
- HashSet<ConflictEdge> returnSet = new HashSet<ConflictEdge>();
+ if (liveInNodeA.getSESEIdentifier() == liveInNodeB.getSESEIdentifier()) {
+ return ConflictEdge.NON_WRITE_CONFLICT;
+ }
- Collection<ConflictNode> nodes = id2cn.values();
- for (Iterator iterator = nodes.iterator(); iterator.hasNext();) {
- ConflictNode conflictNode = (ConflictNode) iterator.next();
- returnSet.addAll(conflictNode.getEdgeSet());
+ Set<HeapRegionNode> liveInHrnSetA = liveInNodeA.getHRNSet();
+ Set<HeapRegionNode> liveInHrnSetB = liveInNodeB.getHRNSet();
+
+ // check whether alloc site is reached from both heap roots
+ boolean isDisjoint=true;
+ HeapRegionNode effectHrn=og.gid2hrn.get(effectB.getHRNUniqueId());
+ if(effectHrn.isSingleObject()){
+ for (Iterator iterator = liveInHrnSetA.iterator(); iterator.hasNext();) {
+ HeapRegionNode r1 = (HeapRegionNode) iterator.next();
+ for (Iterator iterator2 = liveInHrnSetB.iterator(); iterator2.hasNext();) {
+ HeapRegionNode r2 = (HeapRegionNode) iterator2.next();
+ r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier());
+ r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier());
+
+ if(isReachableFrom(r1,r2,effectB.getRSet())){
+ isDisjoint=false;
+ }else{
+ }
+ }
+ }
+ if(isDisjoint){
+ return ConflictEdge.NON_WRITE_CONFLICT;
+ }
+ }
+
+ /*
+ HeapRegionNode r1=liveInHrnSetA.iterator().next();
+ HeapRegionNode r2=liveInHrnSetB.iterator().next();
+
+// r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier());
+// r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier());
+ System.out.println("@@r1="+r1);
+ System.out.println("@@r2="+r2);
+ System.out.println("@@effectB="+effectA.getRSet());
+
+ if(!isReachableFrom(r1,r2,effectA.getRSet())){
+ // two heap root are disjoint
+ return ConflictEdge.NON_WRITE_CONFLICT;
+ }
+ */
+
+ Set<HeapRegionNode> entryHRNSet = getSameHeapRoot(liveInHrnSetA,
+ liveInHrnSetB);
+ if (entryHRNSet.size() == 0) {
+ return ConflictEdge.COARSE_GRAIN_EDGE;
}
- return returnSet;
- }
+ int count=0;
+ for (Iterator iterator = entryHRNSet.iterator(); iterator.hasNext();) {
+ HeapRegionNode hrn = (HeapRegionNode) iterator.next();
+ if(hrn.getType()!=null && hrn.getType().isImmutable()){
+ count++;
+ }
+ }
+ if(count==entryHRNSet.size()){
+ return ConflictEdge.FINE_GRAIN_EDGE;
+ }
+
+ for (Iterator iterator = entryHRNSet.iterator(); iterator.hasNext();) {
+ HeapRegionNode hrn = (HeapRegionNode) iterator.next();
- static public int generateUniqueCliqueID() {
- ++uniqueCliqueIDcount;
- return uniqueCliqueIDcount;
- }
+ String entryIdentifier = hrn.getGloballyUniqueIdentifier();
+ HeapRegionNode entryHRN = og.gid2hrn.get(entryIdentifier);
- public void writeGraph(String graphName, boolean filter)
- throws java.io.IOException {
+ TokenTuple h1 = new TokenTuple(entryHRN.getID(), !entryHRN
+ .isSingleObject(), TokenTuple.ARITY_ONE).makeCanonical();
- graphName = graphName.replaceAll("[\\W]", "");
+ TokenTuple h1star = new TokenTuple(entryHRN.getID(), true,
+ TokenTuple.ARITY_ONEORMORE).makeCanonical();
- BufferedWriter bw = new BufferedWriter(new FileWriter(graphName
- + ".dot"));
- bw.write("graph " + graphName + " {\n");
+ if (effectA.getRSet().containsTuple(h1star)) {
+ return ConflictEdge.COARSE_GRAIN_EDGE;
+ } else if (effectA.getRSet().containsTuple(h1)) {
+ // rechability states contain heap root with arity 1
+ return ConflictEdge.FINE_GRAIN_EDGE;
+ }
- HashSet<HeapRegionNode> visited = new HashSet<HeapRegionNode>();
- // then visit every heap region node
- Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
- Iterator<Entry<String, ConflictNode>> i = s.iterator();
+ }
- HashSet<ConflictEdge> addedSet = new HashSet<ConflictEdge>();
+ return ConflictEdge.NON_WRITE_CONFLICT;
- while (i.hasNext()) {
- Entry<String, ConflictNode> entry = i.next();
- ConflictNode node = entry.getValue();
+ }
+
+ private int calculateSelfConflictType(LiveInNode liveInNode) {
+
+ // if strong update effect exists, it conflicts every effects of objects that are reachable from same heap root
+ Set<SESEEffectsKey> strongUpdateSet = liveInNode.getStrongUpdateSet();
+ if(strongUpdateSet!=null && strongUpdateSet.size()>0){
+ return ConflictEdge.FINE_GRAIN_EDGE;
+ }
+
+ if (liveInNode.getWriteEffectsSet() != null
+ && liveInNode.getWriteEffectsSet().size() > 0) {
+
+ Set<SESEEffectsKey> writeEffectsSet=liveInNode.getWriteEffectsSet();
+
+ int immuntableCount = 0;
+ for (Iterator<HeapRegionNode> iterator = liveInNode.getHRNSet()
+ .iterator(); iterator.hasNext();) {
+ HeapRegionNode root = iterator.next();
+ if(root.getType()!=null && root.getType().isImmutable()){
+ immuntableCount++;
+ }
+ }
+ if (immuntableCount == liveInNode.getHRNSet().size()) {
+ // in this case, heap root is a parameter heap region
+ return ConflictEdge.FINE_GRAIN_EDGE;
+ }
+
+
+ int paramCount = 0;
+ for (Iterator<HeapRegionNode> iterator = liveInNode.getHRNSet()
+ .iterator(); iterator.hasNext();) {
+ HeapRegionNode root = iterator.next();
+ if (root.isParameter()) {
+ paramCount++;
+ }
+ }
- if (filter) {
- if (node.getID().startsWith("___dst")
- || node.getID().startsWith("___srctmp")
- || node.getID().startsWith("___neverused")
- || node.getID().startsWith("___temp")) {
+ if (paramCount == liveInNode.getHRNSet().size()) {
+ // in this case, heap root is a parameter heap region
+ return ConflictEdge.FINE_GRAIN_EDGE;
+ }
- continue;
+ if (liveInNode.getHRNSet().size()==1) {
+ HeapRegionNode hrn = liveInNode.getHRNSet().iterator().next();
+ String entryIdentifier = hrn.getGloballyUniqueIdentifier();
+ HeapRegionNode entryHRN = og.gid2hrn.get(entryIdentifier);
+
+ boolean containsStar=false;
+ for (Iterator iterator = writeEffectsSet.iterator(); iterator
+ .hasNext();) {
+ SESEEffectsKey effect = (SESEEffectsKey) iterator.next();
+ TokenTuple h1 = new TokenTuple(entryHRN.getID(), !entryHRN
+ .isSingleObject(), TokenTuple.ARITY_ONE).makeCanonical();
+ TokenTuple h1star = new TokenTuple(entryHRN.getID(), true, TokenTuple.ARITY_ZEROORMORE).makeCanonical();
+ if (effect.getRSet().containsTuple(h1star)) {
+ // rechability states contain heap root with arity star
+ containsStar=true;
+ }
+ }
+ if(containsStar){
+ return ConflictEdge.COARSE_GRAIN_EDGE;
+ }else{
+ return ConflictEdge.FINE_GRAIN_EDGE;
+ }
+ }else{
+ return ConflictEdge.COARSE_GRAIN_EDGE;
+ }
+
+
+ /*
+ boolean containsAllTuple=true;
+ for (Iterator iterator2 = writeEffectsSet.iterator(); iterator2
+ .hasNext();) {
+ SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2
+ .next();
+ ReachabilitySet rset = seseEffectsKey.getRSet();
+ Iterator<TokenTupleSet> tsetIter=rset.iterator();
+ int countNotContained=0;
+ while (tsetIter.hasNext()) {
+ TokenTupleSet tokenTupleSet = (TokenTupleSet) tsetIter
+ .next();
+ boolean found=true;
+ for (Iterator iterator = rootIDSet.iterator(); iterator
+ .hasNext();) {
+ Integer rootID = (Integer) iterator.next();
+ if(tokenTupleSet.containsToken(rootID)==null){
+ found=false;
+ }
+ }
+ if(!found){
+ countNotContained++;
+ }
}
+ if(countNotContained==rset.size()){
+ containsAllTuple=false;
+ }
+ }
+
+ if (containsAllTuple && liveInNode.getHRNSet().size() > 1) {
+ return ConflictEdge.COARSE_GRAIN_EDGE;
+ } else {
+ return ConflictEdge.FINE_GRAIN_EDGE;
}
+ */
+
+
+
+ }
+
+ return ConflictEdge.NON_WRITE_CONFLICT;
- String attributes = "[";
+ }
- attributes += "label=\"ID" + node.getID() + "\\n";
+ public void analyzePossibleConflicts(Set<String> analyzedIDSet,
+ ConflictNode currentNode) {
- if (node instanceof StallSiteNode) {
- attributes += "STALL SITE" + "\\n" + "\"]";
- } else {
- attributes += "LIVE-IN" + "\\n" + "\"]";
+ // compare with all nodes
+ // examine the case where self-edge exists
+ if (currentNode instanceof LiveInNode) {
+ LiveInNode liveInNode = (LiveInNode) currentNode;
+ int conflictType=calculateSelfConflictType(liveInNode);
+ if(conflictType>0){
+ addConflictEdge(conflictType, currentNode,
+ currentNode);
}
- bw.write(entry.getKey() + attributes + ";\n");
+ }
- HashSet<ConflictEdge> edgeSet = node.getEdgeSet();
- for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
- ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
+ Set<Entry<String, ConflictNode>> set = id2cn.entrySet();
+ for (Iterator iterator = set.iterator(); iterator.hasNext();) {
+ Entry<String, ConflictNode> entry = (Entry<String, ConflictNode>) iterator
+ .next();
- ConflictNode u = conflictEdge.getVertexU();
- ConflictNode v = conflictEdge.getVertexV();
+ String entryNodeID = entry.getKey();
+ ConflictNode entryNode = entry.getValue();
- if (filter) {
- String uID = u.getID();
- String vID = v.getID();
- if (uID.startsWith("___dst") || uID.startsWith("___srctmp")
- || uID.startsWith("___neverused")
- || uID.startsWith("___temp")
- || vID.startsWith("___dst")
- || vID.startsWith("___srctmp")
- || vID.startsWith("___neverused")
- || vID.startsWith("___temp")) {
- continue;
+ if ((!currentNode.getID().equals(entryNodeID))
+ && !(analyzedIDSet.contains(currentNode.getID()
+ + entryNodeID) || analyzedIDSet
+ .contains(entryNodeID + currentNode.getID()))) {
+
+ if (currentNode instanceof StallSiteNode
+ && entryNode instanceof LiveInNode) {
+
+ int conflictType = calculateConflictType((StallSiteNode) currentNode, (LiveInNode) entryNode);
+ if (conflictType > 0) {
+ addConflictEdge(conflictType, currentNode, entryNode);
}
- }
+
+ analyzedIDSet.add(currentNode.getID() + entryNodeID);
- if (!addedSet.contains(conflictEdge)) {
- bw.write(" " + u.getID() + "--" + v.getID() + "[label="
- + conflictEdge.toGraphEdgeString()
- + ",decorate];\n");
- addedSet.add(conflictEdge);
+ } else if (currentNode instanceof LiveInNode
+ && entryNode instanceof LiveInNode) {
+
+ int conflictType = calculateConflictType(
+ (LiveInNode) currentNode, (LiveInNode) entryNode);
+ if (conflictType > 0) {
+ addConflictEdge(conflictType, currentNode, entryNode);
+ }
+ analyzedIDSet.add(currentNode.getID() + entryNodeID);
}
}
- }
-
- bw.write(" graphTitle[label=\"" + graphName + "\",shape=box];\n");
- bw.write("}\n");
- bw.close();
+ }
}
public int getType() {
return type;
}
-
- public String toString(){
- return getVertexU()+"-"+getVertexV();
+
+ public String toString() {
+ return getVertexU() + "-" + getVertexV();
}
}
\ No newline at end of file
FlatNode key = (FlatNode) keyEnum.nextElement();
ConflictGraph cg=conflictGraphResults.get(key);
try {
- cg.writeGraph("ConflictGraphFor"+key, false);
+ if(cg.hasConflictEdge()){
+ cg.writeGraph("ConflictGraphFor"+key, false);
+ }
} catch (IOException e) {
System.out.println("Error writing");
System.exit(0);
while (iter.hasNext()) {
TempDescriptor td = iter.next();
LabelNode ln = og.td2ln.get(td);
+
+ if(currentSESE.getSeseEffectsSet().getMapTempDescToInVarIdx().containsKey(td)){
+ idx=currentSESE.getSeseEffectsSet().getInVarIdx(td);
+ }
+
if (ln != null) {
int taint = (int) Math.pow(2, idx);
- taintLabelNode(ln, taint);
+ taintLabelNode(ln, taint,currentSESE.getSeseEffectsSet());
currentSESE.getSeseEffectsSet().setInVarIdx(idx, td);
// collects related allocation sites
case FKind.FlatFieldNode: {
FlatFieldNode ffn = (FlatFieldNode) fn;
+ TempDescriptor dst = ffn.getDst();
TempDescriptor src = ffn.getSrc();
FieldDescriptor field = ffn.getField();
LabelNode srcLN = og.td2ln.get(src);
if(srcLN!=null){
Iterator<ReferenceEdge> edgeIter=srcLN.iteratorToReferencees();
+ int taintIdentifier=0;
while (edgeIter.hasNext()) {
ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
.next();
HeapRegionNode refHRN=referenceEdge.getDst();
- int edgeTaint=referenceEdge.getSESETaintIdentifier();
+ taintIdentifier=currentSESE.getSeseEffectsSet().getTaint(referenceEdge);
+// taintIdentifier=referenceEdge.getSESETaintIdentifier();
// figure out which invar has related effects
- int taint=referenceEdge.getSESETaintIdentifier();
Hashtable<TempDescriptor, Integer> map=currentSESE.getSeseEffectsSet().getMapTempDescToInVarIdx();
Set<TempDescriptor> keySet=map.keySet();
for (Iterator iterator = keySet.iterator(); iterator
TempDescriptor inVarTD = (TempDescriptor) iterator
.next();
int inVarMask=(int) Math.pow(2, map.get(inVarTD).intValue());
- if((inVarMask&edgeTaint)>0){
+ if((inVarMask&taintIdentifier)>0){
// found related invar, contribute effects
currentSESE.readEffects(inVarTD, field.getSymbol(),src.getType(), refHRN);
}
}
}
+
+ // taint
+ if(!field.getType().isImmutable()){
+ LabelNode dstLN = og.td2ln.get(dst);
+ edgeIter=dstLN.iteratorToReferencees();
+ while (edgeIter.hasNext()) {
+ ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
+ .next();
+ currentSESE.getSeseEffectsSet().mapEdgeToTaint(referenceEdge, taintIdentifier);
+// referenceEdge.unionSESETaintIdentifier(taintIdentifier);
+ }
+ }
}
+
}
break;
while (refEdgeIter.hasNext()) {
ReferenceEdge edge = refEdgeIter.next();
int newTaint = (int) Math.pow(2, idx);
- edge.unionSESETaintIdentifier(newTaint);
+// System.out.println("fon="+fon);
+// System.out.println(currentSESE+" src:"+src+"->"+"dest:"+dest+" with taint="+newTaint);
+// System.out.println("referenceEdge="+edge);
+ currentSESE.getSeseEffectsSet().mapEdgeToTaint(edge, newTaint);
+// System.out.println("after tainting="+edge.getSESETaintIdentifier());
}
}
}
ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
.next();
HeapRegionNode dstHRN=referenceEdge.getDst();
- taintIdentifier=referenceEdge.getSESETaintIdentifier();
+ taintIdentifier=currentSESE.getSeseEffectsSet().getTaint(referenceEdge);
+// taintIdentifier=referenceEdge.getSESETaintIdentifier();
// figure out which invar has related effects
- int taint=referenceEdge.getSESETaintIdentifier();
Hashtable<TempDescriptor, Integer> map=currentSESE.getSeseEffectsSet().getMapTempDescToInVarIdx();
Set<TempDescriptor> keySet=map.keySet();
for (Iterator iterator = keySet.iterator(); iterator
while (edgeIter.hasNext()) {
ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
.next();
- referenceEdge.unionSESETaintIdentifier(taintIdentifier);
+ currentSESE.getSeseEffectsSet().mapEdgeToTaint(referenceEdge, taintIdentifier);
+// referenceEdge.unionSESETaintIdentifier(taintIdentifier);
}
}
ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
.next();
HeapRegionNode dstHRN=referenceEdge.getDst();
- int edgeTaint=referenceEdge.getSESETaintIdentifier();
+ int edgeTaint=currentSESE.getSeseEffectsSet().getTaint(referenceEdge);
+// int edgeTaint=referenceEdge.getSESETaintIdentifier();
// we can do a strong update here if one of two cases
// holds
ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
.next();
HeapRegionNode dstHRN=referenceEdge.getDst();
- int edgeTaint=referenceEdge.getSESETaintIdentifier();
+ int edgeTaint=currentSESE.getSeseEffectsSet().getTaint(referenceEdge);
+// int edgeTaint=referenceEdge.getSESETaintIdentifier();
// we can do a strong update here if one of two cases
// holds
ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
.next();
HeapRegionNode dstHRN=referenceEdge.getDst();
- int edgeTaint=referenceEdge.getSESETaintIdentifier();
+ int edgeTaint=currentSESE.getSeseEffectsSet().getTaint(referenceEdge);
+// int edgeTaint=referenceEdge.getSESETaintIdentifier();
// figure out which invar has related effects
Hashtable<TempDescriptor, Integer> map = currentSESE
return new HashSet<Integer>();
}
- private void taintLabelNode(LabelNode ln, int identifier) {
+ private void taintLabelNode(LabelNode ln, int identifier, SESEEffectsSet effectSet) {
Iterator<ReferenceEdge> edgeIter = ln.iteratorToReferencees();
while (edgeIter.hasNext()) {
ReferenceEdge edge = edgeIter.next();
- edge.setSESETaintIdentifier(identifier);
+ effectSet.mapEdgeToTaint(edge, identifier);
}
}
while (mcIter.hasNext()) {
MethodContext mc = mcIter.next();
+ OwnershipGraph og=ownAnalysisForSESEConflicts.getOwnvershipGraphByMethodContext(mc);
Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
flatNodesToVisit.add(fm);
.getCurrentSESE());
if (conflictGraph == null) {
- conflictGraph = new ConflictGraph();
+ conflictGraph = new ConflictGraph(og);
}
for (Iterator<Entry<TempDescriptor, StallSite>> iterator2 = entrySet
.iterator(); iterator2.hasNext();) {
StallSite stallSite = entry.getValue();
// reachability set
- OwnershipGraph og = ownAnalysisForSESEConflicts
+ og = ownAnalysisForSESEConflicts
.getOwnvershipGraphByMethodContext(mc);
Set<Set> reachabilitySet = calculateReachabilitySet(og,
td);
return reachabilitySet;
}
+ private ReachabilitySet packupStates(OwnershipGraph og, HeapRegionNode hrn) {
+
+ ReachabilitySet betaSet = new ReachabilitySet().makeCanonical();
+
+ Iterator<ReferenceEdge> itrEdge = hrn.iteratorToReferencers();
+ while (itrEdge.hasNext()) {
+ ReferenceEdge edge = itrEdge.next();
+ betaSet = betaSet.union(edge.getBeta());
+ }
+
+ return betaSet;
+
+ }
+
+ private ReachabilitySet packupStates(OwnershipGraph og, AllocationSite as) {
+
+ ReachabilitySet betaSet = new ReachabilitySet().makeCanonical();
+ assert as!=null;
+ HeapRegionNode hrnSummary = og.id2hrn.get(as.getSummary());
+ if(hrnSummary!=null){
+ Iterator<ReferenceEdge> itrEdge = hrnSummary.iteratorToReferencers();
+ while (itrEdge.hasNext()) {
+ ReferenceEdge edge = itrEdge.next();
+ betaSet = betaSet.union(edge.getBeta());
+ }
+ }
+
+ // check for other nodes
+ for (int i = 0; i < as.getAllocationDepth(); ++i) {
+
+ HeapRegionNode hrnIthOldest = og.id2hrn.get(as.getIthOldest(i));
+// betaSet = new ReachabilitySet().makeCanonical();
+// itrEdge = hrnIthOldest.iteratorToReferencees();
+ Iterator<ReferenceEdge> itrEdge = hrnIthOldest.iteratorToReferencers();
+ while (itrEdge.hasNext()) {
+ ReferenceEdge edge = itrEdge.next();
+ betaSet = betaSet.union(edge.getBeta());
+ }
+ }
+
+ Iterator<TokenTupleSet> ttSetIter = betaSet.iterator();
+ while (ttSetIter.hasNext()) {
+ TokenTupleSet tokenTupleSet = (TokenTupleSet) ttSetIter.next();
+ Iterator iter = tokenTupleSet.iterator();
+ while (iter.hasNext()) {
+ TokenTuple tt = (TokenTuple) iter.next();
+ int token = tt.getToken();
+ String uniqueID = og.id2hrn.get(new Integer(token))
+ .getGloballyUniqueIdentifier();
+ GloballyUniqueTokenTuple gtt = new GloballyUniqueTokenTuple(
+ uniqueID, tt);
+ }
+ }
+ return betaSet;
+ }
+
private void conflictGraph_nodeAction(MethodContext mc, FlatMethod fm,
FlatNode fn,Hashtable<TempDescriptor, TempDescriptor> invarMap) {
conflictGraph=conflictGraphResults.get(seseSummary.getCurrentParent());
if(conflictGraph==null){
- conflictGraph = new ConflictGraph();
+ conflictGraph = new ConflictGraph(og);
}
continue;
}
-// if(tempDescriptor.getType().isArray()){
-//
-// }
-
// effects set
SESEEffectsSet seseEffectsSet = fsen.getSeseEffectsSet();
Set<SESEEffectsKey> readEffectsSet = seseEffectsSet
.getReadingSet(tempDescriptor);
+
+ if (readEffectsSet != null) {
+ for (Iterator iterator2 = readEffectsSet.iterator(); iterator2
+ .hasNext();) {
+ SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2
+ .next();
+ String uniqueID = seseEffectsKey.getHRNUniqueId();
+ HeapRegionNode node = og.gid2hrn.get(uniqueID);
+ if(node.isParameter()){
+ seseEffectsKey.setRSet(packupStates(og,node));
+ }else{
+ AllocationSite as = node.getAllocationSite();
+ seseEffectsKey.setRSet(packupStates(og,as));
+ }
+ }
+ }
+
+ if (readEffectsSet != null) {
+ for (Iterator iterator2 = readEffectsSet.iterator(); iterator2
+ .hasNext();) {
+ SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2
+ .next();
+ }
+ }
Set<SESEEffectsKey> writeEffectsSet = seseEffectsSet
.getWritingSet(tempDescriptor);
+
+ if (writeEffectsSet != null) {
+ for (Iterator iterator2 = writeEffectsSet.iterator(); iterator2
+ .hasNext();) {
+ SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2
+ .next();
+ String uniqueID = seseEffectsKey.getHRNUniqueId();
+ HeapRegionNode node = og.gid2hrn.get(uniqueID);
+
+ if(node.isParameter()){
+ seseEffectsKey.setRSet(packupStates(og,node));
+ }else{
+ AllocationSite as = node.getAllocationSite();
+ seseEffectsKey.setRSet(packupStates(og,as));
+ }
+ }
+ }
+
Set<SESEEffectsKey> strongUpdateSet = seseEffectsSet.getStrongUpdateSet(tempDescriptor);
Set<Set> reachabilitySet = calculateReachabilitySet(og,
tempDescriptor);
// add new live-in node
-// LabelNode ln = og.td2ln.get(tempDescriptor);
OwnershipGraph lastOG = ownAnalysis
.getOwnvershipGraphByMethodContext(mc);
while (refIter.hasNext()) {
ReferenceEdge referenceEdge = (ReferenceEdge) refIter
.next();
- hrnSet.add(referenceEdge.getDst());
+ //
+ SESEEffectsSet seseEffects=fsen.getSeseEffectsSet();
+ int taintIdentifier=fsen.getSeseEffectsSet().getTaint(referenceEdge);
+ int invarIdx=fsen.getSeseEffectsSet().getInVarIdx(tempDescriptor);
+ int inVarMask=(int) Math.pow(2,invarIdx);
+ if((inVarMask&taintIdentifier)>0){
+ // find tainted edge, add heap root to live-in node
+ hrnSet.add(referenceEdge.getDst());
+ }
+ //
}
conflictGraph.addLiveInNode(tempDescriptor, hrnSet, fsen,
outmethod.print(" struct "+cd.getSafeSymbol()+locality.getMain().getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
} else
outmethod.print(" struct "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
- outmethod.println("1, NULL,"+"stringarray};");
+ outmethod.println("1, NULL,"+"stringarray};");
if (state.DSM||state.SINGLETM)
outmethod.println(" "+cd.getSafeSymbol()+locality.getMain().getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(& __parameterlist__);");
else
output.println("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params {");
else
output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params {");
- output.println(" INTPTR size;");
- output.println(" void * next;");
+ output.println(" int size;");
+ output.println(" void * next;");
for(int i=0; i<objectparams.numPointers(); i++) {
TempDescriptor temp=objectparams.getPointer(i);
output.println(" struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
output.println("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals {");
else
output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals {");
- output.println(" INTPTR size;");
+ output.println(" int size;");
output.println(" void * next;");
for(int i=0; i<objecttemps.numPointers(); i++) {
TempDescriptor temp=objecttemps.getPointer(i);
/* Output parameter structure */
if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
output.println("struct "+task.getSafeSymbol()+"_params {");
-
- output.println(" INTPTR size;");
+ output.println(" int size;");
output.println(" void * next;");
for(int i=0; i<objectparams.numPointers(); i++) {
TempDescriptor temp=objectparams.getPointer(i);
/* Output temp structure */
if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
output.println("struct "+task.getSafeSymbol()+"_locals {");
- output.println(" INTPTR size;");
+ output.println(" int size;");
output.println(" void * next;");
for(int i=0; i<objecttemps.numPointers(); i++) {
TempDescriptor temp=objecttemps.getPointer(i);
output.print(" struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={");
else
output.print(" struct "+task.getSafeSymbol()+"_locals "+localsprefix+"={");
-
output.print(objecttemp.numPointers()+",");
output.print(paramsprefix);
for(int j=0; j<objecttemp.numPointers(); j++)
/* Check to see if we need to do a GC if this is a
* multi-threaded program...*/
- if (((state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC)
+ if (((state.MLP||state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC)
|| this.state.MULTICOREGC) {
//Don't bother if we aren't in recursive methods...The loops case will catch it
if (callgraph.getAllMethods(md).contains(md)) {
fsen.getmdBogus().getSafeSymbol()+"_"+
fsen.getmdBogus().getSafeMethodDescriptor()+
"_locals {");
- outputStructs.println(" INTPTR size;");
+ outputStructs.println(" int size;");
outputStructs.println(" void * next;");
for(int i=0; i<objecttemps.numPointers(); i++) {
TempDescriptor temp=objecttemps.getPointer(i);
outputStructs.println(" SESEcommon common;");
// then garbage list stuff
- outputStructs.println(" INTPTR size;");
+ outputStructs.println(" int size;");
outputStructs.println(" void * next;");
- // in-set source tracking
- // in-vars that are READY come from parent, don't need anything
- // stuff STATIC needs a custom SESE pointer for each age pair
- Iterator<SESEandAgePair> itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator();
- while( itrStaticInVarSrcs.hasNext() ) {
- SESEandAgePair srcPair = itrStaticInVarSrcs.next();
- outputStructs.println(" "+srcPair.getSESE().getSESErecordName()+"* "+srcPair+";");
- }
-
- // DYNAMIC stuff needs a source SESE ptr and offset
- Iterator<TempDescriptor> itrDynInVars = fsen.getDynamicInVarSet().iterator();
- while( itrDynInVars.hasNext() ) {
- TempDescriptor dynInVar = itrDynInVars.next();
- outputStructs.println(" void* "+dynInVar+"_srcSESE;");
- outputStructs.println(" int "+dynInVar+"_srcOffset;");
- }
+ // DYNAMIC stuff was here
+
+ // invar source taking was here
// space for all in and out set primitives
Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
while( itrPrims.hasNext() ) {
TempDescriptor temp = itrPrims.next();
TypeDescriptor type = temp.getType();
- outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";");
+ if(!type.isPrimitive()){
+ outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";");
+ }
}
for(int i=0; i<objectparams.numPointers(); i++) {
outputStructs.println(" struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
}
+ // DYNAMIC stuff needs a source SESE ptr and offset
+ Iterator<TempDescriptor> itrDynInVars = fsen.getDynamicInVarSet().iterator();
+ while( itrDynInVars.hasNext() ) {
+ TempDescriptor dynInVar = itrDynInVars.next();
+// outputStructs.println(" void* "+dynInVar+"_srcSESE;");
+ outputStructs.println(" int "+dynInVar+"_srcOffset;");
+ }
+
+ itrPrims = inSetAndOutSetPrims.iterator();
+ while( itrPrims.hasNext() ) {
+ TempDescriptor temp = itrPrims.next();
+ TypeDescriptor type = temp.getType();
+ if(type.isPrimitive()){
+ outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";");
+ }
+ }
+
+ outputStructs.println(" int prevSESECount;");
+
+ // DYNAMIC stuff needs a source SESE ptr and offset
+ itrDynInVars = fsen.getDynamicInVarSet().iterator();
+ while( itrDynInVars.hasNext() ) {
+ TempDescriptor dynInVar = itrDynInVars.next();
+ outputStructs.println(" void* "+dynInVar+"_srcSESE;");
+// outputStructs.println(" int "+dynInVar+"_srcOffset;");
+ }
+
+ // in-set source tracking
+ // in-vars that are READY come from parent, don't need anything
+ // stuff STATIC needs a custom SESE pointer for each age pair
+ Iterator<SESEandAgePair> itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator();
+ while( itrStaticInVarSrcs.hasNext() ) {
+ SESEandAgePair srcPair = itrStaticInVarSrcs.next();
+ outputStructs.println(" "+srcPair.getSESE().getSESErecordName()+"* "+srcPair+";");
+ }
+
outputStructs.println("};\n");
if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
output.print(" struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={");
output.print(objecttemp.numPointers()+",");
- output.print("(void*) &("+paramsprefix+"->size)");
+ output.print("&(((SESEcommon*)(___params___))[1])");
for(int j=0; j<objecttemp.numPointers(); j++)
output.print(", NULL");
output.println("};");
// Check to see if we need to do a GC if this is a
// multi-threaded program...
if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
+ output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
//Don't bother if we aren't in recursive methods...The loops case will catch it
- if (callgraph.getAllMethods(md).contains(md)) {
- if(this.state.MULTICOREGC) {
- output.println("if(gcflag) gc("+localsprefixaddr+");");
- } else {
- output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
- }
- }
+// if (callgraph.getAllMethods(md).contains(md)) {
+// if(this.state.MULTICOREGC) {
+// output.println("if(gcflag) gc("+localsprefixaddr+");");
+// } else {
+// output.println("if (unlikely(needtocollect)) checkcollect("+localsprefixaddr+");");
+// }
+// }
}
// initialize thread-local var to a non-zero, invalid address
if(state.DSM&&state.SANDBOX&&(locality.getAtomic(lb).get(fn).intValue()>0)) {
output.println("if (unlikely((--transaction_check_counter)<=0)) checkObjects();");
}
- if (((state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC)
+ if (((state.MLP||state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC)
|| (this.state.MULTICOREGC)) {
if(state.DSM&&locality.getAtomic(lb).get(fn).intValue()>0) {
output.println("if (needtocollect) checkcollect2("+localsprefixaddr+");");
output.println(" "+fsen.getSESErecordName()+"* seseToIssue = ("+
fsen.getSESErecordName()+"*) mlpAllocSESErecord( sizeof( "+
fsen.getSESErecordName()+" ) );");
+ //eomgc need to set next, size
+// output.println(" struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(seseToIssue))[1]);");
+ output.println(" struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(seseToIssue))[1]);");
+ // sizeof(int)*2 + sizeof(void*)*calculateSizeOfSESEParamList(fsen)
+ //output.println(" // sizeof(int)*2+sizeof(void*)*"+calculateSizeOfSESEParamList(fsen));
+ //output.println(" // blah="+calculateSizeOfSESEParamSize(fsen));
+ output.println(" (seseToIssue->common).offsetsize=sizeof(int)+sizeof(void*)+sizeof(void*)*"+calculateSizeOfSESEParamList(fsen)+calculateSizeOfSESEParamSize(fsen)+";");
+ output.println(" gl->size="+calculateSizeOfSESEParamList(fsen)+";");
+// output.println(" gl->next = (struct garbagelist *)&___locals___;");
+ output.println(" seseToIssue->prevSESECount="+calculatePrevSESECount(fsen)+";");
+// output.println(" seseToIssue->prevSESECount=50;");
+ output.println(" gl->next = NULL;");
+// output.println(" seseToIssue->size = "+calculateSizeOfSESEParamList(fsen)+";");
+// output.println(" seseToIssue->next = &___locals___;");
+
// and keep the thread-local sese stack up to date
//output.println(" addNewItem( seseCallStack, (void*) seseToIssue);");
SESEandAgePair srcPair = staticSrcsItr.next();
output.println(" {");
output.println(" SESEcommon* src = (SESEcommon*)"+srcPair+";");
+ //eomgc
+ if(GENERATEPRECISEGC){
+ output.println(" stopforgc((struct garbagelist *)&___locals___);");
+ }
output.println(" pthread_mutex_lock( &(src->lock) );");
+ if(GENERATEPRECISEGC){
+ output.println(" restartaftergc();");
+ }
output.println(" if( !isEmpty( src->forwardList ) &&");
output.println(" seseToIssue == peekItem( src->forwardList ) ) {");
output.println(" printf( \"This shouldnt already be here\\n\");");
// the address off to the new child, because you're not done executing and
// might change the variable, so copy it right now
output.println(" if( src != NULL ) {");
+ //eomgc
+ if(GENERATEPRECISEGC){
+ output.println(" stopforgc((struct garbagelist *)&___locals___);");
+ }
output.println(" pthread_mutex_lock( &(src->lock) );");
+ if(GENERATEPRECISEGC){
+ output.println(" restartaftergc();");
+ }
output.println(" if( isEmpty( src->forwardList ) ||");
output.println(" seseToIssue != peekItem( src->forwardList ) ) {");
output.println(" if( !src->doneExecuting ) {");
// this SESE cannot be done until all of its children are done
// so grab your own lock with the condition variable for watching
// that the number of your running children is greater than zero
+ if (GENERATEPRECISEGC){
+ output.println(" stopforgc((struct garbagelist *)&___locals___);");
+ }
output.println(" pthread_mutex_lock( &("+com+".lock) );");
+ if (GENERATEPRECISEGC){
+ output.println(" restartaftergc();");
+ }
output.println(" while( "+com+".numRunningChildren > 0 ) {");
+ if (GENERATEPRECISEGC){
+// output.println(" stopforgc((struct garbagelist *)&(((SESEcommon*)(___params___))[1]));");
+ output.println(" stopforgc((struct garbagelist *)&___locals___);");
+ }
output.println(" pthread_cond_wait( &("+com+".runningChildrenCond), &("+com+".lock) );");
+ if (GENERATEPRECISEGC){
+ output.println(" restartaftergc();");
+ }
output.println(" }");
+
// copy out-set from local temps into the sese record
Iterator<TempDescriptor> itr = fsen.getOutVarSet().iterator();
while( itr.hasNext() ) {
// last of all, decrement your parent's number of running children
output.println(" if( "+paramsprefix+"->common.parent != NULL ) {");
output.println(" if (atomic_sub_and_test(1, &"+paramsprefix+"->common.parent->numRunningChildren)) {");
+ if (GENERATEPRECISEGC){
+ output.println(" stopforgc((struct garbagelist *)&___locals___);");
+ }
output.println(" pthread_mutex_lock( &("+paramsprefix+"->common.parent->lock) );");
+ if (GENERATEPRECISEGC){
+ output.println(" restartaftergc();");
+ }
output.println(" pthread_cond_signal( &("+paramsprefix+"->common.parent->runningChildrenCond) );");
output.println(" pthread_mutex_unlock( &("+paramsprefix+"->common.parent->lock) );");
output.println(" }");
output.print(" struct "+cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
} else
output.print(" struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
-
output.print(objectparams.numPointers());
output.print(", "+localsprefixaddr);
if (md.getThis()!=null) {
output.println(generateTemp(fm, ffn.getDst(),lb)+"="+ generateTemp(fm,ffn.getSrc(),lb)+"->"+ ffn.getField().getSafeSymbol()+";");
} else
throw new Error("Read from non-global/non-local in:"+lb.getExplanation());
- } else
+ } else{
+// DEBUG if(!ffn.getDst().getType().isPrimitive()){
+// DEBUG output.println("within((void*)"+generateTemp(fm,ffn.getSrc(),lb)+"->"+ ffn.getField().getSafeSymbol()+");");
+// DEBUG }
output.println(generateTemp(fm, ffn.getDst(),lb)+"="+ generateTemp(fm,ffn.getSrc(),lb)+"->"+ ffn.getField().getSafeSymbol()+";");
+ }
}
output.println(fcrevert+"=(struct ___Object___ *)"+dst+";");
output.println("}");
}
+
+// DEBUG if(!fsfn.getField().getType().isPrimitive()){
+// DEBUG output.println("within((void*)"+generateTemp(fm,fsfn.getSrc(),lb)+");");
+// DEBUG }
output.println(generateTemp(fm, fsfn.getDst(),lb)+"->"+ fsfn.getField().getSafeSymbol()+"="+ generateTemp(fm,fsfn.getSrc(),lb)+";");
}
}
} else
throw new Error("Read from non-global/non-local in:"+lb.getExplanation());
} else {
- output.println(generateTemp(fm, fen.getDst(),lb)+"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
+// DEBUG output.println("within((void*)"+generateTemp(fm,fen.getSrc(),lb)+");");
+ output.println(generateTemp(fm, fen.getDst(),lb)+"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
}
}
output.println(fcrevert+"=(struct ___Object___ *)"+dst+";");
output.println("}");
}
+// DEBUG output.println("within((void*)"+generateTemp(fm,fsen.getDst(),lb)+");");
output.println("(("+type +"*)(((char *) &("+ generateTemp(fm,fsen.getDst(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fsen.getIndex(),lb)+"]="+generateTemp(fm,fsen.getSrc(),lb)+";");
}
}
protected void outputTransCode(PrintWriter output) {
}
+
+ private int calculateSizeOfSESEParamList(FlatSESEEnterNode fsen){
+
+ Set<TempDescriptor> tdSet=new HashSet<TempDescriptor>();
+
+ for (Iterator iterator = fsen.getInVarSet().iterator(); iterator.hasNext();) {
+ TempDescriptor tempDescriptor = (TempDescriptor) iterator.next();
+ if(!tempDescriptor.getType().isPrimitive() || tempDescriptor.getType().isArray()){
+ tdSet.add(tempDescriptor);
+ }
+ }
+
+ for (Iterator iterator = fsen.getOutVarSet().iterator(); iterator.hasNext();) {
+ TempDescriptor tempDescriptor = (TempDescriptor) iterator.next();
+ if(!tempDescriptor.getType().isPrimitive() || tempDescriptor.getType().isArray()){
+ tdSet.add(tempDescriptor);
+ }
+ }
+
+ return tdSet.size();
+ }
+
+private String calculateSizeOfSESEParamSize(FlatSESEEnterNode fsen){
+ HashMap <String,Integer> map=new HashMap();
+ HashSet <TempDescriptor> processed=new HashSet<TempDescriptor>();
+ String rtr="";
+
+ // space for all in and out set primitives
+ Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
+ inSetAndOutSet.addAll( fsen.getInVarSet() );
+ inSetAndOutSet.addAll( fsen.getOutVarSet() );
+
+ Set<TempDescriptor> inSetAndOutSetPrims = new HashSet<TempDescriptor>();
+
+ Iterator<TempDescriptor> itr = inSetAndOutSet.iterator();
+ while( itr.hasNext() ) {
+ TempDescriptor temp = itr.next();
+ TypeDescriptor type = temp.getType();
+ if( !type.isPtr() ) {
+ inSetAndOutSetPrims.add( temp );
+ }
+ }
+
+ Iterator<TempDescriptor> itrPrims = inSetAndOutSetPrims.iterator();
+ while( itrPrims.hasNext() ) {
+ TempDescriptor temp = itrPrims.next();
+ TypeDescriptor type = temp.getType();
+ if(type.isPrimitive()){
+ Integer count=map.get(type.getSymbol());
+ if(count==null){
+ count=new Integer(1);
+ map.put(type.getSymbol(), count);
+ }else{
+ map.put(type.getSymbol(), new Integer(count.intValue()+1));
+ }
+ }
+ }
+
+ Set<String> keySet=map.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+ String key = (String) iterator.next();
+ rtr+="+sizeof("+key+")*"+map.get(key);
+ }
+ return rtr;
+}
+
+private int calculatePrevSESECount(FlatSESEEnterNode fsen){
+ int count=0;
+
+ // dynamic stuff
+ Iterator<TempDescriptor>itrDynInVars = fsen.getDynamicInVarSet().iterator();
+ while( itrDynInVars.hasNext() ) {
+ TempDescriptor dynInVar = itrDynInVars.next();
+ count++;
+ }
+
+ // in-set source tracking
+ Iterator<SESEandAgePair> itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator();
+ while( itrStaticInVarSrcs.hasNext() ) {
+ SESEandAgePair srcPair = itrStaticInVarSrcs.next();
+ count++;
+ }
+
+ return count;
+}
+
+
}