From 338b40f8f52cf09dc5fcef67796acc65a69758b9 Mon Sep 17 00:00:00 2001 From: yeom Date: Thu, 2 Aug 2012 00:48:32 +0000 Subject: [PATCH] add PCLOC annotations. all three benchmarks are type-checked now. --- Robust/src/Analysis/SSJava/FlowDownCheck.java | 55 +++++++++---------- .../SSJava/EyeTracking/Classifier.java | 1 + .../SSJava/EyeTracking/ClassifierTree.java | 6 +- .../SSJava/EyeTracking/LEAImplementation.java | 4 +- .../SSJava/MP3Decoder/BitReserve.java | 1 + .../SSJava/MP3Decoder/Equalizer.java | 1 + .../SSJava/MP3Decoder/LayerIIIDecoder.java | 4 ++ .../SSJava/MP3Decoder/SideInfoBuffer.java | 3 +- .../SSJava/MP3Decoder/huffcodetab.java | 1 + Robust/src/ClassLibrary/SSJava/Math.java | 1 + 10 files changed, 46 insertions(+), 31 deletions(-) diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index 2e879b18..a16a6e9f 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -903,7 +903,7 @@ public class FlowDownCheck { CompositeLocation constraint) { ClassDescriptor cd = md.getClassDesc(); - MethodDescriptor calleeMD = min.getMethod(); + MethodDescriptor calleeMethodDesc = min.getMethod(); NameDescriptor baseName = min.getBaseName(); boolean isSystemout = false; @@ -911,8 +911,9 @@ public class FlowDownCheck { isSystemout = baseName.getSymbol().equals("System.out"); } - if (!ssjava.isSSJavaUtil(calleeMD.getClassDesc()) && !ssjava.isTrustMethod(calleeMD) - && !calleeMD.getModifiers().isNative() && !isSystemout) { + if (!ssjava.isSSJavaUtil(calleeMethodDesc.getClassDesc()) + && !ssjava.isTrustMethod(calleeMethodDesc) && !calleeMethodDesc.getModifiers().isNative() + && !isSystemout) { CompositeLocation baseLocation = null; if (min.getExpression() != null) { @@ -940,11 +941,14 @@ public class FlowDownCheck { // setup the location list of caller's arguments List callerArgList = new ArrayList(); + // setup the location list of callee's parameters + MethodLattice calleeLattice = ssjava.getMethodLattice(calleeMethodDesc); + List calleeParamList = new ArrayList(); + if (min.numArgs() > 0) { - // setup caller args set - // first, add caller's base(this) location - callerArgList.add(baseLocation); - // second, add caller's arguments + if (!calleeMethodDesc.isStatic()) { + callerArgList.add(baseLocation); + } for (int i = 0; i < min.numArgs(); i++) { ExpressionNode en = min.getArg(i); CompositeLocation callerArgLoc = @@ -952,21 +956,18 @@ public class FlowDownCheck { constraint, false); callerArgList.add(callerArgLoc); } - } - // setup the location list of callee's parameters - MethodDescriptor calleemd = min.getMethod(); - MethodLattice calleeLattice = ssjava.getMethodLattice(calleemd); - CompositeLocation calleeThisLoc = - new CompositeLocation(new Location(calleemd, calleeLattice.getThisLoc())); - List calleeParamList = new ArrayList(); - // first, add callee's this location - calleeParamList.add(calleeThisLoc); - // second, add callee's parameters - for (int i = 0; i < calleemd.numParameters(); i++) { - VarDescriptor calleevd = (VarDescriptor) calleemd.getParameter(i); - CompositeLocation calleeLoc = d2loc.get(calleevd); - calleeParamList.add(calleeLoc); + if (!calleeMethodDesc.isStatic()) { + CompositeLocation calleeThisLoc = + new CompositeLocation(new Location(calleeMethodDesc, calleeLattice.getThisLoc())); + calleeParamList.add(calleeThisLoc); + } + + for (int i = 0; i < calleeMethodDesc.numParameters(); i++) { + VarDescriptor calleevd = (VarDescriptor) calleeMethodDesc.getParameter(i); + CompositeLocation calleeLoc = d2loc.get(calleevd); + calleeParamList.add(calleeLoc); + } } if (constraint != null) { @@ -975,17 +976,15 @@ public class FlowDownCheck { // annotation that declares the program counter that is higher than // corresponding parameter - CompositeLocation calleePCLOC = ssjava.getPCLocation(calleemd); + CompositeLocation calleePCLOC = ssjava.getPCLocation(calleeMethodDesc); for (int idx = 0; idx < callerArgList.size(); idx++) { CompositeLocation argLocation = callerArgList.get(idx); - int compareResult = - CompositeLattice - .compare(argLocation, constraint, true, generateErrorMessage(cd, min)); - // need to check that param is higher than PCLOC - if (compareResult == ComparisonResult.GREATER) { + if (!argLocation.get(0).isTop() + && CompositeLattice.compare(argLocation, constraint, true, + generateErrorMessage(cd, min)) == ComparisonResult.GREATER) { CompositeLocation paramLocation = calleeParamList.get(idx); @@ -1003,7 +1002,7 @@ public class FlowDownCheck { + argLocation + ". Need to specify that the initial PC location of the callee, which is currently set to " + calleePCLOC + ", is lower than " + paramLocation + " in the method " - + calleeMD.getSymbol() + ":" + min.getNumLine()); + + calleeMethodDesc.getSymbol() + ":" + min.getNumLine()); } } diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java b/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java index 87ada5b5..f5a3c6de 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java @@ -75,6 +75,7 @@ public class Classifier { * @return true if this region was classified as face, else false */ @LATTICE("OUT 0 ? +1 : 1)); } diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java b/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java index e77c0e24..cf564ff1 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java @@ -37,6 +37,7 @@ public class LEAImplementation { } @LATTICE("OUT