@Override public boolean isFactValid(FrameType fact) { return fact.isValid(); }
public boolean contains(ValueType value) { if (!isValid()) { throw new IllegalStateException("accessing top or bottom frame"); } for (ValueType v : slotList) { if (v.equals(value)) { return true; } } return false; }
/** * Get the value at the <i>n</i>th slot. * * @param n * the slot to get the value of * @return the value in the slot */ public ValueType getValue(int n) { if (!isValid()) { throw new IllegalStateException("accessing top or bottom frame"); } return slotList.get(n); }
/** * Push a value onto the Java operand stack. * * @param value * the ValueType to push */ public void pushValue(ValueType value) { if (VERIFY_INTEGRITY && value == null) { throw new IllegalArgumentException(); } if (!isValid()) { throw new IllegalStateException("accessing top or bottom frame"); } slotList.add(value); }
/** * Clear the Java operand stack. Only local variable slots will remain in * the frame. */ public void clearStack() { if (!isValid()) { throw new IllegalStateException("accessing top or bottom frame"); } assert slotList.size() >= numLocals; if (slotList.size() > numLocals) { slotList.subList(numLocals, slotList.size()).clear(); } }
/** * Set the value at the <i>n</i>th slot. * * @param n * the slot in which to set a new value * @param value * the value to set */ public void setValue(int n, ValueType value) { if (VERIFY_INTEGRITY && value == null) { throw new IllegalArgumentException(); } if (!isValid()) { throw new IllegalStateException("accessing top or bottom frame"); } slotList.set(n, value); }
/** * Get the value on the top of the Java operand stack. * * @throws DataflowAnalysisException * if the Java operand stack is empty */ public ValueType getTopValue() throws DataflowAnalysisException { if (!isValid()) { throw new DataflowAnalysisException("accessing top or bottom frame"); } assert slotList.size() >= numLocals; if (slotList.size() == numLocals) { throw new DataflowAnalysisException("operand stack is empty"); } return slotList.get(slotList.size() - 1); }
/** * Pop a value off of the Java operand stack. * * @return the value that was popped * @throws DataflowAnalysisException * if the Java operand stack is empty */ public ValueType popValue() throws DataflowAnalysisException { if (!isValid()) { throw new DataflowAnalysisException("accessing top or bottom frame"); } if (slotList.size() == numLocals) { throw new DataflowAnalysisException("operand stack empty"); } return slotList.remove(slotList.size() - 1); }
/** * Analyze the given Instruction. * * @param ins * the Instruction * @throws DataflowAnalysisException * if an error occurs analyzing the instruction; in most cases, * this indicates that the bytecode for the method being * analyzed is invalid */ public void analyzeInstruction(Instruction ins) throws DataflowAnalysisException { if (frame.isValid()) { try { ins.accept(this); } catch (InvalidBytecodeException e) { String message = "Invalid bytecode: could not analyze instr. " + ins + " at frame " + frame; throw new DataflowAnalysisException(message, e); } } }
/** * 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); }
@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; }
@Override public boolean isFactValid(FrameType fact) { return fact.isValid(); }
public boolean contains(ValueType value) { if (!isValid()) { throw new IllegalStateException("accessing top or bottom frame"); } for (ValueType v : slotList) { if (v.equals(value)) { return true; } } return false; }
/** * Get the value at the <i>n</i>th slot. * * @param n * the slot to get the value of * @return the value in the slot */ public ValueType getValue(int n) { if (!isValid()) { throw new IllegalStateException("accessing top or bottom frame"); } return slotList.get(n); }
/** * Push a value onto the Java operand stack. * * @param value * the ValueType to push */ public void pushValue(ValueType value) { if (VERIFY_INTEGRITY && value == null) { throw new IllegalArgumentException(); } if (!isValid()) { throw new IllegalStateException("accessing top or bottom frame"); } slotList.add(value); }
/** * Clear the Java operand stack. Only local variable slots will remain in * the frame. */ public void clearStack() { if (!isValid()) { throw new IllegalStateException("accessing top or bottom frame"); } assert slotList.size() >= numLocals; if (slotList.size() > numLocals) { slotList.subList(numLocals, slotList.size()).clear(); } }
/** * Set the value at the <i>n</i>th slot. * * @param n * the slot in which to set a new value * @param value * the value to set */ public void setValue(int n, ValueType value) { if (VERIFY_INTEGRITY && value == null) { throw new IllegalArgumentException(); } if (!isValid()) { throw new IllegalStateException("accessing top or bottom frame"); } slotList.set(n, value); }
/** * Get the value on the top of the Java operand stack. * * @throws DataflowAnalysisException * if the Java operand stack is empty */ public ValueType getTopValue() throws DataflowAnalysisException { if (!isValid()) { throw new DataflowAnalysisException("accessing top or bottom frame"); } assert slotList.size() >= numLocals; if (slotList.size() == numLocals) { throw new DataflowAnalysisException("operand stack is empty"); } return slotList.get(slotList.size() - 1); }
/** * Pop a value off of the Java operand stack. * * @return the value that was popped * @throws DataflowAnalysisException * if the Java operand stack is empty */ public ValueType popValue() throws DataflowAnalysisException { if (!isValid()) { throw new DataflowAnalysisException("accessing top or bottom frame"); } if (slotList.size() == numLocals) { throw new DataflowAnalysisException("operand stack empty"); } return slotList.remove(slotList.size() - 1); }