@Override public InstanceKey getInstanceKeyForAllocation(CGNode node, NewSiteReference allocation) { return delegate.getInstanceKeyForAllocation(node, allocation); }
@Override public InstanceKey getInstanceKeyForAllocation(CGNode node, NewSiteReference allocation) { return h.getInstanceKeyForAllocation(node, allocation); }
@Override public InstanceKey getInstanceKeyForAllocation(CGNode node, NewSiteReference allocation) { return delegate.getInstanceKeyForAllocation(node, allocation); }
@Override public InstanceKey getInstanceKeyForAllocation(CGNode node, NewSiteReference allocation) { return h.getInstanceKeyForAllocation(node, allocation); }
@Override public boolean mayBeLive(CGNode allocMethod, int allocPC, CGNode m, int instructionIndex) throws IllegalArgumentException, WalaException { if (allocMethod == null) { throw new IllegalArgumentException("allocMethod == null"); } NewSiteReference site = TrivialMethodEscape.findAlloc(allocMethod, allocPC); InstanceKey ik = heapGraph.getHeapModel().getInstanceKeyForAllocation(allocMethod, site); return mayBeLive(ik, m, instructionIndex); }
@Override public boolean mayBeLive(CGNode allocMethod, int allocPC, CGNode m, int instructionIndex) throws IllegalArgumentException, WalaException { if (allocMethod == null) { throw new IllegalArgumentException("allocMethod == null"); } NewSiteReference site = TrivialMethodEscape.findAlloc(allocMethod, allocPC); InstanceKey ik = heapGraph.getHeapModel().getInstanceKeyForAllocation(allocMethod, site); return mayBeLive(ik, m, instructionIndex); }
/** * convert a pointer key to one in the memory access map's heap model * * TODO move this somewhere more appropriate * * @throws UnsupportedOperationException if it doesn't know how to handle a {@link PointerKey} */ public static PointerKey convertPointerKeyToHeapModel(PointerKey pk, HeapModel h) { if (pk == null) { throw new IllegalArgumentException("null pk"); } if (pk instanceof LocalPointerKey) { LocalPointerKey lpk = (LocalPointerKey) pk; return h.getPointerKeyForLocal(lpk.getNode(), lpk.getValueNumber()); } else if (pk instanceof ArrayContentsKey) { ArrayContentsKey ack = (ArrayContentsKey) pk; InstanceKey ik = ack.getInstanceKey(); if (ik instanceof NormalAllocationInNode) { NormalAllocationInNode nain = (NormalAllocationInNode) ik; ik = h.getInstanceKeyForAllocation(nain.getNode(), nain.getSite()); } else { assert false : "need to handle " + ik.getClass(); } return h.getPointerKeyForArrayContents(ik); } else if (pk instanceof ReturnValueKey) { ReturnValueKey rvk = (ReturnValueKey) pk; return h.getPointerKeyForReturnValue(rvk.getNode()); } throw new UnsupportedOperationException("need to handle " + pk.getClass()); }
/** * convert a pointer key to one in the memory access map's heap model * * TODO move this somewhere more appropriate * * @throws UnsupportedOperationException if it doesn't know how to handle a {@link PointerKey} */ public static PointerKey convertPointerKeyToHeapModel(PointerKey pk, HeapModel h) { if (pk == null) { throw new IllegalArgumentException("null pk"); } if (pk instanceof LocalPointerKey) { LocalPointerKey lpk = (LocalPointerKey) pk; return h.getPointerKeyForLocal(lpk.getNode(), lpk.getValueNumber()); } else if (pk instanceof ArrayContentsKey) { ArrayContentsKey ack = (ArrayContentsKey) pk; InstanceKey ik = ack.getInstanceKey(); if (ik instanceof NormalAllocationInNode) { NormalAllocationInNode nain = (NormalAllocationInNode) ik; ik = h.getInstanceKeyForAllocation(nain.getNode(), nain.getSite()); } else { assert false : "need to handle " + ik.getClass(); } return h.getPointerKeyForArrayContents(ik); } else if (pk instanceof ReturnValueKey) { ReturnValueKey rvk = (ReturnValueKey) pk; return h.getPointerKeyForReturnValue(rvk.getNode()); } throw new UnsupportedOperationException("need to handle " + pk.getClass()); }
InstanceKey ik = hg.getHeapModel().getInstanceKeyForAllocation(n, site); if (ik == null) { throw new WalaException("could not get instance key at site " + site + " in " + n);
InstanceKey ik = hg.getHeapModel().getInstanceKeyForAllocation(n, site); if (ik == null) { throw new WalaException("could not get instance key at site " + site + " in " + n);
public static InstanceKey mapInstKey(InstanceKey ik, CallGraph fromCG, CallGraph toCG, HeapModel heapModel) throws UnimplementedError, NullPointerException { InstanceKey ret = null; if (ik instanceof InstanceKeyWithNode) { CGNode oldCGNode = ((InstanceKeyWithNode) ik).getNode(); CGNode newCGNode = mapCGNode(oldCGNode, fromCG, toCG); if (newCGNode == null) { return null; } if (ik instanceof AllocationSiteInNode) { if (ik instanceof NormalAllocationInNode) { ret = heapModel.getInstanceKeyForAllocation(newCGNode, ((AllocationSiteInNode) ik).getSite()); } else if (ik instanceof MultiNewArrayInNode) { MultiNewArrayInNode mnik = (MultiNewArrayInNode) ik; ret = heapModel.getInstanceKeyForMultiNewArray(newCGNode, mnik.getSite(), mnik.getDim()); } else { Assertions.UNREACHABLE(); } } else { Assertions.UNREACHABLE(); } } else if (ik instanceof ConcreteTypeKey) { return ik; } else { Assertions.UNREACHABLE(); } assert ret != null; assert ret.getClass() == ik.getClass(); return ret; }
public static InstanceKey mapInstKey(InstanceKey ik, CallGraph fromCG, CallGraph toCG, HeapModel heapModel) throws UnimplementedError, NullPointerException { InstanceKey ret = null; if (ik instanceof InstanceKeyWithNode) { CGNode oldCGNode = ((InstanceKeyWithNode) ik).getNode(); CGNode newCGNode = mapCGNode(oldCGNode, fromCG, toCG); if (newCGNode == null) { return null; } if (ik instanceof AllocationSiteInNode) { if (ik instanceof NormalAllocationInNode) { ret = heapModel.getInstanceKeyForAllocation(newCGNode, ((AllocationSiteInNode) ik).getSite()); } else if (ik instanceof MultiNewArrayInNode) { MultiNewArrayInNode mnik = (MultiNewArrayInNode) ik; ret = heapModel.getInstanceKeyForMultiNewArray(newCGNode, mnik.getSite(), mnik.getDim()); } else { Assertions.UNREACHABLE(); } } else { Assertions.UNREACHABLE(); } } else if (ik instanceof ConcreteTypeKey) { return ik; } else { Assertions.UNREACHABLE(); } assert ret != null; assert ret.getClass() == ik.getClass(); return ret; }
InstanceKey iKey = heapModel.getInstanceKeyForAllocation(node, instruction.getNewSite()); if (iKey == null) {
/** * returns the instance key corresponding to the single allocation site of * type FlowsToType */ private InstanceKey getFlowsToInstanceKey(CGNode mainMethod, HeapModel heapModel) { // TODO Auto-generated method stub TypeReference flowsToTypeRef = TypeReference.findOrCreate(ClassLoaderReference.Application, StringStuff.deployment2CanonicalTypeString("demandpa.FlowsToType")); final IR mainIR = mainMethod.getIR(); if (debug) { System.err.println(mainIR); } for (NewSiteReference n : Iterator2Iterable.make(mainIR.iterateNewSites())) { if (n.getDeclaredType().equals(flowsToTypeRef)) { return heapModel.getInstanceKeyForAllocation(mainMethod, n); } } assert false : "could not find appropriate allocation"; return null; }
@Override public void visitNew(SSANewInstruction instruction) { InstanceKey iKey = heapModel.getInstanceKeyForAllocation(node, instruction.getNewSite()); if (iKey == null) { // something went wrong. I hope someone raised a warning. return; } PointerKey def = heapModel.getPointerKeyForLocal(node, instruction.getDef()); g.addNode(iKey); g.addNode(def); g.addEdge(def, iKey, NewLabel.v()); NewMultiDimInfo multiDimInfo = getInfoForNewMultiDim(instruction, heapModel, node); if (multiDimInfo != null) { for (Pair<PointerKey, InstanceKey> newInstr : multiDimInfo.newInstrs) { g.addNode(newInstr.fst); g.addNode(newInstr.snd); g.addEdge(newInstr.fst, newInstr.snd, NewLabel.v()); } for (Pair<PointerKey, PointerKey> arrStoreInstr : multiDimInfo.arrStoreInstrs) { g.addNode(arrStoreInstr.fst); g.addNode(arrStoreInstr.snd); g.addEdge(arrStoreInstr.fst, arrStoreInstr.snd, PutFieldLabel.make(ArrayContents.v())); } } }
@Override public void visitNew(SSANewInstruction instruction) { InstanceKey iKey = heapModel.getInstanceKeyForAllocation(node, instruction.getNewSite()); if (iKey == null) { // something went wrong. I hope someone raised a warning. return; } PointerKey def = heapModel.getPointerKeyForLocal(node, instruction.getDef()); g.addNode(iKey); g.addNode(def); g.addEdge(def, iKey, NewLabel.v()); NewMultiDimInfo multiDimInfo = getInfoForNewMultiDim(instruction, heapModel, node); if (multiDimInfo != null) { for (Pair<PointerKey, InstanceKey> newInstr : multiDimInfo.newInstrs) { g.addNode(newInstr.fst); g.addNode(newInstr.snd); g.addEdge(newInstr.fst, newInstr.snd, NewLabel.v()); } for (Pair<PointerKey, PointerKey> arrStoreInstr : multiDimInfo.arrStoreInstrs) { g.addNode(arrStoreInstr.fst); g.addNode(arrStoreInstr.snd); g.addEdge(arrStoreInstr.fst, arrStoreInstr.snd, PutFieldLabel.make(ArrayContents.v())); } } }
InstanceKey iKey = hm.getInstanceKeyForAllocation(node, def.getNewSite()); result = (iKey == null) ? new InstanceKey[0] : new InstanceKey[] { iKey };
InstanceKey iKey = hm.getInstanceKeyForAllocation(node, def.getNewSite()); result = (iKey == null) ? new InstanceKey[0] : new InstanceKey[] { iKey };
@Override public void visitNew(SSANewInstruction instruction) { InstanceKey iKey = heapModel.getInstanceKeyForAllocation(node, instruction.getNewSite()); if (iKey == null) {
@Override public void visitNew(SSANewInstruction instruction) { InstanceKey iKey = heapModel.getInstanceKeyForAllocation(node, instruction.getNewSite()); if (iKey == null) {