Skip to content

Commit

Permalink
Merge pull request dotnet/coreclr#9598 from ahsonkhan/OptimizeSpanClear
Browse files Browse the repository at this point in the history
Optimize span clear

Commit migrated from dotnet/coreclr@da44463
  • Loading branch information
ahsonkhan authored Feb 25, 2017
2 parents 57765ab + 959d2c9 commit 70b6f08
Show file tree
Hide file tree
Showing 10 changed files with 474 additions and 64 deletions.
81 changes: 23 additions & 58 deletions src/coreclr/src/mscorlib/System.Private.CoreLib.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Always use latest Roslyn compiler -->
<Import Project="..\..\Tools\net45\roslyn\build\Microsoft.Net.Compilers.props" Condition="'$(OS)'=='Windows_NT'" />

<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

<!-- Include common build properties -->
<Import Project="..\..\dir.props" />

<!-- Compilation options -->
<PropertyGroup>
<AvailablePlatforms>amd64,x86,arm,armel,arm64</AvailablePlatforms>
Expand All @@ -19,16 +15,13 @@
<Platform Condition=" '$(Platform)' == 'x64' ">amd64</Platform>
<Platform Condition=" '$(Platform)' == 'armel' ">arm</Platform>
<ProjectGuid>{3DA06C3A-2E7B-4CB7-80ED-9B12916013F9}</ProjectGuid>

<OutputType>Library</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<!-- This prevents the default MsBuild targets from referencing System.Core.dll -->
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
<!-- These prevent the default MsBuild targets from referencing System.dll and mscorlib.dll -->
<NoStdLib>true</NoStdLib>
<NoCompilerStandardLib>true</NoCompilerStandardLib>

<SubsystemVersion>6.00</SubsystemVersion>
<UTF8OutPut>true</UTF8OutPut>
<HighEntropyVA>true</HighEntropyVA>
Expand All @@ -39,20 +32,16 @@
<WarningsNotAsErrors>$(WarningsNotAsErrors);618</WarningsNotAsErrors>
<NoWarn>649,3019,414,169,3015</NoWarn>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>

<SignAssembly>true</SignAssembly>
<DelaySign>true</DelaySign>

<DefineConstants>$(DefineConstants);CORECLR;_USE_NLS_PLUS_TABLE;RESOURCE_SATELLITE_CONFIG;INSIDE_CLR;CODE_ANALYSIS_BASELINE</DefineConstants>
</PropertyGroup>

<!-- Add Serviceable attribute to the project's metadata -->
<ItemGroup>
<AssemblyMetadata Include="Serviceable">
<Value>True</Value>
<Value>True</Value>
</AssemblyMetadata>
</ItemGroup>

<!-- Platform specific properties -->
<PropertyGroup Condition="'$(Platform)' == 'amd64'">
<PlatformTarget>x64</PlatformTarget>
Expand All @@ -73,7 +62,6 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DefineConstants>BIT64;ARM64;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<!-- Configuration specific properties -->
<PropertyGroup Condition="'$(Configuration)' == 'Debug' or '$(Configuration)' == 'Checked'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -89,13 +77,11 @@
<DebugType>pdbOnly</DebugType>
<DefineConstants>TRACE;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<!-- Roslyn does not support writing PDBs on Unix -->
<PropertyGroup Condition="'$(OsEnvironment)' == 'Unix'">
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
</PropertyGroup>

<!-- Assembly attributes -->
<PropertyGroup>
<AssemblyName>System.Private.CoreLib</AssemblyName>
Expand All @@ -109,7 +95,6 @@
<AssemblyInfoLines Include="[assembly: System.Runtime.InteropServices.ComVisible(false)]" />
<AssemblyInfoLines Include="[assembly: System.Resources.NeutralResourcesLanguage(&quot;en-US&quot;)]" />
</ItemGroup>

<!--
Helper Paths
-->
Expand All @@ -120,21 +105,17 @@
<MscorlibDir>$(MSBuildThisFileDirectory)</MscorlibDir>
<NlpObjDir>$(BclSourcesRoot)\System\Globalization\Tables</NlpObjDir>
</PropertyGroup>

<!-- Msbuild variables needed to get CoreCLR features to be set properly. -->
<PropertyGroup>
<ClrProduct>core_clr</ClrProduct>
<BuildForCoreSystem>true</BuildForCoreSystem>

<!-- These are needed to make sure we have the right set of defines -->
<TargetArch Condition="'$(Platform)'=='x86'">i386</TargetArch>
<TargetArch Condition="'$(Platform)'!='x86'">$(Platform)</TargetArch>
</PropertyGroup>

<!-- CLR Features -->
<Import Project="$(MSBuildThisFileDirectory)..\..\clr.coreclr.props" />
<Import Project="$(MSBuildThisFileDirectory)..\..\clr.defines.targets" />

<!-- Sources -->
<ItemGroup>
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\AccessedThroughPropertyAttribute.cs" />
Expand Down Expand Up @@ -325,15 +306,15 @@
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\RuntimeClass.cs" />
</ItemGroup>
<ItemGroup Condition="'$(FeatureCominterop)' == 'true'">
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CLRIPropertyValueImpl.cs' />
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CLRIReferenceImpl.cs' />
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IPropertyValue.cs' />
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IReference.cs' />
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsFoundationEventHandler.cs' />
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomPropertyProvider.cs' />
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomProperty.cs' />
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CustomPropertyImpl.cs' />
<MscorlibSources Include='$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsRuntimeBufferHelper.cs' />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CLRIPropertyValueImpl.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CLRIReferenceImpl.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IPropertyValue.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IReference.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsFoundationEventHandler.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomPropertyProvider.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\ICustomProperty.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\CustomPropertyImpl.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\WindowsRuntimeBufferHelper.cs" />
</ItemGroup>
<ItemGroup Condition="'$(FeatureCominterop)' == 'true'">
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\WindowsRuntime\IIterable.cs" />
Expand Down Expand Up @@ -761,7 +742,7 @@
<MscorlibSources Include="$(CoreFxSourcesRoot)\System\Globalization\ThaiBuddhistCalendar.cs" />
<MscorlibSources Include="$(CoreFxSourcesRoot)\System\Globalization\TimeSpanStyles.cs" />
<MscorlibSources Include="$(CoreFxSourcesRoot)\System\Globalization\UmAlQuraCalendar.cs" />
<MscorlibSources Include="$(CoreFxSourcesRoot)\System\Globalization\UnicodeCategory.cs " />
<MscorlibSources Include="$(CoreFxSourcesRoot)\System\Globalization\UnicodeCategory.cs " />
</ItemGroup>
<ItemGroup Condition="'$(FeatureCoreFxGlobalization)' == 'true' and '$(TargetsUnix)' == 'true'">
<MscorlibSources Include="$(BclSourcesRoot)\System\Globalization\EncodingTable.Unix.cs" />
Expand Down Expand Up @@ -897,8 +878,8 @@
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\BinaryReader.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\BinaryWriter.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\Directory.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\SearchOption.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\DirectoryNotFoundException.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\SearchOption.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\DirectoryNotFoundException.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\DriveNotFoundException.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\EncodingCache.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\EndOfStreamException.cs" />
Expand All @@ -917,7 +898,7 @@
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\SeekOrigin.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\Stream.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\StreamHelpers.CopyValidation.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\TextReader.cs" Condition="'$(TargetsUnix)' == 'true'" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\TextReader.cs" Condition="'$(TargetsUnix)' == 'true'" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\StreamReader.cs" Condition="'$(TargetsUnix)' == 'true'" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\UnmanagedMemoryAccessor.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\IO\UnmanagedMemoryStream.cs" />
Expand Down Expand Up @@ -1022,7 +1003,7 @@
</ItemGroup>
<ItemGroup>
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\TargetFrameworkAttribute.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\CompatibilitySwitch.cs" Condition="'$(TargetsUnix)' == 'true'" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\CompatibilitySwitch.cs" Condition="'$(TargetsUnix)' == 'true'" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Runtime\Versioning\NonVersionableAttribute.cs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -1053,7 +1034,7 @@
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\EncodingProvider.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\Latin1Encoding.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\Normalization.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\Normalization.Windows.cs" Condition="'$(TargetsUnix)' != 'true'"/>
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\Normalization.Windows.cs" Condition="'$(TargetsUnix)' != 'true'" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\UnicodeEncoding.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\UTF7Encoding.cs" />
<MscorlibSources Include="$(BclSourcesRoot)\System\Text\UTF8Encoding.cs" />
Expand Down Expand Up @@ -1213,91 +1194,75 @@
<ItemGroup>
<MscorlibSources Include="$(CoreFxSourcesRoot)\Debug.cs" />
</ItemGroup>

<!-- Include additional sources shared files in the compilation -->
<ItemGroup>
<!-- These are files are preprocessed -->
<MscorlibSources Include="$(CommonPath)\Preprocessed\AssemblyRefs.g.cs" />

<!-- These files are shared with other framework components and don't live the same folder as the rest of them-->
<MscorlibSources Include="$(CommonPath)\PinnableBufferCache.cs" />

<!-- Include Internals visible to file in the compilation -->
<MscorlibSources Include="$(BclSourcesRoot)\mscorlib.Friends.cs" />

<!-- TODO list of types to be cleaned up from CoreLib -->
<MscorlibSources Include="$(BclSourcesRoot)\CleanupToDoList.cs" />
</ItemGroup>

<ItemGroup>
<!-- We want the sources to show up nicely in VS-->
<Compile Include="@(MscorlibSources)">
</Compile>
<Compile Include="src\System\Runtime\CompilerServices\ITuple.cs" />
<Compile Include="src\System\Runtime\CompilerServices\TupleElementNamesAttribute.cs" />
<Compile Include="src\System\Runtime\RuntimeImports.cs" />
<Compile Include="src\System\TupleExtensions.cs" />
<Compile Include="src\System\ValueTuple.cs" />
</ItemGroup>

<!-- Resources -->
<ItemGroup>
<SplitTextStringResource Include="$(BclSourcesRoot)\System.Private.CoreLib.txt">
<ResFile>System.Private.CoreLib</ResFile>
<ResGenDefines>$(DefineConstants)</ResGenDefines>
</SplitTextStringResource>
</ItemGroup>

<PropertyGroup>
<CheckCDefines Condition="'$(CheckCDefines)'==''">true</CheckCDefines>
</PropertyGroup>

<Target Name="CDefineChecker" BeforeTargets="Build" Condition="'$(CheckCDefines)'=='true'">
<!-- Compiler Definition Verification -->
<Message Importance="High" Text="============" />
<PropertyGroup>
<IgnoreDefineConstants>FEATURE_IMPLICIT_TLS;FEATURE_HIJACK</IgnoreDefineConstants>
<CMakeDefinitionSaveFile>$(IntermediateOutputPath)\cmake.definitions</CMakeDefinitionSaveFile>
</PropertyGroup>
<Exec Command='python $(MSBuildThisFileDirectory)..\scripts\check-definitions.py "$(CMakeDefinitionSaveFile)" "$(DefineConstants)" "$(IgnoreDefineConstants)" ' />
<Exec Command="python $(MSBuildThisFileDirectory)..\scripts\check-definitions.py &quot;$(CMakeDefinitionSaveFile)&quot; &quot;$(DefineConstants)&quot; &quot;$(IgnoreDefineConstants)&quot; " />
<Message Importance="High" Text="============" />
</Target>

<ItemGroup>
<EmbeddedResource Include="$(NlpObjDir)\charinfo.nlp">
<LogicalName>charinfo.nlp</LogicalName>
</EmbeddedResource>
</ItemGroup>

<PropertyGroup Condition="'$(BuildOS)' == 'Windows_NT'">
<EnableDotnetAnalyzers Condition="'$(EnableDotnetAnalyzers)'==''">true</EnableDotnetAnalyzers>
<UseWin32Apis>true</UseWin32Apis>
<OSGroup>Windows_NT</OSGroup>
</PropertyGroup>
<Import Project="$(ToolsDir)\codeAnalysis.targets" />

<Import Project="$(ToolsDir)\Microsoft.CSharp.Targets" />

<PropertyGroup>
<StrongNameSig>Silverlight</StrongNameSig>
</PropertyGroup>

<!-- Import signing tools -->
<Import Condition="Exists('$(ToolsDir)\sign.targets')" Project="$(ToolsDir)\sign.targets" />

<!-- Overwrite the key that we are going to use for signing -->
<PropertyGroup>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Tools\Signing\mscorlib.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)Tools\Versioning\GenerateVersionInfo.targets"/>
<Import Project="$(MSBuildThisFileDirectory)Tools\Versioning\GenerateVersionInfo.targets" />
<!-- Override versioning targets -->
<Import Condition="Exists('$(ToolsDir)versioning.targets')" Project="$(ToolsDir)versioning.targets" />

<PropertyGroup>
<!-- Use a different nativeresource file to avoid conflicts with mscorlib-->
<Win32Resource Condition="'$(GenerateNativeVersionInfo)'=='true'">$(IntermediateOutputPath)\System.Private.CoreLib.res</Win32Resource>
</PropertyGroup>

<Import Project="GenerateSplitStringResources.targets"/>
<Import Project="GenerateCompilerResponseFile.targets"/>
</Project>
<Import Project="GenerateSplitStringResources.targets" />
<Import Project="GenerateCompilerResponseFile.targets" />
</Project>
5 changes: 2 additions & 3 deletions src/coreclr/src/mscorlib/System.Private.CoreLib.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Expand Down Expand Up @@ -49,4 +48,4 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

using System.Runtime.Versioning;

#if BIT64
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
#endif

namespace System.Runtime.CompilerServices
{
//
Expand Down Expand Up @@ -65,6 +71,18 @@ public static ref T Add<T>(ref T source, int elementOffset)
throw new InvalidOperationException();
}

/// <summary>
/// Adds an element offset to the given reference.
/// </summary>
[NonVersionable]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T AddByteOffset<T>(ref T source, nuint byteOffset)
{
// The body of this function will be replaced by the EE with unsafe code!!!
// See getILIntrinsicImplementationForUnsafe for how this happens.
throw new InvalidOperationException();
}

/// <summary>
/// Determines whether the specified references point to the same location.
/// </summary>
Expand Down
32 changes: 32 additions & 0 deletions src/coreclr/src/mscorlib/src/System/Runtime/RuntimeImports.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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.

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

#if BIT64
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
#endif

namespace System.Runtime
{
public class RuntimeImports
{
// Non-inlinable wrapper around the QCall that avoids poluting the fast path
// with P/Invoke prolog/epilog.
[MethodImplAttribute(MethodImplOptions.NoInlining)]
internal unsafe static void RhZeroMemory(ref byte b, nuint byteLength)
{
fixed (byte* bytePointer = &b)
{
RhZeroMemory(bytePointer, byteLength);
}
}

[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
extern private unsafe static void RhZeroMemory(byte* b, nuint byteLength);
}
}
Loading

0 comments on commit 70b6f08

Please sign in to comment.