public LockAnalysis(MethodGen methodGen, ValueNumberDataflow vnaDataflow, DepthFirstSearch dfs) { super(dfs); this.methodGen = methodGen; this.vnaDataflow = vnaDataflow; this.vna = vnaDataflow.getAnalysis(); this.isSynchronized = methodGen.isSynchronized(); this.isStatic = methodGen.isStatic(); if (DEBUG) { System.out.println("Analyzing Locks in " + methodGen.getClassName() + "." + methodGen.getName()); } }
public ValueNumberAnalysis(MethodGen methodGen, DepthFirstSearch dfs, LoadedFieldSet loadedFieldSet, RepositoryLookupFailureCallback lookupFailureCallback) { super(dfs); this.methodGen = methodGen; this.factory = new ValueNumberFactory(); ValueNumberCache cache = new ValueNumberCache(); this.visitor = new ValueNumberFrameModelingVisitor(methodGen, factory, cache, loadedFieldSet, lookupFailureCallback); int numLocals = methodGen.getMaxLocals(); this.entryLocalValueList = new ValueNumber[numLocals]; for (int i = 0; i < numLocals; ++i) { this.entryLocalValueList[i] = factory.createFreshValue(); } this.exceptionHandlerValueNumberMap = new IdentityHashMap<>(); // For non-static methods, keep track of which value represents the // "this" reference if (!methodGen.isStatic()) { this.thisValue = entryLocalValueList[0]; } this.factAtLocationMap = new HashMap<>(); this.factAfterLocationMap = new HashMap<>(); if (DEBUG) { System.out.println("VNA Analysis " + methodGen.getClassName() + "." + methodGen.getName() + " : " + methodGen.getSignature()); } }
/** * Get the value number assigned to the given parameter upon entry to the * method. * * @param param * a parameter (0 == first parameter) * @return the ValueNumber assigned to that parameter */ public ValueNumber getEntryValueForParameter(int param) { SignatureParser sigParser = new SignatureParser(methodGen.getSignature()); int p = 0; int slotOffset = methodGen.isStatic() ? 0 : 1; for ( String paramSig : sigParser.parameterSignatures()) { if (p == param) { return getEntryValue(slotOffset); } p++; slotOffset += SignatureParser.getNumSlotsForType(paramSig); } throw new IllegalStateException(); }
/** * Add a method annotation. If this is the first method annotation added, it * becomes the primary method annotation. If the method has source line * information, then a SourceLineAnnotation is added to the method. * * @param methodGen * the MethodGen object for the method * @param sourceFile * source file method is defined in * @return this object */ @Nonnull public BugInstance addMethod(MethodGen methodGen, String sourceFile) { String className = methodGen.getClassName(); MethodAnnotation methodAnnotation = new MethodAnnotation(className, methodGen.getName(), methodGen.getSignature(), methodGen.isStatic()); addMethod(methodAnnotation); addSourceLinesForMethod(methodAnnotation, SourceLineAnnotation.fromVisitedMethod(methodGen, sourceFile)); return this; }
if (!methodGen.isStatic()) { ValueNumber v = vnaFrame.getValue(0); if (v.equals(vn)) {
if (!methodGen.isStatic()) { result.setValue(slot++, ObjectTypeFactory.getInstance(methodGen.getClassName()));
boolean instanceMethod = !methodGen.isStatic(); XMethod xm = XFactory.createXMethod(methodGen.getClassName(), methodGen.getName(), methodGen.getSignature(), methodGen.isStatic()); INullnessAnnotationDatabase db = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase(); int paramShift = instanceMethod ? 1 : 0;
Location firstLocation = new Location(cfg.getEntry().getFirstInstruction(), cfg.getEntry()); int local = methodGen.isStatic() ? 0 : 1;
public LockAnalysis(MethodGen methodGen, ValueNumberDataflow vnaDataflow, DepthFirstSearch dfs) { super(dfs); this.methodGen = methodGen; this.vnaDataflow = vnaDataflow; this.vna = vnaDataflow.getAnalysis(); this.isSynchronized = methodGen.isSynchronized(); this.isStatic = methodGen.isStatic(); if (DEBUG) { System.out.println("Analyzing Locks in " + methodGen.getClassName() + "." + methodGen.getName()); } }
public ValueNumberAnalysis(MethodGen methodGen, DepthFirstSearch dfs, LoadedFieldSet loadedFieldSet, RepositoryLookupFailureCallback lookupFailureCallback) { super(dfs); this.methodGen = methodGen; this.factory = new ValueNumberFactory(); ValueNumberCache cache = new ValueNumberCache(); this.visitor = new ValueNumberFrameModelingVisitor(methodGen, factory, cache, loadedFieldSet, lookupFailureCallback); int numLocals = methodGen.getMaxLocals(); this.entryLocalValueList = new ValueNumber[numLocals]; for (int i = 0; i < numLocals; ++i) { this.entryLocalValueList[i] = factory.createFreshValue(); } this.exceptionHandlerValueNumberMap = new IdentityHashMap<BasicBlock, ValueNumber>(); // For non-static methods, keep track of which value represents the // "this" reference if (!methodGen.isStatic()) { this.thisValue = entryLocalValueList[0]; } this.factAtLocationMap = new HashMap<Location, ValueNumberFrame>(); this.factAfterLocationMap = new HashMap<Location, ValueNumberFrame>(); if (DEBUG) { System.out.println("VNA Analysis " + methodGen.getClassName() + "." + methodGen.getName() + " : " + methodGen.getSignature()); } }
/** * Get the value number assigned to the given parameter upon entry to the * method. * * @param param * a parameter (0 == first parameter) * @return the ValueNumber assigned to that parameter */ public ValueNumber getEntryValueForParameter(int param) { SignatureParser sigParser = new SignatureParser(methodGen.getSignature()); int p = 0; int slotOffset = methodGen.isStatic() ? 0 : 1; for ( String paramSig : sigParser.parameterSignatures()) { if (p == param) { return getEntryValue(slotOffset); } param++; slotOffset += SignatureParser.getNumSlotsForType(paramSig); } throw new IllegalStateException(); }
/** * Add a method annotation. If this is the first method annotation added, it * becomes the primary method annotation. If the method has source line * information, then a SourceLineAnnotation is added to the method. * * @param methodGen * the MethodGen object for the method * @param sourceFile * source file method is defined in * @return this object */ @Nonnull public BugInstance addMethod(MethodGen methodGen, String sourceFile) { String className = methodGen.getClassName(); MethodAnnotation methodAnnotation = new MethodAnnotation(className, methodGen.getName(), methodGen.getSignature(), methodGen.isStatic()); addMethod(methodAnnotation); addSourceLinesForMethod(methodAnnotation, SourceLineAnnotation.fromVisitedMethod(methodGen, sourceFile)); return this; }
if (!methodGen.isStatic()) { ValueNumber v = vnaFrame.getValue(0); if (v.equals(vn)) {
/** * Compute maximum number of local variables. */ public void setMaxLocals() { if(il != null) { int max = isStatic()? 0 : 1; if(arg_types != null) for(int i=0; i < arg_types.length; i++) max += arg_types[i].getSize(); for(InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) { Instruction ins = ih.getInstruction(); if((ins instanceof LocalVariableInstruction) || (ins instanceof RET) || (ins instanceof IINC)) { int index = ((IndexedInstruction)ins).getIndex() + ((TypedInstruction)ins).getType(cp).getSize(); if(index > max) max = index; } } max_locals = max; } else max_locals = 0; }
/** * Compute maximum number of local variables. */ public void setMaxLocals() { // TODO could be package-protected? (some tests would need repackaging) if (il != null) { int max = isStatic() ? 0 : 1; if (arg_types != null) { for (final Type arg_type : arg_types) { max += arg_type.getSize(); } } for (InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) { final Instruction ins = ih.getInstruction(); if ((ins instanceof LocalVariableInstruction) || (ins instanceof RET) || (ins instanceof IINC)) { final int index = ((IndexedInstruction) ins).getIndex() + ((TypedInstruction) ins).getType(super.getConstantPool()).getSize(); if (index > max) { max = index; } } } max_locals = max; } else { max_locals = 0; } }
if (!methodGen.isStatic()) { result.setValue(slot++, ObjectTypeFactory.getInstance(methodGen.getClassName()));
boolean instanceMethod = !methodGen.isStatic(); XMethod xm = XFactory.createXMethod(methodGen.getClassName(), methodGen.getName(), methodGen.getSignature(), methodGen.isStatic()); INullnessAnnotationDatabase db = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase(); int paramShift = instanceMethod ? 1 : 0;
if ( !mg.isStatic() ){ if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)){ f._this = new UninitializedObjectType(new ObjectType(jc.getClassName())); argtypes[j] = Type.INT; f.getLocals().set(twoslotoffset + j + (mg.isStatic()?0:1), argtypes[j]); if (argtypes[j].getSize() == 2){ twoslotoffset++; f.getLocals().set(twoslotoffset + j + (mg.isStatic()?0:1), Type.UNKNOWN);