@Override public void visitCHECKCAST(CHECKCAST obj) { try { ResourceValueFrame frame = getFrame(); ResourceValue topValue; topValue = frame.getTopValue(); if (topValue.equals(ResourceValue.instance())) { frame.setStatus(ResourceValueFrame.ESCAPED); } } catch (DataflowAnalysisException e) { AnalysisContext.logError("Analysis error", e); } }
@Override public void visitARETURN(ARETURN ins) { try { ResourceValueFrame frame = getFrame(); ResourceValue topValue = frame.getTopValue(); if (topValue.equals(ResourceValue.instance())) { frame.setStatus(ResourceValueFrame.ESCAPED); } } catch (DataflowAnalysisException e) { throw new InvalidBytecodeException("Stack underflow", e); } handleNormalInstruction(ins); }
private void handleFieldStore(FieldInstruction ins) { try { // If the resource instance is stored in a field, then it escapes ResourceValueFrame frame = getFrame(); ResourceValue topValue = frame.getTopValue(); if (topValue.equals(ResourceValue.instance())) { frame.setStatus(ResourceValueFrame.ESCAPED); } } catch (DataflowAnalysisException e) { throw new InvalidBytecodeException("Stack underflow", e); } handleNormalInstruction(ins); }
private void handleArrayStore(ArrayInstruction ins) { try { // If the resource instance is stored in an array, then we consider // it as having escaped. This is conservative; ideally we would // check whether this array is a field or gets passed out of the // method. ResourceValueFrame frame = getFrame(); ResourceValue topValue = frame.getTopValue(); if (topValue.equals(ResourceValue.instance())) { frame.setStatus(ResourceValueFrame.ESCAPED); } } catch (DataflowAnalysisException e) { throw new InvalidBytecodeException("Stack underflow", e); } handleNormalInstruction(ins); }
@Override public void initEntryFact(ResourceValueFrame result) { result.setValid(); result.clearStack(); final int numSlots = result.getNumSlots(); for (int i = 0; i < numSlots; ++i) { boolean slotContainsInstance = resourceTracker.isParamInstance(resource, i); result.setValue(i, slotContainsInstance ? ResourceValue.instance() : ResourceValue.notInstance()); } }
private void handleInvoke(InvokeInstruction inv) { ResourceValueFrame frame = getFrame(); int numSlots = frame.getNumSlots(); int numConsumed = getNumWordsConsumed(inv); // See if the resource instance is passed as an argument int instanceArgNum = -1; for (int i = numSlots - numConsumed, argCount = 0; i < numSlots; ++i, ++argCount) { ResourceValue value = frame.getValue(i); if (value.equals(ResourceValue.instance())) { instanceArgNum = argCount; break; } } if (instanceArgNum >= 0 && instanceEscapes(inv, instanceArgNum)) { frame.setStatus(ResourceValueFrame.ESCAPED); } handleNormalInstruction(inv); }
System.out.println("Saw lock value!"); frame.setValue(i, ResourceValue.instance());
frame.setStatus(status); if (created) { frame.setValue(frame.getNumSlots() - 1, ResourceValue.instance());
@Override public void visitCHECKCAST(CHECKCAST obj) { try { ResourceValueFrame frame = getFrame(); ResourceValue topValue; topValue = frame.getTopValue(); if (topValue.equals(ResourceValue.instance())) { frame.setStatus(ResourceValueFrame.ESCAPED); } } catch (DataflowAnalysisException e) { AnalysisContext.logError("Analysis error", e); } }
@Override public void visitARETURN(ARETURN ins) { try { ResourceValueFrame frame = getFrame(); ResourceValue topValue = frame.getTopValue(); if (topValue.equals(ResourceValue.instance())) { frame.setStatus(ResourceValueFrame.ESCAPED); } } catch (DataflowAnalysisException e) { throw new InvalidBytecodeException("Stack underflow", e); } handleNormalInstruction(ins); }
private void handleFieldStore(FieldInstruction ins) { try { // If the resource instance is stored in a field, then it escapes ResourceValueFrame frame = getFrame(); ResourceValue topValue = frame.getTopValue(); if (topValue.equals(ResourceValue.instance())) { frame.setStatus(ResourceValueFrame.ESCAPED); } } catch (DataflowAnalysisException e) { throw new InvalidBytecodeException("Stack underflow", e); } handleNormalInstruction(ins); }
private void handleArrayStore(ArrayInstruction ins) { try { // If the resource instance is stored in an array, then we consider // it as having escaped. This is conservative; ideally we would // check whether this array is a field or gets passed out of the // method. ResourceValueFrame frame = getFrame(); ResourceValue topValue = frame.getTopValue(); if (topValue.equals(ResourceValue.instance())) { frame.setStatus(ResourceValueFrame.ESCAPED); } } catch (DataflowAnalysisException e) { throw new InvalidBytecodeException("Stack underflow", e); } handleNormalInstruction(ins); }
@Override public void initEntryFact(ResourceValueFrame result) { result.setValid(); result.clearStack(); final int numSlots = result.getNumSlots(); for (int i = 0; i < numSlots; ++i) { boolean slotContainsInstance = resourceTracker.isParamInstance(resource, i); result.setValue(i, slotContainsInstance ? ResourceValue.instance() : ResourceValue.notInstance()); } }
private void handleInvoke(InvokeInstruction inv) { ResourceValueFrame frame = getFrame(); int numSlots = frame.getNumSlots(); int numConsumed = getNumWordsConsumed(inv); // See if the resource instance is passed as an argument int instanceArgNum = -1; for (int i = numSlots - numConsumed, argCount = 0; i < numSlots; ++i, ++argCount) { ResourceValue value = frame.getValue(i); if (value.equals(ResourceValue.instance())) { instanceArgNum = argCount; break; } } if (instanceArgNum >= 0 && instanceEscapes(inv, instanceArgNum)) { frame.setStatus(ResourceValueFrame.ESCAPED); } handleNormalInstruction(inv); }
System.out.println("Saw lock value!"); frame.setValue(i, ResourceValue.instance());
frame.setStatus(status); if (created) { frame.setValue(frame.getNumSlots() - 1, ResourceValue.instance());