NTuple<Location> locTuple = deriveLocationTuple(md, lhs);
fieldLoc = locTuple.get(locTuple.size() - 1);
+ break;
}
if (!isEventLoopBody && fieldLoc.getDescriptor().equals(md)) {
NTuple<Descriptor> fldHeapPath = new NTuple<Descriptor>();
fldHeapPath.addAll(computePath(lhs));
- fldHeapPath.add(fld);
+ if (fn.kind() == FKind.FlatSetFieldNode) {
+ fldHeapPath.add(fld);
+ }
// computing gen/kill set
computeKILLSetForWrite(curr, killSet, fieldLocTuple, fldHeapPath);
case FKind.FlatCall: {
FlatCall fc = (FlatCall) fn;
- if (ssjava.needTobeAnnotated(fc.getMethod())) {
+ // if (ssjava.needTobeAnnotated(fc.getMethod())) {
+ // System.out.println("#FLATCALL=" + fc);
- bindHeapPathCallerArgWithCaleeParamForSharedLoc(fm.getMethod(), fc);
+ bindHeapPathCallerArgWithCaleeParamForSharedLoc(fm.getMethod(), fc);
- // computing gen/kill set
- generateKILLSetForFlatCall(curr, killSet);
- generateGENSetForFlatCall(curr, genSet);
+ // computing gen/kill set
+ generateKILLSetForFlatCall(curr, killSet);
+ 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);
if (!curr.map.isEmpty()) {
-// System.out.println(fn + "#######" + curr);
+ // System.out.println(fn + "#######" + curr);
}
}
System.out.println("computeSharedCoverSet_analyzeMethod=" + fm);
MethodDescriptor md = fm.getMethod();
+
Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
Set<FlatNode> visited = new HashSet<FlatNode>();
NTuple<Location> rhsLocTuple = new NTuple<Location>();
NTuple<Location> lhsLocTuple = new NTuple<Location>();
if (mapDescriptorToLocationPath.containsKey(rhs)) {
- mapDescriptorToLocationPath.put(lhs, mapDescriptorToLocationPath.get(rhs));
+ mapDescriptorToLocationPath.put(lhs, deriveLocationTuple(md, rhs));
} else {
// rhs side
if (rhs.getType().getExtension() != null
NTuple<Descriptor> fieldHeapPath = new NTuple<Descriptor>();
fieldHeapPath.addAll(computePath(lhs));
- fieldHeapPath.add(fld);
+ if (fn.kind() == FKind.FlatSetFieldNode) {
+ fieldHeapPath.add(fld);
+ }
// mapLocationPathToMayWrittenSet.put(locTuple, null, fld);
addMayWrittenSet(md, fieldLocTuple, fieldHeapPath);
FlatCall fc = (FlatCall) fn;
- if (ssjava.needTobeAnnotated(fc.getMethod())) {
- bindLocationPathCallerArgWithCalleeParam(md, fc);
- }
+ // if (ssjava.needTobeAnnotated(fc.getMethod())) {
+ bindLocationPathCallerArgWithCalleeParam(md, fc);
+ // }
}
break;
mapArgIdx2CallerArgLocationPath.put(Integer.valueOf(0), thisLocationPath);
// heap path for 'this'
- NTuple<Descriptor> thisHeapPath = mapHeapPath.get(fc.getThis());
- if (thisHeapPath == null) {
+ NTuple<Descriptor> thisHeapPath = new NTuple<Descriptor>();
+ if (mapHeapPath.containsKey(fc.getThis())) {
+ thisHeapPath.addAll(mapHeapPath.get(fc.getThis()));
+ } else {
// method is called without creating new flat node representing
// 'this'
- thisHeapPath = new NTuple<Descriptor>();
thisHeapPath.add(fc.getThis());
}
mapArgIdx2CallerArgHeapPath.put(Integer.valueOf(0), thisHeapPath);
// write(field)
NTuple<Descriptor> lhsHeapPath = computePath(lhs);
NTuple<Descriptor> fldHeapPath = new NTuple<Descriptor>(lhsHeapPath.getList());
- fldHeapPath.add(fld);
+ if (fn.kind() == FKind.FlatSetFieldNode) {
+ fldHeapPath.add(fld);
+ }
// shared loc extension
Location fieldLoc = (Location) fld.getType().getExtension();
NTuple<Location> fieldLocTuple = new NTuple<Location>();
fieldLocTuple.addAll(mapDescriptorToLocationPath.get(lhs));
- fieldLocTuple.add(fieldLoc);
+ if (fn.kind() == FKind.FlatSetFieldNode) {
+ fieldLocTuple.add(fieldLoc);
+ }
Set<NTuple<Descriptor>> writtenSet =
mapFlatNodeToSharedLocMapping.get(fn).get(fieldLocTuple);
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);
}
private void generateErrorMessage(NTuple<Descriptor> path, FlatNode fn) {
- Descriptor lastDesc = path.get(path.size() - 1);
+ Descriptor lastDesc = path.get(getArrayBaseDescriptorIdx(path));
if (ssjava.isSharedLocation(getLocation(lastDesc))) {
NTuple<Location> locPathTuple = getLocationTuple(path);
Hashtable<NTuple<Descriptor>, Set<WriteAge>> GENSet) {
Set<NTuple<Descriptor>> boundMayWriteSet = mapFlatNodeToBoundMayWriteSet.get(fc);
-// System.out.println("boundMayWriteSet=" + boundMayWriteSet);
+ // 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);
+ // System.out.println("boundMustWriteSet=" + boundMustWriteSet);
for (Iterator iterator = boundMustWriteSet.iterator(); iterator.hasNext();) {
NTuple<Descriptor> heapPath = (NTuple<Descriptor>) iterator.next();
KILLSet.put(heapPath, curr.get(heapPath));
}
} else {
- if (curr.get(heapPath) != null) {
- KILLSet.put(heapPath, curr.get(heapPath));
+
+ for (Enumeration<NTuple<Descriptor>> e = curr.keys(); e.hasMoreElements();) {
+ NTuple<Descriptor> key = e.nextElement();
+ if (key.startsWith(heapPath)) {
+ KILLSet.put(key, curr.get(key));
+ }
}
+
}
}
calleeIntersectBoundSharedSet.clear();
calleeUnionBoundDeleteSet.clear();
- // if arg is not primitive type, we need to propagate maywritten set to
- // the caller's location path
+ if (ssjava.isSSJavaUtil(fc.getMethod().getClassDesc())) {
+ // ssjava util case!
+ // have write effects on the first argument
+ TempDescriptor arg = fc.getArg(0);
+ NTuple<Descriptor> argHeapPath = computePath(arg);
- MethodDescriptor mdCallee = fc.getMethod();
- Set<MethodDescriptor> setPossibleCallees = new HashSet<MethodDescriptor>();
- setPossibleCallees.addAll(callGraph.getMethods(mdCallee));
+ // convert heap path to location path
+ NTuple<Location> argLocTuple = new NTuple<Location>();
+ argLocTuple.addAll(deriveLocationTuple(mdCaller, (TempDescriptor) argHeapPath.get(0)));
+ for (int i = 1; i < argHeapPath.size(); i++) {
+ argLocTuple.add(getLocation(argHeapPath.get(i)));
+ }
- // create mapping from arg idx to its heap paths
- Hashtable<Integer, NTuple<Descriptor>> mapArgIdx2CallerArgHeapPath =
- new Hashtable<Integer, NTuple<Descriptor>>();
+ calleeIntersectBoundSharedSet.addWrite(argLocTuple, argHeapPath);
- // arg idx is starting from 'this' arg
- if (fc.getThis() != null) {
- NTuple<Descriptor> thisHeapPath = mapHeapPath.get(fc.getThis());
- if (thisHeapPath == null) {
- // method is called without creating new flat node representing 'this'
- thisHeapPath = new NTuple<Descriptor>();
- thisHeapPath.add(fc.getThis());
- }
+ } else {
- mapArgIdx2CallerArgHeapPath.put(Integer.valueOf(0), thisHeapPath);
- }
+ // if arg is not primitive type, we need to propagate maywritten set to
+ // the caller's location path
- for (int i = 0; i < fc.numArgs(); i++) {
- TempDescriptor arg = fc.getArg(i);
- NTuple<Descriptor> argHeapPath = computePath(arg);
- mapArgIdx2CallerArgHeapPath.put(Integer.valueOf(i + 1), argHeapPath);
- }
+ MethodDescriptor mdCallee = fc.getMethod();
+ Set<MethodDescriptor> setPossibleCallees = new HashSet<MethodDescriptor>();
+ setPossibleCallees.addAll(callGraph.getMethods(mdCallee));
- // create mapping from arg idx to its location paths
- Hashtable<Integer, NTuple<Location>> mapArgIdx2CallerAgLocationPath =
- new Hashtable<Integer, NTuple<Location>>();
+ // create mapping from arg idx to its heap paths
+ Hashtable<Integer, NTuple<Descriptor>> mapArgIdx2CallerArgHeapPath =
+ new Hashtable<Integer, NTuple<Descriptor>>();
- // arg idx is starting from 'this' arg
- if (fc.getThis() != null) {
- NTuple<Location> thisLocationPath = deriveLocationTuple(mdCaller, fc.getThis());
- mapArgIdx2CallerAgLocationPath.put(Integer.valueOf(0), thisLocationPath);
- }
+ // arg idx is starting from 'this' arg
+ if (fc.getThis() != null) {
+ NTuple<Descriptor> thisHeapPath = mapHeapPath.get(fc.getThis());
+ if (thisHeapPath == null) {
+ // method is called without creating new flat node representing 'this'
+ thisHeapPath = new NTuple<Descriptor>();
+ thisHeapPath.add(fc.getThis());
+ }
- for (int i = 0; i < fc.numArgs(); i++) {
- TempDescriptor arg = fc.getArg(i);
- NTuple<Location> argLocationPath = deriveLocationTuple(mdCaller, arg);
- if (argLocationPath != null) {
- mapArgIdx2CallerAgLocationPath.put(Integer.valueOf(i + 1), argLocationPath);
+ mapArgIdx2CallerArgHeapPath.put(Integer.valueOf(0), thisHeapPath);
}
- }
- for (Iterator iterator = setPossibleCallees.iterator(); iterator.hasNext();) {
- MethodDescriptor callee = (MethodDescriptor) iterator.next();
- FlatMethod calleeFlatMethod = state.getMethodFlat(callee);
+ for (int i = 0; i < fc.numArgs(); i++) {
+ TempDescriptor arg = fc.getArg(i);
+ NTuple<Descriptor> argHeapPath = computePath(arg);
+ mapArgIdx2CallerArgHeapPath.put(Integer.valueOf(i + 1), argHeapPath);
+ }
- // binding caller's args and callee's params
+ // create mapping from arg idx to its location paths
+ Hashtable<Integer, NTuple<Location>> mapArgIdx2CallerAgLocationPath =
+ new Hashtable<Integer, NTuple<Location>>();
- Hashtable<Integer, TempDescriptor> mapParamIdx2ParamTempDesc =
- new Hashtable<Integer, TempDescriptor>();
- int offset = 0;
- if (calleeFlatMethod.getMethod().isStatic()) {
- // static method does not have implicit 'this' arg
- offset = 1;
+ // arg idx is starting from 'this' arg
+ if (fc.getThis() != null) {
+ NTuple<Location> thisLocationPath = deriveLocationTuple(mdCaller, fc.getThis());
+ if (thisLocationPath != null) {
+ mapArgIdx2CallerAgLocationPath.put(Integer.valueOf(0), thisLocationPath);
+ }
}
- for (int i = 0; i < calleeFlatMethod.numParameters(); i++) {
- TempDescriptor param = calleeFlatMethod.getParameter(i);
- mapParamIdx2ParamTempDesc.put(Integer.valueOf(i + offset), param);
+
+ for (int i = 0; i < fc.numArgs(); i++) {
+ TempDescriptor arg = fc.getArg(i);
+ NTuple<Location> argLocationPath = deriveLocationTuple(mdCaller, arg);
+ if (argLocationPath != null) {
+ mapArgIdx2CallerAgLocationPath.put(Integer.valueOf(i + 1), argLocationPath);
+ }
}
- Set<Integer> keySet = mapArgIdx2CallerAgLocationPath.keySet();
- for (Iterator iterator2 = keySet.iterator(); iterator2.hasNext();) {
- Integer idx = (Integer) iterator2.next();
- NTuple<Location> callerArgLocationPath = mapArgIdx2CallerAgLocationPath.get(idx);
- NTuple<Descriptor> callerArgHeapPath = mapArgIdx2CallerArgHeapPath.get(idx);
+ for (Iterator iterator = setPossibleCallees.iterator(); iterator.hasNext();) {
+ MethodDescriptor callee = (MethodDescriptor) iterator.next();
+ FlatMethod calleeFlatMethod = state.getMethodFlat(callee);
- TempDescriptor calleeParam = mapParamIdx2ParamTempDesc.get(idx);
- NTuple<Location> calleeLocationPath = deriveLocationTuple(mdCallee, calleeParam);
- SharedLocMap calleeDeleteSet = mapFlatMethodToDeleteSet.get(calleeFlatMethod);
- SharedLocMap calleeSharedLocMap = mapFlatMethodToSharedLocMap.get(calleeFlatMethod);
+ // binding caller's args and callee's params
- if (calleeDeleteSet != null) {
- createNewMappingOfDeleteSet(callerArgLocationPath, callerArgHeapPath, calleeLocationPath,
- calleeDeleteSet);
+ Hashtable<Integer, TempDescriptor> mapParamIdx2ParamTempDesc =
+ new Hashtable<Integer, TempDescriptor>();
+ int offset = 0;
+ if (calleeFlatMethod.getMethod().isStatic()) {
+ // static method does not have implicit 'this' arg
+ offset = 1;
+ }
+ for (int i = 0; i < calleeFlatMethod.numParameters(); i++) {
+ TempDescriptor param = calleeFlatMethod.getParameter(i);
+ mapParamIdx2ParamTempDesc.put(Integer.valueOf(i + offset), param);
}
- if (calleeSharedLocMap != null) {
- createNewMappingOfSharedSet(callerArgLocationPath, callerArgHeapPath, calleeLocationPath,
- calleeSharedLocMap);
+ Set<Integer> keySet = mapArgIdx2CallerAgLocationPath.keySet();
+ for (Iterator iterator2 = keySet.iterator(); iterator2.hasNext();) {
+ Integer idx = (Integer) iterator2.next();
+ NTuple<Location> callerArgLocationPath = mapArgIdx2CallerAgLocationPath.get(idx);
+ NTuple<Descriptor> callerArgHeapPath = mapArgIdx2CallerArgHeapPath.get(idx);
+
+ TempDescriptor calleeParam = mapParamIdx2ParamTempDesc.get(idx);
+ NTuple<Location> calleeLocationPath = deriveLocationTuple(mdCallee, calleeParam);
+ SharedLocMap calleeDeleteSet = mapFlatMethodToDeleteSet.get(calleeFlatMethod);
+ SharedLocMap calleeSharedLocMap = mapFlatMethodToSharedLocMap.get(calleeFlatMethod);
+
+ if (calleeDeleteSet != null) {
+ createNewMappingOfDeleteSet(callerArgLocationPath, callerArgHeapPath,
+ calleeLocationPath, calleeDeleteSet);
+ }
+
+ if (calleeSharedLocMap != null) {
+ createNewMappingOfSharedSet(callerArgLocationPath, callerArgHeapPath,
+ calleeLocationPath, calleeSharedLocMap);
+ }
+
}
}
-
}
}
// callee's parameters. so just ignore it
NTuple<Descriptor> readingHeapPath = new NTuple<Descriptor>(srcHeapPath.getList());
- readingHeapPath.add(fld);
+ if (fn.kind() == FKind.FlatFieldNode) {
+ readingHeapPath.add(fld);
+ }
+
mapHeapPath.put(lhs, readingHeapPath);
// read (x.f)
// if lhs heap path is null, it means that it is not reachable from
// callee's parameters. so just ignore it
NTuple<Descriptor> fldHeapPath = new NTuple<Descriptor>(lhsHeapPath.getList());
- fldHeapPath.add(fld);
- mapHeapPath.put(fld, fldHeapPath);
+ if (fn.kind() != FKind.FlatSetElementNode) {
+ fldHeapPath.add(fld);
+ }
+ // mapHeapPath.put(fld, fldHeapPath);
// write(x.f)
// need to add hp(y) to WT
- currMustWriteSet.add(fldHeapPath);
+ if (fn.kind() != FKind.FlatSetElementNode) {
+ currMustWriteSet.add(fldHeapPath);
+ }
mayWriteSet.add(fldHeapPath);
}