From: yeom Date: Wed, 27 Jul 2011 18:57:46 +0000 (+0000) Subject: changes: 1) generate a class lattice graph DOT file for the debug mode. it makes... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=73fba8f27deccb38b873d0efe40e33d55a71c54a changes: 1) generate a class lattice graph DOT file for the debug mode. it makes annotation and debug easier 2) updates more annotation --- diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index 375e92e8..11f3f2e3 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -1595,14 +1595,14 @@ public class FlowDownCheck { // check if the shared location is appeared only at the end of the // composite location - if (lattice.getSpinLocSet().contains(loc1.getLocIdentifier())) { + if (lattice.getSharedLocSet().contains(loc1.getLocIdentifier())) { if (i != (compLoc1.getSize() - 1)) { throw new Error("The shared location " + loc1.getLocIdentifier() + " cannot be appeared in the middle of composite location at" + msg); } } - if (lattice.getSpinLocSet().contains(loc2.getLocIdentifier())) { + if (lattice.getSharedLocSet().contains(loc2.getLocIdentifier())) { if (i != (compLoc2.getSize() - 1)) { throw new Error("The shared location " + loc2.getLocIdentifier() + " cannot be appeared in the middle of composite location at " + msg); @@ -1621,7 +1621,7 @@ public class FlowDownCheck { // note that the spinning location only can be appeared in the last // part of the composite location if (awareSharedLoc && numOfTie == compLoc1.getSize() - && lattice.getSpinLocSet().contains(loc1.getLocIdentifier())) { + && lattice.getSharedLocSet().contains(loc1.getLocIdentifier())) { return ComparisonResult.GREATER; } continue; diff --git a/Robust/src/Analysis/SSJava/SSJavaAnalysis.java b/Robust/src/Analysis/SSJava/SSJavaAnalysis.java index 5e0d556f..dd4a5b29 100644 --- a/Robust/src/Analysis/SSJava/SSJavaAnalysis.java +++ b/Robust/src/Analysis/SSJava/SSJavaAnalysis.java @@ -1,5 +1,8 @@ package Analysis.SSJava; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; @@ -19,6 +22,7 @@ import IR.TypeUtil; import IR.Flat.BuildFlat; import IR.Flat.FlatMethod; import IR.Flat.TempDescriptor; +import Util.Pair; public class SSJavaAnalysis { @@ -128,6 +132,12 @@ public class SSJavaAnalysis { new SSJavaLattice(SSJavaLattice.TOP, SSJavaLattice.BOTTOM); cd2lattice.put(cd, locOrder); parseClassLatticeDefinition(cd, an.getValue(), locOrder); + + if (state.SSJAVADEBUG) { + // generate lattice dot file + writeLatticeDotFile(cd, locOrder); + } + } else if (marker.equals(METHODDEFAULT)) { MethodLattice locOrder = new MethodLattice(SSJavaLattice.TOP, SSJavaLattice.BOTTOM); @@ -170,6 +180,40 @@ public class SSJavaAnalysis { } } + private void writeLatticeDotFile(ClassDescriptor cd, SSJavaLattice locOrder) { + + String className = cd.getSymbol().replaceAll("[\\W_]", ""); + + Set> pairSet = locOrder.getOrderingPairSet(); + + try { + BufferedWriter bw = new BufferedWriter(new FileWriter(className + ".dot")); + + bw.write("digraph " + className + " {\n"); + + for (Iterator iterator = pairSet.iterator(); iterator.hasNext();) { + // pair is in the form of + Pair pair = (Pair) iterator.next(); + + String highLocId = pair.getFirst(); + if (locOrder.isSharedLoc(highLocId)) { + highLocId = "\"" + highLocId + "*\""; + } + String lowLocId = pair.getSecond(); + if (locOrder.isSharedLoc(lowLocId)) { + lowLocId = "\"" + lowLocId + "*\""; + } + bw.write(highLocId + " -> " + lowLocId + ";\n"); + } + bw.write("}\n"); + bw.close(); + + } catch (IOException e) { + e.printStackTrace(); + } + + } + private void parseMethodDefaultLatticeDefinition(ClassDescriptor cd, String value, MethodLattice locOrder) { @@ -199,7 +243,7 @@ public class SSJavaAnalysis { locOrder.setReturnLoc(returnLoc); } else if (orderElement.contains("*")) { // spin loc definition - locOrder.addSpinLoc(orderElement.substring(0, orderElement.length() - 1)); + locOrder.addSharedLoc(orderElement.substring(0, orderElement.length() - 1)); } else { // single element locOrder.put(orderElement); @@ -239,7 +283,7 @@ public class SSJavaAnalysis { } } else if (orderElement.contains("*")) { // spin loc definition - locOrder.addSpinLoc(orderElement.substring(0, orderElement.length() - 1)); + locOrder.addSharedLoc(orderElement.substring(0, orderElement.length() - 1)); } else { // single element locOrder.put(orderElement); @@ -247,7 +291,7 @@ public class SSJavaAnalysis { } // sanity check - Set spinLocSet = locOrder.getSpinLocSet(); + Set spinLocSet = locOrder.getSharedLocSet(); for (Iterator iterator = spinLocSet.iterator(); iterator.hasNext();) { String spinLoc = (String) iterator.next(); if (!locOrder.containsKey(spinLoc)) { @@ -345,7 +389,7 @@ public class SSJavaAnalysis { public boolean isSharedLocation(Location loc) { SSJavaLattice lattice = getLattice(loc.getDescriptor()); - return lattice.getSpinLocSet().contains(loc.getLocIdentifier()); + return lattice.getSharedLocSet().contains(loc.getLocIdentifier()); } public void mapSharedLocation2Descriptor(Location loc, Descriptor d) { diff --git a/Robust/src/Analysis/SSJava/SSJavaLattice.java b/Robust/src/Analysis/SSJava/SSJavaLattice.java index 7b8d8620..e0dec6cb 100644 --- a/Robust/src/Analysis/SSJava/SSJavaLattice.java +++ b/Robust/src/Analysis/SSJava/SSJavaLattice.java @@ -6,23 +6,27 @@ import java.util.Set; import Util.Lattice; public class SSJavaLattice extends Lattice { - - public static final String TOP="_top_"; - public static final String BOTTOM="_bottom_"; - Set spinLocSet; + public static final String TOP = "_top_"; + public static final String BOTTOM = "_bottom_"; + + Set sharedLocSet; public SSJavaLattice(T top, T bottom) { super(top, bottom); - spinLocSet = new HashSet(); + sharedLocSet = new HashSet(); + } + + public Set getSharedLocSet() { + return sharedLocSet; } - public Set getSpinLocSet() { - return spinLocSet; + public void addSharedLoc(T loc) { + sharedLocSet.add(loc); } - public void addSpinLoc(T loc) { - spinLocSet.add(loc); + public boolean isSharedLoc(T loc) { + return sharedLocSet.contains(loc); } } diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java index e3006572..6bdfddfc 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java @@ -37,7 +37,7 @@ * * @since 0.0 */ -//@LATTICE("FS 0; bytes_to_discard--){ + for (; bytes_to_discard > 0; bytes_to_discard--) { // bytes_to_discard > br br.hgetbits(8); } @@ -368,7 +368,8 @@ final class LayerIIIDecoder implements FrameDecoder { // here, decoding the compressed audio data huffman_decode(ch, gr); // no need to care from this side // System.out.println("CheckSum HuffMan = " + CheckSumHuff); - dequantize_sample(ro[ch], ch, gr); // no need to care from this side + dequantize_sample(/* ro[ch], */ch, gr); // no need to care from this + // side } stereo(gr); // no need to care from this side @@ -385,7 +386,7 @@ final class LayerIIIDecoder implements FrameDecoder { // read set= lr,ch,gr,out_1d, sb18, ss, SSLIMIT, out_1d // write set= out_1d - reorder(lr[ch], ch, gr); + reorder(/* lr[ch], */ch, gr); antialias(ch, gr); // for (int hb = 0;hb<576;hb++) CheckSumOut1d = CheckSumOut1d + // out_1d[hb]; @@ -578,7 +579,9 @@ final class LayerIIIDecoder implements FrameDecoder { * */ @LATTICE("THIS 0) - xr[quotien][reste] = g_gain * t_43[abv]; + ro[ch][quotien][reste] = g_gain * t_43[abv]; else { if (-abv < t_43.length) - xr[quotien][reste] = -g_gain * t_43[-abv]; + ro[ch][quotien][reste] = -g_gain * t_43[-abv]; else - xr[quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); + ro[ch][quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); } } else { if (is_1d[j] > 0) - xr[quotien][reste] = g_gain * (float) Math.pow(abv, d43); + ro[ch][quotien][reste] = g_gain * (float) Math.pow(abv, d43); else - xr[quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); + ro[ch][quotien][reste] = -g_gain * (float) Math.pow(-abv, d43); } } } @@ -1094,7 +1101,7 @@ final class LayerIIIDecoder implements FrameDecoder { @LOC("IDX") int idx = scalefac[ch].s[t_index][cb] << gr_info.scalefac_scale; idx += (gr_info.subblock_gain[t_index] << 2); - xr[quotien][reste] *= two_to_negative_half_pow[idx]; + ro[ch][quotien][reste] *= two_to_negative_half_pow[idx]; } else { // LONG block types 0,1,3 & 1st 2 subbands of switched blocks /* @@ -1107,7 +1114,7 @@ final class LayerIIIDecoder implements FrameDecoder { idx += pretab[cb]; idx = idx << gr_info.scalefac_scale; - xr[quotien][reste] *= two_to_negative_half_pow[idx]; + ro[ch][quotien][reste] *= two_to_negative_half_pow[idx]; } index++; } @@ -1120,7 +1127,7 @@ final class LayerIIIDecoder implements FrameDecoder { reste = 0; if (quotien < 0) quotien = 0; - xr[quotien][reste] = 0.0f; + ro[ch][quotien][reste] = 0.0f; } return; @@ -1130,7 +1137,8 @@ final class LayerIIIDecoder implements FrameDecoder { * */ @LATTICE("THIS