コード例 #1
0
  private void updateKillGenSet(String methodName, CallStmt stmt, BlockDataFlowState bFlow) {
    if (stmt.getMethodLabel().equals(ProgramFlattener.exceptionHandlerLabel)) return;

    // Kill all stores!
    for (int i = 0; i < bFlow.getOut().size(); i++) {
      if (bFlow.getOut().get(i)) {
        bFlow.getKill().set(i);
      }
    }

    bFlow.getGen().clear();
  }
コード例 #2
0
  public void updateKillGenSet(String methodName, QuadrupletStmt stmt, BlockDataFlowState bFlow) {
    if (stmt == null) return;

    BitSet out = bFlow.getOut();
    BitSet gen = bFlow.getGen();
    BitSet kill = bFlow.getKill();

    for (Name name : this.uniqueGlobals.get(methodName)) {
      int i = this.uniqueGlobals.get(methodName).indexOf(name);

      boolean resetName = false;

      if (name.isArray()) {
        Name myName = name;

        do {
          ArrayName array = (ArrayName) myName;
          if (array.getIndex().equals(stmt.getDestination())) { // Index being reassigned, KILL!
            resetName = true;
          }

          myName = array.getIndex();

        } while (myName.isArray());

        if (stmt.getDestination().isArray()) {
          ArrayName dest = (ArrayName) stmt.getDestination();
          ArrayName arrName = (ArrayName) name;
          if (dest.getIndex().getClass().equals(ConstantName.class)
              && !arrName.getIndex().getClass().equals(ConstantName.class)) {
            if (arrName.getId().equals(dest.getId())) {
              resetName = true;
            }
          }
        }
      }

      if (resetName) {
        if (out.get(i)) {
          kill.set(i);
        }

        gen.clear(i);
      }

      if (name.equals(stmt.getDestination())) {
        gen.set(i);
      }
    }
  }
コード例 #3
0
  private void setExitBlock(String methodName) {
    for (CFGBlock block : this.mMap.get(methodName).getCfgBlocks()) {
      if (block.getSuccessors().size() == 0) {
        //				return block;
        CFGBlock exit = block;
        BlockDataFlowState entryBlockFlow =
            new BlockDataFlowState(
                this.uniqueGlobals.get(methodName).size()); // IN = GEN for entry block
        calculateGenKillSets(exit, entryBlockFlow);
        entryBlockFlow.setIn(entryBlockFlow.getGen());
        cfgBlocksToProcess.remove(exit);

        this.cfgBlocksState.put(exit, entryBlockFlow);
      }
    }
  }
コード例 #4
0
  private void updateKillGenSet(String methodName, StoreStmt stmt, BlockDataFlowState bFlow) {
    if (stmt == null) return;

    BitSet gen = bFlow.getGen();

    gen.set(this.uniqueGlobals.get(methodName).indexOf(stmt.getVariable()));
  }
コード例 #5
0
  private BlockDataFlowState generateDFState(CFGBlock block) {
    int totalGlobals = this.uniqueGlobals.get(block.getMethodName()).size();

    // Get the original inBitSet for this block
    BitSet origIn;
    if (this.cfgBlocksState.containsKey(block)) {
      origIn = this.cfgBlocksState.get(block).getIn();
    } else {
      origIn = new BitSet(totalGlobals);
      origIn.set(0, totalGlobals);
    }

    // Calculate the in BitSet by taking intersection of predecessors
    BlockDataFlowState bFlow = new BlockDataFlowState(totalGlobals);

    // If there exist at least one successor, set Out to all True
    if (block.getSuccessors().size() > 0) {
      bFlow.getOut().set(0, totalGlobals);
    }

    BitSet out = bFlow.getOut();
    for (CFGBlock pred : block.getSuccessors()) {
      if (this.cfgBlocksState.containsKey(pred)) {
        out.and(this.cfgBlocksState.get(pred).getIn());
      }
    }

    calculateGenKillSets(block, bFlow);

    // Calculate Out
    BitSet in = bFlow.getIn(); // IN = (OUT - KILL) U GEN
    in.or(out);
    in.xor(bFlow.getKill());
    in.or(bFlow.getGen());

    if (!in.equals(origIn)) {
      // Add successors to cfgBlocks list
      for (CFGBlock pred : block.getPredecessors()) {
        if (!cfgBlocksToProcess.contains(pred)) {
          cfgBlocksToProcess.add(pred);
        }
      }
    }

    // Remove this block, since it has been processed
    cfgBlocksToProcess.remove(block);

    return bFlow;
  }