Example #1
0
        private static void Main()
        {
            const string platform = "x86";

            var compilerOptions = new CompilerOptions()
            {
                EnableSSA             = true,
                EnableIROptimizations = true,
                EnableSparseConditionalConstantPropagation = true,
                EnableInlinedMethods = true,
                EnableLongExpansion  = true,
                EnableValueNumbering = true,
                TwoPassOptimizations = true,
                EnableMethodScanner  = true,
                EnableBitTracker     = true,             // FUTURE

                MultibootSpecification = MultibootSpecification.V1,
                LinkerFormatType       = LinkerFormatType.Elf32,
                InlinedIRMaximum       = 12,

                BaseAddress           = 0x00500000,
                EmitStaticRelocations = false,
                EmitAllSymbols        = false,

                EmitBinary = false,
                TraceLevel = 0,

                EnableStatistics = true,
            };

            compilerOptions.Architecture = SelectArchitecture(platform);

            compilerOptions.AddSourceFile($"Mosa.TestWorld.{platform}.exe");
            compilerOptions.AddSourceFile("Mosa.Plug.Korlib.dll");
            compilerOptions.AddSourceFile($"Mosa.Plug.Korlib.{platform}.dll");
            compilerOptions.TraceLevel = 5;

            var stopwatch = new Stopwatch();

            var compiler = new MosaCompiler(compilerOptions);

            compiler.Load();
            compiler.Initialize();
            compiler.Setup();

            stopwatch.Start();

            //MeasureCompileTime(stopwatch, compiler, "Mosa.Kernel.x86.IDT::SetTableEntries");
            //MeasureCompileTime(stopwatch, compiler, "System.Void Mosa.TestWorld.x86.Boot::Thread1");
            //MeasureCompileTime(stopwatch, compiler, "System.String System.Int32::CreateString(System.UInt32, System.Boolean, System.Boolean)");

            //compiler.ScheduleAll();

            var start = stopwatch.Elapsed.TotalSeconds;

            Console.WriteLine("Threaded Execution Time:");

            compiler.ThreadedCompile();

            //compiler.Execute();

            Console.WriteLine($"Elapsed: {(stopwatch.Elapsed.TotalSeconds - start).ToString("F2")} secs");

            Console.ReadKey();
        }