diff --git a/source/Cosmos.sln b/source/Cosmos.sln index abff84be4..e6099473e 100644 --- a/source/Cosmos.sln +++ b/source/Cosmos.sln @@ -188,9 +188,11 @@ Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "SSchockeTestBoot", "..\sour {0AAD9114-6F08-4344-A282-CD6BC77595E5} = {0AAD9114-6F08-4344-A282-CD6BC77595E5} EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.IL2CPU.Profiler", "..\source2\IL2CPU\Cosmos.IL2CPU.Profiler\Cosmos.IL2CPU.Profiler.csproj", "{F708C866-1C9B-4579-8C28-0728ECCFC1ED}" +EndProject Global GlobalSection(TeamFoundationVersionControl) = preSolution - SccNumberOfProjects = 48 + SccNumberOfProjects = 49 SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs04 SccLocalPath0 = . @@ -384,6 +386,10 @@ Global SccProjectTopLevelParentUniqueName47 = Cosmos.sln SccProjectName47 = ../source2/Users/SSchocke/SSchockeTest SccLocalPath47 = ..\\source2\\Users\\SSchocke\\SSchockeTest + SccProjectUniqueName48 = ..\\source2\\IL2CPU\\Cosmos.IL2CPU.Profiler\\Cosmos.IL2CPU.Profiler.csproj + SccProjectTopLevelParentUniqueName48 = Cosmos.sln + SccProjectName48 = ../source2/IL2CPU/Cosmos.IL2CPU.Profiler + SccLocalPath48 = ..\\source2\\IL2CPU\\Cosmos.IL2CPU.Profiler EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Bootstrap|Any CPU = Bootstrap|Any CPU @@ -1135,6 +1141,21 @@ Global {4527D60E-25F4-4617-B463-7CDA3C219097}.Release|Mixed Platforms.Build.0 = Release|x86 {4527D60E-25F4-4617-B463-7CDA3C219097}.Release|x86.ActiveCfg = Release|x86 {4527D60E-25F4-4617-B463-7CDA3C219097}.Release|x86.Build.0 = Release|x86 + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Bootstrap|Any CPU.ActiveCfg = Release|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Bootstrap|Any CPU.Build.0 = Release|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Bootstrap|Mixed Platforms.ActiveCfg = Release|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Bootstrap|Mixed Platforms.Build.0 = Release|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Bootstrap|x86.ActiveCfg = Release|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Debug|x86.ActiveCfg = Debug|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Release|Any CPU.Build.0 = Release|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {F708C866-1C9B-4579-8C28-0728ECCFC1ED}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1182,6 +1203,7 @@ Global {52BF0A64-EBEF-420A-9F27-6C5226A4B77B} = {6A15C540-8278-4B9C-B890-FA57FB6AE6A6} {C801F19C-A9D3-42D5-9A57-9FFDF9B4D05E} = {6A15C540-8278-4B9C-B890-FA57FB6AE6A6} {239E33A7-F0C3-4801-85CA-4D8F89A31DC0} = {6A15C540-8278-4B9C-B890-FA57FB6AE6A6} + {F708C866-1C9B-4579-8C28-0728ECCFC1ED} = {6A15C540-8278-4B9C-B890-FA57FB6AE6A6} {6658FCE0-7032-4B7B-BD95-F2765C393442} = {2DF5F17F-4890-4856-ADFD-4DE23282C3B7} {6882C74B-3ED2-4D76-9E7B-67B6A28808BC} = {0CF14D0F-6054-4D3D-9062-E3D2EB064A4E} {23476FAD-3712-4A4B-90C0-CCCC9AC8D953} = {0CF14D0F-6054-4D3D-9062-E3D2EB064A4E} diff --git a/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Assembler.cs b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Assembler.cs new file mode 100644 index 000000000..dd49e310c --- /dev/null +++ b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Assembler.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Cosmos.IL2CPU.Profiler { + public class Assembler : Cosmos.IL2CPU.Assembler { + + protected override void InitILOps() { + var xILOp = new ILOp(this); + // Don't change the type in the foreach to a var, its necessary as it is now + // to typecast it, so we can then recast to an int. + foreach (ILOpCode.Code xCode in Enum.GetValues(typeof(ILOpCode.Code))) { + int xCodeValue = (int)xCode; + if (xCodeValue <= 0xFF) { + mILOpsLo[xCodeValue] = xILOp; + } else { + mILOpsHi[xCodeValue & 0xFF] = xILOp; + } + } + } + + } +} diff --git a/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Cosmos.IL2CPU.Profiler.csproj b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Cosmos.IL2CPU.Profiler.csproj new file mode 100644 index 000000000..d6dfb5a4f --- /dev/null +++ b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Cosmos.IL2CPU.Profiler.csproj @@ -0,0 +1,83 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {F708C866-1C9B-4579-8C28-0728ECCFC1ED} + Exe + Properties + Cosmos.IL2CPU.Profiler + Cosmos.IL2CPU.Profiler + v3.5 + 512 + + + 3.5 + SAK + SAK + SAK + SAK + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + AllRules.ruleset + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + AllRules.ruleset + + + + + 3.5 + + + + + + + + + + + + + {BCB66614-20FE-4184-B214-FD42844AD8A6} + Cosmos.Hardware.Plugs + + + {B168BEDD-C6A6-4E7C-B9A5-0144286E9E42} + Cosmos.Kernel.Plugs + + + {6110AD07-EB07-4A99-BB73-7A69AF5732F1} + Cosmos.Sys.Plugs + + + {239E33A7-F0C3-4801-85CA-4D8F89A31DC0} + Cosmos.IL2CPU + + + + + \ No newline at end of file diff --git a/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Cosmos.IL2CPU.Profiler.csproj.vspscc b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Cosmos.IL2CPU.Profiler.csproj.vspscc new file mode 100644 index 000000000..feffdecaa --- /dev/null +++ b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Cosmos.IL2CPU.Profiler.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/source2/IL2CPU/Cosmos.IL2CPU.Profiler/ILOp.cs b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/ILOp.cs new file mode 100644 index 000000000..426668ae1 --- /dev/null +++ b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/ILOp.cs @@ -0,0 +1,13 @@ +using System; + +namespace Cosmos.IL2CPU.Profiler { + public class ILOp : Cosmos.IL2CPU.ILOp { + public ILOp(Cosmos.IL2CPU.Assembler aAsmblr) + : base(aAsmblr) { + } + + public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) { + // Do Nothing + } + } +} diff --git a/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Program.cs b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Program.cs new file mode 100644 index 000000000..a30b2a5cd --- /dev/null +++ b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Program.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Reflection.Emit; +using System.Text; + +namespace Cosmos.IL2CPU.Profiler { + class Program { + + // This program profiles the scanning engine. + // In the future it may profile other aspects as well. + + static void Main(string[] args) { + DoScan(); + } + + private static void DoScan() { + var xSW = new Stopwatch(); + xSW.Start(); + + var xAsmblr = new Assembler(); + var xScanner = new ILScanner(xAsmblr); + //TODO: Add plugs into the scanning equation to profile scanning them too + var xEntryPoint = typeof(Program).GetMethod("ScannerEntryPoint", BindingFlags.NonPublic | BindingFlags.Static); + xScanner.Execute(xEntryPoint); + + xSW.Stop(); + Console.WriteLine("Total time : {0}", xSW.Elapsed); + Console.WriteLine("Method count: {0}", xScanner.MethodCount); + //Console.WriteLine("Instruction count: {0}", xScanner.InstructionCount); + } + + // This is a dummy entry point for the scanner to start at. + // Its not even a Cosmos app, just a standard Windows console app, + // but that fine for the scanner profiling as it does + // not actually compile it. + private static void ScannerEntryPoint() { + Console.WriteLine("Hello, World!"); + var xInt = 0; + object xObj = xInt; + xObj.ToString(); + } + + } +} diff --git a/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Properties/AssemblyInfo.cs b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..b53baaf49 --- /dev/null +++ b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Cosmos.IL2CPU.Profiler")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Cosmos.IL2CPU.Profiler")] +[assembly: AssemblyCopyright("Copyright © 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e4553c3e-1412-4524-8ac0-d2da7c9465b6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]