Ejemplo n.º 1
0
 static public void BeginSection(string name)
 {
     if (m_CurrentPlayerBuildProfilerOutputFile != null)
     {
         m_ProfilerSections.Push(TinyProfiler.Section(name));
     }
 }
Ejemplo n.º 2
0
 private IEnumerable <NPath> BuildAllCppFiles(IEnumerable <CppCompilationInstruction> sourceFilesToCompile)
 {
     using (TinyProfiler.Section("Compile", ""))
     {
         Stopwatch stopwatch = new Stopwatch();
         stopwatch.Start();
         if (< > f__am$cache2 == null)
         {
Ejemplo n.º 3
0
        public void Write(AssemblyDefinition assemblyDefinition, InflatedCollectionCollector allGenerics, NPath outputDir, TypeDefinition[] typeList, AttributeCollection attributeCollection, MethodCollector methodCollector, IMetadataCollection metadataCollection)
        {
            string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(assemblyDefinition.MainModule.FullyQualifiedName);

            using (TinyProfiler.Section("Code", ""))
            {
                if (< > f__am$cache0 == null)
                {
Ejemplo n.º 4
0
 private static void MakeSureRunnerIsBuilt()
 {
     using (TinyProfiler.Section("MakeSureRunnerIsBuilt", ""))
     {
         Console.WriteLine("Making sure WinRT runner is built.");
         Shell.ExecuteAndCaptureOutput(MSBuildPath, WinRTRunnerSolutionPath.InQuotes(), null);
     }
 }
Ejemplo n.º 5
0
 public NPath Build()
 {
     object[] arg = new object[] { this._programBuildDescription.OutputFile.FileName, this._cppToolChain.GetType().Name, Environment.NewLine, this._programBuildDescription.OutputFile.Parent, this._workingDirectory };
     Console.WriteLine("Building {0} with {1}.{2}\tOutput directory: {3}{2}\tCache directory: {4}", arg);
     if (!this.CanBuildInCurrentEnvironment())
     {
         throw new InvalidOperationException($"Builder is unable to build using selected toolchain ({this._cppToolChain.GetType().Name}) or architecture ({this._cppToolChain.Architecture})!");
     }
     using (TinyProfiler.Section("BuildBinary", ""))
     {
         CppCompilationInstruction[] instructionArray;
         IEnumerable <NPath>         enumerable;
         CppToolChainContext         toolChainContext = this._cppToolChain.CreateToolChainContext();
         using (TinyProfiler.Section("ToolChain OnBeforeCompile Build", ""))
         {
             this._cppToolChain.OnBeforeCompile(this._programBuildDescription, toolChainContext, this._workingDirectory, this._forceRebuild, this._verbose);
         }
         using (TinyProfiler.Section("FindFilesToCompile", ""))
         {
             instructionArray = this._programBuildDescription.CppCompileInstructions.Concat <CppCompilationInstruction>(toolChainContext.ExtraCompileInstructions).ToArray <CppCompilationInstruction>();
             foreach (CppCompilationInstruction instruction in instructionArray)
             {
                 instruction.Defines      = instruction.Defines.Concat <string>(this._cppToolChain.ToolChainDefines());
                 instruction.IncludePaths = instruction.IncludePaths.Concat <NPath>(this._cppToolChain.ToolChainIncludePaths()).Concat <NPath>(toolChainContext.ExtraIncludeDirectories);
             }
         }
         using (TinyProfiler.Section("Calculate header hashes", ""))
         {
             this._headerHashProvider.Initialize(instructionArray);
         }
         using (TinyProfiler.Section("BuildAllCppFiles", ""))
         {
             enumerable = this.BuildAllCppFiles(instructionArray);
         }
         using (TinyProfiler.Section("OnBeforeLink Build", ""))
         {
             this.OnBeforeLink(enumerable, toolChainContext);
         }
         using (TinyProfiler.Section("Postprocess Object Files", ""))
         {
             this.PostprocessObjectFiles(enumerable, toolChainContext);
         }
         using (TinyProfiler.Section("ProgramDescription Finalize Build", ""))
         {
             this._programBuildDescription.FinalizeBuild(this._cppToolChain);
         }
         using (TinyProfiler.Section("ToolChain OnAfterLink Build", ""))
         {
             this._cppToolChain.OnAfterLink(this._programBuildDescription.OutputFile, toolChainContext, this._forceRebuild, this._verbose);
         }
         using (TinyProfiler.Section("Clean IL2CPP Cache", ""))
         {
             this.CleanWorkingDirectory(enumerable);
         }
     }
     return(this._programBuildDescription.OutputFile);
 }
Ejemplo n.º 6
0
        private void Apply()
        {
            InflatedCollectionCollector collector;

            TypeDefinition[] definitionArray;
            using (TinyProfiler.Section("PreProcessStage", ""))
            {
                this.PreProcessStage(out collector, out definitionArray);
            }
            MethodCollector     methodCollector     = new MethodCollector();
            AttributeCollection attributeCollection = new AttributeCollection();
            MetadataCollector   metadataCollection  = new MetadataCollector();

            using (TinyProfiler.Section("MetadataCollector", ""))
            {
                metadataCollection.AddAssemblies(this._assembliesOrderedByDependency);
            }
            using (TinyProfiler.Section("AllAssemblyConversion", ""))
            {
                foreach (AssemblyDefinition definition in this._assembliesOrderedByDependency)
                {
                    using (TinyProfiler.Section("Convert", definition.Name.Name))
                    {
                        this.Convert(definition, collector, attributeCollection, methodCollector, metadataCollection);
                    }
                }
            }
            methodCollector.Complete();
            using (TinyProfiler.Section("WriteGenerics", ""))
            {
                this.WriteGenerics(collector.AsReadOnly(), definitionArray, metadataCollection);
            }
            using (TinyProfiler.Section("VariousInvokers", ""))
            {
                this._virtualInvokerCollector.Write(this.GetPathFor("GeneratedVirtualInvokers", "h"));
                this._genericVirtualInvokerCollector.Write(this.GetPathFor("GeneratedGenericVirtualInvokers", "h"));
                this._interfaceInvokerCollector.Write(this.GetPathFor("GeneratedInterfaceInvokers", "h"));
                this._genericInterfaceInvokerCollector.Write(this.GetPathFor("GeneratedGenericInterfaceInvokers", "h"));
            }
            using (TinyProfiler.Section("Metadata", "Global"))
            {
                SourceWriter.WriteCollectedMetadata(collector, this._assembliesOrderedByDependency, this._outputDir, this._dataFolder, metadataCollection, attributeCollection, this._vTableBuilder, methodCollector);
            }
            using (TinyProfiler.Section("Copy Etc", ""))
            {
                if (CodeGenOptions.Dotnetprofile == DotNetProfile.Net45)
                {
                    MonoInstall.BleedingEdge.ConfigPath.Copy(this._dataFolder);
                }
                else
                {
                    MonoInstall.TwoSix.ConfigPath.Copy(this._dataFolder);
                }
            }
            this._debuggerSupport.GenerateSupportFilesIfNeeded(this._outputDir);
        }
Ejemplo n.º 7
0
        static public NPath GetTraceEventsOutputForNewBeeDriver()
        {
            if (m_CurrentPlayerBuildProfilerOutputFile == null)
            {
                return(null);
            }
            NPath path = $"{m_CurrentPlayerBuildProfilerOutputFile.Parent}/{m_CurrentPlayerBuildProfilerOutputFile.FileName}_{m_BeeDriverForCurrentPlayerBuildIndex++}.traceevents";

            TinyProfiler.AddExternalTraceEventFile(path);
            return(path);
        }
Ejemplo n.º 8
0
        private void ApplyDefaultMarshalAsAttribute()
        {
            ApplyDefaultMarshalAsAttributeVisitor visitor = new ApplyDefaultMarshalAsAttributeVisitor();

            foreach (AssemblyDefinition definition in this._assembliesOrderedByDependency)
            {
                using (TinyProfiler.Section("ApplyDefaultMarshalAsAttributeVisitor in assembly", definition.Name.Name))
                {
                    definition.Accept(visitor);
                }
            }
        }
Ejemplo n.º 9
0
 private StringBuilder EmitSingleThread(TinyProfiler.ThreadContext threadContext)
 {
     List<TinyProfiler.TimedSection> sections = threadContext.Sections;
     int num = this.MaxParents(sections);
     int num2 = 20 + (15 * (num + 1));
     StringBuilder builder = new StringBuilder();
     builder.AppendLine(string.Format("<rect x=\"0.0\" y=\"{0}\" width=\"2000.0\" height=\"{1}\" fill=\"url(#background)\"  />", this.YTopOfCurrentThread, num2));
     builder.AppendLine(string.Format("<text text-anchor=\"left\" x=\"0\" y=\"{0}\" font-size=\"12\" font-family=\"Verdana\" fill=\"rgb(0,0,0)\"  >ThreadID: {1} {2}</text>", this.YTopOfCurrentThread + 12, threadContext.ThreadID, threadContext.ThreadName));
     for (int i = 0; i != sections.Count; i++)
     {
         builder.Append(this.SectionRect(sections, i));
     }
     this.YTopOfCurrentThread += num2 + 50;
     return builder;
 }
 private static TableInfo WriteCCWMarshalingFunctions(NPath outputDir, IMethodCollectorResults methodCollector)
 {
     using (TinyProfiler.Section("CCWMarshalingFunctions", "Il2CppCcwMarshalingFunctionsTable.cpp"))
     {
         TableInfo empty = TableInfo.Empty;
         ReadOnlyCollection <TypeDefinition> cCWMarshalingFunctions = methodCollector.GetCCWMarshalingFunctions();
         if (cCWMarshalingFunctions.Count > 0)
         {
             string[] append = new string[] { "Il2CppCcwMarshalingFunctionsTable.cpp" };
             using (SourceCodeWriter writer = new SourceCodeWriter(outputDir.Combine(append)))
             {
                 writer.AddCodeGenIncludes();
                 foreach (TypeDefinition definition in cCWMarshalingFunctions)
                 {
                     object[] args = new object[] { Naming.ForCreateComCallableWrapperFunction(definition) };
                     writer.WriteLine("extern \"C\" void {0} ();", args);
                 }
                 if (< > f__am$cache2 == null)
                 {
Ejemplo n.º 11
0
        public override Shell.ExecuteResult RunAndMakeExecuteResult(string executable)
        {
            bool flag;

            Shell.ExecuteResult result;
            string[]            append = new string[] { "AppxManifest.xml" };
            NPath path = new NPath(Path.GetDirectoryName(executable)).Combine(append);

            if (!File.Exists(executable))
            {
                throw new ArgumentException($"Specified executable (" { executable } ") does not exist!");
            }
            if (!path.Exists(""))
            {
                throw new ArgumentException($"AppX manifest was not found next to the executable at " { path } "!");
            }
            WinRTManifest.AddActivatableClasses(path);
            using (Mutex mutex = new Mutex(true, @"Global\WinRTRunnerBuild", out flag))
            {
                if (!flag)
                {
                    mutex.WaitOne();
                }
                try
                {
                    MakeSureRunnerIsBuilt();
                    Shell.ExecuteArgs executeArgs = new Shell.ExecuteArgs {
                        Executable       = WinRTRunnerExecutablePath.ToString(),
                        Arguments        = path.InQuotes(),
                        WorkingDirectory = WinRTRunnerExecutablePath.Parent.ToString()
                    };
                    using (TinyProfiler.Section("Run WinRT Application", ""))
                    {
                        result = Shell.Execute(executeArgs, null);
                    }
                }
                finally
                {
                    mutex.ReleaseMutex();
                }
            }
            return(result);
        }
Ejemplo n.º 12
0
 static public void Start(NPath path)
 {
     m_CurrentPlayerBuildProfilerOutputFile = path;
     m_BeeDriverForCurrentPlayerBuildIndex  = 0;
     TinyProfiler.ConfigureOutput(m_CurrentPlayerBuildProfilerOutputFile, "Unity", -100);
 }
Ejemplo n.º 13
0
 public static ProfilerSnapshot Capture() =>
 new ProfilerSnapshot(TinyProfiler.CaptureSnapshot());