public String toString() { StringBuffer buffer = new StringBuffer(); for (int index = 0; index < this.size(); index++) { Value value = this.values[index]; Value producerValue = producerStack.getBottom(index); buffer = buffer.append('[') .append(producerValue == null ? "empty:" : producerValue.toString()) .append(value == null ? "empty" : value.toString()) .append(']'); } return buffer.toString(); }
public String toString() { StringBuffer buffer = new StringBuffer(); for (int index = 0; index < this.size(); index++) { Value value = this.values[index]; Value producerValue = producerStack.getBottom(index); Value actualProducerValue = actualProducerStack.getBottom(index); buffer = buffer.append('[') .append(producerValue == null ? "empty:" : producerValue.equals(actualProducerValue) ? producerValue.toString() : producerValue.toString() + actualProducerValue.toString()) .append(value == null ? "empty" : value.toString()) .append(']'); } return buffer.toString(); }
public String toString() { StringBuffer buffer = new StringBuffer(); for (int index = 0; index < this.size(); index++) { Value value = this.values[index]; Value producerValue = producerStack.getBottom(index); Value actualProducerValue = actualProducerStack.getBottom(index); buffer = buffer.append('[') .append(producerValue == null ? "empty:" : producerValue.equals(actualProducerValue) ? producerValue.toString() : producerValue.toString() + actualProducerValue.toString()) .append(value == null ? "empty" : value.toString()) .append(']'); } return buffer.toString(); }
public String toString() { StringBuffer buffer = new StringBuffer(); for (int index = 0; index < this.size(); index++) { Value value = this.values[index]; Value producerValue = producerStack.getBottom(index); Value actualProducerValue = actualProducerStack.getBottom(index); buffer = buffer.append('[') .append(producerValue == null ? "empty:" : producerValue.equals(actualProducerValue) ? producerValue.toString() : producerValue.toString() + actualProducerValue.toString()) .append(value == null ? "empty" : value.toString()) .append(']'); } return buffer.toString(); }
/** * Returns the 'new' instruction offset value (or method parameter) at * which the object instance is created that is initialized at the given * offset. */ private InstructionOffsetValue creationOffsetValue(int initializationOffset) { int stackEntryIndexBottom = partialEvaluator.getStackAfter(initializationOffset).size(); return creationOffsetValue(initializationOffset, stackEntryIndexBottom); }
/** * Returns the 'new' instruction offset value (or method parameter) at * which the object instance is created that is initialized at the given * offset. */ private InstructionOffsetValue creationOffsetValue(int initializationOffset) { int stackEntryIndexBottom = partialEvaluator.getStackAfter(initializationOffset).size(); return creationOffsetValue(initializationOffset, stackEntryIndexBottom); }
/** * Returns the 'new' instruction offset value (or method parameter) at * which the object instance is created that is initialized at the given * offset. */ private InstructionOffsetValue creationOffsetValue(int initializationOffset) { int stackEntryIndexBottom = partialEvaluator.getStackAfter(initializationOffset).size(); return creationOffsetValue(initializationOffset, stackEntryIndexBottom); }
/** * Marks the stack entry and the corresponding producing instructions * of the consumer at the given offset, if the stack entry of the * consumer is marked. * @param consumerOffset the offset of the consumer. * @param consumerTopStackIndex the index of the stack entry to be checked * (counting from the top). * @param producerTopStackIndex the index of the stack entry to be marked * (counting from the top). */ private void conditionallyMarkStackEntryProducers(int consumerOffset, int consumerTopStackIndex, int producerTopStackIndex) { int consumerBottomStackIndex = partialEvaluator.getStackAfter(consumerOffset).size() - consumerTopStackIndex - 1; if (isStackEntryNecessaryAfter(consumerOffset, consumerBottomStackIndex)) { int producerBottomStackIndex = partialEvaluator.getStackBefore(consumerOffset).size() - producerTopStackIndex - 1; markStackEntryProducers(consumerOffset, producerBottomStackIndex, true); } }
public void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction) { // We check all entries to make sure the stack is also consistent // at method exit points, where some stack entries might be // discarded. int stackSize = partialEvaluator.getStackBefore(offset).size(); for (int stackIndex = 0; stackIndex < stackSize; stackIndex++) { // Is this stack entry pushed by any producer // (because it is required by other consumers)? if (!isStackEntryUnwantedBefore(offset, stackIndex) && isStackEntryPresentBefore(offset, stackIndex)) { // Mark all produced stack entries. markStackEntryProducers(offset, stackIndex, false); } } } }
public void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction) { // We check all entries to make sure the stack is also consistent // at method exit points, where some stack entries might be // discarded. int stackSize = partialEvaluator.getStackBefore(offset).size(); for (int stackIndex = 0; stackIndex < stackSize; stackIndex++) { // Is this stack entry pushed by any producer // (because it is required by other consumers)? if (!isStackEntryUnwantedBefore(offset, stackIndex) && isStackEntryPresentBefore(offset, stackIndex)) { // Mark all produced stack entries. markStackEntryProducers(offset, stackIndex, false); } } } }
public void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction) { // We check all entries to make sure the stack is also consistent // at method exit points, where some stack entries might be // discarded. int stackSize = partialEvaluator.getStackBefore(offset).size(); for (int stackIndex = 0; stackIndex < stackSize; stackIndex++) { // Is this stack entry pushed by any producer // (because it is required by other consumers)? if (!isStackEntryUnwantedBefore(offset, stackIndex) && isStackEntryPresentBefore(offset, stackIndex)) { // Mark all produced stack entries. markStackEntryProducers(offset, stackIndex, false); } } } }
/** * Marks the stack entry and the corresponding producing instructions * of the consumer at the given offset, if the stack entry of the * consumer is marked. * @param consumerOffset the offset of the consumer. * @param consumerStackIndex the index of the stack entry to be checked * (counting from the top). * @param producerStackIndex the index of the stack entry to be marked * (counting from the top). */ private void conditionallyMarkStackEntryProducers(int consumerOffset, int consumerStackIndex, int producerStackIndex) { int top = partialEvaluator.getStackAfter(consumerOffset).size() - 1; if (isStackEntryNecessaryAfter(consumerOffset, top - consumerStackIndex)) { markStackEntryProducers(consumerOffset, producerStackIndex); } }
/** * Marks the stack entries and their producing instructions of the * consumer at the given offset. * @param clazz the containing class. * @param consumerOffset the offset of the consumer. * @param consumer the consumer of the stack entries. */ private void markStackProducers(Clazz clazz, int consumerOffset, Instruction consumer) { TracedStack tracedStack = partialEvaluator.getStackBefore(consumerOffset); int stackSize = tracedStack.size(); // Mark the producers of the popped values. int popCount = consumer.stackPopCount(clazz); for (int stackIndex = stackSize - popCount; stackIndex < stackSize; stackIndex++) { markStackEntryProducers(consumerOffset, stackIndex, true); } }
/** * Marks the stack entries and their producing instructions of the * consumer at the given offset. * @param clazz the containing class. * @param consumerOffset the offset of the consumer. * @param consumer the consumer of the stack entries. */ private void markStackProducers(Clazz clazz, int consumerOffset, Instruction consumer) { TracedStack tracedStack = partialEvaluator.getStackBefore(consumerOffset); int stackSize = tracedStack.size(); // Mark the producers of the popped values. int popCount = consumer.stackPopCount(clazz); for (int stackIndex = stackSize - popCount; stackIndex < stackSize; stackIndex++) { markStackEntryProducers(consumerOffset, stackIndex, true); } }
/** * Marks the stack entry and its initializing instruction * ('invokespecial *.<init>') for the given 'new' instruction offset. * @param newInstructionOffset the offset of the 'new' instruction. */ private void markInitialization(int newInstructionOffset) { int initializationOffset = partialEvaluator.initializationOffset(newInstructionOffset); TracedStack tracedStack = partialEvaluator.getStackAfter(newInstructionOffset); markStackEntryAfter(initializationOffset, tracedStack.size() - 1); markInstruction(initializationOffset); }
/** * Marks the stack entry and the corresponding producing instructions * of the consumer at the given offset. * @param consumerOffset the offset of the consumer. * @param stackIndex the index of the stack entry to be marked * (counting from the top). */ private void markStackEntryProducers(int consumerOffset, int stackIndex) { TracedStack tracedStack = partialEvaluator.getStackBefore(consumerOffset); int stackBottomIndex = tracedStack.size() - 1 - stackIndex; if (!isStackSimplifiedBefore(consumerOffset, stackBottomIndex)) { markStackEntryProducers(tracedStack.getTopProducerValue(stackIndex).instructionOffsetValue(), stackBottomIndex); } }
public void visitAnySwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SwitchInstruction switchInstruction) { if (instructionUsageMarker.isInstructionNecessary(offset)) { if (switchInstruction.stackPopCount(clazz) > 0 && !instructionUsageMarker.isStackEntryPresentBefore(offset, instructionUsageMarker.getStackBefore(offset).size() - 1)) { // Replace the switch instruction by a simple goto. Instruction replacementInstruction = new BranchInstruction(InstructionConstants.OP_GOTO, switchInstruction.defaultOffset); codeAttributeEditor.replaceInstruction(offset, replacementInstruction); if (DEBUG) System.out.println(" Replacing switch instruction "+switchInstruction.toString(offset)+" by "+replacementInstruction.toString()); } } else { visitAnyInstruction(clazz, method, codeAttribute, offset, switchInstruction); } }
public void visitAnySwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SwitchInstruction switchInstruction) { if (instructionUsageMarker.isInstructionNecessary(offset)) { if (switchInstruction.stackPopCount(clazz) > 0 && !instructionUsageMarker.isStackEntryPresentBefore(offset, instructionUsageMarker.getStackBefore(offset).size() - 1)) { // Replace the switch instruction by a simple goto. Instruction replacementInstruction = new BranchInstruction(InstructionConstants.OP_GOTO, switchInstruction.defaultOffset); codeAttributeEditor.replaceInstruction(offset, replacementInstruction); if (DEBUG) System.out.println(" Replacing switch instruction "+switchInstruction.toString(offset)+" by "+replacementInstruction.toString()); } } else { visitAnyInstruction(clazz, method, codeAttribute, offset, switchInstruction); } }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { if (instructionUsageMarker.isInstructionNecessary(offset)) { if (branchInstruction.stackPopCount(clazz) > 0 && !instructionUsageMarker.isStackEntryPresentBefore(offset, instructionUsageMarker.getStackBefore(offset).size() - 1)) { // Replace the branch instruction by a simple goto. Instruction replacementInstruction = new BranchInstruction(InstructionConstants.OP_GOTO, branchInstruction.branchOffset); codeAttributeEditor.replaceInstruction(offset, replacementInstruction); if (DEBUG) System.out.println(" Replacing branch instruction "+branchInstruction.toString(offset)+" by "+replacementInstruction.toString()); } } else { visitAnyInstruction(clazz, method, codeAttribute, offset, branchInstruction); } }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { if (instructionUsageMarker.isInstructionNecessary(offset)) { if (branchInstruction.stackPopCount(clazz) > 0 && !instructionUsageMarker.isStackEntryPresentBefore(offset, instructionUsageMarker.getStackBefore(offset).size() - 1)) { // Replace the branch instruction by a simple goto. Instruction replacementInstruction = new BranchInstruction(InstructionConstants.OP_GOTO, branchInstruction.branchOffset); codeAttributeEditor.replaceInstruction(offset, replacementInstruction); if (DEBUG) System.out.println(" Replacing branch instruction "+branchInstruction.toString(offset)+" by "+replacementInstruction.toString()); } } else { visitAnyInstruction(clazz, method, codeAttribute, offset, branchInstruction); } }