Package edu.umd.cs.findbugs.ba.vna

Examples of edu.umd.cs.findbugs.ba.vna.ValueNumber


        super.visitPUTFIELD(obj);
        XField field = XFactory.createXField(obj, cpg);
        if (nullValueStored != null && ValueNumberAnalysisFeatures.REDUNDANT_LOAD_ELIMINATION) {
            try {
                ValueNumberFrame vnaFrameBefore = vnaDataflow.getFactAtLocation(getLocation());
                ValueNumber refValue = vnaFrameBefore.getStackValue(1);
                AvailableLoad load = new AvailableLoad(refValue, field);
                ValueNumberFrame vnaFrameAfter = vnaDataflow.getFactAfterLocation(getLocation());
                ValueNumber[] newValueNumbersForField = vnaFrameAfter.getAvailableLoad(load);
                if (newValueNumbersForField != null && trackValueNumbers) {
                    for (ValueNumber v : newValueNumbersForField) {
View Full Code Here


        if (trackValueNumbers) {
            try {
                // See if the value number loaded here is a known value
                ValueNumberFrame vnaFrameAfter = vnaDataflow.getFactAfterLocation(getLocation());
                if (vnaFrameAfter.isValid()) {
                    ValueNumber tosVN = vnaFrameAfter.getTopValue();
                    IsNullValue knownValue = getFrame().getKnownValue(tosVN);
                    if (knownValue != null) {
                        // System.out.println("Produce known value!");
                        // The value produced by this instruction is known.
                        // Push the known value.
View Full Code Here

        }
        if (!ValueNumberAnalysisFeatures.REDUNDANT_LOAD_ELIMINATION) {
            return;
        }
        for (Iterator<ValueNumber> i = knownValueMap.keySet().iterator(); i.hasNext();) {
            ValueNumber v = i.next();
            if (vnaFrameAfter.getLoad(v) == null) {
                if (IsNullValueAnalysis.DEBUG) {
                    System.out.println("PURGING " + v);
                }
                i.remove();
View Full Code Here

        final boolean areEqual;

        public PointerEqualityInfo(ValueNumber addr1, ValueNumber addr2, boolean areEqual) {
            if (addr1.getNumber() > addr2.getNumber()) {
                ValueNumber tmp = addr1;
                addr1 = addr2;
                addr2 = tmp;
            }
            this.addr1 = addr1;
            this.addr2 = addr2;
View Full Code Here

        if (!vnaFrameAfter.isValid()) {
            assert false : "Invalid VNA after location " + location + " in " +  SignatureConverter.convertMethodSignature(methodGen);
        return;
        }
        for (int i = start; i < fact.getNumSlots(); ++i) {
            ValueNumber value = vnaFrameAfter.getValue(i);
            IsNullValue isNullValue = fact.getValue(i);

            for (int j = 0; j < start; ++j) {
                ValueNumber otherValue = vnaFrameAfter.getValue(j);
                if (value.equals(otherValue)) {
                    // Same value is in both slots.
                    // Update the is-null information to match
                    // the new information.
                    fact.setValue(j, isNullValue);
                }
            }
        }

        if (visitor.getSlotContainingNewNullValue() >= 0) {
            ValueNumber newNullValue = vnaFrameAfter.getValue(visitor.getSlotContainingNewNullValue());
            addLocationWhereValueBecomesNull(new LocationWhereValueBecomesNull(location, newNullValue// ,
                    // handle
                    ));
        }
View Full Code Here

                            // The incoming edge is infeasible; just use TOP
                            // as the start fact for this block.
                            tmpFact = createFact();
                            tmpFact.setTop();
                        } else {
                            ValueNumber valueTested = decision.getValue();
                            if (valueTested != null) {
                                // A value has been determined for this edge.
                                // Use the value to update the is-null
                                // information in
                                // the start fact for this block.

                                if (DEBUG) {
                                    System.out.println("Updating edge information for " + valueTested);
                                }
                                final Location atIf = new Location(sourceBlock.getLastInstruction(), sourceBlock);
                                final ValueNumberFrame prevVnaFrame = vnaDataflow.getFactAtLocation(atIf);

                                IsNullValue decisionValue = decision.getDecision(edgeType);
                                if (decisionValue != null) {

                                    if (DEBUG) {
                                        System.out.println("Set decision information");
                                        System.out.println("  " + valueTested + " becomes " + decisionValue);
                                        System.out.println("  at " + targetBlock.getFirstInstruction().getPosition());
                                        System.out.println("  prev available loads: " + prevVnaFrame.availableLoadMapAsString());
                                        System.out.println("  target available loads: "
                                                + targetVnaFrame.availableLoadMapAsString());
                                    }
                                    tmpFact = replaceValues(fact, tmpFact, valueTested, prevVnaFrame, targetVnaFrame,
                                            decisionValue);
                                    if (decisionValue.isDefinitelyNull()) {
                                        // Make a note of the value that has
                                        // become null
                                        // due to the if comparison.
                                        addLocationWhereValueBecomesNull(new LocationWhereValueBecomesNull(atIf, valueTested));
                                        ValueNumber knownNonnull = getKnownNonnullDueToPointerDisequality(valueTested, atIf
                                                .getHandle().getPosition());
                                        if (knownNonnull != null) {
                                            tmpFact = replaceValues(fact, tmpFact, knownNonnull, prevVnaFrame, targetVnaFrame,
                                                    IsNullValue.checkedNonNullValue());
                                        }
                                    }
                                }
                            }
                        }
                    }
                } // if (edgeType == IFCMP_EDGE || edgeType ==
                // FALL_THROUGH_EDGE)

                // If this is a fall-through edge from a null check,
                // then we know the value checked is not null.
                if (sourceBlock.isNullCheck() && edgeType == FALL_THROUGH_EDGE) {
                    ValueNumberFrame vnaFrame = vnaDataflow.getStartFact(destBlock);
                    if (vnaFrame == null) {
                        throw new IllegalStateException("no vna frame at block entry?");
                    }

                    Instruction firstInDest = edge.getTarget().getFirstInstruction().getInstruction();

                    IsNullValue instance = fact.getInstance(firstInDest, methodGen.getConstantPool());

                    if (instance.isDefinitelyNull()) {
                        // If we know the variable is null, this edge is
                        // infeasible
                        tmpFact = createFact();
                        tmpFact.setTop();
                    } else if (!instance.isDefinitelyNotNull()) {
                        // If we're not sure that the instance is definitely
                        // non-null,
                        // update the is-null information for the dereferenced
                        // value.
                        InstructionHandle kaBoomLocation = targetBlock.getFirstInstruction();
                        ValueNumber replaceMe = vnaFrame.getInstance(firstInDest, methodGen.getConstantPool());
                        IsNullValue noKaboomNonNullValue = IsNullValue.noKaboomNonNullValue(new Location(kaBoomLocation,
                                targetBlock));
                        if (DEBUG) {
                            System.out.println("Start vna fact: " + vnaFrame);
                            System.out.println("inva fact: " + fact);
View Full Code Here

        case Constants.IFNULL:
        case Constants.IFNONNULL: {
            IsNullValue tos = lastFrame.getTopValue();
            boolean ifnull = (lastInSourceOpcode == Constants.IFNULL);
            ValueNumber prevTopValue = prevVnaFrame.getTopValue();

            return handleIfNull(tos, prevTopValue, ifnull);
        }
        case Constants.IF_ACMPEQ:
        case Constants.IF_ACMPNE: {
            IsNullValue tos = lastFrame.getStackValue(0);
            IsNullValue nextToTos = lastFrame.getStackValue(1);

            boolean tosNull = tos.isDefinitelyNull();
            boolean nextToTosNull = nextToTos.isDefinitelyNull();

            boolean cmpeq = (lastInSourceOpcode == Constants.IF_ACMPEQ);

            // Initially, assume neither branch is feasible.
            IsNullValue ifcmpDecision = null;
            IsNullValue fallThroughDecision = null;
            ValueNumber value;

            if (tosNull && nextToTosNull) {
                // Redundant comparison: both values are null, only one branch
                // is feasible
                value = null; // no value will be replaced - just want to
View Full Code Here

        // their is-null information updated to "replacementValue"
        // This should thoroughly make use of the updated information.

        for (int i = 0; i < prefixNumSlots; ++i) {
            if (prevVnaFrame.getValue(i).equals(replaceMe)) {
                ValueNumber corresponding = targetVnaFrame.getValue(i);
                for (int j = 0; j < targetNumSlots; ++j) {
                    if (targetVnaFrame.getValue(j).equals(corresponding)) {
                        frame.setValue(j, replacementValue);
                    }
                }
View Full Code Here

                try {
                    // Get the value number
                    ValueNumberFrame vnaFrame = classContext.getValueNumberDataflow(method).getFactAfterLocation(location);
                    if (vnaFrame.isValid()) {

                        ValueNumber valueNumber = vnaFrame.getTopValue();
                        if (valueNumber.hasFlag(ValueNumber.CONSTANT_CLASS_OBJECT)) {
                            return;
                        }
                        variableAnnotation = ValueNumberSourceInfo.findAnnotationFromValueNumber(method, location, valueNumber, vnaFrame,
                                "VALUE_OF");
                        if (variableAnnotation instanceof LocalVariableAnnotation) {
View Full Code Here

        // The instruction must be PUTFIELD or PUTSTATIC
        if (ins instanceof PUTFIELD) {
            fieldIns = (PUTFIELD) ins;
            int numSlots = before.getNumSlots();
            ValueNumber ref = before.getValue(isLongOrDouble(fieldIns, cpg) ? numSlots - 3 : numSlots - 2);
            field = new FieldVariable(ref, fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg));
        } else if (ins instanceof PUTSTATIC) {
            fieldIns = (PUTSTATIC) ins;
            field = new FieldVariable(fieldIns.getClassName(cpg), fieldIns.getFieldName(cpg), fieldIns.getSignature(cpg));
        } else {
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.ba.vna.ValueNumber

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.