From: yeom Date: Mon, 13 Aug 2012 08:12:28 +0000 (+0000) Subject: changes. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=cdfc189fb3563488aa35b9faed2165a95aaee103 changes. --- diff --git a/Robust/src/Analysis/SSJava/LocationInference.java b/Robust/src/Analysis/SSJava/LocationInference.java index c9877d8e..6404a8f9 100644 --- a/Robust/src/Analysis/SSJava/LocationInference.java +++ b/Robust/src/Analysis/SSJava/LocationInference.java @@ -184,7 +184,14 @@ public class LocationInference { } private void addMapClassDefinitionToLineNum(ClassDescriptor cd, String strLine, int lineNum) { - String pattern = "class " + cd.getSymbol() + " "; + + String classSymbol = cd.getSymbol(); + int idx = classSymbol.lastIndexOf("$"); + if (idx != -1) { + classSymbol = classSymbol.substring(idx + 1); + } + + String pattern = "class " + classSymbol + " "; if (strLine.indexOf(pattern) != -1) { mapDescToDefinitionLine.put(cd, lineNum); } @@ -246,6 +253,8 @@ public class LocationInference { private String generateLatticeDefinition(Descriptor desc) { + Set sharedLocSet = new HashSet(); + SSJavaLattice lattice = getLattice(desc); String rtr = "@LATTICE(\""; @@ -266,6 +275,9 @@ public class LocationInference { first = false; } rtr += key; + if (lattice.isSharedLoc(key)) { + rtr += "," + key + "*"; + } } } @@ -279,6 +291,15 @@ public class LocationInference { first = false; } rtr += loc + "<" + key; + if (lattice.isSharedLoc(key) && (!sharedLocSet.contains(key))) { + rtr += "," + key + "*"; + sharedLocSet.add(key); + } + if (lattice.isSharedLoc(loc) && (!sharedLocSet.contains(loc))) { + rtr += "," + loc + "*"; + sharedLocSet.add(loc); + } + } } } @@ -303,63 +324,60 @@ public class LocationInference { readOriginalSourceFiles(); setupToAnalyze(); - while (!toAnalyzeIsEmpty()) { ClassDescriptor cd = toAnalyzeNext(); setupToAnalazeMethod(cd); LocationInfo locInfo = mapClassToLocationInfo.get(cd); - String sourceFileName = cd.getSourceFileName(); + if (cd.isInterface()) { + continue; + } + int classDefLine = mapDescToDefinitionLine.get(cd); Vector sourceVec = mapFileNameToLineVector.get(sourceFileName); - if (locInfo != null) { + if (locInfo == null) { + locInfo = getLocationInfo(cd); + } - Map mapDescToInferLoc = locInfo.getMapDescToInferLocation(); - Set fieldDescSet = mapDescToInferLoc.keySet(); - for (Iterator iterator = fieldDescSet.iterator(); iterator.hasNext();) { - Descriptor fieldDesc = (Descriptor) iterator.next(); - String locIdentifier = locInfo.getFieldInferLocation(fieldDesc).getLocIdentifier(); - if (!getLattice(cd).containsKey(locIdentifier)) { - getLattice(cd).put(locIdentifier); - } + for (Iterator iter = cd.getFields(); iter.hasNext();) { + Descriptor fieldDesc = (Descriptor) iter.next(); + String locIdentifier = locInfo.getFieldInferLocation(fieldDesc).getLocIdentifier(); + if (!getLattice(cd).containsKey(locIdentifier)) { + getLattice(cd).put(locIdentifier); } + } - String fieldLatticeDefStr = generateLatticeDefinition(cd); - String annoatedSrc = fieldLatticeDefStr + newline + sourceVec.get(classDefLine); - sourceVec.set(classDefLine, annoatedSrc); - - // generate annotations for field declarations - LocationInfo fieldLocInfo = getLocationInfo(cd); - Map inferLocMap = fieldLocInfo.getMapDescToInferLocation(); - - for (Iterator iter = cd.getFields(); iter.hasNext();) { - FieldDescriptor fd = (FieldDescriptor) iter.next(); + String fieldLatticeDefStr = generateLatticeDefinition(cd); + String annoatedSrc = fieldLatticeDefStr + newline + sourceVec.get(classDefLine); + sourceVec.set(classDefLine, annoatedSrc); - String locAnnotationStr; - if (inferLocMap.containsKey(fd)) { - CompositeLocation inferLoc = inferLocMap.get(fd); - locAnnotationStr = generateLocationAnnoatation(inferLoc); - } else { - // if the field is not accssed by SS part, just assigns dummy - // location - locAnnotationStr = "@LOC(\"LOC\")"; - } - int fdLineNum = fd.getLineNum(); - String orgFieldDeclarationStr = sourceVec.get(fdLineNum); - String fieldDeclaration = fd.toString(); - fieldDeclaration = fieldDeclaration.substring(0, fieldDeclaration.length() - 1); + // generate annotations for field declarations + LocationInfo fieldLocInfo = getLocationInfo(cd); + Map inferLocMap = fieldLocInfo.getMapDescToInferLocation(); - int idx = orgFieldDeclarationStr.indexOf(fieldDeclaration); - String annoatedStr = - orgFieldDeclarationStr.substring(0, idx) + locAnnotationStr + " " - + orgFieldDeclarationStr.substring(idx); - sourceVec.set(fdLineNum, annoatedStr); + for (Iterator iter = cd.getFields(); iter.hasNext();) { + FieldDescriptor fd = (FieldDescriptor) iter.next(); + String locAnnotationStr; + if (inferLocMap.containsKey(fd)) { + CompositeLocation inferLoc = inferLocMap.get(fd); + locAnnotationStr = generateLocationAnnoatation(inferLoc); + } else { + // if the field is not accssed by SS part, just assigns dummy + // location + locAnnotationStr = "@LOC(\"LOC\")"; } + int fdLineNum = fd.getLineNum(); + String orgFieldDeclarationStr = sourceVec.get(fdLineNum); + String fieldDeclaration = fd.toString(); + fieldDeclaration = fieldDeclaration.substring(0, fieldDeclaration.length() - 1); + + String annoatedStr = locAnnotationStr + " " + orgFieldDeclarationStr; + sourceVec.set(fdLineNum, annoatedStr); } @@ -372,22 +390,23 @@ public class LocationInference { MethodLocationInfo methodLocInfo = getMethodLocationInfo(md); - Map inferLocMap = + Map methodInferLocMap = methodLocInfo.getMapDescToInferLocation(); - Set localVarDescSet = inferLocMap.keySet(); + Set localVarDescSet = methodInferLocMap.keySet(); for (Iterator iterator = localVarDescSet.iterator(); iterator.hasNext();) { Descriptor localVarDesc = (Descriptor) iterator.next(); - CompositeLocation inferLoc = inferLocMap.get(localVarDesc); + CompositeLocation inferLoc = methodInferLocMap.get(localVarDesc); String locAnnotationStr = generateLocationAnnoatation(inferLoc); if (!isParameter(md, localVarDesc)) { if (mapDescToDefinitionLine.containsKey(localVarDesc)) { int varLineNum = mapDescToDefinitionLine.get(localVarDesc); - String orgSourceLine = sourceVec.get(varLineNum); - int idx = orgSourceLine.indexOf(localVarDesc.toString()); + int idx = + orgSourceLine.indexOf(generateVarDeclaration((VarDescriptor) localVarDesc)); + assert (idx != -1); String annoatedStr = orgSourceLine.substring(0, idx) + locAnnotationStr + " " + orgSourceLine.substring(idx); @@ -395,7 +414,7 @@ public class LocationInference { } } else { String methodDefStr = sourceVec.get(methodDefLine); - int idx = methodDefStr.indexOf(localVarDesc.toString()); + int idx = methodDefStr.indexOf(generateVarDeclaration((VarDescriptor) localVarDesc)); assert (idx != -1); String annoatedStr = methodDefStr.substring(0, idx) + locAnnotationStr + " " @@ -411,11 +430,26 @@ public class LocationInference { } } + } codeGen(); } + private String generateVarDeclaration(VarDescriptor varDesc) { + + TypeDescriptor td = varDesc.getType(); + String rtr = td.toString(); + if (td.isArray()) { + for (int i = 0; i < td.getArrayCount(); i++) { + rtr += "[]"; + } + } + rtr += " " + varDesc.getName(); + return rtr; + + } + private String generateLocationAnnoatation(CompositeLocation loc) { String rtr = "@LOC(\""; diff --git a/Robust/src/Benchmarks/SSJava/MP3DecoderInfer/LayerIIIDecoder.java b/Robust/src/Benchmarks/SSJava/MP3DecoderInfer/LayerIIIDecoder.java index d0f217dc..c022ba06 100644 --- a/Robust/src/Benchmarks/SSJava/MP3DecoderInfer/LayerIIIDecoder.java +++ b/Robust/src/Benchmarks/SSJava/MP3DecoderInfer/LayerIIIDecoder.java @@ -197,8 +197,7 @@ final class LayerIIIDecoder implements FrameDecoder { channels = (header.mode() == Header.SINGLE_CHANNEL) ? 1 : 2; max_gr = (header.version() == Header.MPEG1) ? 2 : 1; - sfreq = header.sample_frequency() + ((header.version() == Header.MPEG1) ? 3 - : (header.version() == Header.MPEG25_LSF) ? 6 : 0); // SZD + sfreq = header.sample_frequency() + ((header.version() == Header.MPEG1) ? 3 : (header.version() == Header.MPEG25_LSF) ? 6 : 0); // SZD if (channels == 2) { switch (which_channels) { @@ -1068,10 +1067,10 @@ final class LayerIIIDecoder implements FrameDecoder { private void huffman_decode(int part2_start_local, int ch, int gr) { - int x[] = new int[1]; - int y[] = new int[1]; - int v[] = new int[1]; - int w[] = new int[1]; + int[] x = new int[1]; + int[] y = new int[1]; + int[] v = new int[1]; + int[] w = new int[1]; int part2_3_end = part2_start_local + si.ch[ch].gr[gr].part2_3_length; int num_bits; @@ -1204,8 +1203,7 @@ final class LayerIIIDecoder implements FrameDecoder { // // ssjava - private void dequantize_sample( - /* float xr[][], */int ch, int gr) { + private void dequantize_sample(int ch, int gr) { // gr_info_s gr_info = (si.ch[ch].gr[gr]); remove alias! int cb = 0; @@ -1367,7 +1365,7 @@ final class LayerIIIDecoder implements FrameDecoder { // ssjava // - private void reorder(/* float xr[][], */int ch, int gr) { + private void reorder(int ch, int gr) { // the purpose of reordering: move 'short samples' back to their original // position // after reorder, the samples are no long ordered by frequency @@ -2403,7 +2401,7 @@ final class LayerIIIDecoder implements FrameDecoder { * ExceptionInInitializerError(ex); } } */ - static int[] reorder(int scalefac_band[]) { // SZD: converted from + static int[] reorder(int[] scalefac_band) { // SZD: converted from // LAME int j = 0; int ix[] = new int[576]; diff --git a/Robust/src/Benchmarks/SSJava/MP3DecoderInfer/infer/makefile b/Robust/src/Benchmarks/SSJava/MP3DecoderInfer/infer/makefile index 4a126244..5304e86a 100644 --- a/Robust/src/Benchmarks/SSJava/MP3DecoderInfer/infer/makefile +++ b/Robust/src/Benchmarks/SSJava/MP3DecoderInfer/infer/makefile @@ -1,4 +1,4 @@ -BUILDSCRIPT=../../../buildscript +BUILDSCRIPT=../../../../buildscript PROGRAM=MP3Player SOURCE_FILES=MP3Player.java Player.java