Beispiel #1
0
 public void AddInstructions(LightCompiler compiler)
 {
     if (this.LoopStatementCount < 300)
     {
         this.EnterLoopInstruction = new System.Management.Automation.Interpreter.EnterLoopInstruction(this.Loop, compiler.Locals, 0x10, compiler.Instructions.Count);
         compiler.Instructions.Emit(this.EnterLoopInstruction);
     }
 }
 public void AddInstructions(LightCompiler compiler)
 {
     EnterLoopInstruction enterLoopInstruction = null;
     compiler.PushLabelBlock(LabelScopeKind.Statement);
     foreach (Expression expression in this._exprs)
     {
         compiler.CompileAsVoid(expression);
         EnterLoopExpression expression2 = expression as EnterLoopExpression;
         if (expression2 != null)
         {
             enterLoopInstruction = expression2.EnterLoopInstruction;
         }
     }
     compiler.PopLabelBlock(LabelScopeKind.Statement);
     if (enterLoopInstruction != null)
     {
         enterLoopInstruction.FinishLoop(compiler.Instructions.Count);
     }
 }
Beispiel #3
0
 public void AddInstructions(LightCompiler compiler)
 {
     compiler.Instructions.Emit(UpdatePositionInstruction.Create(this._sequencePoint, this._checkBreakpoints));
 }
Beispiel #4
0
 private void CompileLambdaExpression(Expression expr)
 {
     LambdaExpression node = (LambdaExpression) expr;
     LightCompiler compiler = new LightCompiler(this);
     LightDelegateCreator creator = compiler.CompileTop(node);
     if (compiler._locals.ClosureVariables != null)
     {
         foreach (ParameterExpression expression2 in compiler._locals.ClosureVariables.Keys)
         {
             this.CompileGetBoxedVariable(expression2);
         }
     }
     this._instructions.EmitCreateDelegate(creator);
 }
Beispiel #5
0
 private LightCompiler(LightCompiler parent) : this(parent._compilationThreshold)
 {
     this._parent = parent;
 }
Beispiel #6
0
 public void AddInstructions(LightCompiler compiler)
 {
     // The EnterLoopInstruction is the instruction the interpreter uses to track the number of iterations a loop
     // has executed and the instruction that kicks of the background compilation.
     // If the statement count is too high, JIT takes too much time/resources to compile, so
     // we just skip it.  By not emitting a EnterLoopInstruction, we'll never attempt to JIT the loop body.
     if (LoopStatementCount < 300)
     {
         // Start compilation after 16 iterations of the loop.
         EnterLoopInstruction = new EnterLoopInstruction(Loop, compiler.Locals, 16, compiler.Instructions.Count);
         compiler.Instructions.Emit(EnterLoopInstruction);
     }
 }
Beispiel #7
0
        public void AddInstructions(LightCompiler compiler)
        {
            EnterLoopInstruction enterLoop = null;

            compiler.PushLabelBlock(LabelScopeKind.Statement);

            // emit loop body:
            foreach (var expr in _exprs)
            {
                compiler.CompileAsVoid(expr);
                var enterLoopExpression = expr as EnterLoopExpression;
                if (enterLoopExpression != null)
                {
                    enterLoop = enterLoopExpression.EnterLoopInstruction;
                }
            }

            compiler.PopLabelBlock(LabelScopeKind.Statement);

            // If enterLoop is null, we will never JIT compile the loop.
            if (enterLoop != null)
            {
                enterLoop.FinishLoop(compiler.Instructions.Count);
            }
        }
Beispiel #8
0
        private Action<FunctionContext> CompileTree(Expression<Action<FunctionContext>> lambda, CompileInterpretChoice compileInterpretChoice)
        {
            if (lambda == null)
                return null;

            if (compileInterpretChoice == CompileInterpretChoice.AlwaysCompile)
            {
                return lambda.Compile();
            }

            // threshold is # of times the script must run before we decide to compile
            // NeverCompile sets the threshold to int.MaxValue, so theoretically we might compile
            // at some point, but it's very unlikely.
            int threshold = (compileInterpretChoice == CompileInterpretChoice.NeverCompile) ? int.MaxValue : -1;
            var deleg = new LightCompiler(threshold).CompileTop(lambda).CreateDelegate();
            return (Action<FunctionContext>)deleg;
        }
Beispiel #9
0
 public virtual object GetDebugCookie(LightCompiler compiler)
 {
     return null;
 }