Skip to content

Commit ddb22ef

Browse files
Wraith2BrzVlad
andauthored
Remove S.R.CS.Unsafe and Intrinsify Unsafe (dotnet#64861)
* private assemblies moved from Internal to System Runtime.CompilerServices * reformat existing unsafe vm intrinsics * implement Copy, CopyBlock, CopyBlockUnaligned, InitBlock, InitBlockUnaligned, Unbox, Add, Subtract, SubtractByteOffset * remove System.Runtime.CompilerServices.Unsafe il project and replace with forward only cs project * change all ilproj references to csproj * remove nativeaot Unsafe * add conditional package reference for S.R.CS.Unsafe on netcoreapp 6.0 * regenerate solutions * mono interp * [mono][interp] Implement Copy and Unbox intrinsics * [mono][jit] Implement Copy and Unbox intrinsics Co-authored-by: Vlad Brezae <brezaevlad@gmail.com>
1 parent 7345109 commit ddb22ef

File tree

467 files changed

+4464
-6807
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

467 files changed

+4464
-6807
lines changed

eng/Version.Details.xml

-4
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,6 @@
230230
<Uri>https://github.com/dotnet/runtime</Uri>
231231
<Sha>6e05d78deba320a54ef10a265c6025bbb686efe6</Sha>
232232
</Dependency>
233-
<Dependency Name="System.Runtime.CompilerServices.Unsafe" Version="7.0.0-preview.2.22113.2">
234-
<Uri>https://github.com/dotnet/runtime</Uri>
235-
<Sha>6e05d78deba320a54ef10a265c6025bbb686efe6</Sha>
236-
</Dependency>
237233
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="7.0.100-1.22115.2">
238234
<Uri>https://github.com/dotnet/linker</Uri>
239235
<Sha>6e11d057a88b3fb403bfbb90317518c94e3e84a7</Sha>

eng/Versions.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
<SystemSecurityPrincipalWindowsVersion>5.0.0</SystemSecurityPrincipalWindowsVersion>
126126
<SystemServiceModelPrimitivesVersion>4.9.0</SystemServiceModelPrimitivesVersion>
127127
<SystemTextJsonVersion>7.0.0-preview.2.22113.2</SystemTextJsonVersion>
128-
<SystemRuntimeCompilerServicesUnsafeVersion>7.0.0-preview.2.22113.2</SystemRuntimeCompilerServicesUnsafeVersion>
128+
<SystemRuntimeCompilerServicesUnsafeVersion>6.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
129129
<SystemThreadingTasksExtensionsVersion>4.5.4</SystemThreadingTasksExtensionsVersion>
130130
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
131131
<runtimenativeSystemIOPortsVersion>7.0.0-preview.2.22113.2</runtimenativeSystemIOPortsVersion>

eng/generators.targets

-10
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@
5757
'$(MSBuildProjectName)' == 'System.Private.CoreLib'
5858
or '$(EnableDllImportGenerator)' == 'true'
5959
or ('@(Reference)' != ''
60-
and (@(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.CompilerServices.Unsafe'))
61-
or ('@(ProjectReference)' != ''
62-
and @(ProjectReference->AnyHaveMetadataValue('Identity', $([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'System.Runtime.CompilerServices.Unsafe', 'src', 'System.Runtime.CompilerServices.Unsafe.ilproj'))))))
6360
and @(Reference->AnyHaveMetadataValue('Identity', 'System.Memory')))
6461
or ('@(ProjectReference)' != ''
6562
and @(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)'))))" Include="$(LibrariesProjectRoot)Common\src\System\Runtime\InteropServices\ArrayMarshaller.cs" />
@@ -77,13 +74,6 @@
7774
<PropertyGroup>
7875
<DllImportGenerator_UseMarshalType>true</DllImportGenerator_UseMarshalType>
7976
</PropertyGroup>
80-
<!-- Projects that directly reference System.Private.CoreLib are typically low level enough that they don't reference
81-
System.Runtime.CompilerServices.Unsafe, so we use the Unsafe type defined in CoreLib (Internal.Runtime.CompilerServices.Unsafe) for these projects. -->
82-
<PropertyGroup Condition="'$(MSBuildProjectName)' == 'System.Private.CoreLib' or
83-
('@(ProjectReference)' != '' and @(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)')))">
84-
<DllImportGenerator_UseInternalUnsafeType>true</DllImportGenerator_UseInternalUnsafeType>
85-
<DefineConstants>$(DefineConstants);DLLIMPORTGENERATOR_INTERNALUNSAFE</DefineConstants>
86-
</PropertyGroup>
8777
</Target>
8878

8979
<Import Project="$(LibrariesProjectRoot)System.Runtime.InteropServices/gen/DllImportGenerator/Microsoft.Interop.DllImportGenerator.props" />

eng/slngen.targets

-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,4 @@
1010
Include the reference project in the solution file if it targets more than just NetCoreAppCurrent as other frameworks like .NETFramework, .NETStandard or older .NETCoreApp ones require it. -->
1111
<IncludeInSolutionFile Condition="'$(IsNETCoreAppRef)' == 'true' and '$(MSBuildProjectName)' != '$(SlnGenMainProject)' and '$(TargetFramework)' == '$(NetCoreAppCurrent)' and ('$(TargetFrameworks)' == '' or '$(TargetFrameworks)' == '$(NetCoreAppCurrent)')">false</IncludeInSolutionFile>
1212
</PropertyGroup>
13-
<ItemGroup>
14-
<SlnGenCustomProjectTypeGuid Include=".ilproj" ProjectTypeGuid="{9A19103F-16F7-4668-BE54-9A1E7A4F7556}" />
15-
</ItemGroup>
1613
</Project>

src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Reflection;
88
using System.Runtime.CompilerServices;
99
using System.Runtime.InteropServices;
10-
using Internal.Runtime.CompilerServices;
1110

1211
namespace System
1312
{

src/coreclr/System.Private.CoreLib/src/System/Buffer.CoreCLR.cs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Diagnostics;
55
using System.Runtime.CompilerServices;
66
using System.Runtime.InteropServices;
7-
using Internal.Runtime.CompilerServices;
87

98
namespace System
109
{

src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Eventing/NativeRuntimeEventSource.PortableThreadPool.NativeSinks.CoreCLR.cs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Diagnostics.Tracing;
66
using System.Runtime.CompilerServices;
77
using System.Runtime.InteropServices;
8-
using Internal.Runtime.CompilerServices;
98

109
namespace System.Diagnostics.Tracing
1110
{

src/coreclr/System.Private.CoreLib/src/System/GC.cs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using System.Collections.Generic;
1717
using System.Runtime.CompilerServices;
1818
using System.Runtime.InteropServices;
19-
using Internal.Runtime.CompilerServices;
2019

2120
namespace System
2221
{

src/coreclr/System.Private.CoreLib/src/System/MulticastDelegate.cs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
using System.Runtime.InteropServices;
99
using System.Runtime.Serialization;
1010

11-
using Internal.Runtime.CompilerServices;
12-
1311
namespace System
1412
{
1513
[ClassInterface(ClassInterfaceType.None)]

src/coreclr/System.Private.CoreLib/src/System/Reflection/MethodBase.CoreCLR.cs

-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Diagnostics;
54
using System.Diagnostics.CodeAnalysis;
6-
using System.Globalization;
7-
using System.Runtime.InteropServices;
85
using System.Threading;
9-
using Internal.Runtime.CompilerServices;
106

117
namespace System.Reflection
128
{

src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
using System.Diagnostics.CodeAnalysis;
77
using System.Runtime.CompilerServices;
88
using System.Runtime.InteropServices;
9-
using System.Text;
10-
11-
using Internal.Runtime.CompilerServices;
129

1310
namespace System.Reflection
1411
{

src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastHelpers.cs

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
using System.Runtime.InteropServices;
77
using System.Threading;
88

9-
using Internal.Runtime.CompilerServices;
10-
119
namespace System.Runtime.CompilerServices
1210
{
1311
internal static unsafe class CastHelpers

src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Runtime.CompilerServices;
88
using System.Runtime.InteropServices;
99
using System.Runtime.Serialization;
10-
using Internal.Runtime.CompilerServices;
1110

1211
namespace System.Runtime.CompilerServices
1312
{

src/coreclr/System.Private.CoreLib/src/System/Runtime/DependentHandle.cs

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Runtime.CompilerServices;
5-
#if !DEBUG
6-
using Internal.Runtime.CompilerServices;
7-
#endif
85

96
namespace System.Runtime
107
{

src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Threading;
77
using System.Runtime.CompilerServices;
88
using System.Runtime.Versioning;
9-
using Internal.Runtime.CompilerServices;
109

1110
namespace System.Runtime.InteropServices
1211
{

src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.CoreCLR.cs

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Runtime.CompilerServices;
5-
#if !DEBUG
6-
using Internal.Runtime.CompilerServices;
7-
#endif
85

96
namespace System.Runtime.InteropServices
107
{

src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/MemoryMarshal.CoreCLR.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Runtime.CompilerServices;
55
using System.Runtime.Versioning;
6-
using Internal.Runtime.CompilerServices;
76

87
namespace System.Runtime.InteropServices
98
{

src/coreclr/System.Private.CoreLib/src/System/Runtime/JitInfo.CoreCLR.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Runtime.CompilerServices;
55
using System.Runtime.InteropServices;
6-
using Internal.Runtime.CompilerServices;
76

87
namespace System.Runtime
98
{

src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using System.Runtime.Serialization;
1111
using System.Runtime.Versioning;
1212
using System.Threading;
13-
using Internal.Runtime.CompilerServices;
1413

1514
namespace System
1615
{

src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using System.Runtime.InteropServices;
1212
using System.Text;
1313
using System.Threading;
14-
using Internal.Runtime.CompilerServices;
14+
1515
using DebuggerStepThroughAttribute = System.Diagnostics.DebuggerStepThroughAttribute;
1616
using MdToken = System.Reflection.MetadataToken;
1717

src/coreclr/System.Private.CoreLib/src/System/String.CoreCLR.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Runtime.CompilerServices;
55
using System.Text;
6-
using Internal.Runtime.CompilerServices;
76

87
namespace System
98
{

src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs

-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Text;
5-
using System.Collections.Generic;
65
using System.Runtime.InteropServices;
76
using System.Runtime.CompilerServices;
87
using System.Diagnostics;
9-
using Internal.Runtime.CompilerServices;
108

119
namespace System.StubHelpers
1210
{

src/coreclr/System.Private.CoreLib/src/System/Threading/Interlocked.CoreCLR.cs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Diagnostics.CodeAnalysis;
55
using System.Runtime.CompilerServices;
66
using System.Runtime.InteropServices;
7-
using Internal.Runtime.CompilerServices;
87

98
namespace System.Threading
109
{

src/coreclr/System.Private.CoreLib/src/System/TypedReference.CoreCLR.cs

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
// TypedReference is basically only ever seen on the call stack, and in param arrays.
55
// These are blob that must be dealt with by the compiler.
66

7-
using System.Reflection;
8-
using System.Runtime.CompilerServices;
9-
using Internal.Runtime.CompilerServices;
10-
117
namespace System
128
{
139
[System.Runtime.Versioning.NonVersionable] // This only applies to field layout

src/coreclr/nativeaot/Common/src/Internal/Runtime/CompilerHelpers/StartupCodeHelpers.cs

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
using System.Runtime.CompilerServices;
77
using System.Runtime.InteropServices;
88

9-
using Internal.Runtime.CompilerServices;
10-
119
using Debug = Internal.Runtime.CompilerHelpers.StartupDebug;
1210

1311
namespace Internal.Runtime.CompilerHelpers

src/coreclr/nativeaot/Common/src/Internal/Runtime/MethodTable.cs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Runtime.InteropServices;
88

99
using Internal.NativeFormat;
10-
using Internal.Runtime.CompilerServices;
1110

1211
using Debug = System.Diagnostics.Debug;
1312

src/coreclr/nativeaot/Runtime.Base/src/System/Array.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Runtime.CompilerServices;
45
using System.Runtime.InteropServices;
56

6-
using Internal.Runtime.CompilerServices;
7-
87
namespace System
98
{
109
// CONTRACT with Runtime

src/coreclr/nativeaot/Runtime.Base/src/System/Object.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Runtime.CompilerServices;
45
using System.Runtime.InteropServices;
56

67
using Internal.Runtime;
7-
using Internal.Runtime.CompilerServices;
88

99
namespace System
1010
{

src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CachedInterfaceDispatch.cs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Runtime.CompilerServices;
77

88
using Internal.Runtime;
9-
using Internal.Runtime.CompilerServices;
109

1110
namespace System.Runtime
1211
{

src/coreclr/nativeaot/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs renamed to src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/CompilerServices/Unsafe.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System;
55
using System.Runtime.CompilerServices;
66

7-
namespace Internal.Runtime.CompilerServices
7+
namespace System.Runtime.CompilerServices
88
{
99
//
1010
// Subsetted clone of System.Runtime.CompilerServices.Unsafe for internal runtime use.

src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/InteropServices/UnsafeGCHandle.cs

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
using System.Runtime.CompilerServices;
66
using System.Diagnostics;
77

8-
using Internal.Runtime.CompilerServices;
9-
108
namespace System.Runtime.InteropServices
119
{
1210
/// <summary>

src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/MethodTable.Runtime.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System;
55
using System.Diagnostics;
66
using System.Runtime;
7-
using Internal.Runtime.CompilerServices;
7+
using System.Runtime.CompilerServices;
88

99
namespace Internal.Runtime
1010
{

src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/RuntimeExports.cs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using System.Runtime.CompilerServices;
1111

1212
using Internal.Runtime;
13-
using Internal.Runtime.CompilerServices;
1413

1514
namespace System.Runtime
1615
{

src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/TypeCast.cs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Runtime.InteropServices;
77

88
using Internal.Runtime;
9-
using Internal.Runtime.CompilerServices;
109

1110
namespace System.Runtime
1211
{

src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerServices/Unsafe.cs

-13
This file was deleted.

src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
<Compile Include="Internal\IntrinsicSupport\ComparerHelpers.cs" />
9595
<Compile Include="Internal\IntrinsicSupport\EqualityComparerHelpers.cs" />
9696
<Compile Include="Internal\Reflection\Augments\ReflectionAugments.cs" />
97-
<Compile Include="Internal\Runtime\CompilerServices\Unsafe.cs" />
9897
<Compile Include="Internal\Runtime\IDynamicInterfaceCastableSupport.cs" />
9998
<Compile Include="Internal\Runtime\MethodTable.Runtime.cs" />
10099
<Compile Include="Internal\Runtime\CompilerHelpers\ThrowHelpers.cs" />

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreRT.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
54
using System.Diagnostics;
65
using System.Diagnostics.CodeAnalysis;
76
using System.Reflection;
7+
using System.Runtime.CompilerServices;
88
using System.Text;
99

1010
using Internal.Runtime.Augments;
11-
using Internal.Runtime.CompilerServices;
1211

1312
namespace System.Runtime.InteropServices
1413
{

src/coreclr/nativeaot/System.Private.CoreLib/src/System/ValueType.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
using System.Diagnostics.CodeAnalysis;
1414
using System.Runtime;
15+
using System.Runtime.CompilerServices;
1516

16-
using Internal.Runtime.CompilerServices;
1717
using Internal.Runtime.Augments;
1818

1919
using Debug = System.Diagnostics.Debug;
@@ -146,11 +146,11 @@ private int RegularGetValueTypeHashCode(EETypePtr type, ref byte data, int numFi
146146

147147
if (fieldType.ElementType == Internal.Runtime.EETypeElementType.Single)
148148
{
149-
hashCode = Unsafe.Read<float>(ref fieldData).GetHashCode();
149+
hashCode = Unsafe.As<byte, float>(ref fieldData).GetHashCode();
150150
}
151151
else if (fieldType.ElementType == Internal.Runtime.EETypeElementType.Double)
152152
{
153-
hashCode = Unsafe.Read<double>(ref fieldData).GetHashCode();
153+
hashCode = Unsafe.As<byte, double>(ref fieldData).GetHashCode();
154154
}
155155
else if (fieldType.IsPrimitive)
156156
{
@@ -178,7 +178,7 @@ private int RegularGetValueTypeHashCode(EETypePtr type, ref byte data, int numFi
178178
}
179179
else
180180
{
181-
object fieldValue = Unsafe.Read<object>(ref fieldData);
181+
object fieldValue = Unsafe.As<byte, object>(ref fieldData);
182182
if (fieldValue != null)
183183
{
184184
hashCode = fieldValue.GetHashCode();

0 commit comments

Comments
 (0)