package Analysis.SSJava;
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
import IR.Flat.FlatSetFieldNode;
import IR.Flat.TempDescriptor;
import IR.Tree.Modifiers;
-import Util.Pair;
public class DefinitelyWrittenCheck {
TypeDescriptor td = lhs.getType().dereference();
fld = getArrayField(td);
- NTuple<Location> locTuple = mapDescriptorToLocationPath.get(lhs);
+ NTuple<Location> locTuple = deriveLocationTuple(md, lhs);
fieldLoc = locTuple.get(locTuple.size() - 1);
}
+ if (!isEventLoopBody && fieldLoc.getDescriptor().equals(md)) {
+ // if the field belongs to the local lattice, no reason to calculate
+ // shared location
+ break;
+ }
+
NTuple<Location> fieldLocTuple = new NTuple<Location>();
if (fld.isStatic()) {
if (fld.isFinal()) {
fieldLocTuple.add(topLocation);
} else {
fieldLocTuple.addAll(deriveGlobalLocationTuple(md));
- fieldLocTuple.add((Location) fld.getType().getExtension());
+ if (fn.kind() == FKind.FlatSetFieldNode) {
+ fieldLocTuple.add((Location) fld.getType().getExtension());
+ }
}
} else {
fieldLocTuple.addAll(deriveLocationTuple(md, lhs));
- fieldLocTuple.add((Location) fld.getType().getExtension());
+ if (fn.kind() == FKind.FlatSetFieldNode) {
+ fieldLocTuple.add((Location) fld.getType().getExtension());
+ }
}
// shared loc extension
generateGENSetForFlatCall(curr, genSet);
}
- // System.out.println("#FLATCALL=" + fc);
- // System.out.println("KILLSET=" + killSet);
- // System.out.println("GENSet=" + genSet);
- // System.out.println("bound DELETE Set=" + calleeUnionBoundDeleteSet);
+// System.out.println("#FLATCALL=" + fc);
+// System.out.println("KILLSET=" + killSet);
+// System.out.println("GENSet=" + genSet);
+// System.out.println("bound DELETE Set=" + calleeUnionBoundDeleteSet);
}
break;
}
computeNewMapping(curr, killSet, genSet);
- // System.out.println("#######" + curr);
+ if (!curr.map.isEmpty()) {
+// System.out.println(fn + "#######" + curr);
+ }
}
flatNodesToVisit.remove(fn);
visited.add(fn);
- computeSharedCoverSet_nodeActions(md, fn);
+ computeSharedCoverSet_nodeActions(md, fn, onlyVisitSSJavaLoop);
for (int i = 0; i < fn.numNext(); i++) {
FlatNode nn = fn.getNext(i);
}
- private void computeSharedCoverSet_nodeActions(MethodDescriptor md, FlatNode fn) {
+ private void computeSharedCoverSet_nodeActions(MethodDescriptor md, FlatNode fn,
+ boolean isEventLoopBody) {
TempDescriptor lhs;
TempDescriptor rhs;
FieldDescriptor fld;
fld = getArrayField(td);
}
+ Location fieldLocation;
+ if (fn.kind() == FKind.FlatSetFieldNode) {
+ fieldLocation = (Location) fld.getType().getExtension();
+ } else {
+ NTuple<Location> locTuple = mapDescriptorToLocationPath.get(lhs);
+ fieldLocation = locTuple.get(locTuple.size() - 1);
+ }
+
+ if (!isEventLoopBody && fieldLocation.getDescriptor().equals(md)) {
+ // if the field belongs to the local lattice, no reason to calculate
+ // shared location
+ break;
+ }
+
NTuple<Location> fieldLocTuple = new NTuple<Location>();
if (fld.isStatic()) {
if (fld.isFinal()) {
}
}
- Location fieldLocation;
- if (fn.kind() == FKind.FlatSetFieldNode) {
- fieldLocation = (Location) fld.getType().getExtension();
- } else {
- NTuple<Location> locTuple = mapDescriptorToLocationPath.get(lhs);
- fieldLocation = locTuple.get(locTuple.size() - 1);
- }
-
NTuple<Location> lTuple = deriveLocationTuple(md, lhs);
if (lTuple != null) {
NTuple<Location> lhsLocTuple = new NTuple<Location>();
generateKILLSetForFlatCall(fc, curr, sharedLocMap, readWriteKillSet);
generateGENSetForFlatCall(fc, sharedLocMap, readWriteGenSet);
- // System.out.println("KILLSET=" + readWriteKillSet);
- // System.out.println("GENSet=" + readWriteGenSet);
+// System.out.println("KILLSET=" + readWriteKillSet);
+// System.out.println("GENSet=" + readWriteGenSet);
checkManyRead(fc, curr);
}
}
computeNewMapping(curr, readWriteKillSet, readWriteGenSet);
- // System.out.println("#######" + curr);
+// System.out.println("#######" + curr);
}
Hashtable<NTuple<Descriptor>, Set<WriteAge>> GENSet) {
Set<NTuple<Descriptor>> boundMayWriteSet = mapFlatNodeToBoundMayWriteSet.get(fc);
+// System.out.println("boundMayWriteSet=" + boundMayWriteSet);
for (Iterator iterator = boundMayWriteSet.iterator(); iterator.hasNext();) {
NTuple<Descriptor> heapPath = (NTuple<Descriptor>) iterator.next();
Hashtable<NTuple<Descriptor>, Set<WriteAge>> KILLSet) {
Set<NTuple<Descriptor>> boundMustWriteSet = mapFlatNodeToBoundMustWriteSet.get(fc);
+// System.out.println("boundMustWriteSet=" + boundMustWriteSet);
for (Iterator iterator = boundMustWriteSet.iterator(); iterator.hasNext();) {
NTuple<Descriptor> heapPath = (NTuple<Descriptor>) iterator.next();
// generate proper path fot input td
// if td is local variable, it just generate one element tuple path
if (mapHeapPath.containsKey(td)) {
- return mapHeapPath.get(td);
+ NTuple<Descriptor> rtrHeapPath = new NTuple<Descriptor>();
+ rtrHeapPath.addAll(mapHeapPath.get(td));
+ return rtrHeapPath;
} else {
- NTuple<Descriptor> path = new NTuple<Descriptor>();
- path.add(td);
- return path;
+ NTuple<Descriptor> rtrHeapPath = new NTuple<Descriptor>();
+ rtrHeapPath.add(td);
+ return rtrHeapPath;
}
}
assert td.getType() != null;
if (mapDescriptorToLocationPath.containsKey(td)) {
- return mapDescriptorToLocationPath.get(td);
+ NTuple<Location> locPath = mapDescriptorToLocationPath.get(td);
+ NTuple<Location> rtrPath = new NTuple<Location>();
+ rtrPath.addAll(locPath);
+ return rtrPath;
} else {
if (td.getSymbol().startsWith("this")) {
- return deriveThisLocationTuple(md);
+ NTuple<Location> thisPath = deriveThisLocationTuple(md);
+
+ NTuple<Location> rtrPath = new NTuple<Location>();
+ rtrPath.addAll(thisPath);
+
+ return rtrPath;
} else {
if (td.getType().getExtension() != null) {
- System.out.println("td.getType().getExtension() =" + td.getType().getExtension());
SSJavaType ssJavaType = (SSJavaType) td.getType().getExtension();
if (ssJavaType.getCompLoc() != null) {
- NTuple<Location> locTuple = new NTuple<Location>();
- locTuple.addAll(ssJavaType.getCompLoc().getTuple());
- return locTuple;
+ NTuple<Location> rtrPath = new NTuple<Location>();
+ rtrPath.addAll(ssJavaType.getCompLoc().getTuple());
+ return rtrPath;
}
}