Exemplo n.º 1
0
        private MethodCompiler GetMethodCompiler(MosaMethod method, BasicBlocks basicBlocks, int threadID = 0)
        {
            var methodCompiler = new MethodCompiler(this, method, basicBlocks, threadID);

            var pipeline = methodStagePipelines[threadID];

            if (pipeline == null)
            {
                pipeline = new Pipeline <BaseMethodCompilerStage>();

                methodStagePipelines[threadID] = pipeline;

                pipeline.Add(GetDefaultMethodPipeline(CompilerOptions));

                foreach (var extension in CompilerExtensions)
                {
                    extension.ExtendMethodCompilerPipeline(pipeline);
                }

                Architecture.ExtendMethodCompilerPipeline(pipeline);

                foreach (var stage in pipeline)
                {
                    stage.Initialize(this);
                }
            }

            methodCompiler.Pipeline = pipeline;

            return(methodCompiler);
        }
Exemplo n.º 2
0
        private Pipeline <BaseMethodCompilerStage> GetOrCreateMethodStagePipeline(int threadID)
        {
            var pipeline = methodStagePipelines[threadID];

            if (pipeline == null)
            {
                pipeline = new Pipeline <BaseMethodCompilerStage>();

                methodStagePipelines[threadID] = pipeline;

                pipeline.Add(GetDefaultMethodPipeline(CompilerOptions));

                foreach (var extension in CompilerExtensions)
                {
                    extension.ExtendMethodCompilerPipeline(pipeline);
                }

                Architecture.ExtendMethodCompilerPipeline(pipeline, CompilerOptions);

                foreach (var stage in pipeline)
                {
                    stage.Initialize(this);
                }
            }

            return(pipeline);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        private Pipeline <BaseMethodCompilerStage> GetOrCreateMethodStagePipeline(int threadID)
        {
            var pipeline = MethodStagePipelines[threadID];

            if (pipeline == null)
            {
                pipeline = new Pipeline <BaseMethodCompilerStage>();

                MethodStagePipelines[threadID] = pipeline;

                pipeline.Add(GetDefaultMethodPipeline(CompilerSettings, Architecture.Is64BitPlatform));

                // Call hook to allow for the extension of the pipeline
                CompilerHooks.ExtendMethodCompilerPipeline?.Invoke(pipeline);

                Architecture.ExtendMethodCompilerPipeline(pipeline, CompilerSettings);

                foreach (var stage in pipeline)
                {
                    stage.Initialize(this);
                }
            }

            return(pipeline);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Compiles the method.
        /// </summary>
        /// <param name="method">The method.</param>
        /// <param name="basicBlocks">The basic blocks.</param>
        /// <param name="threadID">The thread identifier.</param>
        public void CompileMethod(MosaMethod method, BasicBlocks basicBlocks, int threadID = 0)
        {
            NewCompilerTraceEvent(CompilerEvent.CompilingMethod, method.FullName, threadID);

            var methodCompiler = CreateMethodCompiler(method, basicBlocks, threadID);

            Architecture.ExtendMethodCompilerPipeline(methodCompiler.Pipeline);

            methodCompiler.Compile();
        }