@Override protected void mergeInto(ResourceValueFrame frame, ResourceValueFrame result) throws DataflowAnalysisException { // Merge slots super.mergeInto(frame, result); // Merge status result.setStatus(Math.min(result.getStatus(), frame.getStatus())); }
@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); }
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); }
frame.setStatus(status);
frame.setStatus(status); if (created) { frame.setValue(frame.getNumSlots() - 1, ResourceValue.instance());
@Override protected void mergeInto(ResourceValueFrame frame, ResourceValueFrame result) throws DataflowAnalysisException { // Merge slots super.mergeInto(frame, result); // Merge status result.setStatus(Math.min(result.getStatus(), frame.getStatus())); }
@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); }
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); }
frame.setStatus(status);
frame.setStatus(status); if (created) { frame.setValue(frame.getNumSlots() - 1, ResourceValue.instance());