new InstructionOffsetValue(offset); int offsetCount = producerOffsets.instructionOffsetCount(); for (int offsetIndex = 0; offsetIndex < offsetCount; offsetIndex++) if (producerOffsets.isNewinstance(offsetIndex)) int producerOffset = producerOffsets.instructionOffset(offsetIndex); reverseDependency == null ? consumerOffset : reverseDependency.generalize(consumerOffset);
/** * Returns whether the given creation offset is initialized before the given * offset. */ public boolean isInitializedBefore(int offset, InstructionOffsetValue creationOffsetValue) { return !uninitializedOffsets[offset].contains(creationOffsetValue.instructionOffset(0)); }
public void branchConditionally(Clazz clazz, CodeAttribute codeAttribute, int offset, int branchTarget, int conditional) { // Accumulate the branch targets. traceBranchTargets = traceBranchTargets.add(branchTarget); wasCalled = true; }
/** * Returns the combined liveness mask of the variables right before the * specified instruction offsets. */ private long combinedLiveness(InstructionOffsetValue instructionOffsetValue) { long alive = 0L; int count = instructionOffsetValue.instructionOffsetCount(); for (int index = 0; index < count; index++) { alive |= isAliveBefore[instructionOffsetValue.instructionOffset(index)]; } return alive; }
/** * Returns an InstructionOffsetValue that contains the instructions offsets * of this value and the given instruction offset. */ public InstructionOffsetValue add(int value) { if (contains(value)) { return this; } int[] newValues = new int[values.length+1]; System.arraycopy(values, 0, newValues, 0, values.length); newValues[values.length] = value; return new InstructionOffsetValue(newValues); }
/** * Marks the method and the producing parameters of the given reference * value. */ private void markReturnedParameters(Method method, ReferenceValue referenceValue) { TracedReferenceValue tracedReferenceValue = (TracedReferenceValue)referenceValue; InstructionOffsetValue producers = tracedReferenceValue.getTraceValue().instructionOffsetValue(); int producerCount = producers.instructionOffsetCount(); for (int index = 0; index < producerCount; index++) { if (producers.isMethodParameter(index)) { // We know exactly which parameter is returned. markParameterReturned(method, producers.methodParameter(index)); } else if (producers.isFieldValue(index)) { markReturnsExternalValues(method); } else if (producers.isNewinstance(index) || producers.isExceptionHandler(index)) { markReturnsNewInstances(method); } } }
visitedOffsets.contains(consumerOffset)) new InstructionOffsetValue(consumerOffset) : visitedOffsets.add(consumerOffset); simplePartialEvaluator.getVariablesBefore(consumerOffset).getProducerValue(variableIndex).instructionOffsetValue(); int offsetCount = producerOffsets.instructionOffsetCount(); for (int offsetIndex = 0; offsetIndex < offsetCount; offsetIndex++) if (!producerOffsets.isMethodParameter(offsetIndex) && !producerOffsets.isExceptionHandler(offsetIndex)) producerOffsets.instructionOffset(offsetIndex); markVariableInitializersAfter(producerOffset, variableIndex, visitedOffsets);
new InstructionOffsetValue(InstructionOffsetValue.METHOD_PARAMETER) : InstructionOffsetValue.EMPTY_VALUE; currentUninitializedOffsets.add(offset); creationOffsetValue.instructionOffset(0); if (creationOffsetValue.isMethodParameter(0)) currentUninitializedOffsets.remove(creationOffset); for (int branchIndex = 0; branchIndex < branchTargets.instructionOffsetCount(); branchIndex++) int branchOffset = branchTargets.instructionOffset(branchIndex); if (branchOffset > offset) uninitializedOffsets[offset].instructionOffsetCount() > 0 ? " u"+uninitializedOffsets[offset] : " ") + (isInitializer(offset) ? " "+creationOffsetValue(offset) : " ") + " " + InstructionFactory.create(codeAttribute.code, offset).toString(offset));
/** * Marks the producing instructions of the variable consumer at the given * offset. * @param consumerOffset the offset of the variable consumer. * @param variableIndex the index of the variable that is loaded. */ private void markVariableProducers(int consumerOffset, int variableIndex) { InstructionOffsetValue producerOffsets = partialEvaluator.getVariablesBefore(consumerOffset).getProducerValue(variableIndex).instructionOffsetValue(); if (producerOffsets != null) { int offsetCount = producerOffsets.instructionOffsetCount(); for (int offsetIndex = 0; offsetIndex < offsetCount; offsetIndex++) { if (!producerOffsets.isMethodParameter(offsetIndex) && !producerOffsets.isExceptionHandler(offsetIndex)) { // Make sure the variable and the instruction are marked // at the producing offset. int offset = producerOffsets.instructionOffset(offsetIndex); markInstruction(offset); } } } }
/** * Marks the producing offsets of the given traced reference value. */ private void markReturnedReferenceValues(ReferenceValue referenceValue) { TracedReferenceValue tracedReferenceValue = (TracedReferenceValue)referenceValue; InstructionOffsetValue instructionOffsetValue = tracedReferenceValue.getTraceValue().instructionOffsetValue(); int parameterCount = instructionOffsetValue.instructionOffsetCount(); for (int index = 0; index < parameterCount; index++) { if (!instructionOffsetValue.isMethodParameter(index)) { instanceReturned[instructionOffsetValue.instructionOffset(index)] = true; } } }
if (isMethodParameter(index)) if (isMethodReturnValue(index)) if (isFieldValue(index)) if (isNewinstance(index)) if (isCast(index)) if (isExceptionHandler(index))
/** * Returns whether the producing reference value is escaping or has escaped. */ private boolean hasEscaped(ReferenceValue referenceValue) { TracedReferenceValue tracedReferenceValue = (TracedReferenceValue)referenceValue; InstructionOffsetValue instructionOffsetValue = tracedReferenceValue.getTraceValue().instructionOffsetValue(); int count = instructionOffsetValue.instructionOffsetCount(); for (int index = 0; index < count; index++) { if (instructionOffsetValue.isMethodParameter(index) ? hasParameterEscaped(referencingMethod, instructionOffsetValue.methodParameter(index)) : referenceEscapeChecker.isInstanceEscaping(instructionOffsetValue.instructionOffset(index))) { return true; } } return false; }
((TracedReferenceValue)returnValue).getTraceValue().instructionOffsetValue().instructionOffset(0); ParameterEscapeMarker.returnsExternalValues(referencedMethod) ? new InstructionOffsetValue(offset | InstructionOffsetValue.FIELD_VALUE) : ParameterEscapeMarker.returnsNewInstances(referencedMethod) ? new InstructionOffsetValue(offset | InstructionOffsetValue.NEW_INSTANCE) : null; traceValue.generalize(parameterTraceValue);
/** * Returns whether any of the stack entries after the given offsets are * necessary. * @param instructionOffsets the offsets of the stack entries to be checked. * @param stackIndex the index of the stack entries to be checked * (counting from the bottom). */ public boolean isAnyStackEntryNecessaryAfter(InstructionOffsetValue instructionOffsets, int stackIndex) { int offsetCount = instructionOffsets.instructionOffsetCount(); for (int offsetIndex = 0; offsetIndex < offsetCount; offsetIndex++) { if (instructionOffsets.isExceptionHandler(offsetIndex) || isStackEntryNecessaryAfter(instructionOffsets.instructionOffset(offsetIndex), stackIndex)) { return true; } } return false; }
/** * Marks the producing parameters (and the classes) of the given * reference value. */ private void markEscapingParameters(Method method, ReferenceValue referenceValue) { TracedReferenceValue tracedReferenceValue = (TracedReferenceValue)referenceValue; InstructionOffsetValue producers = tracedReferenceValue.getTraceValue().instructionOffsetValue(); int producerCount = producers.instructionOffsetCount(); for (int index = 0; index < producerCount; index++) { if (producers.isMethodParameter(index)) { // We know exactly which parameter is escaping. markParameterEscaping(method, producers.methodParameter(index)); } } }
branchTargets.instructionOffset(branchTargets.instructionOffsetCount()-1) - offset; for (int index = 0; index < jumpOffsets.length; index++) if (!branchTargets.contains(offset + jumpOffsets[index])) if (!branchTargets.contains(offset + switchInstruction.defaultOffset))
public void branch(Clazz clazz, CodeAttribute codeAttribute, int offset, int branchTarget) { // Override the branch targets. traceBranchTargets = new InstructionOffsetValue(branchTarget); wasCalled = true; }
public final Value generalize(Value other) { return this.generalize(other.instructionOffsetValue()); }
public boolean equals(Object object) { if (object == null || this.getClass() != object.getClass()) { return false; } InstructionOffsetValue other = (InstructionOffsetValue)object; if (this.values == other.values) { return true; } if (this.values == null || other.values == null || this.values.length != other.values.length) { return false; } for (int index = 0; index < other.values.length; index++) { if (!this.contains(other.values[index])) { return false; } } return true; }
public void branchConditionally(Clazz clazz, CodeAttribute codeAttribute, int offset, int branchTarget, int conditional) { // Accumulate the branch targets. traceBranchTargets = traceBranchTargets.generalize(new InstructionOffsetValue(branchTarget)).instructionOffsetValue(); wasCalled = true; }