From 34e201e35ec38f4d644a5279a9fa6d9a4ca1e08d Mon Sep 17 00:00:00 2001 From: yeom Date: Tue, 7 Aug 2012 01:19:59 +0000 Subject: [PATCH] changes. --- Robust/src/Analysis/SSJava/FlowDownCheck.java | 27 ++++++++------- .../Analysis/SSJava/LocationInference.java | 33 ++++++++++++------- .../SSJava/MP3Decoder/LayerIIIDecoder.java | 10 +++--- .../SSJava/MP3Decoder/huffcodetab.java | 5 +-- 4 files changed, 45 insertions(+), 30 deletions(-) diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index f466b0ed..85b36731 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -1162,11 +1162,10 @@ public class FlowDownCheck { private void checkCalleeConstraints(MethodDescriptor md, SymbolTable nametable, MethodInvokeNode min, CompositeLocation callerBaseLoc, CompositeLocation constraint) { - // System.out.println("checkCalleeConstraints=" + min.printNode(0)); - MethodDescriptor calleemd = min.getMethod(); MethodLattice calleeLattice = ssjava.getMethodLattice(calleemd); + CompositeLocation calleeThisLoc = new CompositeLocation(new Location(calleemd, calleeLattice.getThisLoc())); @@ -1179,7 +1178,8 @@ public class FlowDownCheck { // setup caller args set // first, add caller's base(this) location - callerArgList.add(callerBaseLoc); + if (!calleemd.isStatic()) + callerArgList.add(callerBaseLoc); // second, add caller's arguments for (int i = 0; i < min.numArgs(); i++) { ExpressionNode en = min.getArg(i); @@ -1191,7 +1191,8 @@ public class FlowDownCheck { // setup callee params set // first, add callee's this location - calleeParamList.add(calleeThisLoc); + if (!calleemd.isStatic()) + calleeParamList.add(calleeThisLoc); // second, add callee's parameters for (int i = 0; i < calleemd.numParameters(); i++) { VarDescriptor calleevd = (VarDescriptor) calleemd.getParameter(i); @@ -1499,26 +1500,28 @@ public class FlowDownCheck { } } + Set inputGLB = new HashSet(); if (left instanceof ArrayAccessNode) { ArrayAccessNode aan = (ArrayAccessNode) left; - left = aan.getExpression(); + CompositeLocation indexLoc = + checkLocationFromExpressionNode(md, nametable, aan.getIndex(), loc, constraint, false); + inputGLB.add(indexLoc); } loc = checkLocationFromExpressionNode(md, nametable, left, loc, constraint, false); - // System.out.println("### checkLocationFromFieldAccessNode=" + - // fan.printNode(0)); - // System.out.println("### left=" + left.printNode(0)); if (!left.getType().isPrimitive()) { - if (fd.getSymbol().equals("length")) { + if (!fd.getSymbol().equals("length")) { // array.length access, return the location of the array - return loc; + Location fieldLoc = getFieldLocation(fd); + loc.addLocation(fieldLoc); } - Location fieldLoc = getFieldLocation(fd); - loc.addLocation(fieldLoc); } + + inputGLB.add(loc); + loc = CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(md.getClassDesc(), fan)); return loc; } diff --git a/Robust/src/Analysis/SSJava/LocationInference.java b/Robust/src/Analysis/SSJava/LocationInference.java index 7d7ad44e..64aa39ad 100644 --- a/Robust/src/Analysis/SSJava/LocationInference.java +++ b/Robust/src/Analysis/SSJava/LocationInference.java @@ -1039,7 +1039,6 @@ public class LocationInference { if (isCompositeLocation(inNodeInferLoc)) { // need to make sure that newLocSymbol is lower than the infernode // location in the field lattice - addRelation(methodLattice, methodInfo, inNodeInferLoc, inferLocation); } @@ -1065,13 +1064,14 @@ public class LocationInference { continue; } - - CompositeLocation outNodeInferLoc= generateInferredCompositeLocation(methodInfo, flowGraph.getLocationTuple(localOutNode)); + CompositeLocation outNodeInferLoc = + generateInferredCompositeLocation(methodInfo, + flowGraph.getLocationTuple(localOutNode)); if (isCompositeLocation(outNodeInferLoc)) { // need to make sure that newLocSymbol is higher than the infernode // location - + addRelation(methodLattice, methodInfo, inferLocation, outNodeInferLoc); } @@ -1117,8 +1117,6 @@ public class LocationInference { // return; // } Set cycleElementSet = lattice.getPossibleCycleElements(higher, lower); - System.out.println("#Check cycle=" + lower + " < " + higher); - System.out.println("#cycleElementSet=" + cycleElementSet); boolean hasNonPrimitiveElement = false; for (Iterator iterator = cycleElementSet.iterator(); iterator.hasNext();) { @@ -1132,6 +1130,8 @@ public class LocationInference { } if (hasNonPrimitiveElement) { + System.out.println("#Check cycle= " + lower + " < " + higher + " cycleElementSet=" + + cycleElementSet); // if there is non-primitive element in the cycle, no way to merge cyclic // elements into the shared location throw new CyclicFlowException(); @@ -1517,7 +1517,7 @@ public class LocationInference { case Kind.FieldAccessNode: flowTuple = analyzeFlowFieldAccessNode(md, nametable, (FieldAccessNode) en, nodeSet, base, - implicitFlowTupleSet); + implicitFlowTupleSet, isLHS); if (flowTuple != null) { nodeSet.addTuple(flowTuple); } @@ -1918,7 +1918,7 @@ public class LocationInference { private NTuple analyzeFlowFieldAccessNode(MethodDescriptor md, SymbolTable nametable, FieldAccessNode fan, NodeTupleSet nodeSet, NTuple base, - NodeTupleSet implicitFlowTupleSet) { + NodeTupleSet implicitFlowTupleSet, boolean isLHS) { ExpressionNode left = fan.getExpression(); TypeDescriptor ltd = left.getType(); @@ -1938,12 +1938,15 @@ public class LocationInference { } if (left instanceof ArrayAccessNode) { + ArrayAccessNode aan = (ArrayAccessNode) left; left = aan.getExpression(); + analyzeFlowExpressionNode(md, nametable, aan.getIndex(), nodeSet, base, implicitFlowTupleSet, + isLHS); } // fanNodeSet base = - analyzeFlowExpressionNode(md, nametable, left, nodeSet, base, implicitFlowTupleSet, false); + analyzeFlowExpressionNode(md, nametable, left, nodeSet, base, implicitFlowTupleSet, isLHS); if (base == null) { // in this case, field is TOP location return null; @@ -1951,9 +1954,8 @@ public class LocationInference { if (!left.getType().isPrimitive()) { - if (fd.getSymbol().equals("length")) { + if (!fd.getSymbol().equals("length")) { // array.length access, just have the location of the array - } else { base.add(fd); } @@ -2036,6 +2038,15 @@ public class LocationInference { addFlowGraphEdge(md, tuple, tuple); } + // creates edges from implicitFlowTupleSet to LHS + for (Iterator> iter = implicitFlowTupleSet.iterator(); iter.hasNext();) { + NTuple fromTuple = iter.next(); + for (Iterator> iter2 = nodeSetLHS.iterator(); iter2.hasNext();) { + NTuple toTuple = iter2.next(); + addFlowGraphEdge(md, fromTuple, toTuple); + } + } + } } diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/LayerIIIDecoder.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/LayerIIIDecoder.java index 52fdb3d4..c6766010 100644 --- a/Robust/src/Benchmarks/SSJava/MP3Decoder/LayerIIIDecoder.java +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/LayerIIIDecoder.java @@ -56,7 +56,7 @@ final class LayerIIIDecoder implements FrameDecoder { // MDM: removed, as this wasn't being used. // private float CheckSumOut1d = 0.0f; - @LOC("SI1") + @LOC("IS1D") private int CheckSumHuff = 0; @LOC("IS1D") private int[] is_1d; @@ -1106,10 +1106,10 @@ final class LayerIIIDecoder implements FrameDecoder { private void huffman_decode(@LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int part2_start_local, @LOC("THIS,LayerIIIDecoder.CH0") int ch, @LOC("THIS,LayerIIIDecoder.CH0") int gr) { - @LOC("RE") int x[] = new int[1]; - @LOC("RE") int y[] = new int[1]; - @LOC("RE") int v[] = new int[1]; - @LOC("RE") int w[] = new int[1]; + @LOC("THIS,LayerIIIDecoder.IS1D") int x[] = new int[1]; + @LOC("THIS,LayerIIIDecoder.IS1D") int y[] = new int[1]; + @LOC("THIS,LayerIIIDecoder.IS1D") int v[] = new int[1]; + @LOC("THIS,LayerIIIDecoder.IS1D") int w[] = new int[1]; @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int part2_3_end = part2_start_local + si.ch[ch].gr[gr].part2_3_length; diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java index ae59051b..895f95fd 100644 --- a/Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java @@ -506,13 +506,14 @@ final class huffcodetab { * Do the huffman-decoding. note! for counta,countb -the 4 bit value is * returned in y, discard x. */ - @LATTICE("OUT