// nullified in the graph to reduce edges
//rg.nullifyDeadVars( liveness.getLiveInTemps( fmContaining, fn ) );
- TempDescriptor lhs;
- TempDescriptor rhs;
- FieldDescriptor fld;
- TypeDescriptor tdElement;
- FieldDescriptor fdElement;
+ TempDescriptor lhs;
+ TempDescriptor rhs;
+ FieldDescriptor fld;
+ TypeDescriptor tdElement;
+ FieldDescriptor fdElement;
+ FlatSESEEnterNode sese;
+ FlatSESEExitNode fsexn;
// use node type to decide what transfer function
// to apply to the reachability graph
if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) {
if(rblockStatus.isInCriticalRegion(fmContaining, fn)){
// x gets status of y
- if(rg.isAccessible(rhs)){
- rg.addAccessibleVar(lhs);
+ if(!rg.isAccessible(rhs)){
+ rg.makeInaccessible(lhs);
}
}
}
TypeDescriptor td = fcn.getType();
assert td != null;
+
+ // before transfer, do effects analysis support
+ if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) {
+ if(rblockStatus.isInCriticalRegion(fmContaining, fn)){
+ // x gets status of y
+ if(!rg.isAccessible(rhs)){
+ rg.makeInaccessible(lhs);
+ }
+ }
+ }
+ // transfer func
rg.assignTempXEqualToCastedTempY( lhs, rhs, td );
break;
}
// after this, x and y are accessbile.
- rg.addAccessibleVar(lhs);
- rg.addAccessibleVar(rhs);
+ rg.makeAccessible(lhs);
+ rg.makeAccessible(rhs);
}
}
}
// accessible status update
- rg.addAccessibleVar(lhs);
- rg.addAccessibleVar(rhs);
+ rg.makeAccessible(lhs);
+ rg.makeAccessible(rhs);
}
}
rg.taintStallSite(fn, rhs);
}
- rg.addAccessibleVar(lhs);
- rg.addAccessibleVar(rhs);
+ rg.makeAccessible(lhs);
+ rg.makeAccessible(rhs);
}
}
}
// accessible status update
- rg.addAccessibleVar(lhs);
- rg.addAccessibleVar(rhs);
+ rg.makeAccessible(lhs);
+ rg.makeAccessible(rhs);
}
}
if (doEffectsAnalysis && fmContaining != fmAnalysisEntry) {
if (rblockStatus.isInCriticalRegion(fmContaining, fn)) {
// after creating new object, lhs is accessible
- rg.addAccessibleVar(lhs);
+ rg.makeAccessible(lhs);
}
}
break;
case FKind.FlatSESEEnterNode:
+ sese = (FlatSESEEnterNode) fn;
+
if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) {
// always remove ALL stall site taints at enter
rg.removeAllStallSiteTaints();
- // inject taints for in-set vars
- FlatSESEEnterNode sese = (FlatSESEEnterNode) fn;
+ // inject taints for in-set vars
rg.taintInSetVars( sese );
}
break;
case FKind.FlatSESEExitNode:
- if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) {
+ fsexn = (FlatSESEExitNode) fn;
+ sese = fsexn.getFlatEnter();
- // sese exit clears all mappings of accessible vars and stall sites
- // need to wipe out stall site taints
- rg.clearAccessibleVarSet();
+ if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) {
+ // @ sese exit make all live variables
+ // inaccessible to later parent statements
+ rg.makeInaccessible( liveness.getLiveInTemps( fmContaining, fn ) );
+
// always remove ALL stall site taints at exit
rg.removeAllStallSiteTaints();
- // remove in-set vars for the exiting rblock
- FlatSESEExitNode fsexn = (FlatSESEExitNode) fn;
- rg.removeInContextTaints( fsexn.getFlatEnter() );
+ // remove in-set var taints for the exiting rblock
+ rg.removeInContextTaints( sese );
}
break;
// convenient set of alloc sites for all heap regions
// present in the graph without having to search
- public HashSet<AllocSite> allocSites;
+ public Set<AllocSite> allocSites;
- // set of accessible variables for current program statement
- // if not contains, it is an inaccessible variable
- public HashSet<TempDescriptor> accessibleVars;
+ // set of inaccessible variables for current program statement
+ // with respect to stall-site analysis
+ public Set<TempDescriptor> inaccessibleVars;
public ReachGraph() {
- id2hrn = new Hashtable<Integer, HeapRegionNode>();
- td2vn = new Hashtable<TempDescriptor, VariableNode >();
- allocSites = new HashSet<AllocSite>();
- accessibleVars = new HashSet<TempDescriptor>();
+ id2hrn = new Hashtable<Integer, HeapRegionNode>();
+ td2vn = new Hashtable<TempDescriptor, VariableNode >();
+ allocSites = new HashSet<AllocSite>();
+ inaccessibleVars = new HashSet<TempDescriptor>();
}
TaintSet.factory() // taints
);
- addRefEdge( lnX, hrnNewest, edgeNew );
-
- // after x=new , x is accessible
- // if (isInRegion()) {
- //accessibleVars.add(x);
+ addRefEdge( lnX, hrnNewest, edgeNew );
}
return;
}
- mergeNodes ( rg );
- mergeRefEdges ( rg );
- mergeAllocSites( rg );
- mergeAccessibleSet( rg );
+ mergeNodes ( rg );
+ mergeRefEdges ( rg );
+ mergeAllocSites ( rg );
+ mergeInaccessibleVars( rg );
}
protected void mergeNodes( ReachGraph rg ) {
allocSites.addAll( rg.allocSites );
}
- protected void mergeAccessibleSet( ReachGraph rg ){
- // inaccesible status is prior to accessible status
-
- Set<TempDescriptor> varsToMerge=rg.getAccessibleVar();
- Set<TempDescriptor> varsRemoved=new HashSet<TempDescriptor>();
-
- for (Iterator iterator = accessibleVars.iterator(); iterator.hasNext();) {
- TempDescriptor accessibleVar = (TempDescriptor) iterator.next();
- if(!varsToMerge.contains(accessibleVar)){
- varsRemoved.add(accessibleVar);
- }
- }
-
- accessibleVars.removeAll(varsRemoved);
-
+ protected void mergeInaccessibleVars( ReachGraph rg ){
+ inaccessibleVars.addAll(rg.inaccessibleVars);
}
return false;
}
- if( !accessibleVars.equals( rg.accessibleVars) ){
+ if( !inaccessibleVars.equals(rg.inaccessibleVars) ){
return false;
}
return common;
}
- public void addAccessibleVar(TempDescriptor td){
- accessibleVars.add(td);
+ public void makeInaccessible( Set<TempDescriptor> vars ) {
+ inaccessibleVars.addAll( vars );
}
-
- public Set<TempDescriptor> getAccessibleVar(){
- return accessibleVars;
+
+ public void makeInaccessible( TempDescriptor td ) {
+ inaccessibleVars.add( td );
+ }
+
+ public void makeAccessible( TempDescriptor td ) {
+ inaccessibleVars.remove( td );
}
public boolean isAccessible(TempDescriptor td) {
- return accessibleVars.contains(td);
+ return !inaccessibleVars.contains(td);
}
- public void clearAccessibleVarSet(){
- accessibleVars.clear();
- }
-
+ public Set<TempDescriptor> getInaccessibleVars() {
+ return inaccessibleVars;
+ }
}