//
// Exception edges are not considered in computing
// dominators/postdominators.
// We will consider this to be all of the code that creates
// the object.
DominatorsAnalysis domAnalysis = classContext.getNonExceptionDominatorsAnalysis(method);
PostDominatorsAnalysis postDomAnalysis = classContext.getNonExceptionPostDominatorsAnalysis(method);
BitSet extent = domAnalysis.getAllDominatedBy(createBegin.getBasicBlock());
BitSet postDom = postDomAnalysis.getAllDominatedBy(store.getBasicBlock());
// System.out.println("Extent: " + extent);
if (DEBUG) {
System.out.println("test dominates: " + extent);
System.out.println("Field store postdominates " + postDom);
}
extent.and(postDom);
if (DEBUG) {
System.out.println("extent: " + extent);
}
// Check all instructions in the object creation extent
//
// (1) to determine the common lock set, and
// (2) to check for NEW and Invoke instructions that might create an
// object
//
// We ignore matches where a lock is held consistently,
// or if the extent does not appear to create a new object.
LockDataflow lockDataflow = classContext.getLockDataflow(method);
LockSet lockSet = null;
boolean sawNEW = false, sawINVOKE = false;
for (BasicBlock block : cfg.getBlocks(extent)) {
for (Iterator<InstructionHandle> j = block.instructionIterator(); j.hasNext();) {
InstructionHandle handle = j.next();
if (handle.equals(store.getMatchedInstructionInstructionHandle())) {
break;
}
Location location = new Location(handle, block);
// Keep track of whether we saw any instructions
// that might actually have created a new object.
Instruction ins = handle.getInstruction();
if (DEBUG) {
System.out.println(location);
}
if (ins instanceof AllocationInstruction) {
sawNEW = true;
} else if (ins instanceof InvokeInstruction) {
if (ins instanceof INVOKESTATIC
&& ((INVOKESTATIC) ins).getMethodName(classContext.getConstantPoolGen()).startsWith("new")) {
sawNEW = true;
}
sawINVOKE = true;
}
// Compute lock set intersection for all matched
// instructions.
LockSet insLockSet = lockDataflow.getFactAtLocation(location);
if (lockSet == null) {
lockSet = new LockSet();
lockSet.copyFrom(insLockSet);
} else {
lockSet.intersectWith(insLockSet);
}
}
}
if (!(sawNEW || sawINVOKE)) {
return;
}
if (lockSet == null) {
throw new IllegalStateException("lock set is null");
}
if (!lockSet.isEmpty()) {
return;
}
boolean sawGetStaticAfterPutStatic = false;
check: if (signature.startsWith("[") || signature.startsWith("L")) {
BitSet postStore = domAnalysis.getAllDominatedBy(store.getBasicBlock());
for (BasicBlock block : cfg.getBlocks(postStore)) {
for (Iterator<InstructionHandle> j = block.instructionIterator(); j.hasNext();) {
InstructionHandle handle = j.next();
InstructionHandle nextHandle = handle.getNext();