@Override public String toString() { return super.toString() + statusList[status]; }
if (result.isTop()) { result.copyFrom(other); return; } else if (other.isTop()) { if (result.isBottom()) { } else if (other.isBottom()) { result.setBottom(); return; if (result.getNumSlots() != other.getNumSlots()) { result.setBottom(); return; for (int i = 0; i < result.getNumSlots(); ++i) { mergeValues(other, result, i);
/** * Get the <i>i</i>th argument passed to given method invocation. * * @param ins * the method invocation instruction * @param cpg * the ConstantPoolGen for the class containing the method * @param i * index of the argument; 0 for the first argument, etc. * @param numArguments * total number of arguments to the method * @return the <i>i</i>th argument * @throws DataflowAnalysisException */ @Deprecated public ValueType getArgument(InvokeInstruction ins, ConstantPoolGen cpg, int i, int numArguments) throws DataflowAnalysisException { SignatureParser sigParser = new SignatureParser(ins.getSignature(cpg)); return getArgument(ins, cpg, i, sigParser); }
/** * Get the value corresponding to the object instance used in the given * instruction. This relies on the observation that in instructions which * use an object instance (such as getfield, invokevirtual, etc.), the * object instance is the first operand used by the instruction. * * @param ins * the instruction * @param cpg * the ConstantPoolGen for the method */ public ValueType getInstance(Instruction ins, ConstantPoolGen cpg) throws DataflowAnalysisException { return getStackValue(getInstanceStackLocation(ins, cpg)); }
if (getNumSlots() != other.getNumSlots()) { return false; for (int i = 0; i < getNumSlots(); ++i) { if (!getValue(i).equals(other.getValue(i))) { return false;
if (isTop()) { return "[TOP]"; if (isBottom()) { return "[BOTTOM]"; int numSlots = getNumSlots(); int start = STACK_ONLY ? getNumLocals() : 0; for (int i = start; i < numSlots; ++i) { if (!STACK_ONLY && i == getNumLocals()) { String value = valueToString(getValue(i)); if (i == numSlots - 1 && value.endsWith(",")) { value = value.substring(0, value.length() - 1);
@Override public void copyFrom(Frame<ValueNumber> other) { if (!(other instanceof ValueNumberFrame)) { throw new IllegalArgumentException(); } // If merged value list hasn't been created yet, create it. if (mergedValueList == null && other.isValid()) { // This is where this frame gets its size. // It will have the same size as long as it remains valid. mergedValueList = new ArrayList<>(other.getNumSlots()); int numSlots = other.getNumSlots(); for (int i = 0; i < numSlots; ++i) { mergedValueList.add(null); } } if (REDUNDANT_LOAD_ELIMINATION) { assignAvailableLoadMap((ValueNumberFrame) other); assignPreviouslyKnownAs((ValueNumberFrame) other); } super.copyFrom(other); }
/** * Get the slot the object instance referred to by given instruction is * located in. * * @param ins * the Instruction * @param cpg * the ConstantPoolGen for the method * @return stack slot the object instance is in * @throws DataflowAnalysisException */ public int getInstanceSlot(Instruction ins, ConstantPoolGen cpg) throws DataflowAnalysisException { if (!isValid()) { throw new DataflowAnalysisException("Accessing invalid frame at " + ins); } int numConsumed = ins.consumeStack(cpg); if (numConsumed == Const.UNPREDICTABLE) { throw new DataflowAnalysisException("Unpredictable stack consumption in " + ins); } if (numConsumed > getStackDepth()) { throw new DataflowAnalysisException("Stack underflow " + ins); } return getNumSlots() - numConsumed; }
if (frame.getStackDepth() < numWordsConsumed) { try { throw new IllegalArgumentException(" asked to pop " + numWordsConsumed + " stack elements but only " + frame.getStackDepth() + " elements remain in " + frame + " while processing " + ins); } catch (Exception e) { throw new IllegalArgumentException(" asked to pop " + numWordsConsumed + " stack elements but only " + frame.getStackDepth() + " elements remain while processing " + ins); frame.popValue(); frame.pushValue(pushValue);
@Override public void copyFrom(Frame<ResourceValue> other_) { super.copyFrom(other_); ResourceValueFrame other = (ResourceValueFrame) other_; this.status = other.status; }
/** * Handler for all instructions which load values from a local variable and * push them on the stack. Note that two locals are loaded for long and * double loads. */ public void handleLoadInstruction(LoadInstruction obj) { int numProduced = obj.produceStack(cpg); if (numProduced == Const.UNPREDICTABLE) { throw new InvalidBytecodeException("Unpredictable stack production"); } int index = obj.getIndex() + numProduced; // Load values from locals in reverse order. // This restores them to the stack in a way consistent // with visitStoreInstruction(). while (numProduced-- > 0) { Value value = frame.getValue(--index); frame.pushValue(value); } }
/** * Get a value on the operand stack. * * @param loc * the stack location, counting downwards from the top (location * 0) */ public ValueType getStackValue(int loc) throws DataflowAnalysisException { if (!isValid()) { throw new DataflowAnalysisException("Accessing TOP or BOTTOM frame!"); } int stackDepth = getStackDepth(); if (loc >= stackDepth) { throw new DataflowAnalysisException("not enough values on stack: access=" + loc + ", avail=" + stackDepth); } if (loc < 0) { throw new DataflowAnalysisException("can't get position " + loc + " of stack"); } int pos = slotList.size() - (loc + 1); return slotList.get(pos); }
/** * Get a the location in the frame of a value on the operand stack. * * @param loc * the stack location, counting downwards from the top (location * 0) */ public int getStackLocation(int loc) throws DataflowAnalysisException { int stackDepth = getStackDepth(); if (loc >= stackDepth) { throw new DataflowAnalysisException("not enough values on stack: access=" + loc + ", avail=" + stackDepth); } return slotList.size() - (loc + 1); }
/** * Get the <i>i</i>th argument passed to given method invocation. * * @param ins * the method invocation instruction * @param cpg * the ConstantPoolGen for the class containing the method * @param i * index of the argument; 0 for the first argument, etc. * @return the <i>i</i>th argument * @throws DataflowAnalysisException */ public ValueType getArgument(InvokeInstruction ins, ConstantPoolGen cpg, int i, SignatureParser sigParser) throws DataflowAnalysisException { if (i >= sigParser.getNumParameters()) { throw new IllegalArgumentException("requesting parameter # " + i + " of " + sigParser); } return getStackValue(sigParser.getSlotsFromTopOfStackForParameter(i)); }
@Override public int getLastUpdateTimestamp(FrameType fact) { return fact.getLastUpdateTimestamp(); }
if (isTop()) { return "[TOP]"; if (isBottom()) { return "[BOTTOM]"; int numSlots = getNumSlots(); int start = STACK_ONLY ? getNumLocals() : 0; for (int i = start; i < numSlots; ++i) { if (!STACK_ONLY && i == getNumLocals()) { String value = valueToString(getValue(i)); if (i == numSlots - 1 && value.endsWith(",")) { value = value.substring(0, value.length() - 1);
@Override public void copyFrom(Frame<ValueNumber> other) { if (!(other instanceof ValueNumberFrame)) { throw new IllegalArgumentException(); } // If merged value list hasn't been created yet, create it. if (mergedValueList == null && other.isValid()) { // This is where this frame gets its size. // It will have the same size as long as it remains valid. mergedValueList = new ArrayList<ValueNumber>(other.getNumSlots()); int numSlots = other.getNumSlots(); for (int i = 0; i < numSlots; ++i) { mergedValueList.add(null); } } if (REDUNDANT_LOAD_ELIMINATION) { assignAvailableLoadMap((ValueNumberFrame) other); assignPreviouslyKnownAs((ValueNumberFrame) other); } super.copyFrom(other); }
/** * Get the slot the object instance referred to by given instruction is * located in. * * @param ins * the Instruction * @param cpg * the ConstantPoolGen for the method * @return stack slot the object instance is in * @throws DataflowAnalysisException */ public int getInstanceSlot(Instruction ins, ConstantPoolGen cpg) throws DataflowAnalysisException { if (!isValid()) { throw new DataflowAnalysisException("Accessing invalid frame at " + ins); } int numConsumed = ins.consumeStack(cpg); if (numConsumed == Constants.UNPREDICTABLE) { throw new DataflowAnalysisException("Unpredictable stack consumption in " + ins); } if (numConsumed > getStackDepth()) { throw new DataflowAnalysisException("Stack underflow " + ins); } return getNumSlots() - numConsumed; }
if (frame.getStackDepth() < numWordsConsumed) { try { throw new IllegalArgumentException(" asked to pop " + numWordsConsumed + " stack elements but only " + frame.getStackDepth() + " elements remain in " + frame + " while processing " + ins); } catch (Exception e) { throw new IllegalArgumentException(" asked to pop " + numWordsConsumed + " stack elements but only " + frame.getStackDepth() + " elements remain while processing " + ins); frame.popValue(); frame.pushValue(pushValue);
@Override public void copy(FrameType source, FrameType dest) { dest.copyFrom(source); }