Set<Location> locKeySet = map.keySet();
for (Iterator iterator2 = locKeySet.iterator(); iterator2.hasNext();) {
Location locKey = (Location) iterator2.next();
- Pair<Set<Descriptor>, Boolean> pair = map.get(locKey);
- if (!pair.getSecond().booleanValue()) {
- // not cleared!
- System.out.println("Concrete locations of the shared location '" + locKey
- + "' are not cleared out, which are reachable through the heap path '" + hpKey + "'");
+ if (status.haveWriteEffect(locKey)) {
+ Pair<Set<Descriptor>, Boolean> pair = map.get(locKey);
+ if (!pair.getSecond().booleanValue()) {
+ // not cleared!
+ System.out.println("Concrete locations of the shared location '" + locKey
+ + "' are not cleared out, which are reachable through the heap path '" + hpKey
+ + "'");
+ }
}
}
}
if (!completeSummary.equals(prevCompleteSummary)) {
ClearingSummary summaryFromCaller = mapMethodDescriptorToInitialClearingSummary.get(md);
+ // System.out.println("###");
// System.out.println("# summaryFromCaller=" + summaryFromCaller);
// System.out.println("# completeSummary=" + completeSummary);
// System.out.println("# prev=" + prevCompleteSummary);
}
}
mergeSharedLocationAnaylsis(completeSummary, summarySet);
+
+ if (md.getSymbol().startsWith("decodeFrame")) {
+ System.out.println("#");
+ System.out.println("# method=" + md);
+ System.out.println("XXXXX summarySet=" + summarySet);
+ System.out.println("XXXXX completeSummary=" + completeSummary);
+ System.out.println("#");
+ }
+
return completeSummary;
}
rhsHeapPath.add(LOCAL);
lhsHeapPath.add(LOCAL);
if (!lhs.getSymbol().startsWith("neverused")) {
- readLocation(curr, rhsHeapPath, rhs);
- writeLocation(curr, lhsHeapPath, lhs);
+ readLocation(curr, rhsHeapPath, getLocation(rhs), rhs);
+ writeLocation(curr, lhsHeapPath, getLocation(lhs), lhs);
}
}
}
// callee's parameters. so just ignore it
NTuple<Descriptor> fldHeapPath = new NTuple<Descriptor>(srcHeapPath.getList());
+ // if (!fld.getType().isArray() && fld.getType().isImmutable()) {
+ // addReadDescriptor(fldHeapPath, getLocation(fld), fld);
+ // } else {
+ // if (fn.kind() == FKind.FlatFieldNode) {
+ // mapDescToLocation.put(lhs, getLocation(fld));
+ // readLocation(curr, fldHeapPath, getLocation(fld), fld);
+ // } else {
+ // fldHeapPath.add(fld);
+ // }
+ // mapHeapPath.put(lhs, fldHeapPath);
+ // }
+
if (!fld.getType().isArray() && fld.getType().isImmutable()) {
- readLocation(curr, fldHeapPath, fld);
+ Location loc;
+ if (fn.kind() == FKind.FlatElementNode) {
+ // array element read case
+ loc = mapDescToLocation.get(rhs);
+ NTuple<Descriptor> newHeapPath = new NTuple<Descriptor>();
+ for (int i = 0; i < fldHeapPath.size() - 1; i++) {
+ newHeapPath.add(fldHeapPath.get(i));
+ }
+
+ Descriptor desc = fldHeapPath.get(fldHeapPath.size() - 1);
+ if (desc instanceof FieldDescriptor) {
+ fld = (FieldDescriptor) desc;
+ fldHeapPath = newHeapPath;
+ readLocation(curr, fldHeapPath, loc, fld);
+ }
+ } else {
+ loc = getLocation(fld);
+ readLocation(curr, fldHeapPath, loc, fld);
+ }
} else {
- fldHeapPath.add(fld);
+
+ if (fn.kind() != FKind.FlatElementNode) {
+ // if it is multi dimensional array, do not need to add heap path
+ // because all accesses from the same array is represented by
+ // "_element_"
+ fldHeapPath.add(fld);
+ }
mapHeapPath.put(lhs, fldHeapPath);
}
NTuple<Descriptor> lhsHeapPath = computePath(lhs);
NTuple<Descriptor> fldHeapPath = new NTuple<Descriptor>(lhsHeapPath.getList());
if (fld.getType().isImmutable()) {
- writeLocation(curr, fldHeapPath, fld);
+ writeLocation(curr, fldHeapPath, getLocation(fld), fld);
+
+ Descriptor desc = fldHeapPath.get(fldHeapPath.size() - 1);
+ if (desc instanceof FieldDescriptor) {
+ NTuple<Descriptor> arrayPath = new NTuple<Descriptor>();
+ for (int i = 0; i < fldHeapPath.size() - 1; i++) {
+ arrayPath.add(fldHeapPath.get(i));
+ }
+ SharedStatus state = getState(curr, arrayPath);
+ state.setWriteEffect(getLocation(desc));
+ }
+
} else {
// updates reference field case:
- // 2. if there exists a tuple t in sharing summary that starts with
- // hp(x) then, set flag of tuple t to 'true'
fldHeapPath.add(fld);
- Set<NTuple<Descriptor>> hpKeySet = curr.keySet();
- for (Iterator iterator = hpKeySet.iterator(); iterator.hasNext();) {
- NTuple<Descriptor> hpKey = (NTuple<Descriptor>) iterator.next();
- if (hpKey.startsWith(fldHeapPath)) {
- curr.get(hpKey).updateFlag(true);
- }
- }
+ updateWriteEffectOnReferenceField(curr, fldHeapPath);
}
}
if (ssjava.isSSJavaUtil(fc.getMethod().getClassDesc())) {
// ssjava util case!
// have write effects on the first argument
- NTuple<Descriptor> argHeapPath = computePath(fc.getArg(0));
- writeLocation(curr, argHeapPath, fc.getArg(0));
+
+ if (fc.getArg(0).getType().isArray()) {
+ // updates reference field case:
+ // 2. if there exists a tuple t in sharing summary that starts with
+ // hp(x) then, set flag of tuple t to 'true'
+ NTuple<Descriptor> argHeapPath = computePath(fc.getArg(0));
+
+ Location loc = getLocation(fc.getArg(0));
+ NTuple<Descriptor> newHeapPath = new NTuple<Descriptor>();
+ for (int i = 0; i < argHeapPath.size() - 1; i++) {
+ newHeapPath.add(argHeapPath.get(i));
+ }
+ fld = (FieldDescriptor) argHeapPath.get(argHeapPath.size() - 1);
+ argHeapPath = newHeapPath;
+
+ writeLocation(curr, argHeapPath, loc, fld);
+ }
+
} else {
// find out the set of callees
MethodDescriptor mdCallee = fc.getMethod();
}
}
- // System.out.println("callee " + fc + " summary=" +
- // possibleCalleeCompleteSummarySetToCaller);
+
// contribute callee's writing effects to the caller
mergeSharedLocationAnaylsis(curr, possibleCalleeCompleteSummarySetToCaller);
+ if (fc.getMethod().getSymbol().startsWith("decode")) {
+ System.out.println("XXXXX callee " + fc + " summary="
+ + possibleCalleeCompleteSummarySetToCaller);
+ System.out.println("XXXXX curr=" + curr);
+ }
+
}
}
}
+ private void updateWriteEffectOnReferenceField(ClearingSummary curr, NTuple<Descriptor> heapPath) {
+
+ // DEBUG!
+ // System.out.println("UPDATE WRITE REF=" + heapPath);
+ // Descriptor d = heapPath.get(heapPath.size() - 1);
+ // boolean print = false;
+ // if (d instanceof FieldDescriptor) {
+ // FieldDescriptor fd = (FieldDescriptor) d;
+ // if (fd.getSymbol().equals("si")) {
+ // System.out.println("UPDATE PREV CURR=" + curr);
+ // print = true;
+ // }
+ // }
+ // 2. if there exists a tuple t in sharing summary that starts with
+ // hp(x) then, set flag of tuple t to 'true'
+ Set<NTuple<Descriptor>> hpKeySet = curr.keySet();
+ for (Iterator iterator = hpKeySet.iterator(); iterator.hasNext();) {
+ NTuple<Descriptor> hpKey = (NTuple<Descriptor>) iterator.next();
+ if (hpKey.startsWith(heapPath)) {
+ curr.get(hpKey).updateFlag(true);
+ }
+ }
+
+ // if (print) {
+ // System.out.println("UPDATE CURR=" + curr);
+ // }
+ }
+
private ClearingSummary bindHeapPathOfCalleeCallerEffects(FlatCall fc,
FlatMethod calleeFlatMethod, ClearingSummary curr) {
Location loc;
if (fn.kind() == FKind.FlatElementNode) {
+ // array element read case
loc = mapDescToLocation.get(rhs);
+ NTuple<Descriptor> newHeapPath = new NTuple<Descriptor>();
+ for (int i = 0; i < fldHeapPath.size() - 1; i++) {
+ newHeapPath.add(fldHeapPath.get(i));
+ }
+
+ Descriptor desc = fldHeapPath.get(fldHeapPath.size() - 1);
+ if (desc instanceof FieldDescriptor) {
+ fld = (FieldDescriptor) desc;
+ fldHeapPath = newHeapPath;
+ addReadDescriptor(fldHeapPath, loc, fld);
+ }
} else {
loc = getLocation(fld);
+ addReadDescriptor(fldHeapPath, loc, fld);
}
-
- addReadDescriptor(fldHeapPath, loc, fld);
} else {
// propagate rhs's heap path to the lhs
if (fn.kind() == FKind.FlatElementNode) {
mapDescToLocation.put(lhs, getLocation(rhs));
+ } else {
+ fldHeapPath.add(fld);
}
-
- fldHeapPath.add(fld);
mapHeapPath.put(lhs, fldHeapPath);
}
}
break;
- case FKind.FlatCall: {
-
- FlatCall fc = (FlatCall) fn;
-
- if (ssjava.isSSJavaUtil(fc.getMethod().getClassDesc())) {
- // ssjava util case!
- // have write effects on the first argument
- NTuple<Descriptor> argHeapPath = computePath(fc.getArg(0));
- Location loc = getLocation(fc.getArg(0));
- addReadDescriptor(argHeapPath, loc, fc.getArg(0));
- }
- }
- break;
-
}
}
return mapDescToLocation.get(d);
}
- private void writeLocation(ClearingSummary curr, NTuple<Descriptor> hp, Descriptor d) {
-
- Location loc = getLocation(d);
- // System.out.println("# WRITE LOC hp=" + hp + " d=" + d);
+ private void writeLocation(ClearingSummary curr, NTuple<Descriptor> hp, Location loc, Descriptor d) {
+ // System.out.println("# WRITE LOC hp=" + hp + " d=" + d + " loc=" + loc);
+ SharedStatus state = getState(curr, hp);
if (loc != null && hasReadingEffectOnSharedLocation(hp, loc, d)) {
// 1. add field x to the clearing set
- SharedStatus state = getState(curr, hp);
+
state.addVar(loc, d);
// 3. if the set v contains all of variables belonging to the shared
state.updateFlag(loc, true);
}
}
+ state.setWriteEffect(loc);
// System.out.println("# WRITE CURR=" + curr);
}
}
}
- private void readLocation(ClearingSummary curr, NTuple<Descriptor> hp, Descriptor d) {
+ private void readLocation(ClearingSummary curr, NTuple<Descriptor> hp, Location loc, Descriptor d) {
// remove reading var x from written set
- Location loc = getLocation(d);
- // System.out.println("# READ LOC hp="+hp+" d="+d);
+ // System.out.println("# READ LOC hp=" + hp + " d=" + d + " loc=" + loc);
if (loc != null && hasReadingEffectOnSharedLocation(hp, loc, d)) {
SharedStatus state = getState(curr, hp);
state.removeVar(loc, d);
}
- // System.out.println("# READ CURR="+curr);
+ // System.out.println("# READ CURR=" + curr);
}
private SharedStatus getState(ClearingSummary curr, NTuple<Descriptor> hp) {