コード例 #1
0
 private void addParamEdges(LocalPointerKey pk, CGNode node) {
   // get parameter position: value number - 1?
   int paramPos = pk.getValueNumber() - 1;
   // iterate over callers
   for (CGNode caller : cg) {
     // TODO we don't need to add the graph if null is passed
     // as the argument
     addSubgraphForNode(caller);
     IR ir = caller.getIR();
     for (Iterator<CallSiteReference> iterator = ir.iterateCallSites(); iterator.hasNext(); ) {
       CallSiteReference call = iterator.next();
       if (cg.getPossibleTargets(caller, call).contains(node)) {
         SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call);
         for (int i = 0; i < callInstrs.length; i++) {
           SSAAbstractInvokeInstruction callInstr = callInstrs[i];
           PointerKey actualPk =
               heapModel.getPointerKeyForLocal(caller, callInstr.getUse(paramPos));
           assert containsNode(actualPk);
           assert containsNode(pk);
           addEdge(pk, actualPk);
         }
       }
     }
   }
 }
コード例 #2
0
  /** @param pk value being def'fed by a call instruction (either normal or exceptional) */
  private void addReturnEdges(LocalPointerKey pk, SSAInvokeInstruction callInstr) {
    boolean isExceptional = pk.getValueNumber() == callInstr.getException();

    // get call targets
    Collection<CGNode> possibleCallees =
        cg.getPossibleTargets(pk.getNode(), callInstr.getCallSite());
    // construct graph for each target
    for (CGNode callee : possibleCallees) {
      addSubgraphForNode(callee);
      PointerKey retVal =
          isExceptional
              ? heapModel.getPointerKeyForExceptionalReturnValue(callee)
              : heapModel.getPointerKeyForReturnValue(callee);
      assert containsNode(retVal);
      addEdge(pk, retVal);
    }
  }
コード例 #3
0
  private void createActualInAndOut(
      final Map<PDGNode, Node> pdg2cfg,
      final ModRefCandidates modref,
      final PDG pdg,
      final CallGraph cg) {
    for (final PDGNode call : pdg.getCalls()) {
      final Node cn = pdg2cfg.get(call);
      final SSAInvokeInstruction invk = (SSAInvokeInstruction) pdg.getInstruction(call);
      final CallSiteReference site = invk.getCallSite();

      final Set<ModRefFieldCandidate> modRefCands = new HashSet<ModRefFieldCandidate>();

      for (final CGNode tgt : cg.getPossibleTargets(pdg.cgNode, site)) {
        final InterProcCandidateModel tgtModRef = modref.getCandidates(tgt);

        if (tgtModRef == null) {
          continue;
        }

        for (final ModRefFieldCandidate c : tgtModRef) {
          modRefCands.add(c);
        }
      }

      final List<ModRefFieldCandidate> refs = new LinkedList<ModRefFieldCandidate>();
      final List<ModRefFieldCandidate> mods = new LinkedList<ModRefFieldCandidate>();

      for (final ModRefFieldCandidate c : modRefCands) {
        if (c.isMod()) {
          mods.add(c);
        }

        if (c.isRef()) {
          refs.add(c);
        }
      }

      addNodesBefore(cn, refs, Node.Kind.ACTUAL_IN);
      addNodesAfter(cn, mods, Node.Kind.ACTUAL_OUT);
    }
  }