diff options
25 files changed, 86 insertions, 36 deletions
diff --git a/dependencies.props b/dependencies.props index ca1640cab..15a55a1be 100644 --- a/dependencies.props +++ b/dependencies.props @@ -1,10 +1,10 @@ <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> - <RyuJITVersion>2.1.0-preview2-26302-06</RyuJITVersion> + <RyuJITVersion>2.1.0-preview2-26310-01</RyuJITVersion> <ObjectWriterVersion>1.0.19-prerelease-00001</ObjectWriterVersion> - <CoreFxVersion>4.5.0-preview2-26228-08</CoreFxVersion> - <CoreFxUapVersion>4.6.0-preview2-26202-05</CoreFxUapVersion> - <MicrosoftNETCoreNativeVersion>2.1.0-preview2-26302-06</MicrosoftNETCoreNativeVersion> + <CoreFxVersion>4.5.0-preview2-26310-02</CoreFxVersion> + <CoreFxUapVersion>4.6.0-preview2-26310-02</CoreFxUapVersion> + <MicrosoftNETCoreNativeVersion>2.1.0-preview2-26310-01</MicrosoftNETCoreNativeVersion> <MicrosoftNETCoreAppPackageVersion>2.0.0</MicrosoftNETCoreAppPackageVersion> <XunitNetcoreExtensionsVersion>1.0.1-prerelease-02104-02</XunitNetcoreExtensionsVersion> </PropertyGroup> diff --git a/src/Common/src/TypeSystem/Canon/CanonTypes.cs b/src/Common/src/TypeSystem/Canon/CanonTypes.cs index ef8b60190..d84341b15 100644 --- a/src/Common/src/TypeSystem/Canon/CanonTypes.cs +++ b/src/Common/src/TypeSystem/Canon/CanonTypes.cs @@ -175,7 +175,7 @@ namespace Internal.TypeSystem } flags |= TypeFlags.HasFinalizerComputed; - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; return flags; } @@ -262,7 +262,7 @@ namespace Internal.TypeSystem } flags |= TypeFlags.HasFinalizerComputed; - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; return flags; } diff --git a/src/Common/src/TypeSystem/CodeGen/TypeDesc.CodeGen.cs b/src/Common/src/TypeSystem/CodeGen/TypeDesc.CodeGen.cs new file mode 100644 index 000000000..e5b0d36a7 --- /dev/null +++ b/src/Common/src/TypeSystem/CodeGen/TypeDesc.CodeGen.cs @@ -0,0 +1,21 @@ +// 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 Internal.TypeSystem +{ + partial class TypeDesc + { + /// <summary> + /// Gets a value indicating whether this is a type that needs to be treated + /// specially. + /// </summary> + public bool IsIntrinsic + { + get + { + return (GetTypeFlags(TypeFlags.IsIntrinsic | TypeFlags.AttributeCacheComputed) & TypeFlags.IsIntrinsic) != 0; + } + } + } +} diff --git a/src/Common/src/TypeSystem/Common/ArrayType.cs b/src/Common/src/TypeSystem/Common/ArrayType.cs index 22a985012..eaa454786 100644 --- a/src/Common/src/TypeSystem/Common/ArrayType.cs +++ b/src/Common/src/TypeSystem/Common/ArrayType.cs @@ -145,7 +145,7 @@ namespace Internal.TypeSystem flags |= TypeFlags.HasFinalizerComputed; - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; return flags; } diff --git a/src/Common/src/TypeSystem/Common/ByRefType.cs b/src/Common/src/TypeSystem/Common/ByRefType.cs index 164925f9d..6d1984594 100644 --- a/src/Common/src/TypeSystem/Common/ByRefType.cs +++ b/src/Common/src/TypeSystem/Common/ByRefType.cs @@ -37,7 +37,7 @@ namespace Internal.TypeSystem flags |= TypeFlags.HasFinalizerComputed; - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; return flags; } diff --git a/src/Common/src/TypeSystem/Common/FunctionPointerType.cs b/src/Common/src/TypeSystem/Common/FunctionPointerType.cs index 5d50620d7..523b105d0 100644 --- a/src/Common/src/TypeSystem/Common/FunctionPointerType.cs +++ b/src/Common/src/TypeSystem/Common/FunctionPointerType.cs @@ -67,7 +67,7 @@ namespace Internal.TypeSystem flags |= TypeFlags.HasFinalizerComputed; - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; return flags; } diff --git a/src/Common/src/TypeSystem/Common/GenericParameterDesc.cs b/src/Common/src/TypeSystem/Common/GenericParameterDesc.cs index d98497921..4eff6c6cb 100644 --- a/src/Common/src/TypeSystem/Common/GenericParameterDesc.cs +++ b/src/Common/src/TypeSystem/Common/GenericParameterDesc.cs @@ -164,7 +164,7 @@ namespace Internal.TypeSystem flags |= TypeFlags.HasGenericVarianceComputed; - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; return flags; } diff --git a/src/Common/src/TypeSystem/Common/InstantiatedType.cs b/src/Common/src/TypeSystem/Common/InstantiatedType.cs index c5ae6776e..f89086f71 100644 --- a/src/Common/src/TypeSystem/Common/InstantiatedType.cs +++ b/src/Common/src/TypeSystem/Common/InstantiatedType.cs @@ -104,9 +104,9 @@ namespace Internal.TypeSystem flags |= TypeFlags.HasFinalizer; } - if ((mask & TypeFlags.IsByRefLikeComputed) != 0) + if ((mask & TypeFlags.AttributeCacheComputed) != 0) { - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; if (_typeDef.IsByRefLike) flags |= TypeFlags.IsByRefLike; diff --git a/src/Common/src/TypeSystem/Common/PointerType.cs b/src/Common/src/TypeSystem/Common/PointerType.cs index e0cd681b2..15e8adbde 100644 --- a/src/Common/src/TypeSystem/Common/PointerType.cs +++ b/src/Common/src/TypeSystem/Common/PointerType.cs @@ -35,7 +35,7 @@ namespace Internal.TypeSystem flags |= TypeFlags.HasGenericVarianceComputed; flags |= TypeFlags.HasFinalizerComputed; - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; return flags; } diff --git a/src/Common/src/TypeSystem/Common/TypeDesc.cs b/src/Common/src/TypeSystem/Common/TypeDesc.cs index a3bc755f2..d9110d148 100644 --- a/src/Common/src/TypeSystem/Common/TypeDesc.cs +++ b/src/Common/src/TypeSystem/Common/TypeDesc.cs @@ -626,7 +626,7 @@ namespace Internal.TypeSystem { get { - return (GetTypeFlags(TypeFlags.IsByRefLike | TypeFlags.IsByRefLikeComputed) & TypeFlags.IsByRefLike) != 0; + return (GetTypeFlags(TypeFlags.IsByRefLike | TypeFlags.AttributeCacheComputed) & TypeFlags.IsByRefLike) != 0; } } } diff --git a/src/Common/src/TypeSystem/Common/TypeFlags.cs b/src/Common/src/TypeSystem/Common/TypeFlags.cs index c177cbe59..028a7356d 100644 --- a/src/Common/src/TypeSystem/Common/TypeFlags.cs +++ b/src/Common/src/TypeSystem/Common/TypeFlags.cs @@ -57,7 +57,8 @@ namespace Internal.TypeSystem HasFinalizerComputed = 0x1000, HasFinalizer = 0x2000, - IsByRefLike = 0x4000, - IsByRefLikeComputed = 0x8000, + IsByRefLike = 0x04000, + AttributeCacheComputed = 0x08000, + IsIntrinsic = 0x10000, } } diff --git a/src/Common/src/TypeSystem/Ecma/EcmaType.cs b/src/Common/src/TypeSystem/Ecma/EcmaType.cs index e2e840f8a..de9f467c9 100644 --- a/src/Common/src/TypeSystem/Ecma/EcmaType.cs +++ b/src/Common/src/TypeSystem/Ecma/EcmaType.cs @@ -242,12 +242,28 @@ namespace Internal.TypeSystem.Ecma flags |= TypeFlags.HasFinalizer; } - if ((mask & TypeFlags.IsByRefLikeComputed) != 0) + if ((mask & TypeFlags.AttributeCacheComputed) != 0) { - flags |= TypeFlags.IsByRefLikeComputed; + MetadataReader reader = MetadataReader; + MetadataStringComparer stringComparer = reader.StringComparer; + bool isValueType = IsValueType; - if (IsValueType && HasCustomAttribute("System.Runtime.CompilerServices", "IsByRefLikeAttribute")) - flags |= TypeFlags.IsByRefLike; + flags |= TypeFlags.AttributeCacheComputed; + + foreach (CustomAttributeHandle attributeHandle in _typeDefinition.GetCustomAttributes()) + { + if (MetadataReader.GetAttributeNamespaceAndName(attributeHandle, out StringHandle namespaceHandle, out StringHandle nameHandle)) + { + if (isValueType && + stringComparer.Equals(nameHandle, "IsByRefLikeAttribute") && + stringComparer.Equals(namespaceHandle, "System.Runtime.CompilerServices")) + flags |= TypeFlags.IsByRefLike; + + if (stringComparer.Equals(nameHandle, "IntrinsicAttribute") && + stringComparer.Equals(namespaceHandle, "System.Runtime.CompilerServices")) + flags |= TypeFlags.IsIntrinsic; + } + } } return flags; diff --git a/src/Common/src/TypeSystem/Interop/IL/InlineArrayType.cs b/src/Common/src/TypeSystem/Interop/IL/InlineArrayType.cs index d7412081f..6f7c711b0 100644 --- a/src/Common/src/TypeSystem/Interop/IL/InlineArrayType.cs +++ b/src/Common/src/TypeSystem/Interop/IL/InlineArrayType.cs @@ -219,7 +219,7 @@ namespace Internal.TypeSystem.Interop } flags |= TypeFlags.HasFinalizerComputed; - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; return flags; } diff --git a/src/Common/src/TypeSystem/Interop/IL/NativeStructType.cs b/src/Common/src/TypeSystem/Interop/IL/NativeStructType.cs index 87fb167a6..56171edf9 100644 --- a/src/Common/src/TypeSystem/Interop/IL/NativeStructType.cs +++ b/src/Common/src/TypeSystem/Interop/IL/NativeStructType.cs @@ -301,7 +301,7 @@ namespace Internal.TypeSystem.Interop } flags |= TypeFlags.HasFinalizerComputed; - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; return flags; } diff --git a/src/Common/src/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs b/src/Common/src/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs index 3ff100bf4..5d95c8461 100644 --- a/src/Common/src/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs +++ b/src/Common/src/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs @@ -204,7 +204,7 @@ namespace Internal.TypeSystem.Interop } flags |= TypeFlags.HasFinalizerComputed; - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; return flags; } diff --git a/src/Common/src/TypeSystem/NativeFormat/NativeFormatType.cs b/src/Common/src/TypeSystem/NativeFormat/NativeFormatType.cs index 6b4cb5902..cde2d125e 100644 --- a/src/Common/src/TypeSystem/NativeFormat/NativeFormatType.cs +++ b/src/Common/src/TypeSystem/NativeFormat/NativeFormatType.cs @@ -287,9 +287,9 @@ namespace Internal.TypeSystem.NativeFormat flags |= TypeFlags.HasFinalizer; } - if ((mask & TypeFlags.IsByRefLikeComputed) != 0) + if ((mask & TypeFlags.AttributeCacheComputed) != 0) { - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; if (IsValueType && HasCustomAttribute("System.Runtime.CompilerServices", "IsByRefLikeAttribute")) flags |= TypeFlags.IsByRefLike; diff --git a/src/Common/src/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs b/src/Common/src/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs index 096fb1c0b..48abf8286 100644 --- a/src/Common/src/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs +++ b/src/Common/src/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs @@ -137,7 +137,7 @@ namespace Internal.TypeSystem flags |= _rawCanonType.GetTypeFlags(mask); } - if ((mask & TypeFlags.IsByRefLikeComputed) != 0) + if ((mask & TypeFlags.AttributeCacheComputed) != 0) { flags |= _rawCanonType.GetTypeFlags(mask); } diff --git a/src/ILCompiler.Compiler/src/Compiler/CompilerGeneratedType.cs b/src/ILCompiler.Compiler/src/Compiler/CompilerGeneratedType.cs index 7bbd0aa45..e562d9500 100644 --- a/src/ILCompiler.Compiler/src/Compiler/CompilerGeneratedType.cs +++ b/src/ILCompiler.Compiler/src/Compiler/CompilerGeneratedType.cs @@ -78,7 +78,7 @@ namespace ILCompiler TypeFlags.HasGenericVarianceComputed | TypeFlags.HasStaticConstructorComputed | TypeFlags.HasFinalizerComputed | - TypeFlags.IsByRefLikeComputed; + TypeFlags.AttributeCacheComputed; } public override ClassLayoutMetadata GetClassLayout() diff --git a/src/ILCompiler.Compiler/src/Compiler/CompilerTypeSystemContext.BoxedTypes.cs b/src/ILCompiler.Compiler/src/Compiler/CompilerTypeSystemContext.BoxedTypes.cs index 9b8bd363c..44e7ec038 100644 --- a/src/ILCompiler.Compiler/src/Compiler/CompilerTypeSystemContext.BoxedTypes.cs +++ b/src/ILCompiler.Compiler/src/Compiler/CompilerTypeSystemContext.BoxedTypes.cs @@ -325,7 +325,7 @@ namespace ILCompiler } flags |= TypeFlags.HasFinalizerComputed; - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; return flags; } diff --git a/src/ILCompiler.Compiler/src/Compiler/SimdHelper.cs b/src/ILCompiler.Compiler/src/Compiler/SimdHelper.cs index 3f523b18d..53f606c57 100644 --- a/src/ILCompiler.Compiler/src/Compiler/SimdHelper.cs +++ b/src/ILCompiler.Compiler/src/Compiler/SimdHelper.cs @@ -17,19 +17,27 @@ namespace ILCompiler { private ModuleDesc[] _simdModulesCached; - public bool IsInSimdModule(TypeDesc type) + public bool IsSimdType(TypeDesc type) { - if (type is MetadataType) + if (type is MetadataType metadataType) { if (_simdModulesCached == null) { InitializeSimdModules(type); } - ModuleDesc typeModule = ((MetadataType)type).Module; + ModuleDesc typeModule = metadataType.Module; foreach (ModuleDesc simdModule in _simdModulesCached) if (typeModule == simdModule) return true; + + if (metadataType.IsIntrinsic) + { + string name = metadataType.Name; + if ((name == "Vector`1" || name == "Vector") && + metadataType.Namespace == "System.Numerics") + return true; + } } return false; @@ -54,7 +62,7 @@ namespace ILCompiler public bool IsVectorOfT(TypeDesc type) { - return IsInSimdModule(type) + return IsSimdType(type) && ((MetadataType)type).Name == "Vector`1" && ((MetadataType)type).Namespace == "System.Numerics"; } diff --git a/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj b/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj index c9b2ef2bf..162c941a7 100644 --- a/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj +++ b/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj @@ -82,6 +82,9 @@ <Compile Include="..\..\Common\src\TypeSystem\CodeGen\TargetDetails.CodeGen.cs"> <Link>TypeSystem\CodeGen\TargetDetails.CodeGen.cs</Link> </Compile> + <Compile Include="..\..\Common\src\TypeSystem\CodeGen\TypeDesc.CodeGen.cs"> + <Link>TypeSystem\CodeGen\TypeDesc.CodeGen.cs</Link> + </Compile> <Compile Include="..\..\Common\src\TypeSystem\Common\AlignmentHelper.cs"> <Link>Utilities\AlignmentHelper.cs</Link> </Compile> diff --git a/src/ILCompiler/src/Program.cs b/src/ILCompiler/src/Program.cs index e980088c8..58d549ec0 100644 --- a/src/ILCompiler/src/Program.cs +++ b/src/ILCompiler/src/Program.cs @@ -498,7 +498,7 @@ namespace ILCompiler // We additionally skip methods in SIMD module because there's just too many intrisics to handle and IL scanner // doesn't expand them. They would show up as noisy diffs. DiffCompilationResults(ref dummy, scanResults.CompiledMethodBodies, compilationResults.CompiledMethodBodies, - "Methods", "scanned", "compiled", method => !(method.GetTypicalMethodDefinition() is EcmaMethod) || simdHelper.IsInSimdModule(method.OwningType)); + "Methods", "scanned", "compiled", method => !(method.GetTypicalMethodDefinition() is EcmaMethod) || simdHelper.IsSimdType(method.OwningType)); DiffCompilationResults(ref dummy, scanResults.ConstructedEETypes, compilationResults.ConstructedEETypes, "EETypes", "scanned", "compiled", type => !(type.GetTypeDefinition() is EcmaType)); } diff --git a/src/JitInterface/src/CorInfoImpl.cs b/src/JitInterface/src/CorInfoImpl.cs index 535ac1cb7..7ce947486 100644 --- a/src/JitInterface/src/CorInfoImpl.cs +++ b/src/JitInterface/src/CorInfoImpl.cs @@ -994,7 +994,7 @@ namespace Internal.JitInterface { TypeDesc type = HandleToObject(classHnd); - if (_simdHelper.IsInSimdModule(type)) + if (_simdHelper.IsSimdType(type)) { #if DEBUG // If this is Vector<T>, make sure the codegen and the type system agree on what instructions/registers diff --git a/src/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeNoMetadataType.cs b/src/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeNoMetadataType.cs index d9c688be6..3e6b79244 100644 --- a/src/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeNoMetadataType.cs +++ b/src/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeNoMetadataType.cs @@ -198,9 +198,9 @@ namespace Internal.TypeSystem.NoMetadata } } - if ((mask & TypeFlags.IsByRefLikeComputed) != 0) + if ((mask & TypeFlags.AttributeCacheComputed) != 0) { - flags |= TypeFlags.IsByRefLikeComputed; + flags |= TypeFlags.AttributeCacheComputed; unsafe { diff --git a/src/System.Private.TypeLoader/src/System.Private.TypeLoader.csproj b/src/System.Private.TypeLoader/src/System.Private.TypeLoader.csproj index 1ba5ae861..09fdd65da 100644 --- a/src/System.Private.TypeLoader/src/System.Private.TypeLoader.csproj +++ b/src/System.Private.TypeLoader/src/System.Private.TypeLoader.csproj @@ -57,6 +57,7 @@ <NativeFormatCommonPath>..\..\Common\src\Internal\NativeFormat</NativeFormatCommonPath> </PropertyGroup> <ItemGroup Condition="'$(JitSupport)' == 'true'"> + <Compile Include="..\..\Common\src\TypeSystem\CodeGen\TypeDesc.CodeGen.cs" /> <Compile Include="..\..\Common\src\TypeSystem\RuntimeDetermined\ArrayType.RuntimeDetermined.cs" /> <Compile Include="..\..\Common\src\TypeSystem\RuntimeDetermined\ByRefType.RuntimeDetermined.cs" /> <Compile Include="..\..\Common\src\TypeSystem\RuntimeDetermined\DefType.RuntimeDetermined.cs" /> |