Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovsky <michals@microsoft.com>2018-07-23 10:23:45 +0300
committerMichal Strehovsky <michals@microsoft.com>2018-07-23 10:23:45 +0300
commit045a28051c6b85b82fe42e944fcb2267768ebbe2 (patch)
tree007e9d069f087ef48bb6270ccc710a555cef7d1a /src/Runtime.Base
parent67ea31d51ad529912b00ad8bc7a29aa9621413db (diff)
Make generic composition details relative addresses
I'm looking at size regressions between .NET Native 1.7 and the current mainline branch. A thing that stood out is universally bigger EETypes. A contributor to this was getting rid of GenericInstanceDescs between 1.7 and 2.0 and replacing them by direct references to generic composition details from the EEType. Size-wise, this was mostly a wash, but we can actually do better - these new fields are not critical to be pointer-sized. This change turns them into relative pointers. This saves 33 kB on a hello world app. I expect around 100 kB savings on the UWP People app based on my back-of-the-envelope calculation. Project N baggage: 1. Update pntestcl build configuration to compile it with a C# compiler that is not 8 years old 2. Disable metadata validation transform on class libraries. This is hitting what appears to be a CCI metadata validator bug (Validator.cs:796) where it thinks a modified type should have the same interned key as the unmodified version of it. The act of resolving a modified type strips off the modifier. This ticks off the validator. 3. Fix a Reducer bug where it wasn't marking non-interface constraints as necessary. The C# unmanaged constraint is expressed as [modreq UnmanagedType] ValueType. We were not marking UnmanagedType as necessary. 4. Update checked in binder because this is a file format change [tfs-changeset: 1708263]
Diffstat (limited to 'src/Runtime.Base')
-rw-r--r--src/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs26
-rw-r--r--src/Runtime.Base/src/Runtime.Base.csproj1
-rw-r--r--src/Runtime.Base/src/System/Runtime/InteropServices/UnmanagedType.cs8
3 files changed, 34 insertions, 1 deletions
diff --git a/src/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs b/src/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs
index 705193a3c..c63760b39 100644
--- a/src/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs
+++ b/src/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs
@@ -21,8 +21,22 @@ namespace Internal.Runtime.CompilerServices
/// <summary>
/// Contains generic, low-level functionality for manipulating pointers.
/// </summary>
- public static class Unsafe
+ public static unsafe class Unsafe
{
+ /// <summary>
+ /// Returns a pointer to the given by-ref parameter.
+ /// </summary>
+ [Intrinsic]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void* AsPointer<T>(ref T value)
+ {
+ throw new PlatformNotSupportedException();
+
+ // ldarg.0
+ // conv.u
+ // ret
+ }
+
[Intrinsic]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int SizeOf<T>()
@@ -83,5 +97,15 @@ namespace Internal.Runtime.CompilerServices
{
return ref AddByteOffset(ref source, (IntPtr)(elementOffset * (nint)SizeOf<T>()));
}
+
+ /// <summary>
+ /// Reinterprets the given location as a reference to a value of type <typeparamref name="T"/>.
+ /// </summary>
+ [Intrinsic]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static ref T AsRef<T>(in T source)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
diff --git a/src/Runtime.Base/src/Runtime.Base.csproj b/src/Runtime.Base/src/Runtime.Base.csproj
index daa602215..58d17c3b9 100644
--- a/src/Runtime.Base/src/Runtime.Base.csproj
+++ b/src/Runtime.Base/src/Runtime.Base.csproj
@@ -77,6 +77,7 @@
<Compile Include="System\Runtime\CompilerServices\MethodImplAttribute.cs" />
<Compile Include="System\Runtime\CompilerServices\RuntimeHelpers.cs" />
<Compile Include="System\Runtime\CompilerServices\UnsafeValueTypeAttribute.cs" />
+ <Compile Include="System\Runtime\InteropServices\UnmanagedType.cs" />
<Compile Include="System\Runtime\InteropServices\CallingConvention.cs" />
<Compile Include="System\Runtime\InteropServices\CharSet.cs" />
<Compile Include="System\Runtime\InteropServices\DllImportAttribute.cs" />
diff --git a/src/Runtime.Base/src/System/Runtime/InteropServices/UnmanagedType.cs b/src/Runtime.Base/src/System/Runtime/InteropServices/UnmanagedType.cs
new file mode 100644
index 000000000..143ed33c0
--- /dev/null
+++ b/src/Runtime.Base/src/System/Runtime/InteropServices/UnmanagedType.cs
@@ -0,0 +1,8 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ internal class UnmanagedType { }
+}