Beispiel #1
0
        public SymGraph <TFunc, TADomain> Join(SymGraph <TFunc, TADomain> that, out IMergeInfo mergeInfo, bool widen)
        {
            SymGraph <TFunc, TADomain> egraph = this;
            int updateSize;
            SymGraph <TFunc, TADomain> commonTail = ComputeCommonTail(egraph, that, out updateSize);
            bool hasCommonTail = true;

            if (commonTail == null)
            {
                hasCommonTail = false;
            }

            bool doingIncrementalJoin = hasCommonTail & commonTail != egraph.root_graph & !widen & DoIncrementalJoin;

            //debug

            if (DebugOptions.Debug)
            {
                Console.WriteLine("SymGraph {0}", widen ? "widen" : "join");
                if (commonTail != null)
                {
                    Console.WriteLine("Last common symbol: {0}", commonTail.LastSymbolId);
                }

                Console.WriteLine("  Doing {0}", doingIncrementalJoin ? "incremental join" : "full join");
            }

            SymGraph <TFunc, TADomain>  result;
            MergeInfo <TFunc, TADomain> mergeState;

            if (doingIncrementalJoin)
            {
                result     = new SymGraph <TFunc, TADomain> (commonTail);
                mergeState = new MergeInfo <TFunc, TADomain> (result, egraph, that, widen);
                mergeState.Replay(commonTail);
                mergeState.Commit();
            }
            else
            {
                result     = new SymGraph <TFunc, TADomain> (commonTail);
                mergeState = new MergeInfo <TFunc, TADomain> (result, egraph, that, widen);
                mergeState.ReplayEliminations(commonTail);
                mergeState.AddMapping(egraph.const_root, that.const_root, result.const_root);
                mergeState.JoinSymbolicValue(egraph.const_root, that.const_root, result.const_root);
                mergeState.Commit();
            }
            mergeInfo = mergeState;

            if (DebugOptions.Debug)
            {
                Console.WriteLine("  Result update size {0}", result.Updates.Length());
                Console.WriteLine("Done with Egraph join: changed = {0}", mergeInfo.Changed ? 1 : 0);
            }

            return(result);
        }
Beispiel #2
0
        public IEGraph Join(IEGraph g2, CfgBlock joinPoint, out IMergeInfo mergeInfo)
        {
            EGraph eg1 = this;
            EGraph eg2 = (EGraph)g2;

            int    updateSize;
            EGraph common = ComputeCommonTail(eg1, eg2, out updateSize);

            EGraph result;
            bool   doReplay = true;

            if (common == null)
            {
                doReplay     = false;
                result       = new EGraph(eg1.elementLattice);
                result.Block = joinPoint;
            }
            else
            {
                result = new EGraph(common, joinPoint);
            }

            if (Analyzer.Debug)
            {
                Console.WriteLine("Last common symbol: {0}", common.idCounter);
            }
            if (Analyzer.Statistics)
            {
                Console.WriteLine("G1:{0} G2:{1} Tail:{2} UpdateSize:{3}", eg1.historySize, eg2.historySize, result.historySize, updateSize);
            }

            MergeState ms = new MergeState(result, eg1, eg2);

            // Heuristic for using Replay vs. full update
            doReplay &= (common != eg1.root);
            doReplay &= (eg1.historySize > 3);
            doReplay &= (eg2.historySize > 3);

            if (doReplay)
            {
                ms.Replay(common);
            }
            else
            {
                ms.AddMapping(eg1.constRoot, eg2.constRoot, result.constRoot);
                ms.JoinSymbolicValue(eg1.constRoot, eg2.constRoot, result.constRoot);
            }
            mergeInfo = ms;
            return(result);
        }
    public IEGraph Join(IEGraph g2, CfgBlock joinPoint, out IMergeInfo mergeInfo) {
      EGraph eg1 = this;
      EGraph eg2 = (EGraph)g2;

      int updateSize;
      EGraph common = ComputeCommonTail(eg1, eg2, out updateSize);

      EGraph result;
      bool doReplay = true;

      if (common == null) {
        doReplay = false;
        result = new EGraph(eg1.elementLattice);
        result.Block = joinPoint;
      }
      else {
        result = new EGraph(common, joinPoint);
      }

      if (Analyzer.Debug) {
        Console.WriteLine("Last common symbol: {0}", common.idCounter);
      }
      if (Analyzer.Statistics) {
        Console.WriteLine("G1:{0} G2:{1} Tail:{2} UpdateSize:{3}", eg1.historySize, eg2.historySize, result.historySize, updateSize);
      }

      MergeState ms = new MergeState(result, eg1, eg2);

      // Heuristic for using Replay vs. full update
      doReplay &= (common != eg1.root);
      doReplay &= (eg1.historySize > 3);
      doReplay &= (eg2.historySize > 3);

      if (doReplay) {
        ms.Replay(common);
      }
      else {
        ms.AddMapping(eg1.constRoot, eg2.constRoot, result.constRoot);
        ms.JoinSymbolicValue(eg1.constRoot, eg2.constRoot, result.constRoot);
      }
      mergeInfo = ms;
      return result;
    }