Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit da44463

Browse files
authoredFeb 25, 2017
Merge pull request #9598 from ahsonkhan/OptimizeSpanClear
Optimize span clear
2 parents b927ad1 + ec6fb88 commit da44463

10 files changed

+474
-64
lines changed
 

‎src/mscorlib/System.Private.CoreLib.csproj

+23-58
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
43
<!-- Always use latest Roslyn compiler -->
54
<Import Project="..\..\Tools\net45\roslyn\build\Microsoft.Net.Compilers.props" Condition="'$(OS)'=='Windows_NT'" />
6-
75
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
8-
96
<!-- Include common build properties -->
107
<Import Project="..\..\dir.props" />
11-
128
<!-- Compilation options -->
139
<PropertyGroup>
1410
<AvailablePlatforms>amd64,x86,arm,armel,arm64</AvailablePlatforms>
@@ -19,16 +15,13 @@
1915
<Platform Condition=" '$(Platform)' == 'x64' ">amd64</Platform>
2016
<Platform Condition=" '$(Platform)' == 'armel' ">arm</Platform>
2117
<ProjectGuid>{3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}</ProjectGuid>
22-
2318
<OutputType>Library</OutputType>
2419
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
25-
2620
<!-- This prevents the default MsBuild targets from referencing System.Core.dll -->
2721
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
2822
<!-- These prevent the default MsBuild targets from referencing System.dll and mscorlib.dll -->
2923
<NoStdLib>true</NoStdLib>
3024
<NoCompilerStandardLib>true</NoCompilerStandardLib>
31-
3225
<SubsystemVersion>6.00</SubsystemVersion>
3326
<UTF8OutPut>true</UTF8OutPut>
3427
<HighEntropyVA>true</HighEntropyVA>
@@ -39,20 +32,16 @@
3932
<WarningsNotAsErrors>$(WarningsNotAsErrors);618</WarningsNotAsErrors>
4033
<NoWarn>649,3019,414,169,3015</NoWarn>
4134
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
42-
4335
<SignAssembly>true</SignAssembly>
4436
<DelaySign>true</DelaySign>
45-
4637
<DefineConstants>$(DefineConstants);CORECLR;_USE_NLS_PLUS_TABLE;RESOURCE_SATELLITE_CONFIG;INSIDE_CLR;CODE_ANALYSIS_BASELINE</DefineConstants>
4738
</PropertyGroup>
48-
4939
<!-- Add Serviceable attribute to the project's metadata -->
5040
<ItemGroup>
5141
<AssemblyMetadata Include="Serviceable">
52-
<Value>True</Value>
42+
<Value>True</Value>
5343
</AssemblyMetadata>
5444
</ItemGroup>
55-
5645
<!-- Platform specific properties -->
5746
<PropertyGroup Condition="'$(Platform)' == 'amd64'">
5847
<PlatformTarget>x64</PlatformTarget>
@@ -73,7 +62,6 @@
7362
<PlatformTarget>AnyCPU</PlatformTarget>
7463
<DefineConstants>BIT64;ARM64;$(DefineConstants)</DefineConstants>
7564
</PropertyGroup>
76-
7765
<!-- Configuration specific properties -->
7866
<PropertyGroup Condition="'$(Configuration)' == 'Debug' or '$(Configuration)' == 'Checked'">
7967
<DebugSymbols>true</DebugSymbols>
@@ -89,13 +77,11 @@
8977
<DebugType>pdbOnly</DebugType>
9078
<DefineConstants>TRACE;$(DefineConstants)</DefineConstants>
9179
</PropertyGroup>
92-
9380
<!-- Roslyn does not support writing PDBs on Unix -->
9481
<PropertyGroup Condition="'$(OsEnvironment)' == 'Unix'">
9582
<DebugSymbols>false</DebugSymbols>
9683
<DebugType>none</DebugType>
9784
</PropertyGroup>
98-
9985
<!-- Assembly attributes -->
10086
<PropertyGroup>
10187
<AssemblyName>System.Private.CoreLib</AssemblyName>
@@ -109,7 +95,6 @@
10995
<AssemblyInfoLines Include="[assembly: System.Runtime.InteropServices.ComVisible(false)]" />
11096
<AssemblyInfoLines Include="[assembly: System.Resources.NeutralResourcesLanguage(&quot;en-US&quot;)]" />
11197
</ItemGroup>
112-
11398
<!--
11499
Helper Paths
115100
-->
@@ -120,21 +105,17 @@
120105
<MscorlibDir>$(MSBuildThisFileDirectory)</MscorlibDir>
121106
<NlpObjDir>$(BclSourcesRoot)\System\Globalization\Tables</NlpObjDir>
122107
</PropertyGroup>
123-
124108
<!-- Msbuild variables needed to get CoreCLR features to be set properly. -->
125109
<PropertyGroup>
126110
<ClrProduct>core_clr</ClrProduct>
127111
<BuildForCoreSystem>true</BuildForCoreSystem>
128-
129112
<!-- These are needed to make sure we have the right set of defines -->
130113
<TargetArch Condition="'$(Platform)'=='x86'">i386</TargetArch>
131114
<TargetArch Condition="'$(Platform)'!='x86'">$(Platform)</TargetArch>
132115
</PropertyGroup>
133-
134116
<!-- CLR Features -->
135117
<Import Project="$(MSBuildThisFileDirectory)..\..\clr.coreclr.props" />
136118
<Import Project="$(MSBuildThisFileDirectory)..\..\clr.defines.targets" />
137-
138119
<!-- Sources -->
139120
<ItemGroup>
140121
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\AccessedThroughPropertyAttribute.cs" />
@@ -325,15 +306,15 @@
325306
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\RuntimeClass.cs" />
326307
</ItemGroup>
327308
<ItemGroup Condition="'$(FeatureCominterop)' == 'true'">
328-
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CLRIPropertyValueImpl.cs' />
329-
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CLRIReferenceImpl.cs' />
330-
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IPropertyValue.cs' />
331-
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IReference.cs' />
332-
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsFoundationEventHandler.cs' />
333-
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomPropertyProvider.cs' />
334-
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomProperty.cs' />
335-
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CustomPropertyImpl.cs' />
336-
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsRuntimeBufferHelper.cs' />
309+
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CLRIPropertyValueImpl.cs" />
310+
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CLRIReferenceImpl.cs" />
311+
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IPropertyValue.cs" />
312+
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IReference.cs" />
313+
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsFoundationEventHandler.cs" />
314+
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomPropertyProvider.cs" />
315+
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomProperty.cs" />
316+
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CustomPropertyImpl.cs" />
317+
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsRuntimeBufferHelper.cs" />
337318
</ItemGroup>
338319
<ItemGroup Condition="'$(FeatureCominterop)' == 'true'">
339320
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IIterable.cs" />
@@ -761,7 +742,7 @@
761742
<MscorlibSources Include="$(CoreFxSourcesRoot)\System\Globalization\ThaiBuddhistCalendar.cs" />
762743
<MscorlibSources Include="$(CoreFxSourcesRoot)\System\Globalization\TimeSpanStyles.cs" />
763744
<MscorlibSources Include="$(CoreFxSourcesRoot)\System\Globalization\UmAlQuraCalendar.cs" />
764-
<MscorlibSources Include="$(CoreFxSourcesRoot)\System\Globalization\UnicodeCategory.cs " />
745+
<MscorlibSources Include="$(CoreFxSourcesRoot)\System\Globalization\UnicodeCategory.cs " />
765746
</ItemGroup>
766747
<ItemGroup Condition="'$(FeatureCoreFxGlobalization)' == 'true' and '$(TargetsUnix)' == 'true'">
767748
<MscorlibSources Include="$(BclSourcesRoot)\System\Globalization\EncodingTable.Unix.cs" />
@@ -897,8 +878,8 @@
897878
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\BinaryReader.cs" />
898879
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\BinaryWriter.cs" />
899880
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\Directory.cs" />
900-
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\SearchOption.cs" />
901-
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\DirectoryNotFoundException.cs" />
881+
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\SearchOption.cs" />
882+
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\DirectoryNotFoundException.cs" />
902883
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\DriveNotFoundException.cs" />
903884
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\EncodingCache.cs" />
904885
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\EndOfStreamException.cs" />
@@ -917,7 +898,7 @@
917898
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\SeekOrigin.cs" />
918899
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\Stream.cs" />
919900
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\StreamHelpers.CopyValidation.cs" />
920-
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\TextReader.cs" Condition="'$(TargetsUnix)' == 'true'" />
901+
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\TextReader.cs" Condition="'$(TargetsUnix)' == 'true'" />
921902
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\StreamReader.cs" Condition="'$(TargetsUnix)' == 'true'" />
922903
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\UnmanagedMemoryAccessor.cs" />
923904
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\UnmanagedMemoryStream.cs" />
@@ -1022,7 +1003,7 @@
10221003
</ItemGroup>
10231004
<ItemGroup>
10241005
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\TargetFrameworkAttribute.cs" />
1025-
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\CompatibilitySwitch.cs" Condition="'$(TargetsUnix)' == 'true'" />
1006+
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\CompatibilitySwitch.cs" Condition="'$(TargetsUnix)' == 'true'" />
10261007
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\NonVersionableAttribute.cs" />
10271008
</ItemGroup>
10281009
<ItemGroup>
@@ -1053,7 +1034,7 @@
10531034
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\EncodingProvider.cs" />
10541035
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\Latin1Encoding.cs" />
10551036
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\Normalization.cs" />
1056-
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\Normalization.Windows.cs" Condition="'$(TargetsUnix)' != 'true'"/>
1037+
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\Normalization.Windows.cs" Condition="'$(TargetsUnix)' != 'true'" />
10571038
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\UnicodeEncoding.cs" />
10581039
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\UTF7Encoding.cs" />
10591040
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\UTF8Encoding.cs" />
@@ -1213,91 +1194,75 @@
12131194
<ItemGroup>
12141195
<MscorlibSources Include="$(CoreFxSourcesRoot)\Debug.cs" />
12151196
</ItemGroup>
1216-
12171197
<!-- Include additional sources shared files in the compilation -->
12181198
<ItemGroup>
12191199
<!-- These are files are preprocessed -->
12201200
<MscorlibSources Include="$(CommonPath)\Preprocessed\AssemblyRefs.g.cs" />
1221-
12221201
<!-- These files are shared with other framework components and don't live the same folder as the rest of them-->
12231202
<MscorlibSources Include="$(CommonPath)\PinnableBufferCache.cs" />
1224-
12251203
<!-- Include Internals visible to file in the compilation -->
12261204
<MscorlibSources Include="$(BclSourcesRoot)\mscorlib.Friends.cs" />
1227-
12281205
<!-- TODO list of types to be cleaned up from CoreLib -->
12291206
<MscorlibSources Include="$(BclSourcesRoot)\CleanupToDoList.cs" />
12301207
</ItemGroup>
1231-
12321208
<ItemGroup>
12331209
<!-- We want the sources to show up nicely in VS-->
12341210
<Compile Include="@(MscorlibSources)">
12351211
</Compile>
12361212
<Compile Include="src\System\Runtime\CompilerServices\ITuple.cs" />
12371213
<Compile Include="src\System\Runtime\CompilerServices\TupleElementNamesAttribute.cs" />
1214+
<Compile Include="src\System\Runtime\RuntimeImports.cs" />
12381215
<Compile Include="src\System\TupleExtensions.cs" />
12391216
<Compile Include="src\System\ValueTuple.cs" />
12401217
</ItemGroup>
1241-
12421218
<!-- Resources -->
12431219
<ItemGroup>
12441220
<SplitTextStringResource Include="$(BclSourcesRoot)\System.Private.CoreLib.txt">
12451221
<ResFile>System.Private.CoreLib</ResFile>
12461222
<ResGenDefines>$(DefineConstants)</ResGenDefines>
12471223
</SplitTextStringResource>
12481224
</ItemGroup>
1249-
12501225
<PropertyGroup>
12511226
<CheckCDefines Condition="'$(CheckCDefines)'==''">true</CheckCDefines>
12521227
</PropertyGroup>
1253-
12541228
<Target Name="CDefineChecker" BeforeTargets="Build" Condition="'$(CheckCDefines)'=='true'">
12551229
<!-- Compiler Definition Verification -->
12561230
<Message Importance="High" Text="============" />
12571231
<PropertyGroup>
12581232
<IgnoreDefineConstants>FEATURE_IMPLICIT_TLS;FEATURE_HIJACK</IgnoreDefineConstants>
12591233
<CMakeDefinitionSaveFile>$(IntermediateOutputPath)\cmake.definitions</CMakeDefinitionSaveFile>
12601234
</PropertyGroup>
1261-
<Exec Command='python $(MSBuildThisFileDirectory)..\scripts\check-definitions.py "$(CMakeDefinitionSaveFile)" "$(DefineConstants)" "$(IgnoreDefineConstants)" ' />
1235+
<Exec Command="python $(MSBuildThisFileDirectory)..\scripts\check-definitions.py &quot;$(CMakeDefinitionSaveFile)&quot; &quot;$(DefineConstants)&quot; &quot;$(IgnoreDefineConstants)&quot; " />
12621236
<Message Importance="High" Text="============" />
12631237
</Target>
1264-
12651238
<ItemGroup>
12661239
<EmbeddedResource Include="$(NlpObjDir)\charinfo.nlp">
12671240
<LogicalName>charinfo.nlp</LogicalName>
12681241
</EmbeddedResource>
12691242
</ItemGroup>
1270-
12711243
<PropertyGroup Condition="'$(BuildOS)' == 'Windows_NT'">
12721244
<EnableDotnetAnalyzers Condition="'$(EnableDotnetAnalyzers)'==''">true</EnableDotnetAnalyzers>
12731245
<UseWin32Apis>true</UseWin32Apis>
12741246
<OSGroup>Windows_NT</OSGroup>
12751247
</PropertyGroup>
12761248
<Import Project="$(ToolsDir)\codeAnalysis.targets" />
1277-
12781249
<Import Project="$(ToolsDir)\Microsoft.CSharp.Targets" />
1279-
12801250
<PropertyGroup>
12811251
<StrongNameSig>Silverlight</StrongNameSig>
12821252
</PropertyGroup>
1283-
12841253
<!-- Import signing tools -->
12851254
<Import Condition="Exists('$(ToolsDir)\sign.targets')" Project="$(ToolsDir)\sign.targets" />
1286-
12871255
<!-- Overwrite the key that we are going to use for signing -->
12881256
<PropertyGroup>
12891257
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Tools\Signing\mscorlib.snk</AssemblyOriginatorKeyFile>
12901258
</PropertyGroup>
1291-
1292-
<Import Project="$(MSBuildThisFileDirectory)Tools\Versioning\GenerateVersionInfo.targets"/>
1259+
<Import Project="$(MSBuildThisFileDirectory)Tools\Versioning\GenerateVersionInfo.targets" />
12931260
<!-- Override versioning targets -->
12941261
<Import Condition="Exists('$(ToolsDir)versioning.targets')" Project="$(ToolsDir)versioning.targets" />
1295-
12961262
<PropertyGroup>
12971263
<!-- Use a different nativeresource file to avoid conflicts with mscorlib-->
12981264
<Win32Resource Condition="'$(GenerateNativeVersionInfo)'=='true'">$(IntermediateOutputPath)\System.Private.CoreLib.res</Win32Resource>
12991265
</PropertyGroup>
1300-
1301-
<Import Project="GenerateSplitStringResources.targets"/>
1302-
<Import Project="GenerateCompilerResponseFile.targets"/>
1303-
</Project>
1266+
<Import Project="GenerateSplitStringResources.targets" />
1267+
<Import Project="GenerateCompilerResponseFile.targets" />
1268+
</Project>

‎src/mscorlib/System.Private.CoreLib.sln

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
Microsoft Visual Studio Solution File, Format Version 12.00
32
# Visual Studio 14
43
VisualStudioVersion = 14.0.25420.1
54
MinimumVisualStudioVersion = 10.0.40219.1
@@ -49,4 +48,4 @@ Global
4948
GlobalSection(SolutionProperties) = preSolution
5049
HideSolutionNode = FALSE
5150
EndGlobalSection
52-
EndGlobal
51+
EndGlobal

‎src/mscorlib/src/System/Runtime/CompilerServices/Unsafe.cs

+18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
using System.Runtime.Versioning;
66

7+
#if BIT64
8+
using nuint = System.UInt64;
9+
#else
10+
using nuint = System.UInt32;
11+
#endif
12+
713
namespace System.Runtime.CompilerServices
814
{
915
//
@@ -65,6 +71,18 @@ public static ref T Add<T>(ref T source, int elementOffset)
6571
throw new InvalidOperationException();
6672
}
6773

74+
/// <summary>
75+
/// Adds an element offset to the given reference.
76+
/// </summary>
77+
[NonVersionable]
78+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
79+
public static ref T AddByteOffset<T>(ref T source, nuint byteOffset)
80+
{
81+
// The body of this function will be replaced by the EE with unsafe code!!!
82+
// See getILIntrinsicImplementationForUnsafe for how this happens.
83+
throw new InvalidOperationException();
84+
}
85+
6886
/// <summary>
6987
/// Determines whether the specified references point to the same location.
7088
/// </summary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Runtime.CompilerServices;
6+
using System.Runtime.InteropServices;
7+
8+
#if BIT64
9+
using nuint = System.UInt64;
10+
#else
11+
using nuint = System.UInt32;
12+
#endif
13+
14+
namespace System.Runtime
15+
{
16+
public class RuntimeImports
17+
{
18+
// Non-inlinable wrapper around the QCall that avoids poluting the fast path
19+
// with P/Invoke prolog/epilog.
20+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
21+
internal unsafe static void RhZeroMemory(ref byte b, nuint byteLength)
22+
{
23+
fixed (byte* bytePointer = &b)
24+
{
25+
RhZeroMemory(bytePointer, byteLength);
26+
}
27+
}
28+
29+
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
30+
extern private unsafe static void RhZeroMemory(byte* b, nuint byteLength);
31+
}
32+
}

0 commit comments

Comments
 (0)