本文整理汇总了Java中org.apache.bcel.Constants.UNPREDICTABLE属性的典型用法代码示例。如果您正苦于以下问题:Java Constants.UNPREDICTABLE属性的具体用法?Java Constants.UNPREDICTABLE怎么用?Java Constants.UNPREDICTABLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.bcel.Constants
的用法示例。
在下文中一共展示了Constants.UNPREDICTABLE属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: consumeStack
/**
* Consume stack. This is a convenience method for instructions
* where the types of popped operands can be ignored.
*/
protected void consumeStack(Instruction ins) {
ConstantPoolGen cpg = getCPG();
BetterTypeFrame frame = getFrame();
int numWordsConsumed = ins.consumeStack(cpg);
if (numWordsConsumed == Constants.UNPREDICTABLE)
throw new AnalysisException("Unpredictable stack consumption", methodGen, ins);
try {
while (numWordsConsumed-- > 0) {
frame.popValue();
}
} catch (DataflowAnalysisException e) {
throw new AnalysisException("Stack underflow", methodGen, ins, e);
}
}
示例2: handleStoreInstruction
/**
* Handler for all instructions which pop values from the stack
* and store them in a local variable. Note that two locals
* are stored into for long and double stores.
*/
public void handleStoreInstruction(StoreInstruction obj) {
try {
int numConsumed = obj.consumeStack(cpg);
if (numConsumed == Constants.UNPREDICTABLE) throw new IllegalStateException();
int index = obj.getIndex();
// Store values into consecutive locals corresponding
// to the order in which the values appeared on the stack.
while (numConsumed-- > 0) {
Value value = frame.popValue();
frame.setValue(index++, value);
}
} catch (DataflowAnalysisException e) {
throw new IllegalStateException(e.toString());
}
}
示例3: consumeStack
/**
* Consume stack. This is a convenience method for instructions
* where the types of popped operands can be ignored.
*/
protected void consumeStack(Instruction ins) {
ConstantPoolGen cpg = getCPG();
TypeFrame frame = getFrame();
int numWordsConsumed = ins.consumeStack(cpg);
if (numWordsConsumed == Constants.UNPREDICTABLE)
throw new IllegalStateException("Unpredictable stack consumption for " + ins);
try {
while (numWordsConsumed-- > 0) {
frame.popValue();
}
} catch (DataflowAnalysisException e) {
throw new IllegalStateException("Stack underflow for " + ins + ": " + e.getMessage());
}
}
示例4: checkConsumedAndProducedValues
private void checkConsumedAndProducedValues(Instruction ins, ValueNumber[] consumedValueList,
ValueNumber[] producedValueList) {
int numConsumed = ins.consumeStack(getCPG());
int numProduced = ins.produceStack(getCPG());
if (numConsumed == Constants.UNPREDICTABLE)
throw new IllegalStateException("Unpredictable stack consumption for " + ins);
if (numProduced == Constants.UNPREDICTABLE)
throw new IllegalStateException("Unpredictable stack production for " + ins);
if (consumedValueList.length != numConsumed) {
throw new IllegalStateException("Wrong number of values consumed for " + ins +
": expected " + numConsumed + ", got " + consumedValueList.length);
}
if (producedValueList.length != numProduced) {
throw new IllegalStateException("Wrong number of values produced for " + ins +
": expected " + numProduced + ", got " + producedValueList.length);
}
}
示例5: handleStoreInstruction
@Override
public void handleStoreInstruction(StoreInstruction obj) {
try {
int numConsumed = obj.consumeStack(cpg);
if (numConsumed == Constants.UNPREDICTABLE) {
throw new InvalidBytecodeException("Unpredictable stack consumption");
}
int index = obj.getIndex();
while (numConsumed-- > 0) {
Taint value = new Taint(getFrame().popValue());
value.setVariableIndex(index);
getFrame().setValue(index++, value);
}
} catch (DataflowAnalysisException ex) {
throw new InvalidBytecodeException(ex.toString(), ex);
}
}
示例6: getInstanceValue
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);
}
示例7: handleLoadInstruction
/**
* Handler for all instructions which load values from a local variable
* and push them on the stack. Note that two locals are loaded for
* long and double loads.
*/
public void handleLoadInstruction(LoadInstruction obj) {
int numProduced = obj.produceStack(cpg);
if (numProduced == Constants.UNPREDICTABLE) throw new IllegalStateException();
int index = obj.getIndex() + numProduced;
// Load values from locals in reverse order.
// This restores them to the stack in a way consistent
// with visitStoreInstruction().
while (numProduced-- > 0) {
Value value = frame.getValue(--index);
frame.pushValue(value);
}
}
示例8: transferInstruction
public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock, StackDepth fact) throws DataflowAnalysisException {
Instruction ins = handle.getInstruction();
int produced = ins.produceStack(cpg);
int consumed = ins.consumeStack(cpg);
if (produced == Constants.UNPREDICTABLE || consumed == Constants.UNPREDICTABLE)
throw new IllegalStateException("Unpredictable stack delta for instruction: " + handle);
int depth = fact.getDepth();
depth += (produced - consumed);
if (depth < 0)
fact.setDepth(BOTTOM);
else
fact.setDepth(depth);
}
示例9: analyzeMethod
private void analyzeMethod(ClassContext classContext, Method method)
throws CFGBuilderException, DataflowAnalysisException {
MethodGen methodGen = classContext.getMethodGen(method);
ConstantPoolGen cpg = methodGen.getConstantPool();
CFG cfg = classContext.getCFG(method);
ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method);
LockDataflow dataflow = classContext.getLockDataflow(method);
for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
Location location = i.next();
BasicBlock basicBlock = location.getBasicBlock();
InstructionHandle handle = location.getHandle();
Instruction ins = handle.getInstruction();
if (!(ins instanceof INVOKEVIRTUAL))
continue;
INVOKEVIRTUAL inv = (INVOKEVIRTUAL) ins;
String methodName = inv.getName(cpg);
String methodSig = inv.getSignature(cpg);
if (Hierarchy.isMonitorWait(methodName, methodSig)
|| Hierarchy.isMonitorNotify(methodName, methodSig)) {
int numConsumed = inv.consumeStack(cpg);
if (numConsumed == Constants.UNPREDICTABLE)
throw new AnalysisException("Unpredictable stack consumption", methodGen, handle);
ValueNumberFrame frame = vnaDataflow.getFactAtLocation(location);
if (!frame.isValid())
// Probably dead code
continue;
if (frame.getStackDepth() - numConsumed < 0)
throw new AnalysisException("Stack underflow", methodGen, handle);
ValueNumber ref = frame.getValue(frame.getNumSlots() - numConsumed);
LockSet lockSet = dataflow.getFactAtLocation(location);
int lockCount = lockSet.getLockCount(ref.getNumber());
if (lockCount == 0) {
String sourceFile = classContext.getJavaClass().getSourceFileName();
String type = methodName.equals("wait")
? "MWN_MISMATCHED_WAIT"
: "MWN_MISMATCHED_NOTIFY";
bugReporter.reportBug(new BugInstance(this, type, NORMAL_PRIORITY)
.addClassAndMethod(methodGen, sourceFile)
.addSourceLine(methodGen, sourceFile, handle));
}
}
}
}
示例10: findObviouslyLockedCallSites
/**
* Find all self-call sites that are obviously locked.
*/
private Set<CallSite> findObviouslyLockedCallSites(ClassContext classContext, SelfCalls selfCalls)
throws CFGBuilderException, DataflowAnalysisException {
ConstantPoolGen cpg = classContext.getConstantPoolGen();
// Find all obviously locked call sites
HashSet<CallSite> obviouslyLockedSites = new HashSet<CallSite>();
for (Iterator<CallSite> i = selfCalls.callSiteIterator(); i.hasNext();) {
CallSite callSite = i.next();
Method method = callSite.getMethod();
Location location = callSite.getLocation();
InstructionHandle handle = location.getHandle();
// Only instance method calls qualify as candidates for
// "obviously locked"
Instruction ins = handle.getInstruction();
if (ins.getOpcode() == Constants.INVOKESTATIC)
continue;
// Get lock set for site
LockDataflow lockDataflow = classContext.getLockDataflow(method);
LockSet lockSet = lockDataflow.getFactAtLocation(location);
// Get value number frame for site
ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method);
ValueNumberFrame frame = vnaDataflow.getFactAtLocation(location);
// NOTE: if the CFG on which the value number analysis was performed
// was pruned, there may be unreachable instructions. Therefore,
// we can't assume the frame is valid.
if (!frame.isValid())
continue;
// Find the ValueNumber of the receiver object
int numConsumed = ins.consumeStack(cpg);
if (numConsumed == Constants.UNPREDICTABLE)
throw new AnalysisException("Unpredictable stack consumption: " + handle);
//if (DEBUG) System.out.println("Getting receiver for frame: " + frame);
ValueNumber instance = frame.getStackValue(numConsumed - 1);
// Is the instance locked?
int lockCount = lockSet.getLockCount(instance.getNumber());
if (lockCount > 0) {
// This is a locked call site
obviouslyLockedSites.add(callSite);
}
}
return obviouslyLockedSites;
}
示例11: getNumWordsConsumed
/**
* Get the number of words consumed by given instruction.
*/
public int getNumWordsConsumed(Instruction ins) {
int numWordsConsumed = ins.consumeStack(cpg);
if (numWordsConsumed == Constants.UNPREDICTABLE) throw new IllegalStateException();
return numWordsConsumed;
}
示例12: getNumWordsProduced
/**
* Get the number of words produced by given instruction.
*/
public int getNumWordsProduced(Instruction ins) {
int numWordsProduced = ins.produceStack(cpg);
if (numWordsProduced == Constants.UNPREDICTABLE) throw new IllegalStateException();
return numWordsProduced;
}
示例13: transferInstruction
public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock, IsNullValueFrame fact)
throws DataflowAnalysisException {
// If this is the last instruction in the block,
// save the result immediately before the instruction.
if (handle == basicBlock.getLastInstruction()) {
lastFrame = createFact();
lastFrame.copyFrom(fact);
}
// Model the instruction
visitor.setFrame(fact);
Instruction ins = handle.getInstruction();
ins.accept(visitor);
// Special case:
// The instruction may have produced previously seen values
// about which new is-null information is known.
// If any other instances of the produced values exist,
// update their is-null information.
int numProduced = ins.produceStack(methodGen.getConstantPool());
if (numProduced == Constants.UNPREDICTABLE)
throw new AnalysisException("Unpredictable stack production", methodGen, handle);
int start = fact.getNumSlots() - numProduced;
ValueNumberFrame vnaFrameAfter = vnaDataflow.getFactAfterLocation(new Location(handle, basicBlock));
for (int i = start; i < fact.getNumSlots(); ++i) {
ValueNumber value = vnaFrameAfter.getValue(i);
IsNullValue isNullValue = fact.getValue(i);
for (int j = 0; j < start; ++j) {
ValueNumber otherValue = vnaFrameAfter.getValue(j);
if (value.equals(otherValue)) {
// Same value is in both slots.
// Update the is-null information to match
// the new information.
fact.setValue(j, isNullValue);
}
}
}
}
示例14: getInstance
/**
* Get the value corresponding to the object instance used in
* the given instruction. This relies on the observation that in
* instructions which use an object instance (such as getfield,
* invokevirtual, etc.), the object instance is the first
* operand used by the instruction.
*
* @param ins the instruction
* @param cpg the ConstantPoolGen for the method
*/
public ValueType getInstance(Instruction ins, ConstantPoolGen cpg) throws DataflowAnalysisException {
int numConsumed = ins.consumeStack(cpg);
if (numConsumed == Constants.UNPREDICTABLE)
throw new DataflowAnalysisException("Unpredictable stack consumption in " + ins);
return getStackValue(numConsumed - 1);
}