import IR.MethodDescriptor;
import IR.Operation;
import IR.State;
+import IR.TypeDescriptor;
import IR.TypeUtil;
import IR.Flat.FKind;
import IR.Flat.FlatCall;
import IR.Flat.FlatEdge;
import IR.Flat.FlatElementNode;
import IR.Flat.FlatFieldNode;
-import IR.Flat.FlatLiteralNode;
import IR.Flat.FlatMethod;
import IR.Flat.FlatNew;
import IR.Flat.FlatNode;
dstHRN, visitedHRN);
}
} else {
+// System.out.println("FLAGGED "+callerMC+":fc="+fc+":arg="+arg+" , paramIdx="+paramIdx);
flagAllocationSite(callerMC, dstHRN
.getAllocationSite());
}
FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn;
assert fsen.equals(currentSESE);
-// if(fsen.getParent()!=null && fsen.getParent().getSeseEffectsSet()!=null){
-// Hashtable<TempDescriptor, HashSet<SESEEffectsKey>> strongTable=
-// fsen.getParent().getSeseEffectsSet().getStrongUpdateTable();
-// fsen.getSeseEffectsSet().getStrongUpdateTable().putAll(strongTable);
-// }
-
-
if (!fsen.getIsCallerSESEplaceholder()) {
// uniquely taint each live-in variable
Set<TempDescriptor> set = fsen.getInVarSet();
- //
-// Set<TempDescriptor> tempSet=fsen.getOutVarSet();
-// for (Iterator iterator = tempSet.iterator(); iterator.hasNext();) {
-// TempDescriptor tempDescriptor = (TempDescriptor) iterator
-// .next();
-// set.add(tempDescriptor);
-// }
- //
Iterator<TempDescriptor> iter = set.iterator();
int idx = 0;
while (iter.hasNext()) {
if (ln != null) {
int taint = (int) Math.pow(2, idx);
taintLabelNode(ln, taint);
+ currentSESE.getSeseEffectsSet().setInVarIdx(idx, td);
// collects related allocation sites
Iterator<ReferenceEdge> referenceeIter = ln
visitedHRN);
} else {
+// System.out.println("FLAGGED "+fsen+":"+td);
flagAllocationSite(mc, dstHRN
.getAllocationSite());
}
FlatSESEExitNode fsexit = (FlatSESEExitNode) fn;
if (!fsexit.getFlatEnter().getIsCallerSESEplaceholder()) {
+
+ // clear taint information of live-in variables
+ Set<Integer> keySet=og.id2hrn.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+ Integer hrnID = (Integer) iterator.next();
+ HeapRegionNode hrn=og.id2hrn.get(hrnID);
+ Iterator<ReferenceEdge> edgeIter=hrn.iteratorToReferencers();
+ while (edgeIter.hasNext()) {
+ ReferenceEdge refEdge = (ReferenceEdge) edgeIter
+ .next();
+ refEdge.setSESETaintIdentifier(0);
+ }
+ }
FlatSESEEnterNode enterNode = fsexit.getFlatEnter();
FlatSESEEnterNode parent = enterNode.getParent();
FieldDescriptor field = ffn.getField();
LabelNode srcLN = og.td2ln.get(src);
- if (srcLN != null) {
- HashSet<TempDescriptor> affectedTDSet = getAccessedTaintNodeSet(srcLN);
- Iterator<TempDescriptor> affectedIter = affectedTDSet
- .iterator();
- while (affectedIter.hasNext()) {
- TempDescriptor affectedTD = affectedIter.next();
-
- if (currentSESE.getInVarSet().contains(affectedTD) || ((!currentSESE.getInVarSet().contains(affectedTD)) && currentSESE.getOutVarSet().contains(affectedTD)) ) {
-
- HashSet<HeapRegionNode> hrnSet = getReferenceHeapIDSet(
- og, affectedTD);
- Iterator<HeapRegionNode> hrnIter = hrnSet.iterator();
- while (hrnIter.hasNext()) {
- HeapRegionNode hrn = hrnIter.next();
-
- Iterator<ReferenceEdge> referencers = hrn
- .iteratorToReferencers();
- while (referencers.hasNext()) {
- ReferenceEdge referenceEdge = (ReferenceEdge) referencers
- .next();
- if (field.getSymbol().equals(
- referenceEdge.getField())) {
-
- HeapRegionNode refHRN = og.id2hrn
- .get(referenceEdge.getDst().getID());
-
- currentSESE
- .readEffects(affectedTD, field
- .getSymbol(),
- src.getType(), refHRN);
- }
- }
-
- }
- }
- }
-
- // handle tainted case
-
- Iterator<ReferenceEdge> edgeIter = srcLN
- .iteratorToReferencees();
+ if(srcLN!=null){
+ Iterator<ReferenceEdge> edgeIter=srcLN.iteratorToReferencees();
while (edgeIter.hasNext()) {
- ReferenceEdge edge = edgeIter.next();
- HeapRegionNode accessHRN = edge.getDst();
- // / follow the chain of reference to identify possible
- // accesses
- Iterator<ReferenceEdge> referIter = accessHRN
- .iteratorToReferencers();
- while (referIter.hasNext()) {
- ReferenceEdge referEdge = (ReferenceEdge) referIter
+ ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
+ .next();
+ HeapRegionNode refHRN=referenceEdge.getDst();
+ int edgeTaint=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
+ .hasNext();) {
+ TempDescriptor inVarTD = (TempDescriptor) iterator
.next();
-
- // if (referEdge.getTaintIdentifier() >0 ||
- // referEdge.getSESETaintIdentifier()>0 ) {
- HashSet<TempDescriptor> referSet = new HashSet<TempDescriptor>();
- followReference(accessHRN, referSet,
- new HashSet<HeapRegionNode>(), currentSESE);
-
- Iterator<TempDescriptor> referSetIter = referSet
- .iterator();
- while (referSetIter.hasNext()) {
- TempDescriptor tempDescriptor = (TempDescriptor) referSetIter
- .next();
- currentSESE.readEffects(tempDescriptor, field
- .getSymbol(), src.getType(), accessHRN);
- }
- // }
- }
- // /
- if (edge.getTaintIdentifier() > 0
- || edge.getSESETaintIdentifier() > 0) {
-
- affectedTDSet = getReferenceNodeSet(accessHRN);
- affectedIter = affectedTDSet.iterator();
- while (affectedIter.hasNext()) {
- TempDescriptor affectedTD = affectedIter.next();
-
- if (currentSESE.getInVarSet().contains(affectedTD)) {
-
- HashSet<HeapRegionNode> hrnSet = getReferenceHeapIDSet(
- og, affectedTD);
- Iterator<HeapRegionNode> hrnIter = hrnSet
- .iterator();
- while (hrnIter.hasNext()) {
- HeapRegionNode hrn = hrnIter.next();
- currentSESE.readEffects(affectedTD, field
- .getSymbol(), src.getType(), hrn);
- }
-
- }
-
+ int inVarMask=(int) Math.pow(2, map.get(inVarTD).intValue());
+ if((inVarMask&edgeTaint)>0){
+ // found related invar, contribute effects
+ currentSESE.readEffects(inVarTD, field.getSymbol(),src.getType(), refHRN);
}
}
}
TempDescriptor dest=fon.getDest();
TempDescriptor src=fon.getLeft();
-// if(!currentSESE.getIsCallerSESEplaceholder()){
- if( fon.getOp().getOp() ==Operation.ASSIGN && ( currentSESE.getInVarSet().contains(src) || (currentSESE.getOutVarSet().contains(src)))){
- invarMap.put(dest, src);
+ if(currentSESE.getInVarSet().contains(src)){
+ int idx=currentSESE.getSeseEffectsSet().getInVarIdx(src);
+ if(idx==-1){
+ break;
+ }
+
+ //mark dest's edges for corresponding sese live in-var.
+ LabelNode srcLN = og.td2ln.get(dest);
+ if (srcLN != null) {
+ Iterator<ReferenceEdge> refEdgeIter=srcLN.iteratorToReferencees();
+ while (refEdgeIter.hasNext()) {
+ ReferenceEdge edge = refEdgeIter.next();
+ int newTaint = (int) Math.pow(2, idx);
+ edge.unionSESETaintIdentifier(newTaint);
+ }
}
-// }
-
- }break;
-
- case FKind.FlatNew:{
- FlatNew fnew=(FlatNew)fn;
- TempDescriptor dst=fnew.getDst();
- if(dst.getType().isArray()){
- currentSESE.getSeseEffectsSet().addStrongUpdateVar(dst, new SESEEffectsKey("", dst.getType(), new Integer(0), ""));
}
-
}break;
case FKind.FlatElementNode:{
FlatElementNode fsen=(FlatElementNode)fn;
TempDescriptor src = fsen.getSrc();
+ TempDescriptor dst = fsen.getDst();
+ String field="___element_";
+
+ LabelNode srcLN = og.td2ln.get(src);
+ int taintIdentifier=0;
+ if(srcLN!=null){
+ Iterator<ReferenceEdge> edgeIter=srcLN.iteratorToReferencees();
+ while (edgeIter.hasNext()) {
+ ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
+ .next();
+ HeapRegionNode dstHRN=referenceEdge.getDst();
+ 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
+ .hasNext();) {
+ TempDescriptor inVarTD = (TempDescriptor) iterator
+ .next();
+ int inVarMask=(int) Math.pow(2, map.get(inVarTD).intValue());
+ if((inVarMask&taintIdentifier)>0){
+ // found related invar, contribute effects
+ currentSESE.readEffects(inVarTD, field,src.getType(), dstHRN);
+ }
+ }
+
+ }
+ }
- if(invarMap.containsKey(src)){
- TempDescriptor invarTD=invarMap.get(src);
- currentSESE.getSeseEffectsSet().addReadingVar(invarTD, new SESEEffectsKey("", src.getType(), new Integer(0), ""));
+ // taint
+ LabelNode dstLN = og.td2ln.get(dst);
+ if(dstLN!=null){
+ Iterator<ReferenceEdge> edgeIter=dstLN.iteratorToReferencees();
+ while (edgeIter.hasNext()) {
+ ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
+ .next();
+ referenceEdge.unionSESETaintIdentifier(taintIdentifier);
+ }
}
}break;
- case FKind.FlatSetElementNode:{
-
- FlatSetElementNode fsen=(FlatSetElementNode)fn;
+ case FKind.FlatSetElementNode: {
+
+ FlatSetElementNode fsen = (FlatSetElementNode) fn;
TempDescriptor dst = fsen.getDst();
+ TypeDescriptor tdElement = dst.getType().dereference();
+
+ String field = "___element_";
- if(invarMap.containsKey(dst)){
- TempDescriptor invarTD=invarMap.get(dst);
+ LabelNode dstLN=og.td2ln.get(dst);
+ if(dst!=null){
- SESEEffectsSet effectSet=currentSESE.getSeseEffectsSet();
- ///// if write effects occurs through variable which was strongly updated, ignore it?
- if(effectSet.getStrongUpdateSet(invarTD)!=null && effectSet.getStrongUpdateSet(invarTD).size()>0){
- SESEEffectsKey key=new SESEEffectsKey("", dst.getType(), new Integer(0), "");
- key.setStrong(true);
- currentSESE.getSeseEffectsSet().addWritingVar(invarTD, key);
- }else{
- currentSESE.getSeseEffectsSet().addWritingVar(invarTD, new SESEEffectsKey("", dst.getType(), new Integer(0), ""));
+ Iterator<ReferenceEdge> edgeIter=dstLN.iteratorToReferencees();
+ while (edgeIter.hasNext()) {
+ ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
+ .next();
+ HeapRegionNode dstHRN=referenceEdge.getDst();
+ int edgeTaint=referenceEdge.getSESETaintIdentifier();
+
+ // we can do a strong update here if one of two cases
+ // holds
+ boolean strongUpdate=false;
+ if (field != null && !dst.getType().isImmutable()
+ && ((dstHRN.getNumReferencers() == 1) || // case 1
+ (dstHRN.isSingleObject() && dstLN
+ .getNumReferencees() == 1) // case 2
+ )) {
+ strongUpdate = true;
+ }
+
+
+ // figure out which invar has related effects
+ Hashtable<TempDescriptor, Integer> map=currentSESE.getSeseEffectsSet().getMapTempDescToInVarIdx();
+ Set<TempDescriptor> keySet=map.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator
+ .hasNext();) {
+ TempDescriptor inVarTD = (TempDescriptor) iterator
+ .next();
+ int inVarMask=(int) Math.pow(2, map.get(inVarTD).intValue());
+ if((inVarMask&edgeTaint)>0){
+ // found related invar, contribute effects
+ currentSESE.writeEffects(inVarTD, field, dst.getType(),dstHRN, strongUpdate);
+ }
}
- /////
+
}
+ }
+
}break;
case FKind.FlatSetFieldNode: {
FieldDescriptor field = fsen.getField();
LabelNode dstLN = og.td2ln.get(dst);
-
- if (dstLN != null) {
-
- // check possible strong updates
- boolean strongUpdate = false;
-
- if (!field.getType().isImmutable() || field.getType().isArray()) {
- Iterator<ReferenceEdge> itrXhrn = dstLN
- .iteratorToReferencees();
- while (itrXhrn.hasNext()) {
- ReferenceEdge edgeX = itrXhrn.next();
- HeapRegionNode hrnX = edgeX.getDst();
-
- // we can do a strong update here if one of two cases
- // holds
- if (field != null
- && field != OwnershipAnalysis
- .getArrayField(field.getType())
- && ((hrnX.getNumReferencers() == 1) || // case 1
- (hrnX.isSingleObject() && dstLN
- .getNumReferencees() == 1) // case 2
- )) {
- strongUpdate = true;
- }
- }
- }
- HashSet<TempDescriptor> affectedTDSet = getAccessedTaintNodeSet(dstLN);
- Iterator<TempDescriptor> affectedIter = affectedTDSet
- .iterator();
-
- while (affectedIter.hasNext()) {
- TempDescriptor affectedTD = affectedIter.next();
- if (currentSESE.getInVarSet().contains(affectedTD) || ((!currentSESE.getInVarSet().contains(affectedTD)) && currentSESE.getOutVarSet().contains(affectedTD)) ) {
-
- HashSet<HeapRegionNode> hrnSet = getReferenceHeapIDSet(
- og, affectedTD);
- Iterator<HeapRegionNode> hrnIter = hrnSet.iterator();
- while (hrnIter.hasNext()) {
- HeapRegionNode hrn = hrnIter.next();
- Iterator<ReferenceEdge> referencers = hrn
- .iteratorToReferencers();
- while (referencers.hasNext()) {
- ReferenceEdge referenceEdge = (ReferenceEdge) referencers
- .next();
- if (field.getSymbol().equals(
- referenceEdge.getField())) {
-
- HeapRegionNode refHRN = og.id2hrn
- .get(referenceEdge.getDst().getID());
- currentSESE.writeEffects(affectedTD, field
- .getSymbol(), dst.getType(),
- refHRN, strongUpdate);
- }
- }
-
- }
- }
- }
-
- // handle tainted case
- Iterator<ReferenceEdge> edgeIter = dstLN
- .iteratorToReferencees();
+ if(dstLN!=null){
+
+ Iterator<ReferenceEdge> edgeIter=dstLN.iteratorToReferencees();
while (edgeIter.hasNext()) {
- ReferenceEdge edge = edgeIter.next();
-
- HeapRegionNode accessHRN = edge.getDst();
- // / follow the chain of reference to identify possible
- // accesses
- Iterator<ReferenceEdge> referIter = accessHRN
- .iteratorToReferencers();
- while (referIter.hasNext()) {
- ReferenceEdge referEdge = (ReferenceEdge) referIter
- .next();
-
- // if (referEdge.getTaintIdentifier() > 0 ||
- // referEdge.getSESETaintIdentifier() > 0 ) {
- HashSet<TempDescriptor> referSet = new HashSet<TempDescriptor>();
- followReference(accessHRN, referSet,
- new HashSet<HeapRegionNode>(), currentSESE);
- Iterator<TempDescriptor> referSetIter = referSet
- .iterator();
- while (referSetIter.hasNext()) {
- TempDescriptor tempDescriptor = (TempDescriptor) referSetIter
- .next();
- SESEEffectsSet effectSet=currentSESE.getSeseEffectsSet();
- ///// if write effects occurs through variable which was strongly updated, ignore it?
- if(effectSet.getStrongUpdateSet(tempDescriptor)!=null && effectSet.getStrongUpdateSet(tempDescriptor).size()>0){
-// System.out.println("not write effect?");
- }else{
- currentSESE.writeEffects(tempDescriptor, field
- .getSymbol(), dst.getType(), accessHRN,
- strongUpdate);
- }
- /////
- }
- // }
+ ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
+ .next();
+ HeapRegionNode dstHRN=referenceEdge.getDst();
+ int edgeTaint=referenceEdge.getSESETaintIdentifier();
+
+ // we can do a strong update here if one of two cases
+ // holds
+ boolean strongUpdate=false;
+ if (field != null && !field.getType().isImmutable()
+ && field != OwnershipAnalysis
+ .getArrayField(field.getType())
+ && ((dstHRN.getNumReferencers() == 1) || // case 1
+ (dstHRN.isSingleObject() && dstLN
+ .getNumReferencees() == 1) // case 2
+ )) {
+ strongUpdate = true;
}
- // /
- if (edge.getTaintIdentifier() > 0
- || edge.getSESETaintIdentifier() > 0) {
- affectedTDSet = getReferenceNodeSet(accessHRN);
- affectedIter = affectedTDSet.iterator();
- while (affectedIter.hasNext()) {
- TempDescriptor affectedTD = affectedIter.next();
- if (currentSESE.getInVarSet().contains(affectedTD)) {
-
- HashSet<HeapRegionNode> hrnSet = getReferenceHeapIDSet(
- og, affectedTD);
- Iterator<HeapRegionNode> hrnIter = hrnSet
- .iterator();
- while (hrnIter.hasNext()) {
- HeapRegionNode hrn = hrnIter.next();
- currentSESE.writeEffects(affectedTD, field
- .getSymbol(), dst.getType(), hrn,
- strongUpdate);
-
- }
-
- }
-
+
+
+ // figure out which invar has related effects
+ Hashtable<TempDescriptor, Integer> map = currentSESE
+ .getSeseEffectsSet().getMapTempDescToInVarIdx();
+ Set<TempDescriptor> keySet = map.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator
+ .hasNext();) {
+ TempDescriptor inVarTD = (TempDescriptor) iterator
+ .next();
+ int inVarMask = (int) Math.pow(2, map.get(inVarTD)
+ .intValue());
+ if ((inVarMask & edgeTaint) > 0) {
+ // found related invar, contribute effects
+ currentSESE.writeEffects(inVarTD,
+ field.getSymbol(), dst.getType(), dstHRN,
+ strongUpdate);
}
}
- }
-
+
+
+ }
}
-
}
break;
MethodEffects me = ownAnalysis.getMethodEffectsAnalysis()
.getMethodEffectsByMethodContext(calleeMC);
-
OwnershipGraph calleeOG = ownAnalysis
.getOwnvershipGraphByMethodContext(calleeMC);
}
LabelNode argLN = og.td2ln.get(arg);
- if (argLN != null) {
- HashSet<TempDescriptor> affectedTDSet = getAccessedTaintNodeSet(argLN);
- Iterator<TempDescriptor> affectedIter = affectedTDSet
- .iterator();
-
- while (affectedIter.hasNext()) {
-
- TempDescriptor affectedTD = affectedIter.next();
- if(isThis){
- if (currentSESE.getInVarSet().contains(affectedTD)) {
-// Integer hrnPrimaryID = calleeOG.paramIndex2idPrimary.get(paramIdx);
-// Integer hrnSecondaryID = calleeOG.paramIndex2idSecondary.get(paramIdx);
-// System.out.println("primID="+hrnPrimaryID);
-// System.out.println("seconID="+hrnSecondaryID);
- }
- }
- if (currentSESE.getInVarSet().contains(affectedTD)) {
-
- if (readSet != null) {
- Iterator<EffectsKey> readIter = readSet
- .iterator();
- while (readIter.hasNext()) {
- EffectsKey key = readIter.next();
- Set<Integer> hrnSet = getCallerHRNId(
- new Integer(paramIdx), calleeOG,
- key.getHRNId(), decomp);
- Iterator<Integer> hrnIter = hrnSet
+ if( argLN!=null){
+ Iterator<ReferenceEdge> edgeIter=argLN.iteratorToReferencees();
+ while (edgeIter.hasNext()) {
+ ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter
+ .next();
+ HeapRegionNode dstHRN=referenceEdge.getDst();
+ int edgeTaint=referenceEdge.getSESETaintIdentifier();
+
+ // figure out which invar has related effects
+ Hashtable<TempDescriptor, Integer> map = currentSESE
+ .getSeseEffectsSet().getMapTempDescToInVarIdx();
+ Set<TempDescriptor> keySet = map.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator
+ .hasNext();) {
+ TempDescriptor inVarTD = (TempDescriptor) iterator
+ .next();
+ int inVarMask = (int) Math.pow(2, map.get(inVarTD)
+ .intValue());
+
+ if ((inVarMask & edgeTaint) > 0) {
+ // found related invar, contribute effects
+
+ if (readSet != null) {
+ Iterator<EffectsKey> readIter = readSet
.iterator();
- while (hrnIter.hasNext()) {
- Integer hrnID = (Integer) hrnIter
- .next();
-
- HeapRegionNode refHRN = og.id2hrn
- .get(hrnID);
-
- currentSESE.readEffects(affectedTD, key
- .getFieldDescriptor(), key
- .getTypeDescriptor(), refHRN);
-
+ while (readIter.hasNext()) {
+ EffectsKey key = readIter.next();
+ Set<Integer> hrnSet = getCallerHRNId(
+ new Integer(paramIdx), calleeOG,
+ key.getHRNId(), decomp);
+ Iterator<Integer> hrnIter = hrnSet
+ .iterator();
+ while (hrnIter.hasNext()) {
+ Integer hrnID = (Integer) hrnIter
+ .next();
+
+ HeapRegionNode refHRN = og.id2hrn
+ .get(hrnID);
+
+ currentSESE.readEffects(inVarTD, key
+ .getFieldDescriptor(), key
+ .getTypeDescriptor(), refHRN);
+
+ }
}
}
- }
-
- if (writeSet != null) {
- Iterator<EffectsKey> writeIter = writeSet
- .iterator();
- while (writeIter.hasNext()) {
- EffectsKey key = writeIter.next();
-
- Set<Integer> hrnSet = getCallerHRNId(
- new Integer(paramIdx), calleeOG,
- key.getHRNId(), decomp);
- Iterator<Integer> hrnIter = hrnSet
+
+ if (writeSet != null) {
+ Iterator<EffectsKey> writeIter = writeSet
.iterator();
- while (hrnIter.hasNext()) {
- Integer hrnID = (Integer) hrnIter
- .next();
+ while (writeIter.hasNext()) {
+ EffectsKey key = writeIter.next();
+
+ Set<Integer> hrnSet = getCallerHRNId(
+ new Integer(paramIdx), calleeOG,
+ key.getHRNId(), decomp);
+ Iterator<Integer> hrnIter = hrnSet
+ .iterator();
+ while (hrnIter.hasNext()) {
+ Integer hrnID = (Integer) hrnIter
+ .next();
+
+ HeapRegionNode refHRN = og.id2hrn
+ .get(hrnID);
+
+ currentSESE.writeEffects(inVarTD,
+ key.getFieldDescriptor(), key
+ .getTypeDescriptor(),
+ refHRN, false);
+ }
- HeapRegionNode refHRN = og.id2hrn
- .get(hrnID);
- currentSESE.writeEffects(affectedTD,
- key.getFieldDescriptor(), key
- .getTypeDescriptor(),
- refHRN, false);
}
-
}
- }
- if (strongUpdateSet != null) {
- Iterator<EffectsKey> strongUpdateIter = strongUpdateSet
- .iterator();
- while (strongUpdateIter.hasNext()) {
- EffectsKey key = strongUpdateIter.next();
-
- Set<Integer> hrnSet = getCallerHRNId(
- new Integer(paramIdx), calleeOG,
- key.getHRNId(), decomp);
- Iterator<Integer> hrnIter = hrnSet
+ if (strongUpdateSet != null) {
+ Iterator<EffectsKey> strongUpdateIter = strongUpdateSet
.iterator();
- while (hrnIter.hasNext()) {
- Integer hrnID = (Integer) hrnIter
+ while (strongUpdateIter.hasNext()) {
+ EffectsKey key = strongUpdateIter
.next();
- HeapRegionNode refHRN = og.id2hrn
- .get(hrnID);
- currentSESE.writeEffects(affectedTD,
- key.getFieldDescriptor(), key
- .getTypeDescriptor(),
- refHRN, true);
+ Set<Integer> hrnSet = getCallerHRNId(
+ new Integer(paramIdx),
+ calleeOG, key.getHRNId(),
+ decomp);
+ Iterator<Integer> hrnIter = hrnSet
+ .iterator();
+ while (hrnIter.hasNext()) {
+ Integer hrnID = (Integer) hrnIter
+ .next();
+
+ HeapRegionNode refHRN = og.id2hrn
+ .get(hrnID);
+
+ currentSESE.writeEffects(inVarTD,
+ key.getFieldDescriptor(),
+ key.getTypeDescriptor(),
+ refHRN, true);
+ }
}
-
- }
- }
-
+ } // end of if (strongUpdateSet != null)
+
+ } // end of if ((inVarMask & edgeTaint) > 0)
}
-
+
}
-
}
-
+
}
}
}
private void flagAllocationSite(MethodContext mc, AllocationSite ac){
-
HashSet<AllocationSite> set=mapMethodContextToLiveInAllocationSiteSet.get(mc);
if(set==null){
set=new HashSet<AllocationSite>();
Iterator<ReferenceEdge> edgeIter = ln.iteratorToReferencees();
while (edgeIter.hasNext()) {
ReferenceEdge edge = edgeIter.next();
- HeapRegionNode hrn = edge.getDst();
-
- Iterator<ReferenceEdge> edgeReferencerIter = hrn
- .iteratorToReferencers();
- while (edgeReferencerIter.hasNext()) {
- ReferenceEdge referencerEdge = edgeReferencerIter.next();
- OwnershipNode node = referencerEdge.getSrc();
- if (node instanceof LabelNode) {
- referencerEdge.unionSESETaintIdentifier(identifier);
- }else if(node instanceof HeapRegionNode){
- referencerEdge.unionSESETaintIdentifier(identifier);
- }
- }
-
+ edge.setSESETaintIdentifier(identifier);
}
}
- private HashSet<TempDescriptor> getReferenceNodeSet(HeapRegionNode hrn){
-
- HashSet<TempDescriptor> returnSet=new HashSet<TempDescriptor>();
-
- Iterator<ReferenceEdge> edgeIter=hrn.iteratorToReferencers();
- while(edgeIter.hasNext()){
- ReferenceEdge edge=edgeIter.next();
- if(edge.getSrc() instanceof LabelNode){
- LabelNode ln=(LabelNode)edge.getSrc();
- returnSet.add(ln.getTempDescriptor());
- }
- }
-
- return returnSet;
-
- }
-
-
private HashSet<HeapRegionNode> getReferenceHeapIDSet(OwnershipGraph og, TempDescriptor td){
HashSet<HeapRegionNode> returnSet=new HashSet<HeapRegionNode>();
}
- private HashSet<TempDescriptor> getAccessedTaintNodeSet(LabelNode ln) {
-
- HashSet<TempDescriptor> returnSet = new HashSet<TempDescriptor>();
-
- Iterator<ReferenceEdge> edgeIter = ln.iteratorToReferencees();
- while (edgeIter.hasNext()) {
- ReferenceEdge edge = edgeIter.next();
- HeapRegionNode hrn = edge.getDst();
-
- Iterator<ReferenceEdge> edgeReferencerIter = hrn
- .iteratorToReferencers();
- while (edgeReferencerIter.hasNext()) {
- ReferenceEdge referencerEdge = edgeReferencerIter.next();
-
- if (referencerEdge.getSrc() instanceof LabelNode) {
- if (!((LabelNode) referencerEdge.getSrc()).equals(ln)) {
-
- if (referencerEdge.getSESETaintIdentifier() > 0) {
- TempDescriptor td = ((LabelNode) referencerEdge
- .getSrc()).getTempDescriptor();
- returnSet.add(td);
- }
- }
- }
- }
-
- }
-
- return returnSet;
-
- }
-
private HashSet<ReferenceEdge> getRefEdgeSetReferenceToSameHRN(
OwnershipGraph og, TempDescriptor td) {
}
private void calculateCovering(ConflictGraph conflictGraph){
-
+ uniqueLockSetId=0; // reset lock counter for every new conflict graph
HashSet<ConflictEdge> fineToCover = new HashSet<ConflictEdge>();
HashSet<ConflictEdge> coarseToCover = new HashSet<ConflictEdge>();
HashSet<SESELock> lockSet=new HashSet<SESELock>();
setupRelatedAllocSiteAnalysis(og, mc, hrn,
visitedHRN);
} else {
+// System.out.println("FLAGGED "+mc+":"+ffn);
flagAllocationSite(mc, hrn.getAllocationSite());
}
}
currentConflictsMap.addAccessibleVar(src);
if (!currentConflictsMap.isAccessible(dst)) {
-
if(invarMap.containsKey(dst)){
currentConflictsMap.addStallSite(dst, new HashSet<HeapRegionNode>(),
new StallTag(fn),invarMap.get(dst));
preEffectAnalysis(og, dst, null, PreEffectsKey.WRITE_EFFECT);
}
-
-// if(invarMap.containsKey(dst)){
-// System.out.println("THIS IS FLAT SET FIELD:"+dst+ "with sese="+currentSESE);
-// TempDescriptor invarTD=invarMap.get(dst);
-// currentSESE.getSeseEffectsSet().addWritingVar(invarTD, new SESEEffectsKey("", dst.getType(), new Integer(0), ""));
-// }
-
-
} break;
case FKind.FlatSetFieldNode: {
Integer paramID = paramIter.next();
effectsSet.addReadingVar(paramID, new EffectsKey(
fieldDesc.getSymbol(), srcDesc.getType(),hrn.getID(),hrn.getGloballyUniqueIdentifier(),0));
-// effectsSet.addReadingVar(paramID, new EffectsKey(
-// fieldDesc.getSymbol(), srcDesc.getType(),hrn.getID()));
}
}
Integer paramID = paramIter.next();
effectsSet.addReadingVar(paramID, new EffectsKey(
fieldDesc.getSymbol(), srcDesc.getType(),hrn.getID(),hrn.getGloballyUniqueIdentifier(),1));
-// effectsSet.addReadingVar(paramID, new EffectsKey(
-// fieldDesc.getSymbol(), srcDesc.getType(),hrn.getID()));
}
}
}
}
+
+ public void analyzeFlatElementNode(OwnershipGraph og,
+ TempDescriptor srcDesc, FieldDescriptor fieldDesc){
+
+ LabelNode ln = getLabelNodeFromTemp(og, srcDesc);
+ if (ln != null) {
+ Iterator<ReferenceEdge> heapRegionsItr = ln.iteratorToReferencees();
+
+ while (heapRegionsItr.hasNext()) {
+ ReferenceEdge edge = heapRegionsItr.next();
+ HeapRegionNode hrn = edge.getDst();
+
+ if (hrn.isParameter()) {
+ Set<Integer> paramSet = og.idPrimary2paramIndexSet.get(hrn
+ .getID());
+
+ if (paramSet != null) {
+ Iterator<Integer> paramIter = paramSet.iterator();
+ while (paramIter.hasNext()) {
+ Integer paramID = paramIter.next();
+ effectsSet.addReadingVar(paramID, new EffectsKey(
+ fieldDesc.getSymbol(), srcDesc.getType(),hrn.getID(),hrn.getGloballyUniqueIdentifier(),0));
+ }
+ }
+
+ // check weather this heap region is parameter
+ // reachable...
+
+ paramSet = og.idSecondary2paramIndexSet.get(hrn.getID());
+ if (paramSet != null) {
+ Iterator<Integer> paramIter = paramSet.iterator();
+
+ while (paramIter.hasNext()) {
+ Integer paramID = paramIter.next();
+ effectsSet.addReadingVar(paramID, new EffectsKey(
+ fieldDesc.getSymbol(), srcDesc.getType(),hrn.getID(),hrn.getGloballyUniqueIdentifier(),1));
+ }
+ }
+
+ }
+ }
+ }
+
+
+
+
+ }
+
+ public void analyzeFlatSetElementNode(OwnershipGraph og,
+ TempDescriptor dstDesc, FieldDescriptor fieldDesc) {
+
+ LabelNode ln = getLabelNodeFromTemp(og, dstDesc);
+ if (ln != null) {
+
+ // / check possible strong updates
+ boolean strongUpdate = false;
+ if (!fieldDesc.getType().isImmutable()
+ || fieldDesc.getType().isArray()) {
+ Iterator<ReferenceEdge> itrXhrn = ln.iteratorToReferencees();
+ while (itrXhrn.hasNext()) {
+ ReferenceEdge edgeX = itrXhrn.next();
+ HeapRegionNode hrnX = edgeX.getDst();
+
+ if (fieldDesc != null
+ && fieldDesc != OwnershipAnalysis
+ .getArrayField(fieldDesc.getType())
+ && ((hrnX.getNumReferencers() == 1) || // case 1
+ (hrnX.isSingleObject() && ln.getNumReferencees() == 1) // case
+ // 2
+ )) {
+ strongUpdate = true;
+ }
+ }
+ }
+ // //
+
+ Iterator<ReferenceEdge> heapRegionsItr = ln.iteratorToReferencees();
+ while (heapRegionsItr.hasNext()) {
+ ReferenceEdge edge = heapRegionsItr.next();
+ HeapRegionNode hrn = edge.getDst();
+
+ if (hrn.isParameter()) {
+ Set<Integer> paramSet = og.idPrimary2paramIndexSet.get(hrn
+ .getID());
+
+ if (paramSet != null) {
+ Iterator<Integer> paramIter = paramSet.iterator();
+ while (paramIter.hasNext()) {
+ Integer paramID = paramIter.next();
+ effectsSet.addWritingVar(paramID, new EffectsKey(
+ fieldDesc.getSymbol(), dstDesc.getType(),
+ hrn.getID(), hrn
+ .getGloballyUniqueIdentifier(), 0));
+ if(strongUpdate){
+ effectsSet.addStrongUpdateVar(paramID, new EffectsKey(
+ fieldDesc.getSymbol(), dstDesc.getType(),hrn.getID(),hrn.getGloballyUniqueIdentifier(),0));
+ }
+ }
+ }
+
+ // check weather this heap region is parameter
+ // reachable...
+
+ paramSet = og.idSecondary2paramIndexSet.get(hrn.getID());
+ if (paramSet != null) {
+ Iterator<Integer> paramIter = paramSet.iterator();
+
+ while (paramIter.hasNext()) {
+ Integer paramID = paramIter.next();
+ effectsSet.addWritingVar(paramID, new EffectsKey(
+ fieldDesc.getSymbol(), dstDesc.getType(),
+ hrn.getID(), hrn
+ .getGloballyUniqueIdentifier(), 1));
+ if(strongUpdate){
+ effectsSet.addStrongUpdateVar(paramID, new EffectsKey(
+ fieldDesc.getSymbol(), dstDesc.getType(),hrn.getID(),hrn.getGloballyUniqueIdentifier(),0));
+ }
+ }
+ }
+
+ }
+
+ }
+ }
+
+ }
public void analyzeFlatSetFieldNode(OwnershipGraph og,
TempDescriptor dstDesc, FieldDescriptor fieldDesc) {
Integer paramID = paramIter.next();
effectsSet.addWritingVar(paramID, new EffectsKey(
fieldDesc.getSymbol(), dstDesc.getType(),hrn.getID(),hrn.getGloballyUniqueIdentifier(),0));
-// effectsSet.addWritingVar(paramID, new EffectsKey(
-// fieldDesc.getSymbol(), dstDesc.getType(),hrn.getID()));
if(strongUpdate){
effectsSet.addStrongUpdateVar(paramID, new EffectsKey(
fieldDesc.getSymbol(), dstDesc.getType(),hrn.getID(),hrn.getGloballyUniqueIdentifier(),0));
-// effectsSet.addStrongUpdateVar(paramID, new EffectsKey(
-// fieldDesc.getSymbol(), dstDesc.getType(),hrn.getID()));
}
}
Integer paramID = paramIter.next();
effectsSet.addWritingVar(paramID, new EffectsKey(
fieldDesc.getSymbol(), dstDesc.getType(),hrn.getID(),hrn.getGloballyUniqueIdentifier(),1));
-// effectsSet.addWritingVar(paramID, new EffectsKey(
-// fieldDesc.getSymbol(), dstDesc.getType(),hrn.getID()));
if(strongUpdate){
effectsSet.addStrongUpdateVar(paramID, new EffectsKey(
fieldDesc.getSymbol(), dstDesc.getType(),hrn.getID(),hrn.getGloballyUniqueIdentifier(),1));
-// effectsSet.addStrongUpdateVar(paramID, new EffectsKey(
-// fieldDesc.getSymbol(), dstDesc.getType(),hrn.getID()));
}
}