private static <T> void dfs(BasicNaturalRelation result, T root, NumberedGraph<T> G, Set<T> visited, Set<T> onstack) { visited.add(root); onstack.add(root); for (T dstNode : Iterator2Iterable.make(G.getSuccNodes(root))) { if (onstack.contains(dstNode)) { int src = G.getNumber(root); int dst = G.getNumber(dstNode); result.add(src, dst); } if (!visited.contains(dstNode)) { dfs(result, dstNode, G, visited, onstack); } } onstack.remove(root); }
result.add(src, dst); } else { stack.push(current);
result.add(src, dst); } else { stack.push(current);
private static <T> void dfs(BasicNaturalRelation result, T root, NumberedGraph<T> G, Set<T> visited, Set<T> onstack) { visited.add(root); onstack.add(root); for (T dstNode : Iterator2Iterable.make(G.getSuccNodes(root))) { if (onstack.contains(dstNode)) { int src = G.getNumber(root); int dst = G.getNumber(dstNode); result.add(src, dst); } if (!visited.contains(dstNode)) { dfs(result, dstNode, G, visited, onstack); } } onstack.remove(root); }
result.add(src, dst); } else { stack.push(current);
private static <T> void dfs(BasicNaturalRelation result, T root, NumberedGraph<T> G, Set<T> visited, Set<T> onstack) { visited.add(root); onstack.add(root); for (T dstNode : Iterator2Iterable.make(G.getSuccNodes(root))) { if (onstack.contains(dstNode)) { int src = G.getNumber(root); int dst = G.getNumber(dstNode); result.add(src, dst); } if (!visited.contains(dstNode)) { dfs(result, dstNode, G, visited, onstack); } } onstack.remove(root); }
/** * traverse locals in order, first by node, then by value number: attempt to improve locality */ private void computePredecessorsForLocals(NumberedNodeManager<Object> nodeManager, BasicNaturalRelation R) { ArrayList<LocalPointerKey> list = new ArrayList<>(); for (Object n : nodeManager) { if (n instanceof LocalPointerKey) { list.add((LocalPointerKey) n); } } Object[] arr = list.toArray(); Arrays.sort(arr, new LocalPointerComparator()); for (int i = 0; i < arr.length; i++) { if (VERBOSE) { if (i % VERBOSE_INTERVAL == 0) { System.err.println("Building HeapGraph: " + i + " of " + arr.length); } } LocalPointerKey n = (LocalPointerKey) arr[i]; int num = nodeManager.getNumber(n); int[] succ = computeSuccNodeNumbers(n, nodeManager); if (succ != null) { for (int j : succ) { R.add(j, num); } } } }
/** * traverse locals in order, first by node, then by value number: attempt to improve locality */ private void computePredecessorsForLocals(NumberedNodeManager<Object> nodeManager, BasicNaturalRelation R) { ArrayList<LocalPointerKey> list = new ArrayList<>(); for (Object n : nodeManager) { if (n instanceof LocalPointerKey) { list.add((LocalPointerKey) n); } } Object[] arr = list.toArray(); Arrays.sort(arr, new LocalPointerComparator()); for (int i = 0; i < arr.length; i++) { if (VERBOSE) { if (i % VERBOSE_INTERVAL == 0) { System.err.println("Building HeapGraph: " + i + " of " + arr.length); } } LocalPointerKey n = (LocalPointerKey) arr[i]; int num = nodeManager.getNumber(n); int[] succ = computeSuccNodeNumbers(n, nodeManager); if (succ != null) { for (int j : succ) { R.add(j, num); } } } }
/** * create mappings from call sites, new sites, and PEIs to instruction index */ protected void setupLocationMap() { for (int i = 0; i < instructions.length; i++) { SSAInstruction x = instructions[i]; if (x != null) { if (x instanceof SSAAbstractInvokeInstruction) { callSiteMapping.add(((SSAAbstractInvokeInstruction) x).getCallSite().getProgramCounter(), i); } if (x instanceof SSANewInstruction) { newSiteMapping.put(((SSANewInstruction) x).getNewSite(), Integer.valueOf(i)); } if (x.isPEI()) { peiMapping.put(new ProgramCounter(cfg.getProgramCounter(i)), Integer.valueOf(i)); } } } }
/** * create mappings from call sites, new sites, and PEIs to instruction index */ protected void setupLocationMap() { for (int i = 0; i < instructions.length; i++) { SSAInstruction x = instructions[i]; if (x != null) { if (x instanceof SSAAbstractInvokeInstruction) { callSiteMapping.add(((SSAAbstractInvokeInstruction) x).getCallSite().getProgramCounter(), i); } if (x instanceof SSANewInstruction) { newSiteMapping.put(((SSANewInstruction) x).getNewSite(), Integer.valueOf(i)); } if (x.isPEI()) { peiMapping.put(new ProgramCounter(cfg.getProgramCounter(i)), Integer.valueOf(i)); } } } }
private void computePredecessorsForNonLocals(NumberedNodeManager<Object> nodeManager, BasicNaturalRelation R) { // Note: we run this loop backwards on purpose, to avoid lots of resizing of // bitvectors // in the backing relation. i.e., we will add the biggest bits first. // pretty damn tricky. for (int i = nodeManager.getMaxNumber(); i >= 0; i--) { if (VERBOSE) { if (i % VERBOSE_INTERVAL == 0) { System.err.println("Building HeapGraph: " + i); } } Object n = nodeManager.getNode(i); if (!(n instanceof LocalPointerKey)) { int[] succ = computeSuccNodeNumbers(n, nodeManager); if (succ != null) { for (int j : succ) { R.add(j, i); } } } } }
private void computePredecessorsForNonLocals(NumberedNodeManager<Object> nodeManager, BasicNaturalRelation R) { // Note: we run this loop backwards on purpose, to avoid lots of resizing of // bitvectors // in the backing relation. i.e., we will add the biggest bits first. // pretty damn tricky. for (int i = nodeManager.getMaxNumber(); i >= 0; i--) { if (VERBOSE) { if (i % VERBOSE_INTERVAL == 0) { System.err.println("Building HeapGraph: " + i); } } Object n = nodeManager.getNode(i); if (!(n instanceof LocalPointerKey)) { int[] succ = computeSuccNodeNumbers(n, nodeManager); if (succ != null) { for (int j : succ) { R.add(j, i); } } } } }