diff options
author | Jan Kotas <jkotas@microsoft.com> | 2016-01-12 18:09:12 +0300 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2016-01-13 02:34:47 +0300 |
commit | c4232511ff688be60494042599eafa259a88b2aa (patch) | |
tree | f05d9ee10373e0ea6b4bbfc7d8466c501be1f44e /src/System.Private.CoreLib | |
parent | 53935c508390f886bf54ff2444be3323bf394ce9 (diff) |
Proper implementations of JIT helpers
Cleanup C++ glue code related to JIT helpers
Diffstat (limited to 'src/System.Private.CoreLib')
5 files changed, 75 insertions, 21 deletions
diff --git a/src/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/ArrayMethodILHelpers.cs b/src/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/ArrayMethodILHelpers.cs deleted file mode 100644 index 543cf80ed..000000000 --- a/src/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/ArrayMethodILHelpers.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; - -namespace Internal.Runtime.CompilerHelpers -{ - /// <summary> - /// These methods are targeted by the ArrayMethodILEmitter in the compiler. - /// </summary> - internal static class ArrayMethodILHelpers - { - private static void ThrowIndexOutOfRangeException() - { - throw new IndexOutOfRangeException(); - } - } -} diff --git a/src/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/ThrowHelpers.cs b/src/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/ThrowHelpers.cs new file mode 100644 index 000000000..6e990bb1a --- /dev/null +++ b/src/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/ThrowHelpers.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; + +namespace Internal.Runtime.CompilerHelpers +{ + /// <summary> + /// These methods are used to throw exceptions from generated code. + /// </summary> + internal static class ThrowHelpers + { + private static void ThrowOverflowException() + { + throw new IndexOutOfRangeException(); + } + + private static void ThrowIndexOutOfRangeException() + { + throw new IndexOutOfRangeException(); + } + + private static void ThrowNullReferenceException() + { + throw new IndexOutOfRangeException(); + } + + private static void ThrowDivideByZeroException() + { + throw new IndexOutOfRangeException(); + } + } +} diff --git a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj index c3b9811f9..5ea039211 100644 --- a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -51,7 +51,7 @@ <ItemGroup> <Compile Include="Internal\Diagnostics\ExceptionExtensions.cs" /> <Compile Include="Internal\Diagnostics\StackTraceHelper.cs" /> - <Compile Include="Internal\Runtime\CompilerHelpers\ArrayMethodILHelpers.cs" /> + <Compile Include="Internal\Runtime\CompilerHelpers\ThrowHelpers.cs" /> <Compile Include="Internal\Runtime\CompilerServices\FixupRuntimeTypeHandle.cs" /> <Compile Include="Internal\Runtime\CompilerServices\FunctionPointerOps.cs" /> <Compile Include="Internal\Runtime\CompilerServices\GenericMethodDescriptor.cs" /> diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/MethodImplAttribute.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/MethodImplAttribute.cs index 13ae0d0fe..68e6a0a1e 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/MethodImplAttribute.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/MethodImplAttribute.cs @@ -11,9 +11,7 @@ namespace System.Runtime.CompilerServices [System.Runtime.InteropServices.ComVisible(true)] public enum MethodImplOptions { - // These should stay in-sync with System.Reflection.MethodImplAttributes NoInlining = 0x0008, - //ForwardRef = 0x0010, NoOptimization = 0x0040, PreserveSig = 0x0080, AggressiveInlining = 0x0100, diff --git a/src/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs b/src/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs index 4d596850b..3a1e85b2c 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs @@ -106,11 +106,51 @@ namespace System.Runtime [MethodImpl(MethodImplOptions.InternalCall)] [RuntimeImport(RuntimeLibrary, "RhGetLastGCDuration")] internal static extern long RhGetLastGCDuration(int generation); + // // calls for GCHandle. // These methods are needed to implement GCHandle class like functionality (optional) // +#if CORERT + // Allocate handle. + [MethodImpl(MethodImplOptions.InternalCall)] + [RuntimeImport(RuntimeLibrary, "RhpHandleAlloc")] + private static extern IntPtr RhpHandleAlloc(Object value, GCHandleType type); + + internal static IntPtr RhHandleAlloc(Object value, GCHandleType type) + { + IntPtr h = RhpHandleAlloc(value, type); + if (h == IntPtr.Zero) + throw new OutOfMemoryException(); + return h; + } + + // Allocate handle for dependent handle case where a secondary can be set at the same time. + [MethodImpl(MethodImplOptions.InternalCall)] + [RuntimeImport(RuntimeLibrary, "RhpHandleAllocDependent")] + private static extern IntPtr RhpHandleAllocDependent(Object primary, Object secondary); + internal static IntPtr RhHandleAllocDependent(Object primary, Object secondary) + { + IntPtr h = RhpHandleAllocDependent(primary, secondary); + if (h == IntPtr.Zero) + throw new OutOfMemoryException(); + return h; + } + + // Allocate variable handle with its initial type. + [MethodImpl(MethodImplOptions.InternalCall)] + [RuntimeImport(RuntimeLibrary, "RhpHandleAllocVariable")] + private static extern IntPtr RhpHandleAllocVariable(Object value, uint type); + + internal static IntPtr RhHandleAllocVariable(Object value, uint type) + { + IntPtr h = RhHandleAllocVariable(value, type); + if (h == IntPtr.Zero) + throw new OutOfMemoryException(); + return h; + } +#else // CORERT // Allocate handle. [MethodImpl(MethodImplOptions.InternalCall)] [RuntimeImport(RuntimeLibrary, "RhHandleAlloc")] @@ -125,6 +165,7 @@ namespace System.Runtime [MethodImpl(MethodImplOptions.InternalCall)] [RuntimeImport(RuntimeLibrary, "RhHandleAllocVariable")] internal static extern IntPtr RhHandleAllocVariable(Object value, uint type); +#endif // CORERT // Free handle. [MethodImpl(MethodImplOptions.InternalCall)] |