ObserveInstructionCount() protected method

Allow application to monitor counter of executed script instructions in Context subclasses.
Allow application to monitor counter of executed script instructions in Context subclasses. Run-time calls this when instruction counting is enabled and the counter reaches limit set by setInstructionObserverThreshold(). The method is useful to observe long running scripts and if necessary to terminate them.

The default implementation calls ContextFactory.ObserveInstructionCount(Context, int) that allows to customize Context behavior without introducing Context subclasses.

to terminate the script
protected ObserveInstructionCount ( int instructionCount ) : void
instructionCount int /// amount of script instruction executed since /// last call to observeInstructionCount ///
return void
Example #1
0
		public static void AddInstructionCount(Context cx, int instructionsToAdd)
		{
			cx.instructionCount += instructionsToAdd;
			if (cx.instructionCount > cx.instructionThreshold)
			{
				cx.ObserveInstructionCount(cx.instructionCount);
				cx.instructionCount = 0;
			}
		}
Example #2
0
		private static void AddInstructionCount(Context cx, Interpreter.CallFrame frame, int extra)
		{
			cx.instructionCount += frame.pc - frame.pcPrevBranch + extra;
			if (cx.instructionCount > cx.instructionThreshold)
			{
				cx.ObserveInstructionCount(cx.instructionCount);
				cx.instructionCount = 0;
			}
		}