import java.util.Set;
import java.util.Stack;
+import Analysis.Liveness;
import Analysis.CallGraph.CallGraph;
import Analysis.Loops.LoopFinder;
import IR.Descriptor;
State state;
CallGraph callGraph;
+ Liveness liveness;
+
int debugcount = 0;
// maps a descriptor to its known dependents: namely
private SharedLocMap calleeUnionBoundDeleteSet;
private SharedLocMap calleeIntersectBoundSharedSet;
+ Set<TempDescriptor> liveInTempSetToEventLoop;
+
private Hashtable<Descriptor, Location> mapDescToLocation;
private TempDescriptor LOCAL;
this.mapMethodToSharedLocCoverSet =
new Hashtable<MethodDescriptor, MultiSourceMap<NTuple<Location>, NTuple<Descriptor>>>();
this.mapFlatNodeToDeleteSet = new Hashtable<FlatNode, SharedLocMap>();
+ this.liveness = new Liveness();
+ this.liveInTempSetToEventLoop = new HashSet<TempDescriptor>();
}
public void definitelyWrittenCheck() {
if (!lhs.getSymbol().startsWith("neverused") && !lhs.getSymbol().startsWith("leftop")
&& !lhs.getSymbol().startsWith("rightop") && rhs.getType().isImmutable()) {
- Location dstLoc = getLocation(lhs);
- if (dstLoc != null && ssjava.isSharedLocation(dstLoc)) {
- NTuple<Descriptor> lhsHeapPath = computePath(lhs);
- NTuple<Location> lhsLocTuple = mapDescriptorToLocationPath.get(lhs);
+ if (mapHeapPath.containsKey(rhs)) {
+ Location dstLoc = getLocation(lhs);
+ if (dstLoc != null && ssjava.isSharedLocation(dstLoc)) {
+ NTuple<Descriptor> lhsHeapPath = computePath(lhs);
+ NTuple<Location> lhsLocTuple = mapDescriptorToLocationPath.get(lhs);
- Location srcLoc = getLocation(lhs);
+ Location srcLoc = getLocation(lhs);
- // computing gen/kill set
- computeKILLSetForWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
- if (!dstLoc.equals(srcLoc)) {
- computeGENSetForHigherWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
- updateDeleteSetForHigherWrite(currDeleteSet, lhsLocTuple, lhsHeapPath);
- } else {
- computeGENSetForSameHeightWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
- updateDeleteSetForSameHeightWrite(currDeleteSet, lhsLocTuple, lhsHeapPath);
- }
+ // computing gen/kill set
+ computeKILLSetForWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
+ if (!dstLoc.equals(srcLoc)) {
+ computeGENSetForHigherWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
+ updateDeleteSetForHigherWrite(currDeleteSet, lhsLocTuple, lhsHeapPath);
+ } else {
+ computeGENSetForSameHeightWrite(curr, killSet, lhsLocTuple, lhsHeapPath);
+ updateDeleteSetForSameHeightWrite(currDeleteSet, lhsLocTuple, lhsHeapPath);
+ }
- // System.out.println("VAR WRITE:" + fn);
- // System.out.println("lhsLocTuple=" + lhsLocTuple +
- // " lhsHeapPath=" + lhsHeapPath);
- // System.out.println("dstLoc=" + dstLoc + " srcLoc=" + srcLoc);
- // System.out.println("KILLSET=" + killSet);
- // System.out.println("GENSet=" + genSet);
- // System.out.println("DELETESET=" + currDeleteSet);
+ // System.out.println("VAR WRITE:" + fn);
+ // System.out.println("lhsLocTuple=" + lhsLocTuple +
+ // " lhsHeapPath=" + lhsHeapPath);
+ // System.out.println("dstLoc=" + dstLoc + " srcLoc=" + srcLoc);
+ // System.out.println("KILLSET=" + killSet);
+ // System.out.println("GENSet=" + genSet);
+ // System.out.println("DELETESET=" + currDeleteSet);
+ }
+ } else {
+ break;
}
}
if (!lhs.getSymbol().startsWith("neverused") && !lhs.getSymbol().startsWith("leftop")
&& !lhs.getSymbol().startsWith("rightop")) {
- NTuple<Location> rhsLocTuple = new NTuple<Location>();
- NTuple<Location> lhsLocTuple = new NTuple<Location>();
- if (mapDescriptorToLocationPath.containsKey(rhs)) {
- mapDescriptorToLocationPath.put(lhs, deriveLocationTuple(md, rhs));
- lhsLocTuple = mapDescriptorToLocationPath.get(lhs);
- } else {
- // rhs side
- if (rhs.getType().getExtension() != null
- && rhs.getType().getExtension() instanceof SSJavaType) {
+ if (mapHeapPath.containsKey(rhs)) {
+ NTuple<Location> rhsLocTuple = new NTuple<Location>();
+ NTuple<Location> lhsLocTuple = new NTuple<Location>();
+ if (mapDescriptorToLocationPath.containsKey(rhs)) {
+ mapDescriptorToLocationPath.put(lhs, deriveLocationTuple(md, rhs));
+ lhsLocTuple = mapDescriptorToLocationPath.get(lhs);
+ } else {
+ // rhs side
+ if (rhs.getType().getExtension() != null
+ && rhs.getType().getExtension() instanceof SSJavaType) {
- if (((SSJavaType) rhs.getType().getExtension()).getCompLoc() != null) {
- rhsLocTuple.addAll(((SSJavaType) rhs.getType().getExtension()).getCompLoc()
- .getTuple());
+ if (((SSJavaType) rhs.getType().getExtension()).getCompLoc() != null) {
+ rhsLocTuple.addAll(((SSJavaType) rhs.getType().getExtension()).getCompLoc()
+ .getTuple());
+ }
+
+ } else {
+ NTuple<Location> locTuple = deriveLocationTuple(md, rhs);
+ if (locTuple != null) {
+ rhsLocTuple.addAll(locTuple);
+ }
+ }
+ if (rhsLocTuple.size() > 0) {
+ mapDescriptorToLocationPath.put(rhs, rhsLocTuple);
}
- } else {
- NTuple<Location> locTuple = deriveLocationTuple(md, rhs);
- if (locTuple != null) {
- rhsLocTuple.addAll(locTuple);
+ // lhs side
+ if (lhs.getType().getExtension() != null
+ && lhs.getType().getExtension() instanceof SSJavaType) {
+ lhsLocTuple.addAll(((SSJavaType) lhs.getType().getExtension()).getCompLoc()
+ .getTuple());
+ mapDescriptorToLocationPath.put(lhs, lhsLocTuple);
+ } else if (mapDescriptorToLocationPath.get(rhs) != null) {
+ // propagate rhs's location to lhs
+ lhsLocTuple.addAll(mapDescriptorToLocationPath.get(rhs));
+ mapDescriptorToLocationPath.put(lhs, lhsLocTuple);
}
}
- if (rhsLocTuple.size() > 0) {
- mapDescriptorToLocationPath.put(rhs, rhsLocTuple);
- }
- // lhs side
- if (lhs.getType().getExtension() != null
- && lhs.getType().getExtension() instanceof SSJavaType) {
- lhsLocTuple.addAll(((SSJavaType) lhs.getType().getExtension()).getCompLoc()
- .getTuple());
- mapDescriptorToLocationPath.put(lhs, lhsLocTuple);
- } else if (mapDescriptorToLocationPath.get(rhs) != null) {
- // propagate rhs's location to lhs
- lhsLocTuple.addAll(mapDescriptorToLocationPath.get(rhs));
- mapDescriptorToLocationPath.put(lhs, lhsLocTuple);
- }
- }
+ if (isEventLoopBody && lhs.getType().isPrimitive()
+ && !lhs.getSymbol().startsWith("srctmp")) {
- if (isEventLoopBody && lhs.getType().isPrimitive()
- && !lhs.getSymbol().startsWith("srctmp")) {
+ NTuple<Descriptor> lhsHeapPath = computePath(lhs);
- NTuple<Descriptor> lhsHeapPath = computePath(lhs);
+ if (lhsLocTuple != null) {
+ addMayWrittenSet(md, lhsLocTuple, lhsHeapPath);
+ }
- if (lhsLocTuple != null) {
- addMayWrittenSet(md, lhsLocTuple, lhsHeapPath);
}
-
+ } else {
+ break;
}
+
}
}
hasWriteEffect = true;
}
- if (hasWriteEffect) {
+ if (hasWriteEffect && mapHeapPath.containsKey(lhs)) {
// write(lhs)
- NTuple<Descriptor> rhsHeapPath = computePath(rhs);
NTuple<Descriptor> lhsHeapPath = new NTuple<Descriptor>();
- lhsHeapPath.addAll(rhsHeapPath);
+ lhsHeapPath.addAll(mapHeapPath.get(lhs));
Location lhsLoc = getLocation(lhs);
if (ssjava.isSharedLocation(lhsLoc)) {
fld = getArrayField(td);
}
- // write(field)
- NTuple<Descriptor> lhsHeapPath = computePath(lhs);
- NTuple<Descriptor> fldHeapPath = new NTuple<Descriptor>(lhsHeapPath.getList());
- if (fn.kind() == FKind.FlatSetFieldNode) {
- fldHeapPath.add(fld);
- }
-
- // shared loc extension
- Location fieldLoc;
- if (fn.kind() == FKind.FlatSetFieldNode) {
- fieldLoc = (Location) fld.getType().getExtension();
- } else {
- NTuple<Location> locTuple = mapDescriptorToLocationPath.get(lhs);
- fieldLoc = locTuple.get(locTuple.size() - 1);
- }
-
- if (ssjava.isSharedLocation(fieldLoc)) {
+ // set up heap path
+ NTuple<Descriptor> lhsHeapPath = mapHeapPath.get(lhs);
+ if (lhsHeapPath != null) {
+ // write(field)
+ NTuple<Descriptor> fldHeapPath = new NTuple<Descriptor>(lhsHeapPath.getList());
+ if (fn.kind() == FKind.FlatSetFieldNode) {
+ fldHeapPath.add(fld);
+ }
- NTuple<Location> fieldLocTuple = new NTuple<Location>();
- fieldLocTuple.addAll(mapDescriptorToLocationPath.get(lhs));
+ // shared loc extension
+ Location fieldLoc;
if (fn.kind() == FKind.FlatSetFieldNode) {
- fieldLocTuple.add(fieldLoc);
+ fieldLoc = (Location) fld.getType().getExtension();
+ } else {
+ NTuple<Location> locTuple = mapDescriptorToLocationPath.get(lhs);
+ fieldLoc = locTuple.get(locTuple.size() - 1);
}
- Set<NTuple<Descriptor>> writtenSet =
- mapFlatNodeToSharedLocMapping.get(fn).get(fieldLocTuple);
+ if (ssjava.isSharedLocation(fieldLoc)) {
+
+ NTuple<Location> fieldLocTuple = new NTuple<Location>();
+ fieldLocTuple.addAll(mapDescriptorToLocationPath.get(lhs));
+ if (fn.kind() == FKind.FlatSetFieldNode) {
+ fieldLocTuple.add(fieldLoc);
+ }
+
+ Set<NTuple<Descriptor>> writtenSet =
+ mapFlatNodeToSharedLocMapping.get(fn).get(fieldLocTuple);
+
+ if (isCovered(fieldLocTuple, writtenSet)) {
+ computeKILLSetForSharedWrite(curr, writtenSet, readWriteKillSet);
+ computeGENSetForSharedAllCoverWrite(curr, writtenSet, readWriteGenSet);
+ } else {
+ computeGENSetForSharedNonCoverWrite(curr, fldHeapPath, readWriteGenSet);
+ }
- if (isCovered(fieldLocTuple, writtenSet)) {
- computeKILLSetForSharedWrite(curr, writtenSet, readWriteKillSet);
- computeGENSetForSharedAllCoverWrite(curr, writtenSet, readWriteGenSet);
} else {
- computeGENSetForSharedNonCoverWrite(curr, fldHeapPath, readWriteGenSet);
+ computeKILLSetForWrite(curr, fldHeapPath, readWriteKillSet);
+ computeGENSetForWrite(fldHeapPath, readWriteGenSet);
}
- } else {
- computeKILLSetForWrite(curr, fldHeapPath, readWriteKillSet);
- computeGENSetForWrite(fldHeapPath, readWriteGenSet);
- }
+ // System.out.println("KILLSET=" + readWriteKillSet);
+ // System.out.println("GENSet=" + readWriteGenSet);
- // System.out.println("KILLSET=" + readWriteKillSet);
- // System.out.println("GENSet=" + readWriteGenSet);
+ }
}
break;
// System.out.println("KILLSET=" + readWriteKillSet);
// System.out.println("GENSet=" + readWriteGenSet);
- checkManyRead(fc, curr);
}
break;
}
computeNewMapping(curr, readWriteKillSet, readWriteGenSet);
+ if (fn instanceof FlatCall) {
+ checkManyRead((FlatCall) fn, curr);
+ }
+
// System.out.println("#######" + curr);
}
Set<NTuple<Descriptor>> coverSet =
mapMethodToSharedLocCoverSet.get(methodContainingSSJavaLoop).get(locTuple);
+ // System.out.println("locTuple=" + locTuple + " coverSet=" + coverSet +
+ // " currSet=" + inSet);
+
return inSet.containsAll(coverSet);
}
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();
if (isSharedLocation(heapPath)) {
NTuple<Location> locTuple = getLocationTuple(heapPath);
- if (isCovered(locTuple, sharedLocMap.get(locTuple))) {
+ if (isCovered(locTuple, sharedLocMap.get(locTuple)) && curr.containsKey(heapPath)) {
// if it is shared loc and corresponding shared loc has been covered
KILLSet.put(heapPath, curr.get(heapPath));
}
Set<MethodDescriptor> methodDescriptorsToAnalyze = new HashSet<MethodDescriptor>();
methodDescriptorsToAnalyze.addAll(ssjava.getAnnotationRequireSet());
sortedDescriptors = topologicalSort(methodDescriptorsToAnalyze);
+
+ liveInTempSetToEventLoop =
+ liveness.getLiveInTemps(state.getMethodFlat(methodContainingSSJavaLoop),
+ ssjava.getSSJavaLoopEntrance());
}
private void methodReadWriteSetAnalysis() {
mapFlatMethodToMustWriteSet.put(flatMethodContainingSSJavaLoop, mustWriteSet);
mapFlatMethodToMayWriteSet.put(flatMethodContainingSSJavaLoop, mayWriteSet);
+ for (Iterator iterator = liveInTempSetToEventLoop.iterator(); iterator.hasNext();) {
+ TempDescriptor liveIn = (TempDescriptor) iterator.next();
+ NTuple<Descriptor> heapPath = new NTuple<Descriptor>();
+ heapPath.add(liveIn);
+ mapHeapPath.put(liveIn, heapPath);
+ }
+
methodReadWriteSet_analyzeBody(ssjava.getSSJavaLoopEntrance(), readSet, mustWriteSet,
mayWriteSet, true);
// mapHeapPath.put(lhs, lhsHeapPath);
// } else
- if (rhsHeapPath != null) {
+ if (rhsHeapPath != null && (!lhs.getType().isPrimitive())) {
mapHeapPath.put(lhs, mapHeapPath.get(rhs));
} else {
- if (isEventLoopBody) {
- NTuple<Descriptor> heapPath = new NTuple<Descriptor>();
- heapPath.add(rhs);
- mapHeapPath.put(lhs, heapPath);
- } else {
- break;
- }
+ break;
+ // if (isEventLoopBody) {
+ // NTuple<Descriptor> lhsHeapPath = new NTuple<Descriptor>();
+ // lhsHeapPath.add(rhs);
+ // mapHeapPath.put(lhs, lhsHeapPath);
+ // } else {
+ // break;
+ // }
}
// shared loc extension
*----------------------------------------------------------------------
*/
-
-
/**
* Class Implementing Layer 3 Decoder.
*
// System.out.println("Counter = ................................."+counter);
// if (counter < 609)
// {
- counter++; // count should be loc*
+ // counter++; // count should be loc*
// buffer.write_buffer(1); // buffer!!!
// }
// else if (counter == 609)
si.ch[ch].gr[gr].big_values = sib.get_bits(9);
si.ch[ch].gr[gr].global_gain = sib.get_bits(8);
si.ch[ch].gr[gr].scalefac_compress = sib.get_bits(4);
- @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.TEMP") int cond =
- sib.get_bits(1);
+ @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.TEMP") int cond = sib.get_bits(1);
// si.ch[ch].gr[gr].window_switching_flag = sib.get_bits(1);
// if ((si.ch[ch].gr[gr].window_switching_flag) != 0) {
if (cond != 0) {
si.ch[ch].gr[0].global_gain = sib.get_bits(8);
si.ch[ch].gr[0].scalefac_compress = sib.get_bits(9);
- @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.TEMP") int cond =
- sib.get_bits(1);
+ @LOC("THIS,LayerIIIDecoder.SI,III_side_info_t.TEMP") int cond = sib.get_bits(1);
// si.ch[ch].gr[0].window_switching_flag = sib.get_bits(1);
// if ((si.ch[ch].gr[0].window_switching_flag) != 0) {
if (cond != 0) {
&& !(si.ch[ch].gr[gr].mixed_block_flag != 0))
return;
-
if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].mixed_block_flag != 0)
&& (si.ch[ch].gr[gr].block_type == 2)) {
sb18lim = 18;
// This may be adjusted for performance without any problems.
// public static final int POW_TABLE_LIMIT=512;
-
private static final int slen[][] = { { 0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
{ 0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3 } };
}
+/************************************************************/
+/* L3TABLE */
+/************************************************************/
+@LATTICE("N<VAR")
+class SBI {
+ @LOC("VAR")
+ public int[] l;
+ @LOC("VAR")
+ public int[] s;
+ public SBI() {
+ l = new int[23];
+ s = new int[14];
+ }
- /************************************************************/
- /* L3TABLE */
- /************************************************************/
+ @LATTICE("THIS<IN,THISLOC=THIS")
+ public SBI(@DELEGATE @LOC("IN") int[] thel, @DELEGATE @LOC("IN") int[] thes) {
+ l = thel;
+ s = thes;
+ }
+}
- @LATTICE("N<VAR")
- class SBI {
- @LOC("VAR")
- public int[] l;
- @LOC("VAR")
- public int[] s;
+@LATTICE("V,V*")
+class gr_info_s {
+ @LOC("V")
+ public int part2_3_length = 0;
+ @LOC("V")
+ public int big_values = 0;
+ @LOC("V")
+ public int global_gain = 0;
+ @LOC("V")
+ public int scalefac_compress = 0;
+ @LOC("V")
+ public int window_switching_flag = 0;
+ @LOC("V")
+ public int block_type = 0;
+ @LOC("V")
+ public int mixed_block_flag = 0;
+ @LOC("V")
+ public int[] table_select;
+ @LOC("V")
+ public int[] subblock_gain;
+ @LOC("V")
+ public int region0_count = 0;
+ @LOC("V")
+ public int region1_count = 0;
+ @LOC("V")
+ public int preflag = 0;
+ @LOC("V")
+ public int scalefac_scale = 0;
+ @LOC("V")
+ public int count1table_select = 0;
- public SBI() {
- l = new int[23];
- s = new int[14];
- }
-
- @LATTICE("THIS<IN,THISLOC=THIS")
- public SBI(@DELEGATE @LOC("IN") int[] thel, @DELEGATE @LOC("IN") int[] thes) {
- l = thel;
- s = thes;
- }
+ /**
+ * Dummy Constructor
+ */
+ public gr_info_s() {
+ table_select = new int[3];
+ subblock_gain = new int[3];
}
+}
- @LATTICE("V,V*")
- class gr_info_s {
- @LOC("V")
- public int part2_3_length = 0;
- @LOC("V")
- public int big_values = 0;
- @LOC("V")
- public int global_gain = 0;
- @LOC("V")
- public int scalefac_compress = 0;
- @LOC("V")
- public int window_switching_flag = 0;
- @LOC("V")
- public int block_type = 0;
- @LOC("V")
- public int mixed_block_flag = 0;
- @LOC("V")
- public int[] table_select;
- @LOC("V")
- public int[] subblock_gain;
- @LOC("V")
- public int region0_count = 0;
- @LOC("V")
- public int region1_count = 0;
- @LOC("V")
- public int preflag = 0;
- @LOC("V")
- public int scalefac_scale = 0;
- @LOC("V")
- public int count1table_select = 0;
-
- /**
- * Dummy Constructor
- */
- public gr_info_s() {
- table_select = new int[3];
- subblock_gain = new int[3];
- }
- }
+@LATTICE("GR2<GR1,GR1<GR,GR2*")
+class temporaire {
+ @LOC("GR")
+ public int[] scfsi;
+ @LOC("GR")
+ public gr_info_s[] gr;
- @LATTICE("GR2<GR1,GR1<GR,GR2*")
- class temporaire {
- @LOC("GR")
- public int[] scfsi;
- @LOC("GR")
- public gr_info_s[] gr;
-
- /**
- * Dummy Constructor
- */
- public temporaire() {
- scfsi = new int[4];
- gr = new gr_info_s[2];
- gr[0] = new gr_info_s();
- gr[1] = new gr_info_s();
- }
+ /**
+ * Dummy Constructor
+ */
+ public temporaire() {
+ scfsi = new int[4];
+ gr = new gr_info_s[2];
+ gr[0] = new gr_info_s();
+ gr[1] = new gr_info_s();
}
+}
- @LATTICE("CH<TEMP,TEMP*")
- class III_side_info_t {
-
- @LOC("CH")
- public int main_data_begin = 0;
- @LOC("CH")
- public int private_bits = 0;
- @LOC("CH")
- public temporaire[] ch;
-
- /**
- * Dummy Constructor
- */
- public III_side_info_t() {
- ch = new temporaire[2];
- ch[0] = new temporaire();
- ch[1] = new temporaire();
- }
+@LATTICE("CH<TEMP,TEMP*")
+class III_side_info_t {
+
+ @LOC("CH")
+ public int main_data_begin = 0;
+ @LOC("CH")
+ public int private_bits = 0;
+ @LOC("CH")
+ public temporaire[] ch;
+
+ /**
+ * Dummy Constructor
+ */
+ public III_side_info_t() {
+ ch = new temporaire[2];
+ ch[0] = new temporaire();
+ ch[1] = new temporaire();
}
+}
- @LATTICE("N<VAR")
- class temporaire2 {
- @LOC("VAR")
- public int[] l; /* [cb] */
- @LOC("VAR")
- public int[][] s; /* [window][cb] */
-
- /**
- * Dummy Constructor
- */
- public temporaire2() {
- l = new int[23];
- s = new int[3][13];
- }
+@LATTICE("N<VAR")
+class temporaire2 {
+ @LOC("VAR")
+ public int[] l; /* [cb] */
+ @LOC("VAR")
+ public int[][] s; /* [window][cb] */
+
+ /**
+ * Dummy Constructor
+ */
+ public temporaire2() {
+ l = new int[23];
+ s = new int[3][13];
}
+}
- // class III_scalefac_t
- // {
- // public temporaire2[] tab;
- // /**
- // * Dummy Constructor
- // */
- // public III_scalefac_t()
- // {
- // tab = new temporaire2[2];
- // }
- // }
+// class III_scalefac_t
+// {
+// public temporaire2[] tab;
+// /**
+// * Dummy Constructor
+// */
+// public III_scalefac_t()
+// {
+// tab = new temporaire2[2];
+// }
+// }