Ejemplo n.º 1
0
        // Clone the points-to info, and start with nothing alive
        public ArgsLocalsState CloneForward()
        {
            var res = new ArgsLocalsState(argsAlive.Capacity, localsAlive.Capacity);

            foreach (var kv in argLocalToPointsTo)
            {
                res.argLocalToPointsTo.Add(kv.Key, kv.Value);
            }
            return(res);
        }
Ejemplo n.º 2
0
        public void ReadPointer(ArgsLocalsState other, PointsTo pointsTo, BoolRef changed)
        {
            var newArgsAlive = other.argsAlive.Clone();

            foreach (var argIndex in pointsTo.Args.Members)
            {
                newArgsAlive[argIndex] = true;
            }
            argsAlive.UnionInPlace(newArgsAlive, changed);
            var newLocalsAlive = other.localsAlive.Clone();

            foreach (var localIndex in pointsTo.Locals.Members)
            {
                newLocalsAlive[localIndex] = true;
            }
            localsAlive.UnionInPlace(newLocalsAlive, changed);
        }
Ejemplo n.º 3
0
        public ArgsLocalsState CloneWithArgLocalPointsTo(ArgLocal argLocal, int index, PointsTo pointsTo)
        {
            var key = ArgLocalInstruction.Key(argLocal, index);
            var res = new ArgsLocalsState(argsAlive.Capacity, localsAlive.Capacity);

            foreach (var kv in argLocalToPointsTo)
            {
                if (kv.Key != key)
                {
                    res.argLocalToPointsTo.Add(kv.Key, kv.Value);
                }
            }
            if (!pointsTo.IsBottom)
            {
                res.argLocalToPointsTo.Add(key, pointsTo);
            }
            return(res);
        }
Ejemplo n.º 4
0
 public void Unify(ArgsLocalsState other, BoolRef changed)
 {
     foreach (var kv in other.argLocalToPointsTo)
     {
         var pt = default(PointsTo);
         if (!kv.Value.IsBottom)
         {
             if (argLocalToPointsTo.TryGetValue(kv.Key, out pt))
             {
                 argLocalToPointsTo[kv.Key] = pt.Lub(kv.Value, changed);
             }
             else
             {
                 changed.Set();
                 argLocalToPointsTo.Add(kv.Key, kv.Value);
             }
         }
     }
     argsAlive.UnionInPlace(other.argsAlive, changed);
     localsAlive.UnionInPlace(other.localsAlive, changed);
 }
Ejemplo n.º 5
0
 public void SourceToTargetTransition(ArgsLocalsState other, BoolRef changed)
 {
     // Any pointers in source are pointers in target
     foreach (var kv in argLocalToPointsTo)
     {
         var pt = default(PointsTo);
         if (!kv.Value.IsBottom)
         {
             if (other.argLocalToPointsTo.TryGetValue(kv.Key, out pt))
             {
                 other.argLocalToPointsTo[kv.Key] = pt.Lub(kv.Value, changed);
             }
             else
             {
                 changed.Set();
                 other.argLocalToPointsTo.Add(kv.Key, kv.Value);
             }
         }
     }
     // Anything alive in target is alive in source
     argsAlive.UnionInPlace(other.argsAlive, changed);
     localsAlive.UnionInPlace(other.localsAlive, changed);
 }
Ejemplo n.º 6
0
        public void PropogateBackwards(ArgsLocalsState other, ArgLocal argLocal, int index, bool isAlive, BoolRef changed)
        {
            var newArgsAlive   = other.argsAlive.Clone();
            var newLocalsAlive = other.localsAlive.Clone();

            if (index >= 0)
            {
                switch (argLocal)
                {
                case ArgLocal.Arg:
                    newArgsAlive[index] = isAlive;
                    break;

                case ArgLocal.Local:
                    newLocalsAlive[index] = isAlive;
                    break;

                default:
                    throw new ArgumentOutOfRangeException("argLocal");
                }
            }
            argsAlive.UnionInPlace(newArgsAlive, changed);
            localsAlive.UnionInPlace(newLocalsAlive, changed);
        }
Ejemplo n.º 7
0
 private InnerMachineState(IImSeq <StackEntryState> stack, ArgsLocalsState argsLocalsState)
 {
     Stack           = stack;
     Ids             = null;
     ArgsLocalsState = argsLocalsState;
 }
Ejemplo n.º 8
0
 // New empty stack and bottom args and locals state
 public InnerMachineState(int nArgs, int nLocals)
 {
     Stack           = new Seq <StackEntryState>();
     Ids             = null;
     ArgsLocalsState = new ArgsLocalsState(nArgs, nLocals);
 }
Ejemplo n.º 9
0
 private InnerMachineState(IImSeq<StackEntryState> stack, ArgsLocalsState argsLocalsState)
 {
     Stack = stack;
     Ids = null;
     ArgsLocalsState = argsLocalsState;
 }
Ejemplo n.º 10
0
 public void SourceToTargetTransition(ArgsLocalsState other, BoolRef changed)
 {
     // Any pointers in source are pointers in target
     foreach (var kv in argLocalToPointsTo)
     {
         var pt = default(PointsTo);
         if (!kv.Value.IsBottom)
         {
             if (other.argLocalToPointsTo.TryGetValue(kv.Key, out pt))
                 other.argLocalToPointsTo[kv.Key] = pt.Lub(kv.Value, changed);
             else
             {
                 changed.Set();
                 other.argLocalToPointsTo.Add(kv.Key, kv.Value);
             }
         }
     }
     // Anything alive in target is alive in source
     argsAlive.UnionInPlace(other.argsAlive, changed);
     localsAlive.UnionInPlace(other.localsAlive, changed);
 }
Ejemplo n.º 11
0
 // New empty stack and bottom args and locals state
 public InnerMachineState(int nArgs, int nLocals)
 {
     Stack = new Seq<StackEntryState>();
     Ids = null;
     ArgsLocalsState = new ArgsLocalsState(nArgs, nLocals);
 }
Ejemplo n.º 12
0
 public void ReadPointer(ArgsLocalsState other, PointsTo pointsTo, BoolRef changed)
 {
     var newArgsAlive = other.argsAlive.Clone();
     foreach (var argIndex in pointsTo.Args.Members)
         newArgsAlive[argIndex] = true;
     argsAlive.UnionInPlace(newArgsAlive, changed);
     var newLocalsAlive = other.localsAlive.Clone();
     foreach (var localIndex in pointsTo.Locals.Members)
         newLocalsAlive[localIndex] = true;
     localsAlive.UnionInPlace(newLocalsAlive, changed);
 }
Ejemplo n.º 13
0
 public void PropogateBackwards(ArgsLocalsState other, ArgLocal argLocal, int index, bool isAlive, BoolRef changed)
 {
     var newArgsAlive = other.argsAlive.Clone();
     var newLocalsAlive = other.localsAlive.Clone();
     if (index >= 0)
     {
         switch (argLocal)
         {
             case ArgLocal.Arg:
                 newArgsAlive[index] = isAlive;
                 break;
             case ArgLocal.Local:
                 newLocalsAlive[index] = isAlive;
                 break;
             default:
                 throw new ArgumentOutOfRangeException("argLocal");
         }
     }
     argsAlive.UnionInPlace(newArgsAlive, changed);
     localsAlive.UnionInPlace(newLocalsAlive, changed);
 }
Ejemplo n.º 14
0
 public void Unify(ArgsLocalsState other, BoolRef changed)
 {
     foreach (var kv in other.argLocalToPointsTo)
     {
         var pt = default(PointsTo);
         if (!kv.Value.IsBottom)
         {
             if (argLocalToPointsTo.TryGetValue(kv.Key, out pt))
                 argLocalToPointsTo[kv.Key] = pt.Lub(kv.Value, changed);
             else
             {
                 changed.Set();
                 argLocalToPointsTo.Add(kv.Key, kv.Value);
             }
         }
     }
     argsAlive.UnionInPlace(other.argsAlive, changed);
     localsAlive.UnionInPlace(other.localsAlive, changed);
 }
Ejemplo n.º 15
0
 public ArgsLocalsState CloneWithArgLocalPointsTo(ArgLocal argLocal, int index, PointsTo pointsTo)
 {
     var key = ArgLocalInstruction.Key(argLocal, index);
     var res = new ArgsLocalsState(argsAlive.Capacity, localsAlive.Capacity);
     foreach (var kv in argLocalToPointsTo)
     {
         if (kv.Key != key)
             res.argLocalToPointsTo.Add(kv.Key, kv.Value);
     }
     if (!pointsTo.IsBottom)
         res.argLocalToPointsTo.Add(key, pointsTo);
     return res;
 }
Ejemplo n.º 16
0
 // Clone the points-to info, and start with nothing alive
 public ArgsLocalsState CloneForward()
 {
     var res = new ArgsLocalsState(argsAlive.Capacity, localsAlive.Capacity);
     foreach (var kv in argLocalToPointsTo)
         res.argLocalToPointsTo.Add(kv.Key, kv.Value);
     return res;
 }