public TestCaseMethodCompiler(IAssemblyLinker linker, IArchitecture architecture, ICompilationSchedulerStage compilationScheduler, IMetadataModule module, RuntimeType type, RuntimeMethod method)
     : base(linker, architecture, compilationScheduler, module, type, method)
 {
     // Populate the pipeline
     this.Pipeline.AddRange(new IMethodCompilerStage[] {
         new DecodingStage(),
         new BasicBlockBuilderStage(),
         new OperandDeterminationStage(),
         new InstructionLogger(),
         //new ConstantFoldingStage(),
         new CILTransformationStage(),
         //new InstructionLogger(),
         //InstructionStatisticsStage.Instance,
         //new DominanceCalculationStage(),
         //new EnterSSA(),
         //new ConstantPropagationStage(),
         //new ConstantFoldingStage(),
         //new LeaveSSA(),
         new StackLayoutStage(),
         new PlatformStubStage(),
         new InstructionLogger(),
         //new BlockReductionStage(),
         new LoopAwareBlockOrderStage(),
         //new SimpleTraceBlockOrderStage(),
         //new ReverseBlockOrderStage(),  // reverse all the basic blocks and see if it breaks anything
         //new BasicBlockOrderStage()
         new CodeGenerationStage(),
         //new InstructionLogger(),
     });
 }
Esempio n. 2
0
        public override IMethodCompiler CreateMethodCompiler(ICompilationSchedulerStage schedulerStage, RuntimeType type, RuntimeMethod method)
        {
            IMethodCompiler mc = new MethodCompiler(this, Architecture, schedulerStage, type, method);

            Architecture.ExtendMethodCompilerPipeline(mc.Pipeline);
            return(mc);
        }
        public ExplorerMethodCompiler(ExplorerAssemblyCompiler assemblyCompiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method, CompilerOptions compilerOptions)
            : base(assemblyCompiler, type, method, null, compilationScheduler)
        {
            // Populate the pipeline
            this.Pipeline.AddRange(new IMethodCompilerStage[] {
                new DecodingStage(),
                new BasicBlockBuilderStage(),
                new ExceptionPrologueStage(),
                new OperandDeterminationStage(),
                //new SingleUseMarkerStage(),
                //new OperandUsageAnalyzerStage(),
                new StaticAllocationResolutionStage(),
                new CILTransformationStage(),

                (compilerOptions.EnableSSA) ? new EdgeSplitStage() : null,
                (compilerOptions.EnableSSA) ? new DominanceCalculationStage() : null,
                (compilerOptions.EnableSSA) ? new PhiPlacementStage() : null,
                (compilerOptions.EnableSSA) ? new EnterSSAStage() : null,

                (compilerOptions.EnableSSA) ? new SSAOptimizations() : null,
                //(compilerOptions.EnableSSA) ? new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PreFolding) : null,
                //(compilerOptions.EnableSSA) ? new ConstantFoldingStage() : null,
                //(compilerOptions.EnableSSA) ? new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PostFolding) : null,

                (compilerOptions.EnableSSA) ? new LeaveSSA() : null,

                new StrengthReductionStage(),
                new StackLayoutStage(),
                new PlatformStubStage(),
                //new LoopAwareBlockOrderStage(),
                new SimpleTraceBlockOrderStage(),
                //new SimpleRegisterAllocatorStage(),
                new CodeGenerationStage(),
            });
        }
        public TestCaseMethodCompiler(TestCaseAssemblyCompiler assemblyCompiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method)
            : base(assemblyCompiler, type, method, null, compilationScheduler)
        {
            // Populate the pipeline
            this.Pipeline.AddRange(new IMethodCompilerStage[] {
                new DecodingStage(),
                new BasicBlockBuilderStage(),
                new ExceptionPrologueStage(),
                new OperandDeterminationStage(),
                new StaticAllocationResolutionStage(),
                new CILTransformationStage(),
                //new CILLeakGuardStage() { MustThrowCompilationException = true },

                new	EdgeSplitStage(),
                new DominanceCalculationStage(),
                new PhiPlacementStage(),
                new EnterSSAStage(),

                new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PreFolding),
                new ConstantFoldingStage() ,
                new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PostFolding),

                new LeaveSSA(),

                new StrengthReductionStage(),
                new StackLayoutStage(),
                new PlatformStubStage(),
                //new BlockReductionStage(),
                //new LoopAwareBlockOrderStage(),
                new SimpleTraceBlockOrderStage(),
                //new ReverseBlockOrderStage(),  // reverse all the basic blocks and see if it breaks anything
                //new BasicBlockOrderStage()
                new CodeGenerationStage(),
            });
        }
        public SimpleJitMethodCompiler(AssemblyCompiler compiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method, Stream codeStream, ITypeSystem typeSystem)
            : base(compiler.Pipeline.FindFirst<IAssemblyLinker>(), compiler.Architecture, compilationScheduler, type, method, typeSystem, compiler.Pipeline.FindFirst<ITypeLayout>())
        {
            if (codeStream == null)
                throw new ArgumentNullException(@"codeStream");

            this.codeStream = codeStream;
        }
        public void Setup(AssemblyCompiler compiler)
        {
            ICompilationSchedulerStage scheduler = compiler.Pipeline.FindFirst<ICompilationSchedulerStage>();
            if (scheduler == null)
                throw new InvalidOperationException(@"No compilation scheduler found in the assembly compiler pipeline.");

            this.compiler = compiler;
            this.scheduler = scheduler;
        }
        void IAssemblyCompilerStage.Setup(AssemblyCompiler compiler)
        {
            base.Setup(compiler);

            scheduler = compiler.Pipeline.FindFirst<ICompilationSchedulerStage>();

            if (scheduler == null)
                throw new InvalidOperationException(@"No compilation scheduler found in the assembly compiler pipeline.");
        }
Esempio n. 8
0
        public SimpleJitMethodCompiler(AssemblyCompiler compiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method, Stream codeStream, ITypeSystem typeSystem)
            : base(compiler.Pipeline.FindFirst <IAssemblyLinker>(), compiler.Architecture, compilationScheduler, type, method, typeSystem, compiler.Pipeline.FindFirst <ITypeLayout>())
        {
            if (codeStream == null)
            {
                throw new ArgumentNullException(@"codeStream");
            }

            this.codeStream = codeStream;
        }
        void IAssemblyCompilerStage.Setup(AssemblyCompiler compiler)
        {
            base.Setup(compiler);

            scheduler = compiler.Pipeline.FindFirst <ICompilationSchedulerStage>();

            if (scheduler == null)
            {
                throw new InvalidOperationException(@"No compilation scheduler found in the assembly compiler pipeline.");
            }
        }
 public override MethodCompilerBase CreateMethodCompiler(ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method)
 {
     MethodCompilerBase mc = new AotMethodCompiler(
         this,
         compilationScheduler,
         type,
         method
     );
     this.Architecture.ExtendMethodCompilerPipeline(mc.Pipeline);
     return mc;
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinkerMethodCompiler"/> class.
 /// </summary>
 /// <param name="compiler">The assembly compiler executing this method compiler.</param>
 /// <param name="method">The metadata of the method to compile.</param>
 /// <param name="instructionSet">The instruction set.</param>
 /// <exception cref="System.ArgumentNullException"><paramref name="compiler"/>, <paramref name="method"/> or <paramref name="instructionSet"/> is null.</exception>
 public LinkerMethodCompiler(AssemblyCompiler compiler, ICompilationSchedulerStage compilationScheduler, RuntimeMethod method, InstructionSet instructionSet)
     : base(compiler.Pipeline.FindFirst<IAssemblyLinker>(), compiler.Architecture, compilationScheduler, compiler.Assembly, method.DeclaringType, method)
 {
     InstructionSet = instructionSet;
     this.Pipeline.AddRange(new IMethodCompilerStage[] {
         new BasicBlockBuilderStage(),
         new PlatformStubStage(),
         new SimpleTraceBlockOrderStage(),
         new CodeGenerationStage(),
     });
     compiler.Architecture.ExtendMethodCompilerPipeline(this.Pipeline);
 }
Esempio n. 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LinkerMethodCompiler"/> class.
        /// </summary>
        /// <param name="assemblyCompiler">The assembly compiler executing this method compiler.</param>
        /// <param name="method">The metadata of the method to compile.</param>
        /// <param name="instructionSet">The instruction set.</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="assemblyCompiler"/>, <paramref name="method"/> or <paramref name="instructionSet"/> is null.</exception>
        public LinkerMethodCompiler(AssemblyCompiler assemblyCompiler, ICompilationSchedulerStage compilationScheduler, RuntimeMethod method, InstructionSet instructionSet)
            : base(assemblyCompiler, method.DeclaringType, method,  instructionSet, compilationScheduler)
        {
            this.CreateBlock(-1, 0);

            this.Pipeline.AddRange(new IMethodCompilerStage[] {
                new SimpleTraceBlockOrderStage(),
                new PlatformStubStage(),
                new CodeGenerationStage(),
            });

            assemblyCompiler.Architecture.ExtendMethodCompilerPipeline(this.Pipeline);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LinkerMethodCompiler"/> class.
        /// </summary>
        /// <param name="compiler">The assembly compiler executing this method compiler.</param>
        /// <param name="method">The metadata of the method to compile.</param>
        /// <param name="instructionSet">The instruction set.</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="compiler"/>, <paramref name="method"/> or <paramref name="instructionSet"/> is null.</exception>
        public LinkerMethodCompiler(AssemblyCompiler compiler, ICompilationSchedulerStage compilationScheduler, RuntimeMethod method, InstructionSet instructionSet)
            : base(compiler.Pipeline.FindFirst <IAssemblyLinker>(), compiler.Architecture, compilationScheduler, method.DeclaringType, method, compiler.TypeSystem, compiler.TypeLayout)
        {
            this.InstructionSet = instructionSet;
            this.CreateBlock(-1, 0);

            this.Pipeline.AddRange(new IMethodCompilerStage[] {
                new SimpleTraceBlockOrderStage(),
                new PlatformStubStage(),
                new CodeGenerationStage(),
            });
            compiler.Architecture.ExtendMethodCompilerPipeline(this.Pipeline);
        }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AotMethodCompiler"/> class.
 /// </summary>
 public AotMethodCompiler(AssemblyCompiler compiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method)
     : base(compiler.Pipeline.FindFirst <IAssemblyLinker>(), compiler.Architecture, compilationScheduler, type, method, compiler.TypeSystem, compiler.TypeLayout)
 {
     this.assemblyCompiler = compiler;
     this.Pipeline.AddRange(
         new IMethodCompilerStage[]
     {
         new DecodingStage(),
         //InstructionLogger.Instance,
         new BasicBlockBuilderStage(),
         InstructionLogger.Instance,
         new OperandDeterminationStage(),
         InstructionLogger.Instance,
         StaticAllocationResolutionStageWrapper.Instance,
         //InstructionLogger.Instance,
         new CILTransformationStage(),
         InstructionLogger.Instance,
         //InstructionStatisticsStage.Instance,
         //new DominanceCalculationStage(),
         //InstructionLogger.Instance,
         //new EnterSSA(),
         //InstructionLogger.Instance,
         //new ConstantPropagationStage(),
         //InstructionLogger.Instance,
         //new ConstantFoldingStage(),
         //new StrengthReductionStage(),
         //InstructionLogger.Instance,
         //new LeaveSSA(),
         //InstructionLogger.Instance,
         new StackLayoutStage(),
         //InstructionLogger.Instance,
         new PlatformStubStage(),
         InstructionLogger.Instance,
         //new BlockReductionStage(),
         new LoopAwareBlockOrderStage(),
         InstructionLogger.Instance,
         //new SimpleTraceBlockOrderStage(),
         //new ReverseBlockOrderStage(),
         //new LocalCSE(),
         new CodeGenerationStage(),
     });
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AotMethodCompiler"/> class.
 /// </summary>
 public AotMethodCompiler(AssemblyCompiler compiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method)
     : base(compiler.Pipeline.FindFirst<IAssemblyLinker>(), compiler.Architecture, compilationScheduler, type, method, compiler.TypeSystem, compiler.Pipeline.FindFirst<ITypeLayout>())
 {
     this.assemblyCompiler = compiler;
     this.Pipeline.AddRange(
         new IMethodCompilerStage[]
         {
             new DecodingStage(),
             //InstructionLogger.Instance,
             new BasicBlockBuilderStage(),
             //InstructionLogger.Instance,
             new OperandDeterminationStage(),
             InstructionLogger.Instance,
             StaticAllocationResolutionStageWrapper.Instance,
             //InstructionLogger.Instance,
             new CILTransformationStage(),
             InstructionLogger.Instance,
             //InstructionStatisticsStage.Instance,
             //new DominanceCalculationStage(),
             //InstructionLogger.Instance,
             //new EnterSSA(),
             //InstructionLogger.Instance,
             //new ConstantPropagationStage(),
             //InstructionLogger.Instance,
             //new ConstantFoldingStage(),
             //new StrengthReductionStage(),
             //InstructionLogger.Instance,
             //new LeaveSSA(),
             //InstructionLogger.Instance,
             new StackLayoutStage(),
             //InstructionLogger.Instance,
             new PlatformStubStage(),
             InstructionLogger.Instance,
             //new BlockReductionStage(),
             new LoopAwareBlockOrderStage(),
             //InstructionLogger.Instance,
             //new SimpleTraceBlockOrderStage(),
             //new ReverseBlockOrderStage(),
             //new LocalCSE(),
             new CodeGenerationStage(),
         });
 }
Esempio n. 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseMethodCompiler"/> class.
        /// </summary>
        /// <param name="linker">The _linker.</param>
        /// <param name="architecture">The target compilation Architecture.</param>
        /// <param name="type">The type, which owns the method to compile.</param>
        /// <param name="method">The method to compile by this instance.</param>
        protected BaseMethodCompiler(
            IAssemblyLinker linker,
            IArchitecture architecture,
            ICompilationSchedulerStage compilationScheduler,
            RuntimeType type,
            RuntimeMethod method,
            ITypeSystem typeSystem,
            ITypeLayout typeLayout)
        {
            if (architecture == null)
            {
                throw new ArgumentNullException(@"architecture");
            }

            if (linker == null)
            {
                throw new ArgumentNullException(@"linker");
            }

            if (compilationScheduler == null)
            {
                throw new ArgumentNullException(@"compilationScheduler");
            }

            this.linker       = linker;
            this.architecture = architecture;
            this.method       = method;
            this.type         = type;

            parameters     = new List <Operand>(new Operand[method.Parameters.Count]);
            nextStackSlot  = 0;
            basicBlocks    = new List <BasicBlock>();
            instructionSet = null;             // this will be set later

            pipeline = new CompilerPipeline();

            this.compilationScheduler = compilationScheduler;
            this.moduleTypeSystem     = method.Module;
            this.typeSystem           = typeSystem;
            this.typeLayout           = typeLayout;
        }
Esempio n. 17
0
        public MethodCompiler(CompilerHelper compiler, IArchitecture architecture, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method)
            : base(compiler.Pipeline.FindFirst <IAssemblyLinker>(), architecture, compilationScheduler, type, method, compiler.TypeSystem, compiler.TypeLayout)
        {
            this.assemblyCompiler = compiler;

            // Populate the pipeline
            this.Pipeline.AddRange(new IMethodCompilerStage[] {
                new DecodingStage(),
                //new InstructionLogger(),
                new BasicBlockBuilderStage(),
                //new InstructionLogger(),
                new OperandDeterminationStage(),
                new InstructionLogger(),
                new StaticAllocationResolutionStage(),
                //new InstructionLogger(),
                //new ConstantFoldingStage(),
                new CILTransformationStage(),
                new InstructionLogger(),
                new CILLeakGuardStage()
                {
                    MustThrowCompilationException = true
                },
                //new InstructionLogger(),
                //InstructionStatisticsStage.Instance,
                //new DominanceCalculationStage(),
                //new EnterSSA(),
                //new ConstantPropagationStage(),
                //new ConstantFoldingStage(),
                //new LeaveSSA(),
                new StackLayoutStage(),
                new PlatformStubStage(),
                //new InstructionLogger(),
                //new BlockReductionStage(),
                new LoopAwareBlockOrderStage(),
                //new SimpleTraceBlockOrderStage(),
                //new ReverseBlockOrderStage(),  // reverse all the basic blocks and see if it breaks anything
                //new BasicBlockOrderStage()
                //new CodeGenerationStage(),
                new InstructionLogger(),
            });
        }
        public TestCaseMethodCompiler(TestCaseAssemblyCompiler compiler, IArchitecture architecture, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method)
            : base(compiler.Pipeline.FindFirst<IAssemblyLinker>(), architecture, compilationScheduler, type, method, compiler.TypeSystem, compiler.Pipeline.FindFirst<ITypeLayout>())
        {
            this.assemblyCompiler = compiler;

            // Populate the pipeline
            this.Pipeline.AddRange(new IMethodCompilerStage[] {
                new DecodingStage(),
                //new InstructionLogger(),
                new BasicBlockBuilderStage(),
                //new InstructionLogger(),
                new OperandDeterminationStage(),
                //new InstructionLogger(),
                new StaticAllocationResolutionStage(),
                //new InstructionLogger(),
                //new ConstantFoldingStage(),
                new CILTransformationStage(),
                //new InstructionLogger(),
                new CILLeakGuardStage() { MustThrowCompilationException = true },
                //new InstructionLogger(),
                //InstructionStatisticsStage.Instance,
                //new DominanceCalculationStage(),
                //new EnterSSA(),
                //new ConstantPropagationStage(),
                //new ConstantFoldingStage(),
                //new LeaveSSA(),
                new StackLayoutStage(),
                new PlatformStubStage(),
                //new InstructionLogger(),
                //new BlockReductionStage(),
                new LoopAwareBlockOrderStage(),
                //new SimpleTraceBlockOrderStage(),
                //new ReverseBlockOrderStage(),  // reverse all the basic blocks and see if it breaks anything
                //new BasicBlockOrderStage()
                new CodeGenerationStage(),
                //new InstructionLogger(),
            });
        }
 public override MethodCompilerBase CreateMethodCompiler(ICompilationSchedulerStage schedulerStage, RuntimeType type, RuntimeMethod method)
 {
     MethodCompilerBase mc = new TestCaseMethodCompiler(this, this.Pipeline.FindFirst<IAssemblyLinker>(), this.Architecture, schedulerStage, this.Assembly, type, method);
     this.Architecture.ExtendMethodCompilerPipeline(mc.Pipeline);
     return mc;
 }
Esempio n. 20
0
 /// <summary>
 /// Creates a method compiler
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="method">The method to compile.</param>
 /// <returns>An instance of a MethodCompilerBase for the given type/method pair.</returns>
 public abstract IMethodCompiler CreateMethodCompiler(ICompilationSchedulerStage schedulerStage, RuntimeType type, RuntimeMethod method);
 public override IMethodCompiler CreateMethodCompiler(ICompilationSchedulerStage schedulerStage, RuntimeType type, RuntimeMethod method)
 {
     IMethodCompiler mc = new TestCaseMethodCompiler(this, schedulerStage, type, method);
     Architecture.ExtendMethodCompilerPipeline(mc.Pipeline);
     return mc;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseMethodCompiler"/> class.
        /// </summary>
        /// <param name="assemblyCompiler">The assembly compiler.</param>
        /// <param name="type">The type, which owns the method to compile.</param>
        /// <param name="method">The method to compile by this instance.</param>
        /// <param name="instructionSet">The instruction set.</param>
        /// <param name="compilationScheduler">The compilation scheduler.</param>
        protected BaseMethodCompiler(AssemblyCompiler assemblyCompiler, RuntimeType type, RuntimeMethod method, InstructionSet instructionSet, ICompilationSchedulerStage compilationScheduler)
        {
            if (compilationScheduler == null)
                throw new ArgumentNullException(@"compilationScheduler");

            this.assemblyCompiler = assemblyCompiler;
            this.method = method;
            this.type = type;
            this.compilationScheduler = compilationScheduler;
            this.moduleTypeSystem = method.Module;

            this.architecture = assemblyCompiler.Architecture;
            this.typeSystem = assemblyCompiler.TypeSystem;
            this.typeLayout = AssemblyCompiler.TypeLayout;
            this.internalTrace = AssemblyCompiler.InternalTrace;

            this.linker = assemblyCompiler.Pipeline.FindFirst<IAssemblyLinker>();
            this.plugSystem = assemblyCompiler.Pipeline.FindFirst<IPlugSystem>();

            this.parameters = new List<Operand>(new Operand[method.Parameters.Count]);
            this.basicBlocks = new BasicBlocks();

            this.instructionSet = instructionSet ?? new InstructionSet(256);

            this.pipeline = new CompilerPipeline();

            this.stackLayout = new StackLayout(architecture, method.Parameters.Count + (method.Signature.HasThis || method.Signature.HasExplicitThis ? 1 : 0));

            this.virtualRegisterLayout = new VirtualRegisterLayout(architecture, stackLayout);

            EvaluateParameterOperands();
        }
Esempio n. 23
0
 /// <summary>
 /// Creates a method compiler
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="method">The method to compile.</param>
 /// <returns>An instance of a MethodCompilerBase for the given type/method pair.</returns>
 public abstract MethodCompilerBase CreateMethodCompiler(ICompilationSchedulerStage schedulerStage, RuntimeType type, RuntimeMethod method);
Esempio n. 24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseMethodCompiler"/> class.
        /// </summary>
        /// <param name="linker">The _linker.</param>
        /// <param name="architecture">The target compilation Architecture.</param>
        /// <param name="type">The type, which owns the method to compile.</param>
        /// <param name="method">The method to compile by this instance.</param>
        protected BaseMethodCompiler(
			IAssemblyLinker linker,
			IArchitecture architecture,
			ICompilationSchedulerStage compilationScheduler,
			RuntimeType type,
			RuntimeMethod method,
			ITypeSystem typeSystem,
			ITypeLayout typeLayout)
        {
            if (architecture == null)
                throw new ArgumentNullException(@"architecture");

            if (linker == null)
                throw new ArgumentNullException(@"linker");

            if (compilationScheduler == null)
                throw new ArgumentNullException(@"compilationScheduler");

            this.linker = linker;
            this.architecture = architecture;
            this.method = method;
            this.type = type;

            parameters = new List<Operand>(new Operand[method.Parameters.Count]);
            nextStackSlot = 0;
            basicBlocks = new List<BasicBlock>();
            instructionSet = null; // this will be set later

            pipeline = new CompilerPipeline();

            this.compilationScheduler = compilationScheduler;
            this.moduleTypeSystem = method.Module;
            this.typeSystem = typeSystem;
            this.typeLayout = typeLayout;
        }
Esempio n. 25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseMethodCompiler"/> class.
        /// </summary>
        /// <param name="assemblyCompiler">The assembly compiler.</param>
        /// <param name="type">The type, which owns the method to compile.</param>
        /// <param name="method">The method to compile by this instance.</param>
        /// <param name="instructionSet">The instruction set.</param>
        /// <param name="compilationScheduler">The compilation scheduler.</param>
        protected BaseMethodCompiler(AssemblyCompiler assemblyCompiler, RuntimeType type, RuntimeMethod method, InstructionSet instructionSet, ICompilationSchedulerStage compilationScheduler)
        {
            if (compilationScheduler == null)
                throw new ArgumentNullException(@"compilationScheduler");

            this.assemblyCompiler = assemblyCompiler;
            this.method = method;
            this.type = type;
            this.compilationScheduler = compilationScheduler;
            this.moduleTypeSystem = method.Module;

            this.architecture = assemblyCompiler.Architecture;
            this.typeSystem = assemblyCompiler.TypeSystem;
            this.typeLayout = AssemblyCompiler.TypeLayout;
            this.internalTrace = AssemblyCompiler.InternalTrace;

            this.linker = assemblyCompiler.Pipeline.FindFirst<IAssemblyLinker>();
            this.plugSystem = assemblyCompiler.Pipeline.FindFirst<IPlugSystem>();

            this.parameters = new List<Operand>(new Operand[method.Parameters.Count]);
            this.nextStackSlot = 0;
            this.basicBlocks = new List<BasicBlock>();

            this.instructionSet = instructionSet ?? new InstructionSet(256);

            this.pipeline = new CompilerPipeline();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MethodCompilerBase"/> class.
        /// </summary>
        /// <param name="linker">The _linker.</param>
        /// <param name="architecture">The target compilation Architecture.</param>
        /// <param name="module">The metadata module, that contains the type.</param>
        /// <param name="type">The type, which owns the _method to compile.</param>
        /// <param name="method">The method to compile by this instance.</param>
        protected MethodCompilerBase(
			IAssemblyLinker linker,
			IArchitecture architecture,
		    ICompilationSchedulerStage compilationScheduler,
			IMetadataModule module,
			RuntimeType type,
			RuntimeMethod method)
        {
            if (architecture == null)
                throw new ArgumentNullException(@"architecture");

            if (linker == null)
                throw new ArgumentNullException(@"linker");

            if (compilationScheduler == null)
                throw new ArgumentNullException(@"compilationScheduler");

            _linker = linker;
            _architecture = architecture;
            this.compilationScheduler = compilationScheduler;
            _method = method;
            _module = module;
            _parameters = new List<Operand>(new Operand[_method.Parameters.Count]);
            _type = type;
            _nextStackSlot = 0;
            _basicBlocks = new List<BasicBlock>();
            _instructionSet = null; // this will be set later
        }