/// <summary>
        /// Initializes a new instance of the <see cref="BaseMethodCompiler" /> class.
        /// </summary>
        /// <param name="compiler">The assembly compiler.</param>
        /// <param name="method">The method to compile by this instance.</param>
        /// <param name="basicBlocks">The basic blocks.</param>
        /// <param name="threadID">The thread identifier.</param>
        protected BaseMethodCompiler(BaseCompiler compiler, MosaMethod method, BasicBlocks basicBlocks, int threadID)
        {
            Compiler          = compiler;
            Method            = method;
            Type              = method.DeclaringType;
            Scheduler         = compiler.CompilationScheduler;
            Architecture      = compiler.Architecture;
            TypeSystem        = compiler.TypeSystem;
            TypeLayout        = compiler.TypeLayout;
            Trace             = compiler.CompilerTrace;
            Linker            = compiler.Linker;
            BasicBlocks       = basicBlocks ?? new BasicBlocks();
            Pipeline          = new CompilerPipeline();
            StackLayout       = new StackLayout(Architecture, method.Signature.Parameters.Count + (method.HasThis || method.HasExplicitThis ? 1 : 0));
            VirtualRegisters  = new VirtualRegisters(Architecture);
            LocalVariables    = emptyOperandList;
            ThreadID          = threadID;
            DominanceAnalysis = new Dominance(Compiler.CompilerOptions.DominanceAnalysisFactory, BasicBlocks);
            PluggedMethod     = compiler.PlugSystem.GetPlugMethod(Method);
            stop              = false;

            MethodData = compiler.CompilerData.GetCompilerMethodData(Method);
            MethodData.Counters.Clear();

            EvaluateParameterOperands();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseMethodCompiler" /> class.
        /// </summary>
        /// <param name="compiler">The assembly compiler.</param>
        /// <param name="method">The method to compile by this instance.</param>
        /// <param name="basicBlocks">The basic blocks.</param>
        /// <param name="threadID">The thread identifier.</param>
        protected BaseMethodCompiler(BaseCompiler compiler, MosaMethod method, BasicBlocks basicBlocks, int threadID)
        {
            Compiler     = compiler;
            Method       = method;
            Type         = method.DeclaringType;
            Scheduler    = compiler.CompilationScheduler;
            Architecture = compiler.Architecture;
            TypeSystem   = compiler.TypeSystem;
            TypeLayout   = compiler.TypeLayout;
            Trace        = compiler.CompilerTrace;
            Linker       = compiler.Linker;
            BasicBlocks  = basicBlocks ?? new BasicBlocks();
            Pipeline     = new CompilerPipeline();
            LocalStack   = new List <Operand>();

            ConstantZero     = Operand.CreateConstant(0, TypeSystem);
            StackFrame       = Operand.CreateCPURegister(TypeSystem.BuiltIn.Pointer, Architecture.StackFrameRegister);
            StackPointer     = Operand.CreateCPURegister(TypeSystem.BuiltIn.Pointer, Architecture.StackPointerRegister);
            Parameters       = new Operand[method.Signature.Parameters.Count + (method.HasThis || method.HasExplicitThis ? 1 : 0)];
            VirtualRegisters = new VirtualRegisters();
            LocalVariables   = emptyOperandList;
            ThreadID         = threadID;
            PluggedMethod    = compiler.PlugSystem.GetPlugMethod(Method);
            stop             = false;

            MethodData = compiler.CompilerData.GetCompilerMethodData(Method);
            MethodData.Counters.Clear();

            EvaluateParameterOperands();

            CalculateMethodParameterSize();
        }
Exemplo n.º 3
0
        public void AddToInlineQueue(CompilerMethodData methodData)
        {
            Debug.Assert(!methodData.Method.IsAbstract && !methodData.Method.HasOpenGenericParams);

            //Debug.Assert(!methodData.Method.IsLinkerGenerated);

            inlineQueue.Enqueue(methodData);
        }
Exemplo n.º 4
0
        public void AddToInlineQueue(CompilerMethodData methodData)
        {
            Debug.Assert(!methodData.Method.IsAbstract && !methodData.Method.HasOpenGenericParams);

            //Debug.Assert(!methodData.Method.IsLinkerGenerated);

            inlineQueue.Enqueue(methodData);
        }
Exemplo n.º 5
0
        public CompilerMethodData GetCompilerMethodData(MosaMethod method)
        {
            lock (methods)
            {
                if (!methods.TryGetValue(method, out CompilerMethodData compilerMethod))
                {
                    compilerMethod = new CompilerMethodData(method);
                    methods.Add(method, compilerMethod);
                }

                return(compilerMethod);
            }
        }
Exemplo n.º 6
0
        public CompilerMethodData GetCompilerMethodData(MosaMethod method)
        {
            lock (compilerMethods)
            {
                CompilerMethodData compilerMethod;

                if (!compilerMethods.TryGetValue(method, out compilerMethod))
                {
                    compilerMethod = new CompilerMethodData(method);
                    compilerMethods.Add(method, compilerMethod);
                }

                return compilerMethod;
            }
        }