Exemple #1
0
        public override void Replay(MergeInfo <TFunc, TAbstractDomain> merge)
        {
            if (!merge.IsCommon(this.sv))
            {
                return;
            }

            TAbstractDomain val1 = merge.Graph1 [this.sv];
            TAbstractDomain val2 = merge.Graph2 [this.sv];
            bool            weaker;
            TAbstractDomain join = val1.Join(val2, merge.Widen, out weaker);

            TAbstractDomain wasInResult = merge.Result [this.sv];

            if (weaker)
            {
                if (DebugOptions.Debug)
                {
                    Console.WriteLine("----SymGraph changed during AbstractDomainUpdate of {3} " +
                                      "due to weaker abstractValue join (val1 = {0}, val2 = {1}, wasInResult = {2}",
                                      val1, val2, wasInResult, this.sv);
                }
                merge.Changed = true;
            }

            if (join.Equals(wasInResult))
            {
                return;
            }

            merge.Result [this.sv] = join;
        }
        public override void Replay(MergeInfo <TFunc, TAbstractDomain> merge)
        {
            if (!merge.IsCommon(this.from))
            {
                return;
            }

            SymValue sv1 = merge.Graph1.LookupWithoutManifesting(this.from, this.function);
            SymValue sv2 = merge.Graph2.LookupWithoutManifesting(this.from, this.function);

            if (sv1 != null && sv2 != null)
            {
                return;
            }
            if (sv1 != null)
            {
                if (DebugOptions.Debug)
                {
                    Console.WriteLine("---SymGraph changed due to EliminateEdgeUpdate {0}-{1} " +
                                      "-> that is only in G1", this.from, this.function);
                }
                merge.Changed = true;
            }

            bool noEdgeInResult = merge.Result.LookupWithoutManifesting(this.from, this.function) == null;

            if (noEdgeInResult)
            {
                return;
            }

            merge.Result.Eliminate(this.function, this.from);
        }
        public override void ReplayElimination(MergeInfo <TFunc, TAbstractDomain> merge)
        {
            if (!merge.IsCommon(this.from))
            {
                return;
            }

            merge.Result.Eliminate(this.function, this.from);
        }
Exemple #4
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);
        }
Exemple #5
0
        public override void Replay(MergeInfo <TFunc, TAbstractDomain> merge)
        {
            int len = this.from.Length;

            for (int i = 0; i < len; i++)
            {
                SymValue sv = this.from [i];
                if (merge.IsCommon(sv))
                {
                    merge.JoinMultiEdge(sv, sv, new MultiEdge <TFunc, TAbstractDomain> (this.function, i, len));
                }
            }
        }
Exemple #6
0
 public override void Replay(MergeInfo <TFunc, TAbstractDomain> merge)
 {
     if (!merge.IsCommon(this.sv1) || !merge.IsCommon(this.sv2) || (!merge.Graph1.IsEqual(this.sv1, this.sv2) || merge.Result.IsEqual(this.sv1, this.sv2)))
     {
         return;
     }
     if (merge.Graph2.IsEqual(this.sv1, this.sv2))
     {
         merge.Result.AssumeEqual(this.sv1, this.sv2);
     }
     else
     {
         merge.Changed = true;
     }
 }
Exemple #7
0
        public override void ReplayElimination(MergeInfo <TFunc, TAbstractDomain> merge)
        {
            if (!merge.IsCommon(this.sv))
            {
                return;
            }

            TAbstractDomain val1 = merge.Graph1 [this.sv];

            if (val1.IsTop)
            {
                merge.Result [this.sv] = val1;
            }
            else
            {
                TAbstractDomain val2 = merge.Graph2 [this.sv];
                if (val2.IsTop)
                {
                    merge.Result [this.sv] = val2;
                }
            }
        }
Exemple #8
0
 public abstract void ReplayElimination(MergeInfo <TFunc, TAbstractDomain> merge);
Exemple #9
0
 public abstract void Replay(MergeInfo <TFunc, TAbstractDomain> merge);
Exemple #10
0
        public override void Replay(MergeInfo <TFunc, TAbstractDomain> merge)
        {
            if (!merge.IsCommon(this.from))
            {
                return;
            }

            SymValue sv1 = merge.Graph1.LookupWithoutManifesting(this.from, this.function);
            SymValue sv2 = merge.Graph2.LookupWithoutManifesting(this.from, this.function);

            if (DebugOptions.Debug)
            {
                Console.WriteLine("Replay edge update: {0} -{1} -> [ {2}, {3} ]",
                                  this.from, this.function, sv1, sv2);
            }
            if (sv1 == null)
            {
                if (this.function.KeepAsBottomField && merge.Graph1.HasAllBottomFields(this.from))
                {
                    sv1 = merge.Graph1.BottomPlaceHolder;
                }
                else
                {
                    if (sv2 == null || merge.Widen || !this.function.ManifestField)
                    {
                        return;
                    }
                    if (DebugOptions.Debug)
                    {
                        Console.WriteLine("---SymGraph changed due to manifestation of a top edge in Graph1");
                    }
                    merge.Changed = true;
                }
            }
            if (sv2 == null)
            {
                if (this.function.KeepAsBottomField && merge.Graph2.HasAllBottomFields(this.from))
                {
                    sv2 = merge.Graph2.BottomPlaceHolder;
                }
                else
                {
                    if (merge.Widen || !this.function.ManifestField)
                    {
                        return;
                    }
                    if (DebugOptions.Debug)
                    {
                        Console.WriteLine("---SymGraph changed due to manifestation of due to missing target in Graph2");
                    }
                    merge.Changed = true;
                    return;
                }
            }

            SymValue r = merge.AddJointEdge(sv1, sv2, this.function, this.from);

            if (r == null || r.UniqueId <= merge.LastCommonVariable)
            {
                return;
            }

            merge.JoinSymbolicValue(sv1, sv2, r);
        }
Exemple #11
0
 public override void ReplayElimination(MergeInfo <TFunc, TAbstractDomain> merge)
 {
 }