コード例 #1
0
        public ProgramCounter(ZingMethod method)
        {
            string name = method.MethodName;
            object o = methodNameTable[name];
            Hashtable blockTable = null;
            if (o == null)
            {
                methodNameTable[name] = ++methodCounter;
                blockTable = new Hashtable();
                methodBlockTable[name] = blockTable;
                methodNumberTable[methodCounter] = name;
                methodNumber = methodCounter;
            }
            else
            {
                blockTable = (Hashtable)methodBlockTable[name];
                methodNumber = (ushort)o;
            }

            nextBlock = method.NextBlock;
            blockTable[nextBlock] = method.ProgramCounter;
        }
コード例 #2
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
 public UndoPop(Process p, ZingMethod theFrame)
     : base(p)
 {
     savedStackFrame = theFrame;
 }
コード例 #3
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
        private void rollbackStackFrames(Stack sules)
        {
            StackULE ule;

            Debug.Assert(stackULEs != null);
            Debug.Assert(stackULEs.Count == 0);

            if (sules == null)
            {
                savedTopOfStack = topOfStack;
                return;
            }
            while (sules.Count > 0)
            {
                ule = (StackULE)sules.Pop();
                ule.Undo();
            }
            savedTopOfStack = topOfStack;
        }
コード例 #4
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
 private void doPush(ZingMethod method)
 {
     method.Caller = topOfStack;
     topOfStack = method;
     if (stackULEs == null)
         return;
     stackULEs.Push(new UndoPush(this));
 }
コード例 #5
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
 private ZingMethod doPop()
 {
     if (stackULEs != null)
     {
         if (stackULEs.Count > 0 && stackULEs.Peek() is UndoPush)
             stackULEs.Pop();
         else
         {
             Debug.Assert(topOfStack == savedTopOfStack);
             stackULEs.Push(new UndoPop(this, topOfStack));
             savedTopOfStack = topOfStack.Caller;
         }
     }
     ZingMethod oldTop = topOfStack;
     topOfStack = topOfStack.Caller;
     return oldTop;
 }
コード例 #6
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
        private Stack checkInStackFrames()
        {
            // this is the first time we checked in
            if (stackULEs == null)
            {
                stackULEs = new Stack();
                for (savedTopOfStack = topOfStack;
                     savedTopOfStack != null;
                     savedTopOfStack = savedTopOfStack.Caller)
                    savedTopOfStack.DoCheckIn();

                savedTopOfStack = topOfStack;
                return null;
            }

            object zmULE = null;

            if (savedTopOfStack != null)
                zmULE = savedTopOfStack.DoCheckIn();

            // small optimization when no changes was made in the
            // current transition
            if (stackULEs.Count == 0 && zmULE == null)
            {
                Debug.Assert(savedTopOfStack == topOfStack);
                return null;
            }

            // the result
            Stack resStack = stackULEs;

            stackULEs = new Stack();

            ZingMethod stackFrame = topOfStack;

            // move newly pushed frames away from the result, save
            // them temporarily in stackULEs; while doing that, we
            // checkIn every newly pushed node
            while (resStack.Count > 0 && resStack.Peek() is UndoPush)
            {
                //object sfULE =
                // this would be the first time we check in these
                // freshly pushed nodes. so we discard their undo log
                // entries
                stackFrame.DoCheckIn();
                stackULEs.Push(resStack.Pop());
                stackFrame = stackFrame.Caller;
            }

            // everything below should be UndoPop's or UndoResetLastFunctionCompleted,
            // and if anything is to be saved, it should be right there at stackFrame
            Debug.Assert(resStack.Count == 0 || resStack.Peek() is UndoPop
                         || resStack.Peek() is UndoResetLastFunctionCompleted);
            Debug.Assert(savedTopOfStack == stackFrame);

            // insert zmULE between UndoPop objects and UndoPush
            // objects
            if (zmULE != null)
                resStack.Push(new UndoUpdate(this, zmULE));

            // move undoPush objects back into the result
            while (stackULEs.Count > 0)
                resStack.Push(stackULEs.Pop());

            savedTopOfStack = topOfStack;
            return resStack;
        }
コード例 #7
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
 //the following is used during application of effects
 public void UpdateDirectLastFunctionCompleted(ZingMethod method)
 {
     lastFunctionCompleted = method;
 }
コード例 #8
0
 internal OutputVars(ZingMethod zm)
 {
     stackFrame = zm;
 }
コード例 #9
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
        public void RaiseZingException(int exception)
        {
            this.lastFunctionCompleted = null;

            doPop();

            while (topOfStack != null)
            {
                this.atomicityLevel = this.topOfStack.SavedAtomicityLevel;
                // If we find a handler, we're done
                if (this.topOfStack.RaiseZingException(exception))
                    return;

                doPop();
            }

            throw new ZingUnhandledExceptionException(exception);
        }
コード例 #10
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
        public void DoCheckout(object currentUle)
        {
            ProcessULE pULE = (ProcessULE)currentUle;

            // cloned components
            atomicityLevel = pULE.atomicityLevel;
            middleOfTransition = pULE.middleOfTransition;
            choicePending = pULE.choicePending;
            lastFunctionCompleted = pULE.lastFunctionCompleted;

            // undoable ones -- do nothing
        }
コード例 #11
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
        /*
        public static ZingAttribute PredicateContext
        {
            get { return predicateContext; }
            set { predicateContext = value; }
        }
        */
        public bool CallPredicateMethod(ZingMethod predicateMethod)
        {
            if (runningPredicateMethod[MyThreadId])
            {
                Debugger.Break();
                throw new Exception("Predicate !");
            }

            Process dummyProc = new Process(this.StateImpl, predicateMethod, string.Empty, 0);

            Exception savedException = this.StateImpl.Exception;
            this.StateImpl.Exception = null;

            while (dummyProc.TopOfStack != null)
            {
                runningPredicateMethod[MyThreadId] = true;
                this.StateImpl.RunBlocks(dummyProc);
                runningPredicateMethod[MyThreadId] = false;

                if (this.StateImpl.Exception != null)
                {
                    if (savedException == null)
                    {
                        this.StateImpl.Exception = new Exception("Predicate");
                        throw this.StateImpl.Exception;
                    }
                    else
                    {
                        // If we already have a pending exception on the state, just
                        // return false and restore the original exception.
                        this.StateImpl.Exception = savedException;
                        return false;
                    }
                }

                if (dummyProc.choicePending)
                    throw new Exception("Predicate");
            }
            this.StateImpl.Exception = savedException;
            return predicateMethod.BooleanReturnValue;
        }
コード例 #12
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
 public void Call(ZingMethod method)
 {
     // method.StateImpl = this.StateImpl;
     method.SavedAtomicityLevel = this.atomicityLevel;
     doPush(method);
 }
コード例 #13
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
 public Process(StateImpl stateObj, ZingMethod entryPoint, string name, uint id, int threadID)
     : this(stateObj, entryPoint, name, id)
 {
     this.MyThreadId = threadID;
 }
コード例 #14
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
        // <summary>
        // Constructor
        // </summary>
        // <param name="entryPoint"></param>
        // <param name="name"></param>
        // <param name="id"></param>
        public Process(StateImpl stateObj, ZingMethod entryPoint, string name, uint id)
        {
            this.StateImpl = stateObj;
            this.entryPoint = entryPoint;
            this.name = name;
            this.id = id;

            this.Call(entryPoint);
        }
コード例 #15
0
 internal LocalVars(ZingMethod zm)
 {
     stackFrame = zm;
 }
コード例 #16
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
 protected override void doUndo()
 {
     savedStackFrame.Caller = process.topOfStack;
     process.topOfStack = process.savedTopOfStack = savedStackFrame;
     savedStackFrame = null;
     process.topOfStack.DoRevert();
 }
コード例 #17
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
 public UndoResetLastFunctionCompleted(Process p, ZingMethod l)
     : base(p)
 {
     savedLastFunctionCompleted = l;
 }
コード例 #18
0
ファイル: Process.cs プロジェクト: ZingModelChecker/Zing
        public void Return(ZingSourceContext context, ZingAttribute contextAttribute)
        {
            ZingMethod returningMethod = doPop();

            this.atomicityLevel = returningMethod.SavedAtomicityLevel;

            // Keep a ref to the completed function so the caller can access
            // the return value and output parameters.

            if (topOfStack != null)
                lastFunctionCompleted = returningMethod;
            else
            {
                lastFunctionCompleted = null;
                middleOfTransition = false;
            }

            if (this.topOfStack == null && ZingerConfiguration.ExecuteTraceStatements && (this.name != null && this.name.Length != 0))
            {
                if (ZingerConfiguration.DegreeOfParallelism == 1)
                {
                    this.StateImpl.ReportEvent(new TerminateProcessEvent(context, contextAttribute));
                }
                else
                {
                    this.StateImpl.ReportEvent(new TerminateProcessEvent(context, contextAttribute, this.MyThreadId));
                }
            }
        }