Esempio n. 1
0
  /* Matches the subgraphs rooted at two nodes and records the
   * isomorphism into a map. */
  private static void matchSubgraph(Node node1, Node node2, Map<RegionVar, RegionVar> map) {
    RegionVar r1 = node1.getRep().getRegion();
    RegionVar r2 = node2.getRep().getRegion();

    if (map.containsKey(r1)) {
      assert (r2 == map.get(r1))
          : "at call: "
              + node2.graph.method
              + " to "
              + node1.graph.method
              + "\n"
              + r2
              + "("
              + node2
              + ") vs "
              + map.get(r1)
              + " corresponding to "
              + r1
              + "("
              + node1
              + ")";
      return;
    }

    map.put(r1, r2);

    if (secondary_index[3]) {
      node1 = node1.getRep();
      node2 = node2.getRep();
      for (Field f : node1.outfields.keySet()) {
        FieldEdge fe1 = node1.outfields.get(f);
        assert (fe1.src == node1);
        FieldEdge fe2 = node2.outfields.get(f);
        assert (fe2 != null);
        matchSubgraph(fe1.dst, fe2.dst, map);
      }
    } else {
      for (Field f : node1.graph.fedges.keySet())
        for (FieldEdge fe1 : node1.graph.fedges.get(f)) {
          if (fe1.src != node1) continue;
          boolean found = false;
          assert (node2.graph.fedges.get(f) != null);
          for (FieldEdge fe2 : node2.graph.fedges.get(f)) {
            if (fe2.src != node2) continue;
            if (!fe1.field.equals(fe2.field)) continue;
            matchSubgraph(fe1.dst, fe2.dst, map);
            found = true;
            break;
          }
          assert (found);
        }
    }
  }
Esempio n. 2
0
  protected RegionVar getUniqueRegionOf(Var var) {
    assert (var != null && varmap.get(var) != null)
        : " Var " + var + method + " " + var.getDeclaringMethod();
    Node node = (varmap.get(var)).get(null);
    if (node == null) return null;

    return node.getRep().getRegion();
  }
Esempio n. 3
0
  protected List<RegionVar> getRegionsOf(Var var, Map<RegionVar, Set<Field>> dead) {
    Node node = (varmap.get(var)).get(null);
    if (node == null) return null;

    List<RegionVar> regions = new ArrayList<RegionVar>();
    getRegionsHelper(node.getRep(), dead, regions);
    return regions;
  }
Esempio n. 4
0
 private void computeCaches() {
   cacheAllRegions = new ArrayList<RegionVar>();
   cacheI2R = new HashMap<Integer, RegionVar>();
   for (Node n : nodes) getRegionsHelper(n.getRep(), null, cacheAllRegions);
   for (RegionVar r : cacheAllRegions) {
     r.setIndex(++numRegions);
     cacheI2R.put(r.getIndex(), r);
   }
   numRegions++;
 }
Esempio n. 5
0
  private void getRegionsHelper(
      Node node, Map<RegionVar, Set<Field>> dead, List<RegionVar> regions) {
    RegionVar reg = node.getRegion();
    if (regions.contains(reg)) return;

    regions.add(reg);
    if (secondary_index[6]) {
      for (Field f : node.getRep().outfields.keySet()) {
        FieldEdge fe = node.getRep().outfields.get(f);
        assert (fe.src == node);
        if (dead == null || dead.get(reg) == null || !dead.get(reg).contains(fe.field))
          getRegionsHelper(fe.dst.getRep(), dead, regions);
      }
    } else {
      for (Field f : fedges.keySet())
        for (FieldEdge fe : fedges.get(f)) {
          if (fe.src == node) {
            if (dead == null || dead.get(reg) == null || !dead.get(reg).contains(fe.field))
              getRegionsHelper(fe.dst, dead, regions);
          }
        }
    }
  }
Esempio n. 6
0
  protected void addRegionsFrom(
      Node node, Map<RegionVar, Set<Field>> dead, IBitVector<RegionVar> marked) {
    RegionVar reg = node.getRegion();
    if (reg.isHeap() || marked.get(reg)) return;

    marked.set(reg);
    if (secondary_index[6]) {
      for (Field f : node.getRep().outfields.keySet()) {
        FieldEdge fe = node.getRep().outfields.get(f);
        assert (fe.src == node);
        if (dead == null || dead.get(reg) == null || !dead.get(reg).contains(fe.field))
          addRegionsFrom(fe.dst.getRep(), dead, marked);
      }
    } else {
      for (Field f : fedges.keySet())
        for (FieldEdge fe : fedges.get(f)) {
          if (fe.src == node) {
            if (dead == null || dead.get(reg) == null || !dead.get(reg).contains(fe.field))
              addRegionsFrom(fe.dst, dead, marked);
          }
        }
    }
  }
Esempio n. 7
0
  protected RegionVar getUniqueRegionOf(Node n, Field f) {
    if (secondary_index[5]) {
      FieldEdge fe = n.getRep().outfields.get(f);
      assert (fe != null && fe.src == n);
      return fe.dst.getRep().getRegion();
    }

    if (fedges.get(f) == null) return null;

    for (FieldEdge fe : fedges.get(f)) {
      assert (fe.field.equals(f));
      if (fe.src.equals(n)) return fe.dst.getRep().getRegion();
    }
    return null;
  }
Esempio n. 8
0
 /* Return the region of an allocation site in this method */
 protected RegionVar getAllocRegion(New alloc) {
   Node node = allocmap.get(alloc);
   assert (node != null);
   return node.getRep().getRegion();
 }
Esempio n. 9
0
 protected RegionVar getUniqueRegionOf(VarF vf) {
   Node node = (varmap.get(vf.getVar())).get(vf.getField());
   if (node == null) return null;
   return node.getRep().getRegion();
 }