From db9832ecde6c582526730ce0e0822cfb71e7d85e Mon Sep 17 00:00:00 2001 From: yeom Date: Sat, 27 Aug 2011 05:02:41 +0000 Subject: [PATCH] it passes the definitely written analysis. the current implementation of the synthesis filter assumes to have the previous internal array values of the previous granule when it combines the subbands to the original PCM signal. So it calls for introducing the temporal data structure keeping the previous ones and making it fall down once per a loop. seems to sacrifice memory spaces for desireable properties but still looking for a better idea to handle it. --- .../SSJava/DefinitelyWrittenCheck.java | 16 +- .../src/Analysis/SSJava/SSJavaAnalysis.java | 12 +- .../ssJava/mp3decoder/LayerIIIDecoder.java | 165 ++++++----- .../ssJava/mp3decoder/SynthesisFilter.java | 261 +++++++++++++++--- 4 files changed, 330 insertions(+), 124 deletions(-) diff --git a/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java b/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java index cec3a49d..c1dfbbbc 100644 --- a/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java +++ b/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java @@ -35,6 +35,8 @@ public class DefinitelyWrittenCheck { State state; CallGraph callGraph; + int debugcount = 0; + // maps a descriptor to its known dependents: namely // methods or tasks that call the descriptor's method // AND are part of this analysis (reachable from main) @@ -833,6 +835,10 @@ public class DefinitelyWrittenCheck { writtenAnalysis_analyzeLoop(); + if (debugcount > 0) { + throw new Error(); + } + } private void writtenAnalysis_analyzeLoop() { @@ -999,7 +1005,6 @@ public class DefinitelyWrittenCheck { // READ_bound set // of callee: callee has 'read' requirement! - for (Iterator iterator = calleeUnionBoundReadSet.iterator(); iterator.hasNext();) { NTuple read = (NTuple) iterator.next(); Hashtable gen = curr.get(read); @@ -1174,13 +1179,15 @@ public class DefinitelyWrittenCheck { NTuple write = (NTuple) iterator.next(); if (hp.startsWith(write)) { // it has write effect! - //throw new Error( - System.out.println("###"+ - "There is a variable, which is reachable through references " + // throw new Error( + System.out + .println("###" + + "There is a variable, which is reachable through references " + hp + ", who comes back to the same read statement without being overwritten at the out-most iteration at " + methodContainingSSJavaLoop.getClassDesc().getSourceFileName() + "::" + fn.getNumLine()); + debugcount++; } } } @@ -1323,7 +1330,6 @@ public class DefinitelyWrittenCheck { } - } private void methodReadOverWrite_nodeActions(FlatNode fn, Set> writtenSet, diff --git a/Robust/src/Analysis/SSJava/SSJavaAnalysis.java b/Robust/src/Analysis/SSJava/SSJavaAnalysis.java index 28635cab..e2b63da2 100644 --- a/Robust/src/Analysis/SSJava/SSJavaAnalysis.java +++ b/Robust/src/Analysis/SSJava/SSJavaAnalysis.java @@ -102,13 +102,13 @@ public class SSJavaAnalysis { public void doCheck() { doMethodAnnotationCheck(); - // computeLinearTypeCheckMethodSet(); - // doLinearTypeCheck(); - if (state.SSJAVADEBUG) { - debugPrint(); - } + computeLinearTypeCheckMethodSet(); + doLinearTypeCheck(); + // if (state.SSJAVADEBUG) { + // debugPrint(); + // } parseLocationAnnotation(); - // doFlowDownCheck(); + doFlowDownCheck(); doDefinitelyWrittenCheck(); // debugDoLoopCheck(); } diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java index 553eda55..812d363f 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIIIDecoder.java @@ -47,7 +47,7 @@ // 10th added for get_scale_factors // llth added for decode // @LATTICE("IS1D*,RO // the body - // in the body - // read set= lr,ch,gr,out_1d, sb18, ss, SSLIMIT, out_1d - // write set= out_1d - reorder(/* lr[ch], */ch, gr); antialias(ch, gr); @@ -598,6 +599,8 @@ final class LayerIIIDecoder implements FrameDecoder { sb++; // sb should be loc* } filter1.input_samples(samples1); + // System.out.println("filter1 writepos=" + filter1.actual_write_pos + // + " vidx=" + filter1.vidx); filter1.calculate_pcm_samples(); } } else { @@ -612,7 +615,8 @@ final class LayerIIIDecoder implements FrameDecoder { filter2.calculate_pcm_samples(); } } - + // System.out.println("#END CH=" + ch + " actual_write_pos=" + + // filter1.actual_write_pos); } // channels // TODO @@ -625,9 +629,16 @@ final class LayerIIIDecoder implements FrameDecoder { // prevblck[chidx][sidx] = raw_full[chidx][sidx]; // } // } - + // System.out.println("#END GR=" + gr + " actual_write_pos=" + + // filter1.actual_write_pos); } // granule + // System.out.println("#END FRAME actual_write_pos=" + + // filter1.actual_write_pos); + + filter1.clear(); + filter2.clear(); + // System.out.println("Counter = ................................."+counter); // if (counter < 609) // { @@ -994,9 +1005,9 @@ final class LayerIIIDecoder implements FrameDecoder { } } - for (@LOC("THIS,LayerIIIDecoder.NS") int x = 0; x < 45; x++) - // why 45, not 54? - scalefac_buffer[x] = 0; + // for (@LOC("THIS,LayerIIIDecoder.NS") int x = 0; x < 45; x++) + // // why 45, not 54? + // scalefac_buffer[x] = 0; m = 0; for (@LOC("THIS,LayerIIIDecoder.NS") int i = 0; i < 4; i++) { @@ -1813,8 +1824,8 @@ final class LayerIIIDecoder implements FrameDecoder { for (ss = 0; ss < 8; ss++) { @LOC("THIS,LayerIIIDecoder.SI1") int src_idx1 = sb18 + 17 - ss; @LOC("THIS,LayerIIIDecoder.SI1") int src_idx2 = sb18 + 18 + ss; - @LOC("THIS,LayerIIIDecoder.OUT") float bu = inter[src_idx1]; - @LOC("THIS,LayerIIIDecoder.OUT") float bd = inter[src_idx2]; + @LOC("THIS,LayerIIIDecoder.OUT0") float bu = inter[src_idx1]; + @LOC("THIS,LayerIIIDecoder.OUT0") float bd = inter[src_idx2]; inter[src_idx1] = (bu * cs[ss]) - (bd * ca[ss]); inter[src_idx2] = (bd * cs[ss]) + (bu * ca[ss]); } @@ -1827,9 +1838,9 @@ final class LayerIIIDecoder implements FrameDecoder { // MDM: tsOutCopy and rawout do not need initializing, so the arrays // can be reused. - @LOC("OUT") + @LOC("TSOUT") float[] tsOutCopy = new float[18]; - @LOC("OUT") + @LOC("RAWOUT") float[] rawout = new float[36]; @LATTICE("THIS