Example #1
0
  /* process field edge constraint */
  public void process(FieldConstraint c) {
    Node csrc = c.src.getRep();
    Node cdst = c.dst.getRep();
    assert (csrc.graph == this);
    assert (cdst.graph == this);

    if (heapfix && csrc.isheap && !cdst.isheap) w.addFirst(new UnifyConstraint(csrc, cdst));

    Collection<FieldEdge> fed = fedges.get(c.field);
    if (secondary_index[9]) {
      FieldEdge e = csrc.outfields.get(c.field);
      if (e != null) {
        if (e.dst != cdst) w.addFirst(new UnifyConstraint(e.dst, cdst));
        return;
      }
    } else {
      if (fed != null)
        for (FieldEdge e : fed) {
          Node esrc = e.src.getRep();
          Node edst = e.dst.getRep();
          assert (e.field.equals(c.field));
          if (esrc == csrc) {
            if (edst != cdst) w.addFirst(new UnifyConstraint(edst, cdst));
            return;
          }
        }
    }

    FieldEdge e = new FieldEdge(csrc, cdst, c.field);

    if (fed == null) {
      fed = new ArrayList<FieldEdge>();
      fedges.put(c.field, fed);
    }
    fed.add(e);
    if (secondary_index[1]) {
      csrc.outfields.put(e.field, e);
      addInField(cdst, e.field, e);
    }

    // Merge nodes according to Tag information
    Node find =
        Options.detailed.value
            ? reachesTag(csrc, cdst.tag, new HashSet<Node>())
            : containsTag(cdst.tag);

    if (find != null) w.addFirst(new UnifyConstraint(cdst, find));
  }
Example #2
0
  /* process call edge constraint */
  public void process(CallConstraint c) {
    Node csrc = c.ncaller.getRep();
    Node cdst = c.ncallee.getRep();
    assert (cdst.graph == this);

    if (heapfix && csrc.graph == this && !csrc.isheap && cdst.isheap)
      w.addFirst(new UnifyConstraint(csrc, cdst));

    Collection<CallEdge> ced = cedges.get(c.call);
    if (ced != null)
      for (CallEdge e : ced) {
        Node esrc = e.src.getRep();
        Node edst = e.dst.getRep();
        if (edst == cdst && e.call.equals(c.call)) {
          if (esrc != csrc) {
            Graph g = esrc.graph;
            assert (g != this || !Options.mergeGraphs.value);
            g.w.addFirst(new UnifyConstraint(esrc, csrc));
          }
          return;
        }
      }
    else {
      ced = new ArrayList<CallEdge>();
      cedges.put(c.call, ced);
    }

    ced.add(new CallEdge(csrc, cdst, c.call));
  }
Example #3
0
  /* Processing regular assignments. Left and right hand side each
  may be a variable or the field of a variable. Variables include
  parameters and locals. */
  public void assignExpr(Var x, Field f, Var y, Field g, boolean isBasic) {

    if (!isBasic) w.addFirst(new UnifyConstraint(getNode(x, f), getNode(y, g)));

    if (f != null) setTouched(x);

    if (g != null) setTouched(y);
  }
Example #4
0
  /* Processing assignments of actuals to formals at a call
  site. The first parameter is the call instruction. The second
  is the formal parameter. The last two represent the variable or
  the field being passed.

  For return values, the second parameter is the formal return
  variable in the callee, and the last two parameters are the
  variable/field that the call is assigned to. */
  public void assignParams(Call call, Var p, Var x, Field f, boolean isBasic) {

    if (!isBasic) {
      Method callee = call.getCallee();
      Graph gcallee = PointsToAnalysis.v().getGraph(callee);

      Node nodeL = gcallee.getNode(p, null);
      Node nodeR = this.getNode(x, f);
      if (Options.mergeGraphs.value && this == gcallee) {
        if (p.isReturn()) w.addFirst(new UnifyConstraint(nodeR, nodeL));
        else w.addFirst(new UnifyConstraint(nodeL, nodeR));
      }
      callsites.add(call);
      callees.add(callee);
      gcallee.callers.add(method);
      gcallee.w.add(new CallConstraint(nodeR, nodeL, call));
    }

    if (f != null) setTouched(x);
  }