Пример #1
0
  /** Is tag reachable from node on paths with no visited nodes? */
  private Node reachesTag(Node node, UniqueTag tag, Set<Node> visited) {
    assert (node.isRep());
    if (visited.contains(node)) return null;
    if (tag.mergeable(node.tag)) return node;

    visited.add(node);

    if (secondary_index[2]) {
      for (Field f : node.infields.keySet())
        for (FieldEdge e : node.infields.get(f)) {
          assert (e.dst == node);
          Node result = reachesTag(e.src.getRep(), tag, visited);
          if (result != null) return result;
        }
    } else {
      for (Field f : fedges.keySet())
        for (FieldEdge e : fedges.get(f)) {
          if (e.dst != node) continue;
          Node result = reachesTag(e.src, tag, visited);
          if (result != null) return result;
        }
    }
    return null;
  }
Пример #2
0
 protected int numSync() {
   int c = 0;
   for (Node node : nodes) if (node.isRep() && node.hasSync()) c++;
   return c;
 }
Пример #3
0
 protected int numTouched() {
   int c = 0;
   for (Node node : nodes) if (node.isRep() && node.isTouched()) c++;
   return c;
 }
Пример #4
0
 protected int numHeap() {
   int c = 0;
   for (Node node : nodes) if (node.isRep() && node.isHeap()) c++;
   return c;
 }
Пример #5
0
 protected int numAlloc() {
   int c = 0;
   for (Node node : nodes) if (node.isRep() && node.hasAllocations()) c++;
   return c;
 }
Пример #6
0
  /* Print the current type graph to the dotfile */
  public void printDot(String title, Call call) {
    boolean printUnifications = false;
    PrintStream ps = PointsToAnalysis.v().file;
    if (ps == null) return;

    ps.println("\ndigraph F {");
    ps.println("   size = \"7,7\"; rankdir = LR;");
    ps.println("   orientation = landscape;");

    ps.println("   subgraph cluster1 {");
    ps.println("   \"Method: " + method.getName() + "\" [color=white];");

    if (nodes.isEmpty()) {
      ps.println("   \"empty graph\" [color = white];");
      ps.println("   }");
      ps.println("}");
      return;
    }

    for (Node node : nodes) {
      if (!printUnifications && !node.isRep()) continue;
      String color = "style=filled,fillcolor=";
      if (node.isheap && node.hasallocs) color += "red,";
      else if (node.isheap) color += "orange,";
      else if (node.hasallocs) color += "grey,";
      else color += "white,";
      // if (node.istouched) color = "khaki";
      // if (node.hassync) color = "khaki";
      String shape = "shape=";
      if (node.istouched) shape += "box";
      else shape += "ellipse";

      ps.println("   o" + node.id + "[label = \"" + node.getName() + "\"," + color + shape + "];");
    }
    ps.println("   }");

    Map<Integer, Map<Integer, String>> labels = new HashMap<Integer, Map<Integer, String>>();
    for (Field f : fedges.keySet())
      for (FieldEdge e : fedges.get(f)) {
        if (labels.containsKey(e.src.id)) {
          if (labels.get(e.src.id).containsKey(e.dst.id)) {
            labels.get(e.src.id).put(e.dst.id, "*");
            //                            labels.get(e.src.id).get(e.dst.id) + ", " +
            //                            e.field.getName());
          } else labels.get(e.src.id).put(e.dst.id, e.field.getName());

        } else {
          Map<Integer, String> is = new HashMap<Integer, String>();
          is.put(e.dst.id, e.field.getName());
          labels.put(e.src.id, is);
        }
      }
    for (Integer i : labels.keySet())
      for (Integer j : labels.get(i).keySet())
        ps.print(
            "   o"
                + i
                + " -> o"
                + j
                + "[label=\""
                + labels.get(i).get(j)
                + "\",style=solid,color=black];");

    for (Call ce : cedges.keySet())
      for (CallEdge e : cedges.get(ce)) {
        if (!(e.call instanceof VirtualCallExpr)) continue;
        // if (!e.call.equals(call)) continue;
        ps.print(
            "   o"
                + e.src.id
                + " -> o"
                + e.dst.id
                + "[label=\""
                + e.call
                + "\",style=solid,color=red];");
      }

    if (printUnifications)
      for (Node node : nodes)
        if (node.parent != null)
          ps.println("   o" + node.id + " -> o" + node.parent.id + " [color = blue];");

    ps.println("}");
  }
Пример #7
0
 /** Does the graph contain a node of a given tag? */
 private Node containsTag(UniqueTag tag) {
   for (Node node : nodes) if (node.isRep() && tag.mergeable(node.tag)) return node;
   return null;
 }