diff --git a/CHANGELOG.md b/CHANGELOG.md index 2188190..e4180e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,18 @@ # Changelog +## v1.3.20 - 2021.03.11 +- Update GrEmit dependency to v3.4.1. +- Run tests against net5.0 tfm. + ## v1.3.10 - 2019.11.21 -- Update GrEmit to v3.2.2 supporting SourceLink +- Update GrEmit to v3.2.2 supporting SourceLink. ## v1.3.7 - 2019.11.21 - Use [SourceLink](https://github.com/dotnet/sourcelink) to help ReSharper decompiler show actual code. ## v1.3.2 - 2019.09.25 -- Fix bug in `LambdaExpressionCreator` -- Update dependencies +- Fix bug in `LambdaExpressionCreator`. +- Update dependencies. ## v1.2.1 - 2018.09.15 - Use [Nerdbank.GitVersioning](https://github.com/AArnott/Nerdbank.GitVersioning) to automate generation of assembly diff --git a/GrobExp.Compiler.Tests/TestPerformance.cs b/GrobExp.Compiler.Tests/TestPerformance.cs index 9f1928f..4d3f2e7 100644 --- a/GrobExp.Compiler.Tests/TestPerformance.cs +++ b/GrobExp.Compiler.Tests/TestPerformance.cs @@ -305,47 +305,47 @@ public unsafe void TestMarshal() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { #endif - byte[] body; - if (IntPtr.Size == 4) - { - // x86 - /* - * xor eax, eax // 0x31, 0xC0 - * ret 8 // 0xC2, 0x08, 0x00 - */ - body = new byte[] - { - 0x31, 0xC0, // xor eax, eax - 0xC2, 0x08, 0x00 // ret 8 - }; - } - else - { - body = new byte[] - { - 0x48, 0x31, 0xC0, // xor rax, rax - 0xC3 // ret - }; - } - IntPtr p = NativeMethods.VirtualAlloc( - IntPtr.Zero, - new UIntPtr((uint)body.Length), - AllocationTypes.Commit | AllocationTypes.Reserve, - MemoryProtections.ExecuteReadWrite); - Marshal.Copy(body, 0, p, body.Length); - var func = (ZzzUnmanagedDelegate)Marshal.GetDelegateForFunctionPointer(p, typeof(ZzzUnmanagedDelegate)); - var method = ((MulticastDelegate)func).Method; - var methodHandle = (RuntimeMethodHandle)method.GetType().GetProperty("MethodHandle", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetGetMethod().Invoke(method, new object[0]); - var pointer = methodHandle.GetFunctionPointer(); - var b = (byte*)pointer; - for (int i = 0; i < 20; ++i) - { - for (int j = 0; j < 10; ++j) - Console.Write(string.Format("{0:X2} ", *b++)); - Console.WriteLine(); - } + byte[] body; + if (IntPtr.Size == 4) + { + // x86 + /* + * xor eax, eax // 0x31, 0xC0 + * ret 8 // 0xC2, 0x08, 0x00 + */ + body = new byte[] + { + 0x31, 0xC0, // xor eax, eax + 0xC2, 0x08, 0x00 // ret 8 + }; + } + else + { + body = new byte[] + { + 0x48, 0x31, 0xC0, // xor rax, rax + 0xC3 // ret + }; + } + IntPtr p = NativeMethods.VirtualAlloc( + IntPtr.Zero, + new UIntPtr((uint)body.Length), + AllocationTypes.Commit | AllocationTypes.Reserve, + MemoryProtections.ExecuteReadWrite); + Marshal.Copy(body, 0, p, body.Length); + var func = (ZzzUnmanagedDelegate)Marshal.GetDelegateForFunctionPointer(p, typeof(ZzzUnmanagedDelegate)); + var method = ((MulticastDelegate)func).Method; + var methodHandle = (RuntimeMethodHandle)method.GetType().GetProperty("MethodHandle", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetGetMethod().Invoke(method, new object[0]); + var pointer = methodHandle.GetFunctionPointer(); + var b = (byte*)pointer; + for (int i = 0; i < 20; ++i) + { + for (int j = 0; j < 10; ++j) + Console.Write(string.Format("{0:X2} ", *b++)); + Console.WriteLine(); + } - func(0, 1); + func(0, 1); // var stopwatch = Stopwatch.StartNew(); // for (int i = 0; i < 1000000001; ++i)