/** * Get the number of arguments passed to given method invocation, including * the object instance if the call is to an instance method. * * @param ins * the method invocation instruction * @param cpg * the ConstantPoolGen for the class containing the method * @return number of arguments, including object instance if appropriate * @throws DataflowAnalysisException */ public int getNumArgumentsIncludingObjectInstance(InvokeInstruction ins, ConstantPoolGen cpg) throws DataflowAnalysisException { int numConsumed = ins.consumeStack(cpg); if (numConsumed == Const.UNPREDICTABLE) { throw new DataflowAnalysisException("Unpredictable stack consumption in " + ins); } return numConsumed; }
private ResourceValue getInstanceValue(ResourceValueFrame frame, InvokeInstruction inv, ConstantPoolGen cpg) { int numConsumed = inv.consumeStack(cpg); if (numConsumed == Const.UNPREDICTABLE) { throw new IllegalStateException(); } return frame.getValue(frame.getNumSlots() - numConsumed); }
void initObservedValues() throws DataflowAnalysisException { for(Iterator<Location> iterator = cfg.locationIterator(); iterator.hasNext(); ) { Location location = iterator.next(); Instruction instruction = location.getHandle().getInstruction(); if(instruction instanceof ANEWARRAY || instruction instanceof NEWARRAY || instruction instanceof MULTIANEWARRAY) { int number = vna.getFactAfterLocation(location).getTopValue().getNumber(); TypeFrame typeFrame = ta.getFactAfterLocation(location); if(typeFrame.isValid()) { Type type = typeFrame.getTopValue(); observedValues.put(number, new ValueInfo(number, location, type)); } } else if(instruction instanceof INVOKESPECIAL) { InvokeInstruction inv = (InvokeInstruction) instruction; if (inv.getMethodName(cpg).equals(CONSTRUCTOR_NAME) && noSideEffectMethods.hasNoSideEffect(new MethodDescriptor(inv, cpg))) { int number = vna.getFactAtLocation(location).getStackValue(inv.consumeStack(cpg)-1).getNumber(); TypeFrame typeFrame = ta.getFactAtLocation(location); if(typeFrame.isValid()) { Type type = typeFrame.getStackValue(inv.consumeStack(cpg)-1); observedValues.put(number, new ValueInfo(number, location, type)); } } } } thisValue = vna.getThisValue(); if(thisValue != null) { observedValues.remove(thisValue.getNumber()); } count = observedValues.size(); }
/** * Get the number of arguments passed to given method invocation, including * the object instance if the call is to an instance method. * * @param ins * the method invocation instruction * @param cpg * the ConstantPoolGen for the class containing the method * @return number of arguments, including object instance if appropriate * @throws DataflowAnalysisException */ public int getNumArgumentsIncludingObjectInstance(InvokeInstruction ins, ConstantPoolGen cpg) throws DataflowAnalysisException { int numConsumed = ins.consumeStack(cpg); if (numConsumed == Constants.UNPREDICTABLE) { throw new DataflowAnalysisException("Unpredictable stack consumption in " + ins); } return numConsumed; }
private ResourceValue getInstanceValue(ResourceValueFrame frame, InvokeInstruction inv, ConstantPoolGen cpg) { int numConsumed = inv.consumeStack(cpg); if (numConsumed == Constants.UNPREDICTABLE) { throw new IllegalStateException(); } return frame.getValue(frame.getNumSlots() - numConsumed); }
void initObservedValues() throws DataflowAnalysisException { for(Iterator<Location> iterator = cfg.locationIterator(); iterator.hasNext(); ) { Location location = iterator.next(); Instruction instruction = location.getHandle().getInstruction(); if(instruction instanceof ANEWARRAY || instruction instanceof NEWARRAY || instruction instanceof MULTIANEWARRAY) { int number = vna.getFactAfterLocation(location).getTopValue().getNumber(); TypeFrame typeFrame = ta.getFactAfterLocation(location); if(typeFrame.isValid()) { Type type = typeFrame.getTopValue(); observedValues.put(number, new ValueInfo(number, location, type)); } } else if(instruction instanceof INVOKESPECIAL) { InvokeInstruction inv = (InvokeInstruction) instruction; if (inv.getMethodName(cpg).equals("<init>") && noSideEffectMethods.hasNoSideEffect(new MethodDescriptor(inv, cpg))) { int number = vna.getFactAtLocation(location).getStackValue(inv.consumeStack(cpg)-1).getNumber(); TypeFrame typeFrame = ta.getFactAtLocation(location); if(typeFrame.isValid()) { Type type = typeFrame.getStackValue(inv.consumeStack(cpg)-1); observedValues.put(number, new ValueInfo(number, location, type)); } } } } thisValue = vna.getThisValue(); if(thisValue != null) { observedValues.remove(thisValue.getNumber()); } count = observedValues.size(); }