/** * Collects all exceptions, which could be dispatched by the throw * instruction, using the pointer analysis. Adds the collected exceptions to * addTo. * * @param addTo * set to add the result * @param instruction * the throw instruction */ private void addThrown(LinkedHashSet<TypeReference> addTo, SSAThrowInstruction instruction) { int exceptionVariable = instruction.getException(); if (pointerAnalysis != null) { PointerKey pointerKey = pointerAnalysis.getHeapModel().getPointerKeyForLocal(node, exceptionVariable); Iterator<Object> it = pointerAnalysis.getHeapGraph().getSuccNodes(pointerKey); while (it.hasNext()) { Object next = it.next(); if (next instanceof InstanceKey) { InstanceKey instanceKey = (InstanceKey) next; IClass iclass = instanceKey.getConcreteType(); addTo.add(iclass.getReference()); } else { throw new IllegalStateException("Internal error: Expected InstanceKey, got " + next.getClass().getName()); } } } }
/** * Collects all exceptions, which could be dispatched by the throw * instruction, using the pointer analysis. Adds the collected exceptions to * addTo. * * @param addTo * set to add the result * @param instruction * the throw instruction */ private void addThrown(LinkedHashSet<TypeReference> addTo, SSAThrowInstruction instruction) { int exceptionVariable = instruction.getException(); if (pointerAnalysis != null) { PointerKey pointerKey = pointerAnalysis.getHeapModel().getPointerKeyForLocal(node, exceptionVariable); Iterator<Object> it = pointerAnalysis.getHeapGraph().getSuccNodes(pointerKey); while (it.hasNext()) { Object next = it.next(); if (next instanceof InstanceKey) { InstanceKey instanceKey = (InstanceKey) next; IClass iclass = instanceKey.getConcreteType(); addTo.add(iclass.getReference()); } else { throw new IllegalStateException("Internal error: Expected InstanceKey, got " + next.getClass().getName()); } } } }
private void initDataStructures(PointerAnalysis<InstanceKey> pa) { HeapGraph<InstanceKey> heapGraph = pa.getHeapGraph(); OrdinalSetMapping<InstanceKey> instanceKeyMapping = pa.getInstanceKeyMapping(); for (Object n : heapGraph){ if (heapGraph.getPredNodeCount(n) == 0){ if (n instanceof PointerKey){ if (n instanceof ObjectPropertyCatalogKey){ ObjectPropertyCatalogKey opck = (ObjectPropertyCatalogKey) n; InstanceKey instanceKey = opck.getObject(); int instanceKeyId = instanceKeyMapping.getMappedIndex(instanceKey); mapUsingMutableMapping(instanceKeyIdToObjectPropertyCatalogKey, instanceKeyId, opck); } else if (n instanceof AstGlobalPointerKey){ globalsPointerKeys.add((AstGlobalPointerKey) n); } } else { System.err.println("Non Pointer key root: " + n); } } } }
private void initDataStructures(PointerAnalysis<InstanceKey> pa) { HeapGraph<InstanceKey> heapGraph = pa.getHeapGraph(); OrdinalSetMapping<InstanceKey> instanceKeyMapping = pa.getInstanceKeyMapping(); for (Object n : heapGraph){ if (heapGraph.getPredNodeCount(n) == 0){ if (n instanceof PointerKey){ if (n instanceof ObjectPropertyCatalogKey){ ObjectPropertyCatalogKey opck = (ObjectPropertyCatalogKey) n; InstanceKey instanceKey = opck.getObject(); int instanceKeyId = instanceKeyMapping.getMappedIndex(instanceKey); mapUsingMutableMapping(instanceKeyIdToObjectPropertyCatalogKey, instanceKeyId, opck); } else if (n instanceof AstGlobalPointerKey){ globalsPointerKeys.add((AstGlobalPointerKey) n); } } else { System.err.println("Non Pointer key root: " + n); } } } }
private void initDataStructures(PointerAnalysis<InstanceKey> pa) { HeapGraph<InstanceKey> heapGraph = pa.getHeapGraph(); OrdinalSetMapping<InstanceKey> instanceKeyMapping = pa.getInstanceKeyMapping(); for (Object n : heapGraph){ if (heapGraph.getPredNodeCount(n) == 0){ // considering only roots of the heap graph. if (n instanceof PointerKey){ if (n instanceof LocalPointerKey){ LocalPointerKey lpk = (LocalPointerKey) n; int nodeId = lpk.getNode().getGraphNodeId(); mapUsingMutableMapping(cgNodeIdToLocalPointers, nodeId, lpk); } else if (n instanceof ReturnValueKey){ ReturnValueKey rvk = (ReturnValueKey) n; int nodeId = rvk.getNode().getGraphNodeId(); mapUsingMutableMapping(cgNodeIdToReturnValue, nodeId, rvk); } else if (n instanceof InstanceFieldPointerKey){ InstanceFieldPointerKey ifpk = (InstanceFieldPointerKey) n; int instanceKeyId = instanceKeyMapping.getMappedIndex(ifpk.getInstanceKey()); mapUsingMutableMapping(instanceKeyIdToInstanceFieldPointers, instanceKeyId, ifpk); } } else { System.err.println("Non Pointer key root: " + n); } } } }
private void initDataStructures(PointerAnalysis<InstanceKey> pa) { HeapGraph<InstanceKey> heapGraph = pa.getHeapGraph(); OrdinalSetMapping<InstanceKey> instanceKeyMapping = pa.getInstanceKeyMapping(); for (Object n : heapGraph){ if (heapGraph.getPredNodeCount(n) == 0){ // considering only roots of the heap graph. if (n instanceof PointerKey){ if (n instanceof LocalPointerKey){ LocalPointerKey lpk = (LocalPointerKey) n; int nodeId = lpk.getNode().getGraphNodeId(); mapUsingMutableMapping(cgNodeIdToLocalPointers, nodeId, lpk); } else if (n instanceof ReturnValueKey){ ReturnValueKey rvk = (ReturnValueKey) n; int nodeId = rvk.getNode().getGraphNodeId(); mapUsingMutableMapping(cgNodeIdToReturnValue, nodeId, rvk); } else if (n instanceof InstanceFieldPointerKey){ InstanceFieldPointerKey ifpk = (InstanceFieldPointerKey) n; int instanceKeyId = instanceKeyMapping.getMappedIndex(ifpk.getInstanceKey()); mapUsingMutableMapping(instanceKeyIdToInstanceFieldPointers, instanceKeyId, ifpk); } } else { System.err.println("Non Pointer key root: " + n); } } } }
protected void test(Predicate<MethodReference> filter, Predicate<Pair<Set<Pair<CGNode, NewSiteReference>>, Set<Pair<CGNode, NewSiteReference>>>> test, CallGraph fbCG, PointerAnalysis<ObjectVertex> fbPA, CallGraph propCG, PointerAnalysis<InstanceKey> propPA) { HeapGraph<ObjectVertex> hg = fbPA.getHeapGraph();