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); }
public StackEntryState(TypeRef type, PointsTo pointsTo) : this(type, null, pointsTo) { }
public MachineState CloneWithArgLocalPointsTo(IImSeq <StackEntryState> stack, ArgLocal argLocal, int index, PointsTo pointsTo) { return(new MachineState(RootEnv, nArgs, nLocals, innerState.Value.CloneWithArgLocalPointsTo(stack, argLocal, index, pointsTo))); }
public StackEntryState(TypeRef type, TypeRef upperBound, PointsTo pointsTo) { Type = type; UpperBound = upperBound; PointsTo = pointsTo; }
public InnerMachineState CloneWithArgLocalPointsTo(IImSeq <StackEntryState> stack, ArgLocal argLocal, int index, PointsTo pointsTo) { return(new InnerMachineState(stack, ArgsLocalsState.CloneWithArgLocalPointsTo(argLocal, index, pointsTo))); }
public void ReadPointer(MachineState nextState, PointsTo pointsTo, BoolRef changed) { innerState.Value.ArgsLocalsState.ReadPointer(nextState.innerState.Value.ArgsLocalsState, pointsTo, changed); }
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); }
public MachineState PopAddArgLocalPointsTo(int n, ArgLocal argLocal, int index, PointsTo pointsTo) { if (n > Depth) { throw new InvalidOperationException("stack is too shallow"); } var stack = new Seq <StackEntryState>(Depth - n); for (var i = n; i < Depth; i++) { stack.Add(innerState.Value.Stack[i]); } return(CloneWithArgLocalPointsTo(stack, argLocal, index, pointsTo)); }
public MachineState PushType(TypeRef type, PointsTo pointsTo) { return(PopPushType(0, type, pointsTo)); }
public MachineState PopPushType(int n, TypeRef type, PointsTo pointsTo) { return(PopPush(n, new StackEntryState(type.ToRunTimeType(RootEnv, true), pointsTo))); }
// Append instructions to evaluate test to its boolean result, leaving an int32 on the stack. // Return the state after the test has been evaluated, but before the int32 is popped. public MachineState Eval(Seq <Instruction> instructions, MachineState beforeState, MachineState afterState, PointsTo bottom) { var cinst = ToCompareInstruction(-1, beforeState, afterState, bottom); instructions.Add(cinst); return(cinst.AfterState); }
// Return instruction to evaluate test to its boolean result, leaving an int32 on the stack. // - beforeState has test operands on stack. // - afterState has the test evaluated AND the resulting int32 consumed. // (These states came from the original brtrue, etc instruction). public CompareInstruction ToCompareInstruction(int offset, MachineState beforeState, MachineState afterState, PointsTo bottom) { var state1 = beforeState.PopPushType(Pops, beforeState.RootEnv.Global.Int32Ref, bottom); var dummy = new BoolRef(); state1.PropogateBackwards(afterState, dummy); beforeState.PropogateBackwards(state1, dummy); var op = default(CompareOp); switch (Op) { case TestOp.True: op = CompareOp.CtruePseudo; break; case TestOp.False: op = CompareOp.CfalsePseudo; break; case TestOp.Equal: op = CompareOp.Ceq; break; case TestOp.NotEqual: op = CompareOp.CnePseudo; break; case TestOp.LessThanOrEqual: op = CompareOp.ClePseudo; break; case TestOp.LessThan: op = CompareOp.Clt; break; case TestOp.GreaterThanOrEqual: op = CompareOp.CgePseudo; break; case TestOp.GreaterThan: op = CompareOp.Cgt; break; default: throw new ArgumentOutOfRangeException(); } return(new CompareInstruction(offset, op, IsUnsigned) { Type = Type, BeforeState = beforeState, AfterState = state1 }); }