}
public ChangeTupleSet union( ChangeTupleSet ctsIn ) {
+ assert ctsIn != null;
+
ChangeTupleSet ctsOut = new ChangeTupleSet( this );
ctsOut.changeTuples.addAll( ctsIn.changeTuples );
return ctsOut.makeCanonical();
}
+ public ChangeTupleSet union( ChangeTuple ctIn ) {
+ assert ctIn != null;
+
+ ChangeTupleSet ctsOut = new ChangeTupleSet( this );
+ ctsOut.changeTuples.add( ctIn );
+ return ctsOut.makeCanonical();
+ }
+
+ public boolean isEmpty() {
+ return changeTuples.isEmpty();
+ }
+
public boolean isSubset( ChangeTupleSet ctsIn ) {
+ assert ctsIn != null;
return ctsIn.changeTuples.containsAll( this.changeTuples );
}
this.isNewSummary = isNewSummary;
this.allocSite = allocSite;
this.alpha = alpha;
- this.alphaNew = null;
this.description = description;
+ alphaNew = new ReachabilitySet();
+ alphaNew = alphaNew.makeCanonical();
+
referencers = new HashSet<OwnershipNode>();
memberFields = new HashSet<TempDescriptor>();
}
public void applyAlphaNew() {
assert alphaNew != null;
- alpha = alphaNew;
- alphaNew = null;
+
+ alpha = alphaNew;
+
+ alphaNew = new ReachabilitySet();
+ alphaNew = alphaNew.makeCanonical();
}
assert rep != null;
referencer.addReferencedRegion( referencee, rep );
referencee.addReferencer( referencer );
+ rep.setSrc( referencer );
+ rep.setDst( referencee );
}
protected void removeReferenceEdge( OwnershipNode referencer,
protected void propagateTokens( HeapRegionNode nPrime, ChangeTupleSet c0 ) {
+ HashSet<HeapRegionNode> todoNodes
+ = new HashSet<HeapRegionNode>();
+ todoNodes.add( nPrime );
+ HashSet<ReferenceEdgeProperties> todoEdges
+ = new HashSet<ReferenceEdgeProperties>();
+
+ Hashtable<HeapRegionNode, ChangeTupleSet> nodePlannedChanges
+ = new Hashtable<HeapRegionNode, ChangeTupleSet>();
+ nodePlannedChanges.put( nPrime, c0 );
+
+ Hashtable<ReferenceEdgeProperties, ChangeTupleSet> edgePlannedChanges
+ = new Hashtable<ReferenceEdgeProperties, ChangeTupleSet>();
+
+ Hashtable<HeapRegionNode, ChangeTupleSet> nodeChangesMade
+ = new Hashtable<HeapRegionNode, ChangeTupleSet>();
+
+ Hashtable<ReferenceEdgeProperties, ChangeTupleSet> edgeChangesMade
+ = new Hashtable<ReferenceEdgeProperties, ChangeTupleSet>();
+
+ while( !todoNodes.isEmpty() ) {
+ HeapRegionNode n = todoNodes.iterator().next();
+ todoNodes.remove( n );
+
+ if( !nodeChangesMade.containsKey( n ) ) {
+ nodeChangesMade.put( n, new ChangeTupleSet().makeCanonical() );
+ }
+
+ ChangeTupleSet C = nodePlannedChanges.get( n );
+
+ Iterator itrC = C.iterator();
+ while( itrC.hasNext() ) {
+ ChangeTuple c = (ChangeTuple) itrC.next();
+
+ if( n.getAlpha().contains( c.getSetToMatch() ) ) {
+ n.setAlphaNew( n.getAlphaNew().union( c.getSetToAdd() ) );
+ nodeChangesMade.put( n, nodeChangesMade.get( n ).union( c ) );
+ }
+ }
+
+ ChangeTupleSet Cprime = nodeChangesMade.get( n );
+
+ Iterator referItr = n.iteratorToReferencers();
+ while( referItr.hasNext() ) {
+ OwnershipNode on = (OwnershipNode) referItr.next();
+ ReferenceEdgeProperties rep = on.getReferenceTo( n );
+ todoEdges.add( rep );
+
+ if( !edgePlannedChanges.containsKey( rep ) ) {
+ edgePlannedChanges.put( rep, new ChangeTupleSet().makeCanonical() );
+ }
+
+ edgePlannedChanges.put( rep, edgePlannedChanges.get( rep ).union( Cprime ) );
+ }
+
+ HeapRegionNode m = null;
+ ReferenceEdgeProperties f = null;
+ Iterator refeeItr = n.setIteratorToReferencedRegions();
+ while( refeeItr.hasNext() ) {
+ Map.Entry me = (Map.Entry) refeeItr.next();
+ m = (HeapRegionNode) me.getKey();
+ f = (ReferenceEdgeProperties) me.getValue();
+
+ ChangeTupleSet changesToPass = new ChangeTupleSet();
+
+ Iterator itrCprime = Cprime.iterator();
+ while( itrCprime.hasNext() ) {
+ ChangeTuple c = (ChangeTuple) itrCprime.next();
+ if( f.getBeta().contains( c.getSetToMatch() ) ) {
+ changesToPass = changesToPass.union( c );
+ }
+ }
+
+ if( !changesToPass.isEmpty() ) {
+ if( !nodePlannedChanges.containsKey( m ) ) {
+ nodePlannedChanges.put( m, new ChangeTupleSet().makeCanonical() );
+ }
+
+ ChangeTupleSet currentChanges = nodePlannedChanges.get( m );
+
+ if( !changesToPass.isSubset( currentChanges ) ) {
+ todoNodes.add( m );
+ nodePlannedChanges.put( m, currentChanges.union( changesToPass ) );
+ }
+ }
+ }
+ }
+
}
}
public ReachabilitySet( TokenTupleSet tts ) {
+ assert tts != null;
possibleReachabilities = new HashSet<TokenTupleSet>();
possibleReachabilities.add( tts );
}
}
public ReachabilitySet( ReachabilitySet rs ) {
+ assert rs != null;
possibleReachabilities = (HashSet<TokenTupleSet>) rs.possibleReachabilities.clone(); // again, DEEP COPY?!
}
return (ReachabilitySet) Canonical.makeCanonical( this );
}
+ public boolean contains( TokenTupleSet tts ) {
+ assert tts != null;
+ return possibleReachabilities.contains( tts );
+ }
+
public Iterator iterator() {
return possibleReachabilities.iterator();
}
public ReachabilitySet union( ReachabilitySet rsIn ) {
+ assert rsIn != null;
+
ReachabilitySet rsOut = new ReachabilitySet( this );
rsOut.possibleReachabilities.addAll( rsIn.possibleReachabilities );
return rsOut.makeCanonical();
}
+ public ReachabilitySet union( TokenTupleSet ttsIn ) {
+ assert ttsIn != null;
+
+ ReachabilitySet rsOut = new ReachabilitySet( this );
+ rsOut.possibleReachabilities.add( ttsIn );
+ return rsOut.makeCanonical();
+ }
+
public ReachabilitySet intersection( ReachabilitySet rsIn ) {
+ assert rsIn != null;
+
ReachabilitySet rsOut = new ReachabilitySet();
Iterator i = this.iterator();
}
public ChangeTupleSet unionUpArity( ReachabilitySet rsIn ) {
+ assert rsIn != null;
+
ChangeTupleSet ctsOut = new ChangeTupleSet();
Iterator itrO = this.iterator();
protected ReachabilitySet beta;
protected ReachabilitySet betaNew;
+ protected OwnershipNode src;
+ protected HeapRegionNode dst;
public ReferenceEdgeProperties() {
- this.isUnique = false;
- this.isInitialParamReflexive = false;
- this.beta = new ReachabilitySet();
- this.betaNew = null;
+ this( false, false, null );
}
public ReferenceEdgeProperties( boolean isUnique ) {
- this.isUnique = isUnique;
- this.isInitialParamReflexive = false;
- this.beta = new ReachabilitySet();
- this.betaNew = null;
+ this( isUnique, false, null );
}
public ReferenceEdgeProperties( boolean isUnique,
boolean isInitialParamReflexive ) {
- this.isUnique = isUnique;
- this.isInitialParamReflexive = isInitialParamReflexive;
- this.beta = new ReachabilitySet();
- this.betaNew = null;
+ this( isUnique, isInitialParamReflexive, null );
}
public ReferenceEdgeProperties( boolean isUnique,
ReachabilitySet beta) {
this.isUnique = isUnique;
this.isInitialParamReflexive = isInitialParamReflexive;
- this.beta = beta;
- this.betaNew = null;
+
+ // these members are set by higher-level code
+ // when this ReferenceEdgeProperties object is
+ // applied to an edge
+ this.src = null;
+ this.dst = null;
+
+ if( beta != null ) {
+ this.beta = beta;
+ } else {
+ this.beta = new ReachabilitySet();
+ this.beta = this.beta.makeCanonical();
+ }
+
+ betaNew = new ReachabilitySet();
+ betaNew = betaNew.makeCanonical();
+ }
+
+
+ public OwnershipNode getSrc() {
+ return src;
+ }
+
+ public void setSrc( OwnershipNode on ) {
+ assert on != null;
+ src = on;
+ }
+
+ public HeapRegionNode getDst() {
+ return dst;
+ }
+
+ public void setDst( HeapRegionNode hrn ) {
+ assert hrn != null;
+ dst = hrn;
}
+ // copying does not copy source and destination members!
public ReferenceEdgeProperties copy() {
return new ReferenceEdgeProperties( isUnique,
isInitialParamReflexive,
public ReachabilitySet getBeta() {
return beta;
}
+
public void setBeta( ReachabilitySet beta ) {
+ assert beta != null;
this.beta = beta;
}
public ReachabilitySet getBetaNew() {
return betaNew;
}
+
public void setBetaNew( ReachabilitySet beta ) {
+ assert beta != null;
this.betaNew = beta;
}
+
public void applyBetaNew() {
assert betaNew != null;
- beta = betaNew;
- betaNew = null;
+
+ beta = betaNew;
+
+ betaNew = new ReachabilitySet();
+ betaNew = betaNew.makeCanonical();
}
public boolean equals( ReferenceEdgeProperties rep ) {
+ assert rep != null;
+
return isUnique == rep.isUnique() &&
isInitialParamReflexive == rep.isInitialParamReflexive();
}