From 11064aaca42ecc3526682c8f0c663542e7f4558a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 4 Sep 2025 08:06:34 +0200 Subject: [PATCH 01/19] Add U8Name properties --- .../MethodNameAndSignature.cs | 9 +++ .../Internal/TypeSystem/RuntimeMethodDesc.cs | 8 +++ .../TypeSystem/Canon/CanonTypes.Diagnostic.cs | 8 +-- .../Common/TypeSystem/Canon/CanonTypes.cs | 52 ++++++++++++----- .../Canon/TypeSystemContext.Canon.cs | 4 +- .../Common/TypeSystem/Common/ArrayType.cs | 20 +++++++ .../tools/Common/TypeSystem/Common/DefType.cs | 6 ++ .../Common/TypeSystem/Common/FieldDesc.cs | 9 +++ .../Common/FieldForInstantiatedType.cs | 9 +++ .../TypeSystem/Common/GenericParameterDesc.cs | 8 +++ .../Common/TypeSystem/Common/IAssemblyDesc.cs | 6 ++ .../Common/ImpliedRepeatedFieldDesc.cs | 4 ++ .../TypeSystem/Common/InstantiatedMethod.cs | 9 +++ .../TypeSystem/Common/InstantiatedType.cs | 17 ++++++ .../TypeSystem/Common/MethodDelegator.cs | 4 ++ .../Common/TypeSystem/Common/MethodDesc.cs | 8 +++ .../Common/MethodForInstantiatedType.cs | 10 ++++ .../TypeSystem/Common/TypeSystemHelpers.cs | 21 +++++++ .../Common/TypeWithRepeatedFields.cs | 4 ++ .../Common/TypeSystem/Ecma/EcmaAssembly.cs | 10 ++++ .../tools/Common/TypeSystem/Ecma/EcmaField.cs | 10 ++++ .../TypeSystem/Ecma/EcmaGenericParameter.cs | 11 ++++ .../Common/TypeSystem/Ecma/EcmaMethod.cs | 11 ++++ .../tools/Common/TypeSystem/Ecma/EcmaType.cs | 18 ++++++ ...AssemblyGetExecutingAssemblyMethodThunk.cs | 9 +++ .../IL/Stubs/CalliMarshallingMethodThunk.cs | 9 +++ .../Stubs/DelegateMarshallingMethodThunk.cs | 27 +++++++++ .../TypeSystem/IL/Stubs/DelegateThunks.cs | 57 +++++++++++++++++++ .../IL/Stubs/DynamicInvokeMethodThunk.cs | 3 + .../Common/TypeSystem/IL/Stubs/EnumThunks.cs | 17 ++++++ .../IL/Stubs/ForwardDelegateCreationThunk.cs | 9 +++ .../Stubs/MethodBaseGetCurrentMethodThunk.cs | 9 +++ .../IL/Stubs/PInvokeLazyFixupField.cs | 9 +++ .../IL/Stubs/PInvokeTargetNativeMethod.cs | 9 +++ .../IL/Stubs/StructMarshallingThunk.cs | 27 +++++++++ .../IL/Stubs/TypeGetTypeMethodThunk.cs | 9 +++ .../ValueTypeGetFieldHelperMethodOverride.cs | 10 ++++ .../TypeSystem/Interop/IL/InlineArrayType.cs | 39 +++++++++++++ .../TypeSystem/Interop/IL/NativeStructType.cs | 24 ++++++++ .../Interop/IL/PInvokeDelegateWrapper.cs | 16 ++++++ .../IL/PInvokeDelegateWrapperConstructor.cs | 9 +++ .../MethodForRuntimeDeterminedType.cs | 2 + .../RuntimeDeterminedType.cs | 17 ++++++ .../CompilerTypeSystemContext.BoxedTypes.cs | 20 +++++++ ...ilerTypeSystemContext.GeneratedAssembly.cs | 30 ++++++++-- ...mpilerTypeSystemContext.InterfaceThunks.cs | 9 +++ .../Compiler/ExternSymbolMappedField.cs | 3 + .../ReachabilityInstrumentationProvider.cs | 1 + .../Compiler/TypeMapMetadata.cs | 1 + .../StartupCode/NativeLibraryStartupMethod.cs | 9 +++ .../StartupCode/StartupCodeMainMethod.cs | 16 ++++++ .../IBC/MIbcProfileParser.cs | 2 + .../SyntheticVirtualOverrideTests.cs | 8 +++ .../TypeRefTypeSystemModule.cs | 2 + .../TypeRefTypeSystemType.cs | 20 ++++--- 55 files changed, 675 insertions(+), 33 deletions(-) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerServices/MethodNameAndSignature.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerServices/MethodNameAndSignature.cs index 04884e5ac54506..fd125110cf748f 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerServices/MethodNameAndSignature.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerServices/MethodNameAndSignature.cs @@ -26,6 +26,15 @@ public string GetName() return Reader.GetString(method.Name); } + public ReadOnlySpan Name + { + get + { + Method method = Reader.GetMethod(Handle); + return Reader.ReadStringAsBytes(method.Name); + } + } + public override bool Equals(object? compare) { if (compare == null) diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs index e07a286b1bb23a..27e14806db0a09 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs @@ -97,6 +97,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return NameAndSignature.Name; + } + } + private bool _unboxingStub; public override bool UnboxingStub { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs index 2a6843397b6022..0bd21802de7cfc 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs @@ -9,14 +9,14 @@ public override string DiagnosticName { get { - return _Name; + return Name; } } public override string DiagnosticNamespace { get { - return _Namespace; + return Namespace; } } } @@ -27,14 +27,14 @@ public override string DiagnosticName { get { - return _Name; + return Name; } } public override string DiagnosticNamespace { get { - return _Namespace; + return Namespace; } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs index ebf78f60e69d76..85c0f6f8dd4317 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs @@ -59,17 +59,21 @@ public sealed override TypeSystemContext Context /// internal sealed partial class CanonType : CanonBaseType { - private const string _Namespace = "System"; - private const string _Name = "__Canon"; - public const string FullName = _Namespace + "." + _Name; - private int _hashcode; public override string Namespace { get { - return _Namespace; + return "System"; + } + } + + public override ReadOnlySpan U8Namespace + { + get + { + return "System"u8; } } @@ -77,7 +81,15 @@ public override string Name { get { - return _Name; + return "__Canon"; + } + } + + public override ReadOnlySpan U8Name + { + get + { + return "__Canon"u8; } } @@ -135,7 +147,7 @@ public override int GetHashCode() { if (_hashcode == 0) { - _hashcode = TypeHashingAlgorithms.ComputeNameHashCode(FullName); + _hashcode = TypeHashingAlgorithms.ComputeNameHashCode("System.__Canon"); } return _hashcode; @@ -147,17 +159,21 @@ public override int GetHashCode() /// internal sealed partial class UniversalCanonType : CanonBaseType { - private const string _Namespace = "System"; - private const string _Name = "__UniversalCanon"; - public const string FullName = _Namespace + "." + _Name; - private int _hashcode; public override string Namespace { get { - return _Namespace; + return "System"; + } + } + + public override ReadOnlySpan U8Namespace + { + get + { + return "System"u8; } } @@ -165,7 +181,15 @@ public override string Name { get { - return _Name; + return "__UniversalCanon"; + } + } + + public override ReadOnlySpan U8Name + { + get + { + return "__UniversalCanon"u8; } } @@ -221,7 +245,7 @@ public override int GetHashCode() { if (_hashcode == 0) { - _hashcode = TypeHashingAlgorithms.ComputeNameHashCode(FullName); + _hashcode = TypeHashingAlgorithms.ComputeNameHashCode("System.__UniversalCanon"); } return _hashcode; diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/TypeSystemContext.Canon.cs b/src/coreclr/tools/Common/TypeSystem/Canon/TypeSystemContext.Canon.cs index 7292e6c06a1895..61ec2a730d4bdf 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/TypeSystemContext.Canon.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/TypeSystemContext.Canon.cs @@ -97,9 +97,9 @@ public DefType GetCanonType(string name) { switch (name) { - case TypeSystem.CanonType.FullName: + case "System.__Canon": return CanonType; - case TypeSystem.UniversalCanonType.FullName: + case "System.__UniversalCanon": return UniversalCanonType; } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs b/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs index 768f5f7eaa4ff5..70757a52919510 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using System.Threading; @@ -318,6 +319,25 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + switch (_kind) + { + case ArrayMethodKind.Get: + return "Get"u8; + case ArrayMethodKind.Set: + return "Set"u8; + case ArrayMethodKind.Address: + case ArrayMethodKind.AddressWithHiddenArg: + return "Address"u8; + default: + return ".ctor"u8; + } + } + } + public override bool HasCustomAttribute(string attributeNamespace, string attributeName) { return false; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs b/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs index 06ee99e9d74e2e..948f090fb4e6c1 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + namespace Internal.TypeSystem { /// @@ -14,11 +16,15 @@ public abstract partial class DefType : TypeDesc /// public virtual string Namespace => null; + public virtual ReadOnlySpan U8Namespace => []; + /// /// Gets the name of the type as represented in the metadata. /// public virtual string Name => null; + public virtual ReadOnlySpan U8Name => []; + /// /// Gets the containing type of this type or null if the type is not nested. /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs index 1047c075c2f623..d8921e16d672be 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Runtime.CompilerServices; using Debug = System.Diagnostics.Debug; @@ -34,6 +35,14 @@ public virtual string Name } } + public virtual ReadOnlySpan U8Name + { + get + { + return []; + } + } + public abstract DefType OwningType { get; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs index 04e403356ba472..3cfc549e44bc43 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem @@ -41,6 +42,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return _fieldDef.U8Name; + } + } + public override TypeDesc FieldType { get diff --git a/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs index c361733737d4ff..8d62f1843d149a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs @@ -77,6 +77,14 @@ public virtual string Name } } + public virtual ReadOnlySpan U8Name + { + get + { + return System.Text.Encoding.UTF8.GetBytes(Name); + } + } + /// /// Gets a value indicating whether this is a type or method generic parameter. /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/IAssemblyDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/IAssemblyDesc.cs index c64e7e3808651a..4487411019e56f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/IAssemblyDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/IAssemblyDesc.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Reflection.Metadata; namespace Internal.TypeSystem @@ -14,5 +15,10 @@ public interface IAssemblyDesc /// Gets the assembly name. /// AssemblyNameInfo GetName(); + + /// + /// Gets the simple assembly name + /// + ReadOnlySpan Name { get; } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs index 93829636916d31..d41c4aa1a78efa 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + namespace Internal.TypeSystem { public sealed partial class ImpliedRepeatedFieldDesc : FieldDesc @@ -41,5 +43,7 @@ public ImpliedRepeatedFieldDesc(DefType owningType, FieldDesc underlyingFieldDes public override MarshalAsDescriptor GetMarshalAsDescriptor() => _underlyingFieldDesc.GetMarshalAsDescriptor(); public override string Name => $"{_underlyingFieldDesc.Name}[{FieldIndex}]"; + + public override ReadOnlySpan U8Name => System.Text.Encoding.UTF8.GetBytes(Name); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs index e215752719dca9..8b18c12d0dfd0f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Diagnostics; using Internal.NativeFormat; @@ -163,5 +164,13 @@ public override string Name return _methodDef.Name; } } + + public override ReadOnlySpan U8Name + { + get + { + return _methodDef.U8Name; + } + } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs index 25ed6d214731c9..a779d7777ac4a8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using System.Diagnostics; @@ -126,6 +127,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return _typeDef.U8Name; + } + } + public override string Namespace { get @@ -134,6 +143,14 @@ public override string Namespace } } + public override ReadOnlySpan U8Namespace + { + get + { + return _typeDef.U8Namespace; + } + } + public override IEnumerable GetMethods() { foreach (var typicalMethodDef in _typeDef.GetMethods()) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs index 74f218a6fec733..956cf0e9a1b9fe 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + namespace Internal.TypeSystem { /// @@ -28,6 +30,8 @@ public MethodDelegator(MethodDesc wrappedMethod) public override string Name => _wrappedMethod.Name; + public override ReadOnlySpan U8Name => _wrappedMethod.U8Name; + public override bool IsVirtual => _wrappedMethod.IsVirtual; public override bool IsNewSlot => _wrappedMethod.IsNewSlot; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs index 93b12af20f141e..1e42f8803c56cd 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs @@ -595,6 +595,14 @@ public virtual string Name } } + public virtual ReadOnlySpan U8Name + { + get + { + return []; + } + } + /// /// Gets a value indicating whether the method is virtual. /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs index db3df985b59d8b..c4f774b9bbc8e6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem @@ -150,5 +152,13 @@ public override string Name return _typicalMethodDef.Name; } } + + public override ReadOnlySpan U8Name + { + get + { + return _typicalMethodDef.U8Name; + } + } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs index 27a0ce99541da9..29f3c6e6f2acf8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs @@ -443,5 +443,26 @@ public static bool RequiresAlign8(this TypeDesc type) return false; } + + public static ReadOnlySpan Append(this ReadOnlySpan s1, ReadOnlySpan s2) + { + Span buffer = new T[s1.Length + s2.Length]; + + s1.CopyTo(buffer); + s2.CopyTo(buffer.Slice(s1.Length)); + + return buffer; + } + + public static ReadOnlySpan Append(this ReadOnlySpan s1, ReadOnlySpan s2, ReadOnlySpan s3) + { + Span buffer = new T[s1.Length + s2.Length + s3.Length]; + + s1.CopyTo(buffer); + s2.CopyTo(buffer.Slice(s1.Length)); + s3.CopyTo(buffer.Slice(s1.Length + s2.Length)); + + return buffer; + } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs index 158925c84e647d..e64480fc3db127 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs @@ -94,8 +94,12 @@ public override IEnumerable GetFields() public override string Namespace => MetadataType.Namespace; + public override ReadOnlySpan U8Namespace => MetadataType.U8Namespace; + public override string Name => MetadataType.Name; + public override ReadOnlySpan U8Name => MetadataType.U8Name; + public override DefType[] ExplicitlyImplementedInterfaces => Array.Empty(); public override bool IsExplicitLayout => MetadataType.IsExplicitLayout; diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.cs index c59d2b5fee5556..881b1500dfe482 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Reflection; using System.Reflection.Metadata; using System.Reflection.PortableExecutable; @@ -61,6 +62,15 @@ public AssemblyNameInfo GetName() return _assemblyName; } + public unsafe ReadOnlySpan Name + { + get + { + BlobReader blob = MetadataReader.GetBlobReader(_assemblyDefinition.Name); + return new ReadOnlySpan(blob.StartPointer, blob.Length); + } + } + public override string ToString() { return GetName().Name; diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs index 8812678f72ae17..c7995c0b402405 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs @@ -278,6 +278,16 @@ public override string Name } } + public override unsafe ReadOnlySpan U8Name + { + get + { + var metadataReader = MetadataReader; + var blob = metadataReader.GetBlobReader(metadataReader.GetFieldDefinition(_handle).Name); + return new ReadOnlySpan(blob.StartPointer, blob.Length); + } + } + public override bool HasCustomAttribute(string attributeNamespace, string attributeName) { return !MetadataReader.GetCustomAttributeHandle(MetadataReader.GetFieldDefinition(_handle).GetCustomAttributes(), diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs index 8ffa09bc12eb78..11f8ba66ebac90 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using System.Reflection.Metadata; using System.Threading; @@ -61,6 +62,16 @@ public override string Name } } + public override unsafe ReadOnlySpan U8Name + { + get + { + MetadataReader reader = _module.MetadataReader; + BlobReader blob = reader.GetBlobReader(reader.GetGenericParameter(_handle).Name); + return new ReadOnlySpan(blob.StartPointer, blob.Length); + } + } + public override GenericParameterKind Kind { get diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index 9a7edd11559165..e37648aa562668 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -6,6 +6,7 @@ using System.Reflection; using System.Reflection.Metadata; using System.Threading; +using System; namespace Internal.TypeSystem.Ecma { @@ -402,6 +403,16 @@ public override string Name } } + public override unsafe ReadOnlySpan U8Name + { + get + { + var metadataReader = MetadataReader; + var blob = metadataReader.GetBlobReader(metadataReader.GetMethodDefinition(_handle).Name); + return new ReadOnlySpan(blob.StartPointer, blob.Length); + } + } + private void ComputeGenericParameters() { var genericParameterHandles = MetadataReader.GetMethodDefinition(_handle).GetGenericParameters(); diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs index a444ebb2e3b596..dec4d61a38336c 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs @@ -292,6 +292,15 @@ public override string Name } } + public override unsafe ReadOnlySpan U8Name + { + get + { + BlobReader blob = MetadataReader.GetBlobReader(_typeDefinition.Name); + return new ReadOnlySpan(blob.StartPointer, blob.Length); + } + } + private string InitializeNamespace() { var metadataReader = this.MetadataReader; @@ -309,6 +318,15 @@ public override string Namespace } } + public override unsafe ReadOnlySpan U8Namespace + { + get + { + BlobReader blob = MetadataReader.GetBlobReader(_typeDefinition.Namespace); + return new ReadOnlySpan(blob.StartPointer, blob.Length); + } + } + public override IEnumerable GetMethods() { foreach (var handle in _typeDefinition.GetMethods()) diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs index 78386fbe55cb4f..870e46ae36612e 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.TypeSystem; namespace Internal.IL.Stubs @@ -44,6 +45,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "GetExecutingAssembly_"u8.Append(ExecutingAssembly.Name); + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs index 23721ea8e1c4c5..3bc8c8823258bc 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.TypeSystem; namespace Internal.IL.Stubs @@ -77,6 +78,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "CalliMarshallingMethodThunk"u8; + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs index 368f19a79a74c2..215f73bfaf8136 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs @@ -237,6 +237,25 @@ private string NamePrefix } } + private ReadOnlySpan U8NamePrefix + { + get + { + switch (Kind) + { + case DelegateMarshallingMethodThunkKind.ReverseOpenStatic: + return "ReverseOpenStaticDelegateStub"u8; + case DelegateMarshallingMethodThunkKind.ReverseClosed: + return "ReverseDelegateStub"u8; + case DelegateMarshallingMethodThunkKind.ForwardNativeFunctionWrapper: + return "ForwardNativeFunctionWrapper"u8; + default: + Debug.Fail("Unexpected DelegateMarshallingMethodThunkKind."); + return []; + } + } + } + public override string Name { get @@ -245,6 +264,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return U8NamePrefix.Append("__"u8, DelegateType.U8Name); + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs index 3ec8a9e22540b6..57838cbb8b25bf 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -134,6 +135,14 @@ public override string Name return "InvokeOpenStaticThunk"; } } + + public override ReadOnlySpan U8Name + { + get + { + return "InvokeOpenStaticThunk"u8; + } + } } /// @@ -227,6 +236,14 @@ public override string Name return "InvokeOpenInstanceThunk"; } } + + public override ReadOnlySpan U8Name + { + get + { + return "InvokeOpenInstanceThunk"u8; + } + } } /// @@ -287,6 +304,14 @@ public override string Name return "InvokeClosedStaticThunk"; } } + + public override ReadOnlySpan U8Name + { + get + { + return "InvokeClosedStaticThunk"u8; + } + } } /// @@ -422,6 +447,14 @@ public override string Name return "InvokeMulticastThunk"; } } + + public override ReadOnlySpan U8Name + { + get + { + return "InvokeMulticastThunk"u8; + } + } } /// @@ -470,6 +503,14 @@ public override string Name return "InvokeInstanceClosedOverGenericMethodThunk"; } } + + public override ReadOnlySpan U8Name + { + get + { + return "InvokeInstanceClosedOverGenericMethodThunk"u8; + } + } } /// @@ -647,6 +688,14 @@ public override string Name return "InvokeObjectArrayThunk"; } } + + public override ReadOnlySpan U8Name + { + get + { + return "InvokeObjectArrayThunk"u8; + } + } } /// @@ -765,6 +814,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "GetThunk"u8; + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs index 9a02967189db31..ff0ed65eca13a9 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -121,6 +122,8 @@ protected override int ComputeHashCode() public override string Name => "DynamicInvoke"; + public override ReadOnlySpan U8Name => "DynamicInvoke"u8; + public override string DiagnosticName => "DynamicInvoke"; public MethodSignature TargetSignature => _targetSignature; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs index f1eb89c48d5215..5466ab78382d4f 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -64,6 +65,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "GetHashCode"u8; + } + } + public override string DiagnosticName { get @@ -155,6 +164,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "Equals"u8; + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs index 3dd0616af51eb2..279fdade1e8da7 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.TypeSystem; using Internal.TypeSystem.Interop; @@ -69,6 +70,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "ForwardDelegateCreationStub__"u8.Append(DelegateType.U8Name); + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs index eaed268049d42c..a0682ec3ee5aba 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -44,6 +45,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return Method.U8Name; + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs index b14891312fa43d..88ea8f6384b2dd 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -130,5 +131,13 @@ public override string Name return _targetMethod.Name; } } + + public override ReadOnlySpan U8Name + { + get + { + return _targetMethod.U8Name; + } + } } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs index 0e3eaeae12e7e0..9276a182879718 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.TypeSystem; namespace Internal.IL.Stubs @@ -61,6 +62,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return _declMethod.U8Name; + } + } + public override bool HasCustomAttribute(string attributeNamespace, string attributeName) { return false; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs index 5c8f57452386cc..8bc6bec60c9132 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs @@ -121,6 +121,25 @@ private string NamePrefix } } + private ReadOnlySpan U8NamePrefix + { + get + { + switch (ThunkType) + { + case StructMarshallingThunkType.ManagedToNative: + return "ManagedToNative"u8; + case StructMarshallingThunkType.NativeToManaged: + return "NativeToManaged"u8; + case StructMarshallingThunkType.Cleanup: + return "Cleanup"u8; + default: + Debug.Fail("Unexpected Struct marshalling thunk type"); + return []; + } + } + } + public override string Name { get @@ -129,6 +148,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return U8NamePrefix.Append("__"u8, ManagedType.U8Name); + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs index 48db579f5ea5a9..0a577019220b64 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -41,6 +42,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return System.Text.Encoding.UTF8.GetBytes(Name); + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs index 0da39be56f58e7..bc429c266a1245 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using ILCompiler; @@ -215,6 +216,7 @@ public override bool IsVirtual } internal const string MetadataName = "__GetFieldHelper"; + internal static ReadOnlySpan U8MetadataName => "__GetFieldHelper"u8; public override string Name { @@ -224,6 +226,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return U8MetadataName; + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs index b52b12a868bd1c..f115da0f45afed 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs @@ -35,6 +35,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return System.Text.Encoding.UTF8.GetBytes(Name); + } + } + public override string DiagnosticName { get @@ -51,6 +59,14 @@ public override string Namespace } } + public override ReadOnlySpan U8Namespace + { + get + { + return "Internal.CompilerGenerated"u8; + } + } + public override string DiagnosticNamespace { get @@ -342,6 +358,21 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + if (_kind == InlineArrayMethodKind.Getter) + { + return "get_Item"u8; + } + else + { + return "set_Item"u8; + } + } + } + public override string DiagnosticName { get @@ -505,6 +536,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "InlineArrayField"u8; + } + } + public InlineArrayField(InlineArrayType owningType) { _owningType = owningType; diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs index 3e0c35c0ae9210..15d2268796fafc 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs @@ -29,6 +29,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "__NativeType__"u8.Append(ManagedStructType.U8Name); + } + } + public override string DiagnosticName { get @@ -45,6 +53,14 @@ public override string Namespace } } + public override ReadOnlySpan U8Namespace + { + get + { + return "Internal.CompilerGenerated"u8; + } + } + public override string DiagnosticNamespace { get @@ -417,6 +433,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return _managedField.U8Name; + } + } + public override LayoutInt MetadataOffset { get diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs index 3708dff16c7d17..85baee169d52e9 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs @@ -34,6 +34,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "PInvokeDelegateWrapper__"u8.Append(DelegateType.U8Name); + } + } + public override string DiagnosticName { get @@ -50,6 +58,14 @@ public override string Namespace } } + public override ReadOnlySpan U8Namespace + { + get + { + return "Internal.CompilerGenerated"u8; + } + } + public override string DiagnosticNamespace { get diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs index 10727fac2b4b8e..b65f79f8495488 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.IL; using Internal.IL.Stubs; @@ -29,6 +30,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return ".ctor"u8; + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs index d111f8b130af73..77bfde2ff26e6c 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Diagnostics; namespace Internal.TypeSystem @@ -36,6 +37,7 @@ internal MethodForRuntimeDeterminedType(MethodDesc typicalMethodDef, RuntimeDete public override bool IsFinal => _typicalMethodDef.IsFinal; public override bool IsDefaultConstructor => _typicalMethodDef.IsDefaultConstructor; public override string Name => _typicalMethodDef.Name; + public override ReadOnlySpan U8Name => _typicalMethodDef.U8Name; public override MethodDesc GetTypicalMethodDefinition() => _typicalMethodDef; public override Instantiation Instantiation => _typicalMethodDef.Instantiation; diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs index fffcc885db2a35..f1d2a68b873d35 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using Debug = System.Diagnostics.Debug; @@ -97,6 +98,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return _rawCanonType.U8Name; + } + } + public override string Namespace { get @@ -105,6 +114,14 @@ public override string Namespace } } + public override ReadOnlySpan U8Namespace + { + get + { + return _runtimeDeterminedDetailsType.U8Name.Append("_"u8, _rawCanonType.U8Namespace); + } + } + public override IEnumerable GetMethods() { foreach (var method in _rawCanonType.GetMethods()) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs index 85e9f484f44b8d..9a3d0ac02c63ac 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs @@ -256,8 +256,10 @@ private sealed partial class BoxedValueType : MetadataType, INonEmittableType public override ModuleDesc Module { get; } public override string Name => "Boxed_" + ValueTypeRepresented.Name; + public override ReadOnlySpan U8Name => "Boxed_"u8.Append(ValueTypeRepresented.U8Name); public override string Namespace => ValueTypeRepresented.Namespace; + public override ReadOnlySpan U8Namespace => ValueTypeRepresented.U8Namespace; public override string DiagnosticName => "Boxed_" + ValueTypeRepresented.DiagnosticName; public override string DiagnosticNamespace => ValueTypeRepresented.DiagnosticNamespace; public override Instantiation Instantiation => ValueTypeRepresented.Instantiation; @@ -417,6 +419,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return _targetMethod.U8Name.Append("_Unbox"u8); + } + } + public override string DiagnosticName { get @@ -514,6 +524,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return _targetMethod.U8Name.Append("_Unbox"u8); + } + } + public override string DiagnosticName { get @@ -609,6 +627,8 @@ public ValueTypeInstanceMethodWithHiddenParameter(MethodDesc methodRepresented) public override TypeDesc OwningType => _methodRepresented.OwningType; public override string Name => _methodRepresented.Name; + + public override ReadOnlySpan U8Name => _methodRepresented.U8Name; public override string DiagnosticName => _methodRepresented.DiagnosticName; public override MethodSignature Signature diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs index ba9801349625c4..2d556824fe1c71 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs @@ -36,10 +36,12 @@ private sealed class CompilerGeneratedAssembly : ModuleDesc, IAssemblyDesc public override IAssemblyDesc Assembly => this; + public ReadOnlySpan Name => "System.Private.CompilerGenerated"u8; + public CompilerGeneratedAssembly(TypeSystemContext context) : base(context, null) { - _globalModuleType = new CompilerGeneratedType(this, ""); + _globalModuleType = new CompilerGeneratedType(this); } public override IEnumerable GetAllTypes() @@ -72,10 +74,9 @@ internal sealed partial class CompilerGeneratedType : MetadataType { private int _hashcode; - public CompilerGeneratedType(ModuleDesc module, string name) + public CompilerGeneratedType(ModuleDesc module) { Module = module; - Name = name; } public override TypeSystemContext Context @@ -88,14 +89,25 @@ public override TypeSystemContext Context public override string Name { - get; + get + { + return ""; + } + } + + public override ReadOnlySpan U8Name + { + get + { + return ""u8; + } } public override string DiagnosticName { get { - return Name; + return ""; } } @@ -107,6 +119,14 @@ public override string Namespace } } + public override ReadOnlySpan U8Namespace + { + get + { + return "Internal.CompilerGenerated"u8; + } + } + public override string DiagnosticNamespace { get diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs index b9c8f7aa3566bb..22942ac6b851e1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs @@ -203,6 +203,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return _targetMethod.U8Name; + } + } + public override string DiagnosticName { get @@ -308,6 +316,7 @@ public DefaultInterfaceMethodImplementationWithHiddenParameter(MethodDesc method public override TypeDesc OwningType => _owningType; public override string Name => _methodRepresented.Name; + public override ReadOnlySpan U8Name => _methodRepresented.U8Name; public override string DiagnosticName => _methodRepresented.DiagnosticName; public override MethodSignature Signature diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExternSymbolMappedField.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExternSymbolMappedField.cs index 18d655748937cd..d48156499d1b98 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExternSymbolMappedField.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExternSymbolMappedField.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using Internal.TypeSystem; namespace ILCompiler @@ -21,6 +22,8 @@ public ExternSymbolMappedField(TypeDesc fieldType, string symbolName) public override string Name => _symbolName; + public override ReadOnlySpan U8Name => System.Text.Encoding.UTF8.GetBytes(Name); + public string SymbolName => _symbolName; public override DefType OwningType => _fieldType.Context.SystemModule.GetGlobalModuleType(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs index 7ce683982fc729..64db8446ffb60f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs @@ -241,6 +241,7 @@ public InitializeMethod(CompilerTypeSystemContext context) public override TypeSystemContext Context => _context; public override TypeDesc OwningType => _context.GeneratedAssembly.GetGlobalModuleType(); public override string Name => "InitializeReachabilityInfo"; + public override ReadOnlySpan U8Name => "InitializeReachabilityInfo"u8; public override string DiagnosticName => "InitializeReachabilityInfo"; public override MethodIL EmitIL() diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs index 5a84855650f394..b62a383915b085 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs @@ -33,6 +33,7 @@ public ThrowingMethodStub(TypeDesc owningType, TypeDesc typeMapGroup, bool exter public TypeSystemException Exception { get; } public override string Name { get; } + public override ReadOnlySpan U8Name => System.Text.Encoding.UTF8.GetBytes(Name); public override MethodIL EmitIL() { return TypeSystemThrowingILEmitter.EmitIL(this, Exception); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs index 160a06bb441a2d..e395e2f2ddc297 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using Internal.TypeSystem; @@ -47,6 +48,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "NativeLibraryStartup"u8; + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs index 3dcbb4f27cc09c..ebec00cc8a572a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs @@ -53,6 +53,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "StartupCodeMain"u8; + } + } + public override string DiagnosticName { get @@ -238,6 +246,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return "MainMethodWrapper"u8; + } + } + public override string DiagnosticName { get diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs index 4c00e5e01a1e5e..1f41af63475e20 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs @@ -620,6 +620,8 @@ private sealed class CustomCanonResolver : IModuleResolver { private sealed class CanonModule : ModuleDesc, IAssemblyDesc { + public ReadOnlySpan Name => "System.Private.Canon"u8; + public CanonModule(TypeSystemContext wrappedContext) : base(wrappedContext, null) { } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs index b23806c7072f86..8379cb230735b0 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs @@ -220,6 +220,14 @@ public override string Name } } + public override ReadOnlySpan U8Name + { + get + { + return System.Text.Encoding.UTF8.GetBytes(Name); + } + } + public override TypeDesc OwningType { get diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs index 0b3b788c49c48c..b6ada5a0e49e8a 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs @@ -49,6 +49,8 @@ public TypeRefTypeSystemType GetOrAddType(string nameSpace, string name) public override IAssemblyDesc Assembly => this; + public ReadOnlySpan Name => System.Text.Encoding.UTF8.GetBytes(_name.Name); + public override IEnumerable GetAllTypes() => _types; public override MetadataType GetGlobalModuleType() => throw new NotImplementedException(); public AssemblyNameInfo GetName() => _name; diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs index 2f600a506325c1..f0e56ece0f14db 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs @@ -18,22 +18,22 @@ class TypeRefTypeSystemType : MetadataType List _fields = new List(); bool? _isValueType; Instantiation? _instantiation; - string _name; - string _namespace; + byte[] _name; + byte[] _namespace; Dictionary _nestedType; TypeRefTypeSystemType _containingType; public TypeRefTypeSystemType(string nameSpace, string name, TypeRefTypeSystemModule module) { - _namespace = nameSpace; - _name = name; + _namespace = string.IsNullOrEmpty(nameSpace) ? [] : Encoding.UTF8.GetBytes(nameSpace); + _name = string.IsNullOrEmpty(name) ? [] : Encoding.UTF8.GetBytes(name); _module = module; } private TypeRefTypeSystemType(string nameSpace, string name, TypeRefTypeSystemType containingType, TypeRefTypeSystemModule module) { - _namespace = nameSpace; - _name = name; + _namespace = string.IsNullOrEmpty(nameSpace) ? [] : Encoding.UTF8.GetBytes(nameSpace); + _name = string.IsNullOrEmpty(name) ? [] : Encoding.UTF8.GetBytes(name); _module = module; _containingType = containingType; } @@ -140,9 +140,13 @@ public FieldDesc GetOrAddField(string name, TypeDesc fieldType, EmbeddedSignatur public override PInvokeStringFormat PInvokeStringFormat => throw new NotImplementedException(); - public override string Name => _name; + public override string Name => Encoding.UTF8.GetString(_name); - public override string Namespace => _namespace; + public override ReadOnlySpan U8Name => _name; + + public override string Namespace => Encoding.UTF8.GetString(_namespace); + + public override ReadOnlySpan U8Namespace => _namespace; public override bool IsExplicitLayout => throw new NotImplementedException(); From 0d9c6f93d57970a2a6b74a33808c241ee8c3c994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 4 Sep 2025 11:31:08 +0200 Subject: [PATCH 02/19] Switch VersionResilientHashCode to Utf8 --- .../VersionResilientHashCode.CoreCLR.cs | 3 +++ .../ReadyToRun/AttributePresenceFilterNode.cs | 2 +- .../ReadyToRun/TypesTableNode.cs | 17 +++++++++++++---- .../VersionResilientHashCode.ReadyToRun.cs | 8 ++++---- .../src/Internal/VersionResilientHashCode.cs | 12 +++++------- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/Internal/VersionResilientHashCode.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/Internal/VersionResilientHashCode.CoreCLR.cs index 5ecf25c5bc7a64..226deaa7a75a10 100644 --- a/src/coreclr/System.Private.CoreLib/src/Internal/VersionResilientHashCode.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/Internal/VersionResilientHashCode.CoreCLR.cs @@ -19,6 +19,9 @@ internal static partial class VersionResilientHashCode public static int TypeHashCode(RuntimeType type) => TypeHashCode(new QCallTypeHandle(ref type)); + private static int NameHashCode(string s1, string s2) + => NameHashCode(System.Text.Encoding.UTF8.GetBytes(s1), System.Text.Encoding.UTF8.GetBytes(s2)); + /// /// CoreCLR 1-parameter GetVersionResilientTypeHashCode /// diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs index 03d26965d4a586..f6f85fb14fe7df 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/AttributePresenceFilterNode.cs @@ -335,7 +335,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { string name = customAttributeEntry.TypeNamespace + "." + customAttributeEntry.TypeName; // This hashing algorithm MUST match exactly the logic in NativeCuckooFilter - int hashOfAttribute = VersionResilientHashCode.NameHashCode(name); + int hashOfAttribute = VersionResilientHashCode.NameHashCode(System.Text.Encoding.UTF8.GetBytes(name)); uint hash = unchecked((uint)VersionResilientHashCode.CombineTwoValuesIntoHash((uint)hashOfAttribute, (uint)customAttributeEntry.Parent)); ushort fingerprint = (ushort)(hash >> 16); if (fingerprint == 0) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypesTableNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypesTableNode.cs index 3acb98d21b22d6..a8f9875d1a6453 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypesTableNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypesTableNode.cs @@ -44,8 +44,8 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) for (; ; ) { TypeDefinition defType = defTypeInfo.MetadataReader.GetTypeDefinition(defTypeHandle); - string namespaceName = defTypeInfo.MetadataReader.GetString(defType.Namespace); - string typeName = defTypeInfo.MetadataReader.GetString(defType.Name); + ReadOnlySpan namespaceName = defTypeInfo.MetadataReader.GetStringBytes(defType.Namespace); + ReadOnlySpan typeName = defTypeInfo.MetadataReader.GetStringBytes(defType.Name); hashCode ^= VersionResilientHashCode.NameHashCode(namespaceName, typeName); if (!defType.Attributes.IsNested()) { @@ -63,8 +63,8 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) for (; ;) { ExportedType expType = expTypeInfo.MetadataReader.GetExportedType(expTypeHandle); - string namespaceName = expTypeInfo.MetadataReader.GetString(expType.Namespace); - string typeName = expTypeInfo.MetadataReader.GetString(expType.Name); + ReadOnlySpan namespaceName = expTypeInfo.MetadataReader.GetStringBytes(expType.Namespace); + ReadOnlySpan typeName = expTypeInfo.MetadataReader.GetStringBytes(expType.Name); hashCode ^= VersionResilientHashCode.NameHashCode(namespaceName, typeName); if (expType.Implementation.Kind != HandleKind.ExportedType) { @@ -88,4 +88,13 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) public override int ClassCode => -944318825; } + + file static class MetadataReaderExtensions + { + public static unsafe ReadOnlySpan GetStringBytes(this MetadataReader reader, StringHandle handle) + { + BlobReader blob = reader.GetBlobReader(handle); + return new ReadOnlySpan(blob.StartPointer, blob.Length); + } + } } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs index 154f369dbfea36..d301233199fb9e 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs @@ -24,7 +24,7 @@ public static int TypeTableHashCode(DefType type) int hashcode = 0; do { - hashcode ^= NameHashCode(type.Namespace, type.Name); + hashcode ^= NameHashCode(type.U8Namespace, type.U8Name); type = type.ContainingType; } while (type != null); @@ -39,7 +39,7 @@ public static int TypeHashCode(TypeDesc type) { if (type.GetTypeDefinition() is DefType defType) { - int hashcode = NameHashCode(defType.Namespace, defType.Name); + int hashcode = NameHashCode(defType.U8Namespace, defType.U8Name); DefType containingType = defType.ContainingType; if (containingType != null) { @@ -95,7 +95,7 @@ private static int GenericInstanceHashCode(int hashcode, Instantiation instantia public static int MethodHashCode(MethodDesc method) { int hashCode = TypeHashCode(method.OwningType); - int methodNameHashCode = NameHashCode(method.Name); + int methodNameHashCode = NameHashCode(method.U8Name); // Todo: Add signature to hash. if (method.HasInstantiation && !method.IsGenericMethodDefinition) @@ -114,7 +114,7 @@ public static int ModuleNameHashCode(ModuleDesc module) { IAssemblyDesc assembly = module.Assembly; Debug.Assert(assembly == module); - return NameHashCode(assembly.GetName().Name); + return NameHashCode(assembly.Name); } } } diff --git a/src/libraries/Common/src/Internal/VersionResilientHashCode.cs b/src/libraries/Common/src/Internal/VersionResilientHashCode.cs index 58edb488ee99e9..c87ec08d19f3c6 100644 --- a/src/libraries/Common/src/Internal/VersionResilientHashCode.cs +++ b/src/libraries/Common/src/Internal/VersionResilientHashCode.cs @@ -16,10 +16,10 @@ internal static partial class VersionResilientHashCode /// /// CoreCLR ComputeNameHashCode /// - /// Name string to hash - public static int NameHashCode(string name) + /// Name string to hash + public static int NameHashCode(ReadOnlySpan src) { - if (string.IsNullOrEmpty(name)) + if (src.Length == 0) { return 0; } @@ -27,8 +27,6 @@ public static int NameHashCode(string name) int hash1 = 0x6DA3B944; int hash2 = 0; - // DIFFERENT FROM NATIVEAOT: We hash UTF-8 bytes here, while NativeAOT hashes UTF-16 characters. - byte[] src = Encoding.UTF8.GetBytes(name); for (int i = 0; i < src.Length; i += 2) { hash1 = unchecked(hash1 + RotateLeft(hash1, 5)) ^ (int)unchecked((sbyte)src[i]); @@ -57,7 +55,7 @@ public static int NameHashCode(string name) /// /// Namespace name /// Type name within the namespace - public static int NameHashCode(string namespacePart, string namePart) + public static int NameHashCode(ReadOnlySpan namespacePart, ReadOnlySpan namePart) { return NameHashCode(namespacePart) ^ NameHashCode(namePart); } @@ -84,7 +82,7 @@ private static int ArrayTypeHashCode(int elementTypeHashcode, int rank) int hashCode = unchecked((int)0xd5313556 + rank); if (rank == 1) { - Debug.Assert(hashCode == NameHashCode("System.Array`1")); + Debug.Assert(hashCode == NameHashCode("System.Array`1"u8)); } hashCode = unchecked(hashCode + RotateLeft(hashCode, 13)) ^ elementTypeHashcode; return unchecked(hashCode + RotateLeft(hashCode, 15)); From 33d62643d7f06657b18d91868f726641cdbb89dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 5 Sep 2025 01:46:46 +0200 Subject: [PATCH 03/19] Switch native AOT to this --- ...ronment.ConstructedGenericMethodsLookup.cs | 2 +- ...vironment.ConstructedGenericTypesLookup.cs | 4 +- ...peLoaderEnvironment.LdTokenResultLookup.cs | 2 +- .../TypeLoaderEnvironment.Metadata.cs | 6 +- .../TypeSystem/TypeSystemContext.Runtime.cs | 4 +- .../src/System.Private.TypeLoader.csproj | 6 + .../MetadataTypeHashingAlgorithms.cs | 62 ++--- .../NativeFormat/NativeMetadataReader.cs | 2 +- .../Common/TypeSystem/Canon/CanonTypes.cs | 4 +- .../Common/TypeSystem/Common/ArrayType.cs | 3 +- .../Common/TypeSystem/Common/ByRefType.cs | 2 +- .../TypeSystem/Common/InstantiatedMethod.cs | 2 +- .../TypeSystem/Common/InstantiatedType.cs | 14 +- .../Common/TypeSystem/Common/Instantiation.cs | 11 +- .../Common/TypeSystem/Common/MethodDesc.cs | 2 +- .../Common/TypeSystem/Common/PointerType.cs | 2 +- .../Common/TypeHashingAlgorithms.cs | 152 ----------- .../TypeSystem/Common/TypeSystemContext.cs | 14 +- .../VersionResilientHashCode.TypeSystem.cs | 39 +++ .../tools/Common/TypeSystem/Ecma/EcmaType.cs | 18 +- .../TypeSystem/Interop/IL/InlineArrayType.cs | 18 +- .../TypeSystem/Interop/IL/NativeStructType.cs | 18 +- .../Interop/IL/PInvokeDelegateWrapper.cs | 18 +- .../TypeSystemContext.RuntimeDetermined.cs | 2 +- .../ILVerification/ILVerification.projitems | 6 + .../CompilerTypeSystemContext.BoxedTypes.cs | 11 +- ...ilerTypeSystemContext.GeneratedAssembly.cs | 10 +- .../ILCompiler.Compiler.csproj | 3 + .../ReadyToRun/ArgIterator.cs | 3 +- .../VersionResilientHashCode.ReadyToRun.cs | 15 -- .../ILCompiler.ReadyToRun.csproj | 3 +- .../CoreTestAssembly/Hashcode.cs | 25 -- .../HashcodeTests.cs | 248 ------------------ .../ILCompiler.TypeSystem.Tests.csproj | 1 - .../ILCompiler.TypeSystem.csproj | 8 +- .../src/Internal/VersionResilientHashCode.cs | 85 +++++- 36 files changed, 228 insertions(+), 597 deletions(-) create mode 100644 src/coreclr/tools/Common/TypeSystem/Common/VersionResilientHashCode.TypeSystem.cs delete mode 100644 src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CoreTestAssembly/Hashcode.cs delete mode 100644 src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/HashcodeTests.cs diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericMethodsLookup.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericMethodsLookup.cs index fe1c59215b9be0..e8e406c8afe825 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericMethodsLookup.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericMethodsLookup.cs @@ -28,7 +28,7 @@ public override int GetHashCode() { if (!_hashCode.HasValue) { - _hashCode = _declaringTypeHandle.GetHashCode() ^ TypeHashingAlgorithms.ComputeGenericInstanceHashCode(TypeHashingAlgorithms.ComputeNameHashCode(_methodNameAndSignature.GetName()), _genericMethodArgumentHandles); + _hashCode = _declaringTypeHandle.GetHashCode() ^ VersionResilientHashCode.GenericInstanceHashCode(VersionResilientHashCode.NameHashCode(_methodNameAndSignature.Name), _genericMethodArgumentHandles); } return _hashCode.Value; } diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericTypesLookup.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericTypesLookup.cs index 0c9adf60c80337..78b6e4c6382488 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericTypesLookup.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericTypesLookup.cs @@ -30,7 +30,7 @@ public override int GetHashCode() { if (!_hashCode.HasValue) { - _hashCode = TypeHashingAlgorithms.ComputeGenericInstanceHashCode(_genericTypeDefinitionHandle.GetHashCode(), _genericTypeArgumentHandles); + _hashCode = VersionResilientHashCode.GenericInstanceHashCode(_genericTypeDefinitionHandle.GetHashCode(), _genericTypeArgumentHandles); } return _hashCode.Value; } @@ -114,7 +114,7 @@ internal GenericTypeLookupData(RuntimeTypeHandle genericTypeDefinitionHandle, Ru internal int LookupHashCode() { - return _typeToLookup != null ? _typeToLookup.GetHashCode() : TypeHashingAlgorithms.ComputeGenericInstanceHashCode(_genericTypeDefinitionHandle.GetHashCode(), _genericTypeArgumentHandles); + return _typeToLookup != null ? _typeToLookup.GetHashCode() : VersionResilientHashCode.GenericInstanceHashCode(_genericTypeDefinitionHandle.GetHashCode(), _genericTypeArgumentHandles); } internal bool MatchParsedEntry(RuntimeTypeHandle tentativeType) diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.LdTokenResultLookup.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.LdTokenResultLookup.cs index f28b55e5b0d6dc..da1f944b2fa99b 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.LdTokenResultLookup.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.LdTokenResultLookup.cs @@ -102,7 +102,7 @@ public bool Equals(RuntimeMethodHandleKey other) public override int GetHashCode() => _handle.GetHashCode() ^ (_genericArgs == null ? _declaringType.GetHashCode() - : TypeHashingAlgorithms.ComputeGenericInstanceHashCode(_declaringType.GetHashCode(), _genericArgs)); + : VersionResilientHashCode.GenericInstanceHashCode(_declaringType.GetHashCode(), _genericArgs)); } private LowLevelDictionary _runtimeFieldHandles = new LowLevelDictionary(); diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.Metadata.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.Metadata.cs index 0545b31ada272c..e65b6230d845fa 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.Metadata.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.Metadata.cs @@ -202,7 +202,7 @@ public static unsafe bool TryGetArrayTypeForNonDynamicElementType(RuntimeTypeHan arrayTypeHandle = default(RuntimeTypeHandle); Debug.Assert(isMdArray || rank == -1); - int arrayHashcode = TypeHashingAlgorithms.ComputeArrayTypeHashCode(elementTypeHandle.GetHashCode(), rank); + int arrayHashcode = VersionResilientHashCode.ArrayTypeHashCode(elementTypeHandle.GetHashCode(), rank == -1 ? 1 : rank); // Note: ReflectionMapBlob.ArrayMap may not exist in the module that contains the element type. // So we must enumerate all loaded modules in order to find ArrayMap and the array type for @@ -239,13 +239,13 @@ public static unsafe bool TryGetArrayTypeForNonDynamicElementType(RuntimeTypeHan public static unsafe bool TryGetByRefTypeForNonDynamicElementType(RuntimeTypeHandle elementTypeHandle, out RuntimeTypeHandle pointerTypeHandle) { - int byRefHashcode = TypeHashingAlgorithms.ComputeByrefTypeHashCode(elementTypeHandle.GetHashCode()); + int byRefHashcode = VersionResilientHashCode.ByrefTypeHashCode(elementTypeHandle.GetHashCode()); return TryGetParameterizedTypeForNonDynamicElementType(elementTypeHandle, byRefHashcode, ReflectionMapBlob.ByRefTypeMap, out pointerTypeHandle); } public static unsafe bool TryGetPointerTypeForNonDynamicElementType(RuntimeTypeHandle elementTypeHandle, out RuntimeTypeHandle pointerTypeHandle) { - int pointerHashcode = TypeHashingAlgorithms.ComputePointerTypeHashCode(elementTypeHandle.GetHashCode()); + int pointerHashcode = VersionResilientHashCode.PointerTypeHashCode(elementTypeHandle.GetHashCode()); return TryGetParameterizedTypeForNonDynamicElementType(elementTypeHandle, pointerHashcode, ReflectionMapBlob.PointerTypeMap, out pointerTypeHandle); } diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/TypeSystemContext.Runtime.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/TypeSystemContext.Runtime.cs index 2cc527b21f4d31..41182e02068c4e 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/TypeSystemContext.Runtime.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/TypeSystemContext.Runtime.cs @@ -287,7 +287,7 @@ public GenericTypeInstanceKey(DefType typeDefinition, Instantiation instantiatio _typeDefinition = typeDefinition; _instantiation = instantiation; - _hashCode = instantiation.ComputeGenericInstanceHashCode(typeDefinition.GetHashCode()); + _hashCode = VersionResilientHashCode.GenericInstanceHashCode(typeDefinition.GetHashCode(), _instantiation); } public bool Equals(GenericTypeInstanceKey other) @@ -331,7 +331,7 @@ public RuntimeMethodKey(bool unboxingStub, DefType owningType, MethodNameAndSign _owningType = owningType; _methodNameAndSignature = nameAndSignature; - _hashCode = TypeHashingAlgorithms.ComputeMethodHashCode(owningType.GetHashCode(), TypeHashingAlgorithms.ComputeNameHashCode(nameAndSignature.GetName())); + _hashCode = owningType.GetHashCode() ^ VersionResilientHashCode.NameHashCode(nameAndSignature.Name); } public class RuntimeMethodKeyHashtable : LockFreeReaderHashtable diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/System.Private.TypeLoader.csproj b/src/coreclr/nativeaot/System.Private.TypeLoader/src/System.Private.TypeLoader.csproj index b14c69d765daf6..67540af5894b7c 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/System.Private.TypeLoader.csproj +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/System.Private.TypeLoader.csproj @@ -23,6 +23,9 @@ MethodTable.cs + + TypeSystem\Common\VersionResilientHashCode.cs + MethodTable.Constants.cs @@ -201,6 +204,9 @@ TypeNameFormatter.cs + + TypeSystem\Common\VersionResilientHashCode.TypeSystem.cs + Internal\TypeSystem\VirtualMethodAlgorithm.cs diff --git a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MetadataTypeHashingAlgorithms.cs b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MetadataTypeHashingAlgorithms.cs index 9c114859e2498c..b33671b5de4f8c 100644 --- a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MetadataTypeHashingAlgorithms.cs +++ b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MetadataTypeHashingAlgorithms.cs @@ -3,7 +3,7 @@ using System; using Debug = System.Diagnostics.Debug; -using HashCodeBuilder = Internal.NativeFormat.TypeHashingAlgorithms.HashCodeBuilder; +using HashCodeBuilder = Internal.VersionResilientHashCode.HashCodeBuilder; using TypeAttributes = System.Reflection.TypeAttributes; using TypeHashingAlgorithms = Internal.NativeFormat.TypeHashingAlgorithms; @@ -11,7 +11,7 @@ namespace Internal.Metadata.NativeFormat { internal static class MetadataTypeHashingAlgorithms { - private static void AppendNamespaceHashCode(ref HashCodeBuilder builder, NamespaceDefinitionHandle namespaceDefHandle, MetadataReader reader) + private static void AppendNamespaceHashCode(ref HashCodeBuilder builder, NamespaceDefinitionHandle namespaceDefHandle, MetadataReader reader, bool appendDot) { NamespaceDefinition namespaceDefinition = reader.GetNamespaceDefinition(namespaceDefHandle); @@ -19,10 +19,11 @@ private static void AppendNamespaceHashCode(ref HashCodeBuilder builder, Namespa HandleType parentHandleType = parentHandle.HandleType; if (parentHandleType == HandleType.NamespaceDefinition) { - AppendNamespaceHashCode(ref builder, parentHandle.ToNamespaceDefinitionHandle(reader), reader); - string namespaceNamePart = reader.GetString(namespaceDefinition.Name); + AppendNamespaceHashCode(ref builder, parentHandle.ToNamespaceDefinitionHandle(reader), reader, appendDot: true); + ReadOnlySpan namespaceNamePart = reader.ReadStringAsBytes(namespaceDefinition.Name); builder.Append(namespaceNamePart); - builder.Append("."); + if (appendDot) + builder.Append("."u8); } else { @@ -31,7 +32,7 @@ private static void AppendNamespaceHashCode(ref HashCodeBuilder builder, Namespa } } - private static void AppendNamespaceHashCode(ref HashCodeBuilder builder, NamespaceReferenceHandle namespaceRefHandle, MetadataReader reader) + private static void AppendNamespaceHashCode(ref HashCodeBuilder builder, NamespaceReferenceHandle namespaceRefHandle, MetadataReader reader, bool appendDot) { NamespaceReference namespaceReference = reader.GetNamespaceReference(namespaceRefHandle); @@ -39,10 +40,11 @@ private static void AppendNamespaceHashCode(ref HashCodeBuilder builder, Namespa HandleType parentHandleType = parentHandle.HandleType; if (parentHandleType == HandleType.NamespaceReference) { - AppendNamespaceHashCode(ref builder, parentHandle.ToNamespaceReferenceHandle(reader), reader); - string namespaceNamePart = reader.GetString(namespaceReference.Name); + AppendNamespaceHashCode(ref builder, parentHandle.ToNamespaceReferenceHandle(reader), reader, appendDot: true); + ReadOnlySpan namespaceNamePart = reader.ReadStringAsBytes(namespaceReference.Name); builder.Append(namespaceNamePart); - builder.Append("."); + if (appendDot) + builder.Append("."u8); } else { @@ -53,50 +55,40 @@ private static void AppendNamespaceHashCode(ref HashCodeBuilder builder, Namespa public static int ComputeHashCode(this TypeDefinitionHandle typeDefHandle, MetadataReader reader) { - HashCodeBuilder builder = new HashCodeBuilder(""); - TypeDefinition typeDef = reader.GetTypeDefinition(typeDefHandle); - bool isNested = typeDef.Flags.IsNested(); - if (!isNested) - { - AppendNamespaceHashCode(ref builder, typeDef.NamespaceDefinition, reader); - } - string typeName = reader.GetString(typeDef.Name); - builder.Append(typeName); + HashCodeBuilder builder = new HashCodeBuilder(""u8); + AppendNamespaceHashCode(ref builder, typeDef.NamespaceDefinition, reader, appendDot: false); + int nameHashCode = VersionResilientHashCode.NameHashCode(reader.ReadStringAsBytes(typeDef.Name)); + + int hashCode = VersionResilientHashCode.NameHashCode(builder.ToHashCode(), nameHashCode); - if (isNested) + if (typeDef.Flags.IsNested()) { int enclosingTypeHashCode = typeDef.EnclosingType.ComputeHashCode(reader); - return TypeHashingAlgorithms.ComputeNestedTypeHashCode(enclosingTypeHashCode, builder.ToHashCode()); + return VersionResilientHashCode.NestedTypeHashCode(enclosingTypeHashCode, hashCode); } - return builder.ToHashCode(); + return hashCode; } public static int ComputeHashCode(this TypeReferenceHandle typeRefHandle, MetadataReader reader) { - HashCodeBuilder builder = new HashCodeBuilder(""); - TypeReference typeRef = reader.GetTypeReference(typeRefHandle); - HandleType parentHandleType = typeRef.ParentNamespaceOrType.HandleType; - bool isNested = parentHandleType == HandleType.TypeReference; - if (!isNested) - { - Debug.Assert(parentHandleType == HandleType.NamespaceReference); - AppendNamespaceHashCode(ref builder, typeRef.ParentNamespaceOrType.ToNamespaceReferenceHandle(reader), reader); - } - string typeName = reader.GetString(typeRef.TypeName); - builder.Append(typeName); + HashCodeBuilder builder = new HashCodeBuilder(""u8); + AppendNamespaceHashCode(ref builder, typeRef.ParentNamespaceOrType.ToNamespaceReferenceHandle(reader), reader, appendDot: false); + int nameHashCode = VersionResilientHashCode.NameHashCode(reader.ReadStringAsBytes(typeRef.TypeName)); + + int hashCode = VersionResilientHashCode.NameHashCode(builder.ToHashCode(), nameHashCode); - if (isNested) + if (typeRef.ParentNamespaceOrType.HandleType == HandleType.TypeReference) { int enclosingTypeHashCode = typeRef.ParentNamespaceOrType.ToTypeReferenceHandle(reader).ComputeHashCode(reader); - return TypeHashingAlgorithms.ComputeNestedTypeHashCode(enclosingTypeHashCode, builder.ToHashCode()); + return VersionResilientHashCode.NestedTypeHashCode(enclosingTypeHashCode, hashCode); } - return builder.ToHashCode(); + return hashCode; } // This mask is the fastest way to check if a type is nested from its flags, diff --git a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeMetadataReader.cs b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeMetadataReader.cs index 53bb71d1c7d5d6..18fd50faac631d 100644 --- a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeMetadataReader.cs +++ b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeMetadataReader.cs @@ -221,7 +221,7 @@ internal bool StringEquals(ConstantStringValueHandle handle, string value) return _streamReader.StringEquals((uint)handle.Offset, value); } - internal ReadOnlySpan ReadStringAsBytes(ConstantStringValueHandle handle) + public ReadOnlySpan ReadStringAsBytes(ConstantStringValueHandle handle) { if (handle.IsNil) { diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs index 85c0f6f8dd4317..01fc7abdc5de1d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs @@ -147,7 +147,7 @@ public override int GetHashCode() { if (_hashcode == 0) { - _hashcode = TypeHashingAlgorithms.ComputeNameHashCode("System.__Canon"); + _hashcode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); } return _hashcode; @@ -245,7 +245,7 @@ public override int GetHashCode() { if (_hashcode == 0) { - _hashcode = TypeHashingAlgorithms.ComputeNameHashCode("System.__UniversalCanon"); + _hashcode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); } return _hashcode; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs b/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs index 70757a52919510..d80d6a7df16eff 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs @@ -23,8 +23,7 @@ internal ArrayType(TypeDesc elementType, int rank) public override int GetHashCode() { - // ComputeArrayTypeHashCode expects -1 for an SzArray - return Internal.NativeFormat.TypeHashingAlgorithms.ComputeArrayTypeHashCode(this.ElementType.GetHashCode(), _rank); + return VersionResilientHashCode.ArrayTypeHashCode(this.ElementType.GetHashCode(), Rank); } public override DefType BaseType diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ByRefType.cs b/src/coreclr/tools/Common/TypeSystem/Common/ByRefType.cs index 4bb3e351a0168e..0f6c8a8527d8df 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ByRefType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ByRefType.cs @@ -15,7 +15,7 @@ internal ByRefType(TypeDesc parameter) public override int GetHashCode() { - return Internal.NativeFormat.TypeHashingAlgorithms.ComputeByrefTypeHashCode(this.ParameterType.GetHashCode()); + return VersionResilientHashCode.ByrefTypeHashCode(this.ParameterType.GetHashCode()); } public override TypeDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs index 8b18c12d0dfd0f..396ef9ba8d6022 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs @@ -34,7 +34,7 @@ internal InstantiatedMethod(MethodDesc methodDef, Instantiation instantiation, i protected override int ComputeHashCode() { - return TypeHashingAlgorithms.ComputeMethodHashCode(OwningType.GetHashCode(), Instantiation.ComputeGenericInstanceHashCode(TypeHashingAlgorithms.ComputeNameHashCode(Name))); + return OwningType.GetHashCode() ^ VersionResilientHashCode.GenericInstanceHashCode(VersionResilientHashCode.NameHashCode(U8Name), Instantiation); } public override TypeSystemContext Context diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs index a779d7777ac4a8..82361007da2698 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs @@ -29,11 +29,19 @@ internal InstantiatedType(MetadataType typeDef, Instantiation instantiation) private int _hashCode; + private int InitializeHashCode() + { + return _hashCode = VersionResilientHashCode.GenericInstanceHashCode(_typeDef.GetHashCode(), Instantiation); + } + public override int GetHashCode() { - if (_hashCode == 0) - _hashCode = _instantiation.ComputeGenericInstanceHashCode(_typeDef.GetHashCode()); - return _hashCode; + if (_hashCode != 0) + { + return _hashCode; + } + + return InitializeHashCode(); } public override TypeSystemContext Context diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Instantiation.cs b/src/coreclr/tools/Common/TypeSystem/Common/Instantiation.cs index d3b0fdd5686e99..7d798253f59192 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Instantiation.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Instantiation.cs @@ -50,15 +50,6 @@ public bool IsNull } } - /// - /// Combines the given generic definition's hash code with the hashes - /// of the generic parameters in this instantiation - /// - public int ComputeGenericInstanceHashCode(int genericDefinitionHashCode) - { - return Internal.NativeFormat.TypeHashingAlgorithms.ComputeGenericInstanceHashCode(genericDefinitionHashCode, _genericParameters); - } - public static readonly Instantiation Empty = new Instantiation(TypeDesc.EmptyTypes); public Enumerator GetEnumerator() @@ -132,6 +123,6 @@ public override bool Equals(object o) return Equals(inst); return false; } - public override int GetHashCode() => ComputeGenericInstanceHashCode(1); + public override int GetHashCode() => VersionResilientHashCode.GenericInstanceHashCode(1, this); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs index 1e42f8803c56cd..d4e97bf64df521 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs @@ -496,7 +496,7 @@ private int AcquireHashCode() /// protected virtual int ComputeHashCode() { - return TypeHashingAlgorithms.ComputeMethodHashCode(OwningType.GetHashCode(), TypeHashingAlgorithms.ComputeNameHashCode(Name)); + return OwningType.GetHashCode() ^ VersionResilientHashCode.NameHashCode(U8Name); } public override bool Equals(object o) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/PointerType.cs b/src/coreclr/tools/Common/TypeSystem/Common/PointerType.cs index 28c3cf31ea00a6..ad71497c3a655b 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/PointerType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/PointerType.cs @@ -15,7 +15,7 @@ internal PointerType(TypeDesc parameterType) public override int GetHashCode() { - return Internal.NativeFormat.TypeHashingAlgorithms.ComputePointerTypeHashCode(this.ParameterType.GetHashCode()); + return VersionResilientHashCode.PointerTypeHashCode(this.ParameterType.GetHashCode()); } public override TypeDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs index 04d2857a2b0014..3a544439b2c408 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeHashingAlgorithms.cs @@ -17,52 +17,6 @@ namespace Internal.NativeFormat #endif public static class TypeHashingAlgorithms { - public struct HashCodeBuilder - { - private int _hash1; - private int _hash2; - private int _numCharactersHashed; - - public HashCodeBuilder(string seed) - { - _hash1 = 0x6DA3B944; - _hash2 = 0; - _numCharactersHashed = 0; - - Append(seed); - } - - public void Append(string src) - { - if (src.Length == 0) - return; - - int startIndex = 0; - if ((_numCharactersHashed & 1) == 1) - { - _hash2 = (_hash2 + _rotl(_hash2, 5)) ^ src[0]; - startIndex = 1; - } - - for (int i = startIndex; i < src.Length; i += 2) - { - _hash1 = (_hash1 + _rotl(_hash1, 5)) ^ src[i]; - if ((i + 1) < src.Length) - _hash2 = (_hash2 + _rotl(_hash2, 5)) ^ src[i + 1]; - } - - _numCharactersHashed += src.Length; - } - - public int ToHashCode() - { - int hash1 = _hash1 + _rotl(_hash1, 8); - int hash2 = _hash2 + _rotl(_hash2, 8); - - return hash1 ^ hash2; - } - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int _rotl(int value, int shift) { @@ -117,99 +71,6 @@ public static unsafe int ComputeASCIINameHashCode(byte* data, int length, out bo return hash1 ^ hash2; } - // This function may be needed in a portion of the codebase which is too low level to use - // globalization, ergo, we cannot call ToString on the integer. - private static string IntToString(int arg) - { - // This IntToString function is only expected to be used for MDArrayRanks, and therefore is only for positive numbers - Debug.Assert(arg > 0); - StringBuilder sb = new StringBuilder(1); - - while (arg != 0) - { - sb.Append((char)('0' + (arg % 10))); - arg /= 10; - } - - // Reverse the string - int sbLen = sb.Length; - int pivot = sbLen / 2; - for (int i = 0; i < pivot; i++) - { - int iToSwapWith = sbLen - i - 1; - char temp = sb[i]; - sb[i] = sb[iToSwapWith]; - sb[iToSwapWith] = temp; - } - - return sb.ToString(); - } - - public static int ComputeArrayTypeHashCode(int elementTypeHashCode, int rank) - { - // Arrays are treated as generic types in some parts of our system. The array hashcodes are - // carefully crafted to be the same as the hashcodes of their implementation generic types. - - int hashCode; - if (rank == -1) - { - hashCode = unchecked((int)0xd5313557u); - Debug.Assert(hashCode == ComputeNameHashCode("System.Array`1")); - } - else - { - hashCode = ComputeNameHashCode("System.MDArrayRank" + IntToString(rank) + "`1"); - } - - hashCode = (hashCode + _rotl(hashCode, 13)) ^ elementTypeHashCode; - return (hashCode + _rotl(hashCode, 15)); - } - - public static int ComputeArrayTypeHashCode(T elementType, int rank) - { - return ComputeArrayTypeHashCode(elementType.GetHashCode(), rank); - } - - - public static int ComputePointerTypeHashCode(int pointeeTypeHashCode) - { - return (pointeeTypeHashCode + _rotl(pointeeTypeHashCode, 5)) ^ 0x12D0; - } - - public static int ComputePointerTypeHashCode(T pointeeType) - { - return ComputePointerTypeHashCode(pointeeType.GetHashCode()); - } - - - public static int ComputeByrefTypeHashCode(int parameterTypeHashCode) - { - return (parameterTypeHashCode + _rotl(parameterTypeHashCode, 7)) ^ 0x4C85; - } - - public static int ComputeByrefTypeHashCode(T parameterType) - { - return ComputeByrefTypeHashCode(parameterType.GetHashCode()); - } - - - public static int ComputeNestedTypeHashCode(int enclosingTypeHashCode, int nestedTypeNameHash) - { - return (enclosingTypeHashCode + _rotl(enclosingTypeHashCode, 11)) ^ nestedTypeNameHash; - } - - - public static int ComputeGenericInstanceHashCode(int genericDefinitionHashCode, ARG[] genericTypeArguments) - { - int hashcode = genericDefinitionHashCode; - for (int i = 0; i < genericTypeArguments.Length; i++) - { - int argumentHashCode = genericTypeArguments[i].GetHashCode(); - hashcode = (hashcode + _rotl(hashcode, 13)) ^ argumentHashCode; - } - return (hashcode + _rotl(hashcode, 15)); - } - public static int ComputeMethodSignatureHashCode(int returnTypeHashCode, ARG[] parameters) { // We're not taking calling conventions into consideration here mostly because there's no @@ -224,19 +85,6 @@ public static int ComputeMethodSignatureHashCode(int returnTypeHashCode, AR return (hashcode + _rotl(hashcode, 15)); } - /// - /// Produce a hashcode for a specific method - /// - /// HashCode of the type that owns the method - /// HashCode of either the name of the method (for non-generic methods) or the GenericInstanceHashCode of the name+generic arguments of the method. - /// - public static int ComputeMethodHashCode(int typeHashCode, int nameOrNameAndGenericArgumentsHashCode) - { - // TODO! This hash combining function isn't good, but it matches logic used in the past - // consider changing to a better combining function once all uses use this function - return typeHashCode ^ nameOrNameAndGenericArgumentsHashCode; - } - /// /// Produce a hashcode for a generic signature variable /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs index d423574901cab8..0aaf611d325a85 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs @@ -93,12 +93,12 @@ public sealed class ArrayTypeKeyHashtable : LockFreeReaderHashtable + /// CoreCLR ComputeGenericInstanceHashCode + /// + /// Base hash code + /// Instantiation to include in the hash + public static int GenericInstanceHashCode(int hashcode, Instantiation instantiation) + { + for (int i = 0; i < instantiation.Length; i++) + { + int argumentHashCode = instantiation[i].GetHashCode(); + hashcode = unchecked(hashcode + RotateLeft(hashcode, 13)) ^ argumentHashCode; + } + return unchecked(hashcode + RotateLeft(hashcode, 15)); + } + + public static int GenericInstanceHashCode(int hashcode, T[] instantiation) + { + for (int i = 0; i < instantiation.Length; i++) + { + int argumentHashCode = instantiation[i].GetHashCode(); + hashcode = unchecked(hashcode + RotateLeft(hashcode, 13)) ^ argumentHashCode; + } + return unchecked(hashcode + RotateLeft(hashcode, 15)); + } + } +} diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs index dec4d61a38336c..f3cd3bdb4f0218 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs @@ -55,23 +55,15 @@ public override int GetHashCode() private int InitializeHashCode() { + int hashCode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); + DefType containingType = ContainingType; - if (containingType == null) - { - string ns = Namespace; - var hashCodeBuilder = new TypeHashingAlgorithms.HashCodeBuilder(ns); - if (ns.Length > 0) - hashCodeBuilder.Append("."); - hashCodeBuilder.Append(Name); - _hashcode = hashCodeBuilder.ToHashCode(); - } - else + if (containingType != null) { - _hashcode = TypeHashingAlgorithms.ComputeNestedTypeHashCode( - containingType.GetHashCode(), TypeHashingAlgorithms.ComputeNameHashCode(Name)); + hashCode = VersionResilientHashCode.NestedTypeHashCode(containingType.GetHashCode(), hashCode); } - return _hashcode; + return _hashcode = hashCode; } EntityHandle EcmaModule.IEntityHandleObject.Handle diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs index f115da0f45afed..1b3dd481ccdbe6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs @@ -222,26 +222,18 @@ public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string na private int _hashCode; - private void InitializeHashCode() + private int InitializeHashCode() { - var hashCodeBuilder = new Internal.NativeFormat.TypeHashingAlgorithms.HashCodeBuilder(Namespace); - - if (Namespace.Length > 0) - { - hashCodeBuilder.Append("."); - } - - hashCodeBuilder.Append(Name); - _hashCode = hashCodeBuilder.ToHashCode(); + return _hashCode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); } public override int GetHashCode() { - if (_hashCode == 0) + if (_hashCode != 0) { - InitializeHashCode(); + return _hashCode; } - return _hashCode; + return InitializeHashCode(); } protected override TypeFlags ComputeTypeFlags(TypeFlags mask) diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs index 15d2268796fafc..71228880a7d480 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs @@ -295,26 +295,18 @@ public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string na private int _hashCode; - private void InitializeHashCode() + private int InitializeHashCode() { - var hashCodeBuilder = new Internal.NativeFormat.TypeHashingAlgorithms.HashCodeBuilder(Namespace); - - if (Namespace.Length > 0) - { - hashCodeBuilder.Append("."); - } - - hashCodeBuilder.Append(Name); - _hashCode = hashCodeBuilder.ToHashCode(); + return _hashCode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); } public override int GetHashCode() { - if (_hashCode == 0) + if (_hashCode != 0) { - InitializeHashCode(); + return _hashCode; } - return _hashCode; + return InitializeHashCode(); } protected override TypeFlags ComputeTypeFlags(TypeFlags mask) diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs index 85baee169d52e9..63b37838aa531b 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs @@ -205,26 +205,18 @@ public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string na private int _hashCode; - private void InitializeHashCode() + private int InitializeHashCode() { - var hashCodeBuilder = new Internal.NativeFormat.TypeHashingAlgorithms.HashCodeBuilder(Namespace); - - if (Namespace.Length > 0) - { - hashCodeBuilder.Append("."); - } - - hashCodeBuilder.Append(Name); - _hashCode = hashCodeBuilder.ToHashCode(); + return _hashCode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); } public override int GetHashCode() { - if (_hashCode == 0) + if (_hashCode != 0) { - InitializeHashCode(); + return _hashCode; } - return _hashCode; + return InitializeHashCode(); } protected override TypeFlags ComputeTypeFlags(TypeFlags mask) diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs index 689905e9526d5e..f2803781574f67 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs @@ -77,7 +77,7 @@ public MethodForRuntimeDeterminedTypeKey(MethodDesc typicalMethodDef, RuntimeDet { _typicalMethodDef = typicalMethodDef; _rdType = rdType; - _hashcode = TypeHashingAlgorithms.ComputeMethodHashCode(rdType.CanonicalType.GetHashCode(), TypeHashingAlgorithms.ComputeNameHashCode(typicalMethodDef.Name)); + _hashcode = rdType.CanonicalType.GetHashCode() ^ VersionResilientHashCode.NameHashCode(typicalMethodDef.U8Name); } public MethodDesc TypicalMethodDef diff --git a/src/coreclr/tools/ILVerification/ILVerification.projitems b/src/coreclr/tools/ILVerification/ILVerification.projitems index 335aaef17ad8f7..c301f2da1d298e 100644 --- a/src/coreclr/tools/ILVerification/ILVerification.projitems +++ b/src/coreclr/tools/ILVerification/ILVerification.projitems @@ -24,6 +24,9 @@ + + TypeSystem\Common\VersionResilientHashCode.cs + TypeSystem\CodeGen\MethodDesc.CodeGen.cs @@ -72,6 +75,9 @@ Utilities\LockFreeReaderHashtable.cs + + TypeSystem\Common\VersionResilientHashCode.TypeSystem.cs + TypeSystem\Common\ArrayType.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs index 9a3d0ac02c63ac..268ae4a6d47c72 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using Internal; using Internal.TypeSystem; using Internal.IL; using Internal.IL.Stubs; @@ -309,15 +310,7 @@ public BoxedValueType(ModuleDesc owningModule, MetadataType valuetype) protected override MethodImplRecord[] ComputeVirtualMethodImplsForType() => Array.Empty(); public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name) => Array.Empty(); - public override int GetHashCode() - { - string ns = Namespace; - var hashCodeBuilder = new Internal.NativeFormat.TypeHashingAlgorithms.HashCodeBuilder(ns); - if (ns.Length > 0) - hashCodeBuilder.Append("."); - hashCodeBuilder.Append(Name); - return hashCodeBuilder.ToHashCode(); - } + public override int GetHashCode() => VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); protected override TypeFlags ComputeTypeFlags(TypeFlags mask) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs index 2d556824fe1c71..483293cd0eea3e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Reflection.Metadata; +using Internal; using Internal.TypeSystem; using TypeHashingAlgorithms = Internal.NativeFormat.TypeHashingAlgorithms; @@ -144,14 +145,7 @@ public override int GetHashCode() private int InitializeHashCode() { - string ns = Namespace; - var hashCodeBuilder = new TypeHashingAlgorithms.HashCodeBuilder(ns); - if (ns.Length > 0) - hashCodeBuilder.Append("."); - hashCodeBuilder.Append(Name); - _hashcode = hashCodeBuilder.ToHashCode(); - - return _hashcode; + return _hashcode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); } public override bool IsCanonicalSubtype(CanonicalFormKind policy) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 862404c49d4eb6..86886d93c2baed 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -77,6 +77,9 @@ TypeSystem\Interop\IL\InlineArrayType.Sorting.cs + + TypeSystem\Common\VersionResilientHashCode.cs + Interop\IL\MarshalHelpers.cs diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ArgIterator.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ArgIterator.cs index 9b7ad00a85abde..5ee35cee18b006 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ArgIterator.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ArgIterator.cs @@ -12,6 +12,7 @@ using Internal.NativeFormat; using Internal.TypeSystem; using Internal.CorConstants; +using Internal; namespace ILCompiler.DependencyAnalysis.ReadyToRun @@ -391,7 +392,7 @@ public override int GetHashCode() { return 37 + (_parameterTypes == null ? _returnType.GetHashCode() : - TypeHashingAlgorithms.ComputeGenericInstanceHashCode(_returnType.GetHashCode(), _parameterTypes)); + VersionResilientHashCode.GenericInstanceHashCode(_returnType.GetHashCode(), _parameterTypes)); } public bool HasThis() { return _hasThis; } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs index d301233199fb9e..f7a9d844ddd2f6 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs @@ -73,21 +73,6 @@ public static int TypeHashCode(TypeDesc type) throw new NotImplementedException(); } - /// - /// CoreCLR ComputeGenericInstanceHashCode - /// - /// Base hash code - /// Instantiation to include in the hash - private static int GenericInstanceHashCode(int hashcode, Instantiation instantiation) - { - for (int i = 0; i < instantiation.Length; i++) - { - int argumentHashCode = TypeHashCode(instantiation[i]); - hashcode = unchecked(hashcode + RotateLeft(hashcode, 13)) ^ argumentHashCode; - } - return unchecked(hashcode + RotateLeft(hashcode, 15)); - } - /// /// CoreCLR GetVersionResilientMethodHashCode /// diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj index d72562ba215f6c..3251ff2660ebe3 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj @@ -1,4 +1,4 @@ - + Library ILCompiler.ReadyToRun @@ -257,6 +257,7 @@ + diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CoreTestAssembly/Hashcode.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CoreTestAssembly/Hashcode.cs deleted file mode 100644 index c88b3be7a7dfbc..00000000000000 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CoreTestAssembly/Hashcode.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Hashcode -{ - class NonNestedType - { - class NestedType - { - - } - - void GenericMethod() - { } - } - - class GenericType - { - void GenericMethod() - { - } - } -} diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/HashcodeTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/HashcodeTests.cs deleted file mode 100644 index a57216950e0b7d..00000000000000 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/HashcodeTests.cs +++ /dev/null @@ -1,248 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -using Internal.TypeSystem; -using Internal.NativeFormat; - -using Xunit; - -namespace TypeSystemTests -{ - public class HashcodeTests - { - private TestTypeSystemContext _context; - private ModuleDesc _testModule; - - public HashcodeTests() - { - _context = new TestTypeSystemContext(TargetArchitecture.X64); - var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); - _context.SetSystemModule(systemModule); - - _testModule = systemModule; - } - - [Fact] - public void TestMultidimensionalArrays() - { - TypeDesc objectType = _context.GetWellKnownType(WellKnownType.Object); - - ArrayType objectMDArrayRank1 = _context.GetArrayType(objectType, 1); - ArrayType objectMDArrayRank2 = _context.GetArrayType(objectType, 2); - ArrayType objectMDArrayRank3 = _context.GetArrayType(objectType, 3); - - Assert.Equal(TypeHashingAlgorithms.ComputeArrayTypeHashCode(objectType.GetHashCode(), 1), objectMDArrayRank1.GetHashCode()); - Assert.Equal(TypeHashingAlgorithms.ComputeArrayTypeHashCode(objectType.GetHashCode(), 2), objectMDArrayRank2.GetHashCode()); - Assert.Equal(TypeHashingAlgorithms.ComputeArrayTypeHashCode(objectType.GetHashCode(), 3), objectMDArrayRank3.GetHashCode()); - } - - [Fact] - public void TestSingleDimensionalArrays() - { - TypeDesc objectType = _context.GetWellKnownType(WellKnownType.Object); - - ArrayType objectArray = _context.GetArrayType(objectType); - - Assert.Equal(TypeHashingAlgorithms.ComputeArrayTypeHashCode(objectType.GetHashCode(), -1), objectArray.GetHashCode()); - } - - [Fact] - public void TestNonGenericTypes() - { - MetadataType nonNestedType = (MetadataType)_testModule.GetType("Hashcode", "NonNestedType"); - TypeDesc nestedType = nonNestedType.GetNestedType("NestedType"); - - int expectedNonNestedTypeHashcode = TypeHashingAlgorithms.ComputeNameHashCode("Hashcode.NonNestedType"); - int expectedNestedTypeNameHashcode = TypeHashingAlgorithms.ComputeNameHashCode("NestedType"); - int expectedNestedTypeHashcode = TypeHashingAlgorithms.ComputeNestedTypeHashCode(expectedNonNestedTypeHashcode, expectedNestedTypeNameHashcode); - - Assert.Equal(expectedNonNestedTypeHashcode, nonNestedType.GetHashCode()); - Assert.Equal(expectedNestedTypeHashcode, nestedType.GetHashCode()); - } - - [Fact] - public void TestGenericTypes() - { - MetadataType ilistType = (MetadataType)_testModule.GetType("System.Collections.Generic", "IList`1"); - DefType systemArrayType = _context.GetWellKnownType(WellKnownType.Array); - DefType ilistOfSystemArray = ilistType.MakeInstantiatedType(systemArrayType); - - int expectedIListOfTHashcode = TypeHashingAlgorithms.ComputeNameHashCode("System.Collections.Generic.IList`1"); - int expectedSystemArrayHashcode = TypeHashingAlgorithms.ComputeNameHashCode("System.Array"); - Assert.Equal(expectedIListOfTHashcode, ilistType.GetHashCode()); - Assert.Equal(TypeHashingAlgorithms.ComputeGenericInstanceHashCode(expectedIListOfTHashcode, new int[] { expectedSystemArrayHashcode }), ilistOfSystemArray.GetHashCode()); - } - - [Fact] - public void TestInstantiatedMethods() - { - MetadataType nonNestedType = (MetadataType)_testModule.GetType("Hashcode", "NonNestedType"); - MetadataType genericType = (MetadataType)_testModule.GetType("Hashcode", "GenericType`2"); - DefType intType = _context.GetWellKnownType(WellKnownType.Int32); - DefType stringType = _context.GetWellKnownType(WellKnownType.String); - - MetadataType genericTypeOfIntString = genericType.MakeInstantiatedType(intType, stringType); - MetadataType genericTypeOfStringInt = genericType.MakeInstantiatedType(stringType, intType); - - // build up expected hash codes for the above - int expHashNonNestedType = TypeHashingAlgorithms.ComputeNameHashCode("Hashcode.NonNestedType"); - Assert.Equal(expHashNonNestedType, nonNestedType.GetHashCode()); - int expHashGenType = TypeHashingAlgorithms.ComputeNameHashCode("Hashcode.GenericType`2"); - Assert.Equal(expHashGenType, genericType.GetHashCode()); - int expHashInt = TypeHashingAlgorithms.ComputeNameHashCode("System.Int32"); - Assert.Equal(expHashInt, intType.GetHashCode()); - int expHashString = TypeHashingAlgorithms.ComputeNameHashCode("System.String"); - Assert.Equal(expHashString, stringType.GetHashCode()); - int expHashGenTypeOfIS = TypeHashingAlgorithms.ComputeGenericInstanceHashCode(expHashGenType, new int[] { expHashInt, expHashString }); - Assert.Equal(expHashGenTypeOfIS, genericTypeOfIntString.GetHashCode()); - int expHashGenTypeOfSI = TypeHashingAlgorithms.ComputeGenericInstanceHashCode(expHashGenType, new int[] { expHashString, expHashInt }); - Assert.Equal(expHashGenTypeOfSI, genericTypeOfStringInt.GetHashCode()); - - // Test that instantiated method's have the right hashes - - int genMethodNameHash = TypeHashingAlgorithms.ComputeNameHashCode("GenericMethod"); - int genMethodNameAndIHash = TypeHashingAlgorithms.ComputeGenericInstanceHashCode(genMethodNameHash, new int[] { expHashInt }); - int genMethodNameAndSHash = TypeHashingAlgorithms.ComputeGenericInstanceHashCode(genMethodNameHash, new int[] { expHashString }); - - - Action testSequence = (MetadataType typeWithGenericMethod, int expectedTypeHash) => - { - // Uninstantiated Generic method - MethodDesc genMethod = typeWithGenericMethod.GetMethod("GenericMethod", null); - Assert.Equal(TypeHashingAlgorithms.ComputeMethodHashCode(expectedTypeHash, genMethodNameHash), genMethod.GetHashCode()); - - // Instantiated over int - MethodDesc genMethodI = genMethod.MakeInstantiatedMethod(intType); - Assert.Equal(TypeHashingAlgorithms.ComputeMethodHashCode(expectedTypeHash, genMethodNameAndIHash), genMethodI.GetHashCode()); - - // Instantiated over string - MethodDesc genMethodS = genMethod.MakeInstantiatedMethod(stringType); - Assert.Equal(TypeHashingAlgorithms.ComputeMethodHashCode(expectedTypeHash, genMethodNameAndSHash), genMethodS.GetHashCode()); - - // Assert they aren't the same as the other hashes - Assert.NotEqual(genMethodI.GetHashCode(), genMethodS.GetHashCode()); - Assert.NotEqual(genMethodI.GetHashCode(), genMethod.GetHashCode()); - Assert.NotEqual(genMethodS.GetHashCode(), genMethod.GetHashCode()); - }; - - // Test cases on non-generic type - testSequence(nonNestedType, expHashNonNestedType); - - // Test cases on generic type - testSequence(genericType, expHashGenType); - - // Test cases on instantiated generic type - testSequence(genericTypeOfIntString, expHashGenTypeOfIS); - testSequence(genericTypeOfStringInt, expHashGenTypeOfSI); - } - - [Fact] - public void TestPointerTypes() - { - DefType intType = _context.GetWellKnownType(WellKnownType.Int32); - - int expHashInt = TypeHashingAlgorithms.ComputeNameHashCode("System.Int32"); - Assert.Equal(expHashInt, intType.GetHashCode()); - - int expHashIntPointer = TypeHashingAlgorithms.ComputePointerTypeHashCode(expHashInt); - TypeDesc intPointerType = _context.GetPointerType(intType); - Assert.Equal(expHashIntPointer, intPointerType.GetHashCode()); - } - - [Fact] - public void TestFunctionPointerTypes() - { - DefType intType = _context.GetWellKnownType(WellKnownType.Int32); - DefType objectType = _context.GetWellKnownType(WellKnownType.Object); - - int expHashInt = TypeHashingAlgorithms.ComputeNameHashCode("System.Int32"); - int expHashObject = TypeHashingAlgorithms.ComputeNameHashCode("System.Object"); - - int expHashFnPtr = TypeHashingAlgorithms.ComputeMethodSignatureHashCode(expHashInt, new[] { expHashObject }); - - MethodSignature fnPtrSig = new MethodSignature(MethodSignatureFlags.None, 0, intType, new TypeDesc[] { objectType }); - var fnPtrType = _context.GetFunctionPointerType(fnPtrSig); - Assert.Equal(expHashFnPtr, fnPtrType.GetHashCode()); - } - - [Fact] - public void TestByRefTypes() - { - DefType intType = _context.GetWellKnownType(WellKnownType.Int32); - - int expHashInt = TypeHashingAlgorithms.ComputeNameHashCode("System.Int32"); - Assert.Equal(expHashInt, intType.GetHashCode()); - - int expHashIntByRef = TypeHashingAlgorithms.ComputeByrefTypeHashCode(expHashInt); - TypeDesc intByRefType = _context.GetByRefType(intType); - Assert.Equal(expHashIntByRef, intByRefType.GetHashCode()); - } - - [Fact] - public void TestHashCodeBuilder() - { - { - var builder = new TypeHashingAlgorithms.HashCodeBuilder("Xy"); - Assert.Equal(TypeHashingAlgorithms.ComputeNameHashCode("Xy"), builder.ToHashCode()); - } - - { - var builder = new TypeHashingAlgorithms.HashCodeBuilder("Xyz"); - Assert.Equal(TypeHashingAlgorithms.ComputeNameHashCode("Xyz"), builder.ToHashCode()); - } - - { - var builder = new TypeHashingAlgorithms.HashCodeBuilder("Xy"); - builder.Append(""); - Assert.Equal(TypeHashingAlgorithms.ComputeNameHashCode("Xy"), builder.ToHashCode()); - } - - { - var builder = new TypeHashingAlgorithms.HashCodeBuilder("Xy"); - builder.Append("."); - Assert.Equal(TypeHashingAlgorithms.ComputeNameHashCode("Xy."), builder.ToHashCode()); - } - - { - var builder = new TypeHashingAlgorithms.HashCodeBuilder("Xyz"); - builder.Append("."); - Assert.Equal(TypeHashingAlgorithms.ComputeNameHashCode("Xyz."), builder.ToHashCode()); - } - - { - var builder = new TypeHashingAlgorithms.HashCodeBuilder("Xy"); - builder.Append(".."); - Assert.Equal(TypeHashingAlgorithms.ComputeNameHashCode("Xy.."), builder.ToHashCode()); - } - - { - var builder = new TypeHashingAlgorithms.HashCodeBuilder("Xyz"); - builder.Append(".."); - Assert.Equal(TypeHashingAlgorithms.ComputeNameHashCode("Xyz.."), builder.ToHashCode()); - } - - { - var builder = new TypeHashingAlgorithms.HashCodeBuilder("Xy"); - builder.Append("."); - builder.Append("Ab"); - Assert.Equal(TypeHashingAlgorithms.ComputeNameHashCode("Xy.Ab"), builder.ToHashCode()); - } - - { - var builder = new TypeHashingAlgorithms.HashCodeBuilder("Xy"); - builder.Append("."); - builder.Append("Abc"); - Assert.Equal(TypeHashingAlgorithms.ComputeNameHashCode("Xy.Abc"), builder.ToHashCode()); - } - - { - var builder = new TypeHashingAlgorithms.HashCodeBuilder("Xyz"); - builder.Append("."); - builder.Append("Abc"); - Assert.Equal(TypeHashingAlgorithms.ComputeNameHashCode("Xyz.Abc"), builder.ToHashCode()); - } - } - } -} diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILCompiler.TypeSystem.Tests.csproj b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILCompiler.TypeSystem.Tests.csproj index 61d16eeb063247..350eb36643f06b 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILCompiler.TypeSystem.Tests.csproj +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILCompiler.TypeSystem.Tests.csproj @@ -70,7 +70,6 @@ - diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj b/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj index b49cc608a4c652..d8c363424d831a 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj @@ -1,4 +1,4 @@ - + Library Internal.TypeSystem @@ -33,6 +33,9 @@ + + TypeSystem\Common\VersionResilientHashCode.cs + TypeSystem\Common\ArrayMethod.Diagnostic.cs @@ -192,6 +195,9 @@ TypeSystem\Common\UniversalCanonLayoutAlgorithm.cs + + TypeSystem\Common\VersionResilientHashCode.TypeSystem.cs + Utilities\CustomAttributeTypeNameFormatter.cs diff --git a/src/libraries/Common/src/Internal/VersionResilientHashCode.cs b/src/libraries/Common/src/Internal/VersionResilientHashCode.cs index c87ec08d19f3c6..0809b514818219 100644 --- a/src/libraries/Common/src/Internal/VersionResilientHashCode.cs +++ b/src/libraries/Common/src/Internal/VersionResilientHashCode.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; using System.Numerics; +using System.Runtime.CompilerServices; using System.Text; namespace Internal @@ -13,6 +14,59 @@ namespace Internal /// internal static partial class VersionResilientHashCode { + public struct HashCodeBuilder + { + private int _hash1; + private int _hash2; + private int _numCharactersHashed; + + public HashCodeBuilder(ReadOnlySpan seed) + { + _hash1 = 0x6DA3B944; + _hash2 = 0; + _numCharactersHashed = 0; + } + + public void Append(ReadOnlySpan src) + { + if (src.Length == 0) + return; + + int startIndex = 0; + if ((_numCharactersHashed & 1) == 1) + { + _hash2 = unchecked(_hash2 + RotateLeft(_hash2, 5)) ^ (int)unchecked((sbyte)src[0]); + startIndex = 1; + } + + for (int i = startIndex; i < src.Length; i += 2) + { + _hash1 = unchecked(_hash1 + RotateLeft(_hash1, 5)) ^ (int)unchecked((sbyte)src[i]); + if (i + 1 < src.Length) + { + _hash2 = unchecked(_hash2 + RotateLeft(_hash2, 5)) ^ (int)unchecked((sbyte)src[i + 1]); + } + else + { + break; + } + } + + _numCharactersHashed += src.Length; + } + + public int ToHashCode() + { + if (_numCharactersHashed == 0) + return 0; + + int hash1 = unchecked(_hash1 + RotateLeft(_hash1, 8)); + int hash2 = unchecked(_hash2 + RotateLeft(_hash2, 8)); + + return unchecked((int)(hash1 ^ hash2)); + } + } + /// /// CoreCLR ComputeNameHashCode /// @@ -49,15 +103,17 @@ public static int NameHashCode(ReadOnlySpan src) /// /// Calculate hash code for a namespace - name combination. /// CoreCLR 2-parameter ComputeNameHashCode - /// DIFFERENT FROM NATIVEAOT: NativeAOT hashes the full name as one string ("namespace.name"), - /// as the full name is already available. In CoreCLR we normally only have separate - /// strings for namespace and name, thus we hash them separately. /// /// Namespace name /// Type name within the namespace public static int NameHashCode(ReadOnlySpan namespacePart, ReadOnlySpan namePart) { - return NameHashCode(namespacePart) ^ NameHashCode(namePart); + return NameHashCode(NameHashCode(namespacePart), NameHashCode(namePart)); + } + + public static int NameHashCode(int namespaceHashCode, int nameHashCode) + { + return namespaceHashCode ^ nameHashCode; } /// @@ -65,7 +121,7 @@ public static int NameHashCode(ReadOnlySpan namespacePart, ReadOnlySpan /// Hash code of the enclosing type /// Hash code of the nested type name - private static int NestedTypeHashCode(int enclosingTypeHashcode, int nestedTypeNameHash) + public static int NestedTypeHashCode(int enclosingTypeHashcode, int nestedTypeNameHash) { return unchecked(enclosingTypeHashcode + RotateLeft(enclosingTypeHashcode, 11)) ^ nestedTypeNameHash; } @@ -75,10 +131,8 @@ private static int NestedTypeHashCode(int enclosingTypeHashcode, int nestedTypeN /// /// Hash code representing the array element type /// Array rank - private static int ArrayTypeHashCode(int elementTypeHashcode, int rank) + public static int ArrayTypeHashCode(int elementTypeHashcode, int rank) { - // DIFFERENT FROM NATIVEAOT: This is much simplified compared to NativeAOT, to avoid converting rank to string. - // For single-dimensinal array, the result is identical to NativeAOT. int hashCode = unchecked((int)0xd5313556 + rank); if (rank == 1) { @@ -92,7 +146,7 @@ private static int ArrayTypeHashCode(int elementTypeHashcode, int rank) /// CoreCLR ComputePointerTypeHashCode /// /// Hash code of the pointee type - private static int PointerTypeHashCode(int pointeeTypeHashcode) + public static int PointerTypeHashCode(int pointeeTypeHashcode) { return unchecked(pointeeTypeHashcode + RotateLeft(pointeeTypeHashcode, 5)) ^ 0x12D0; } @@ -101,7 +155,7 @@ private static int PointerTypeHashCode(int pointeeTypeHashcode) /// CoreCLR ComputeByrefTypeHashCode /// /// Hash code representing the parameter type - private static int ByrefTypeHashCode(int parameterTypeHashcode) + public static int ByrefTypeHashCode(int parameterTypeHashcode) { return unchecked(parameterTypeHashcode + RotateLeft(parameterTypeHashcode, 7)) ^ 0x4C85; } @@ -150,3 +204,14 @@ public static uint CombineTwoValuesIntoHash(uint value1, uint value2) } } } + +namespace System.Numerics +{ +#if !NET + internal static class BitOperations + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static uint RotateLeft(uint value, int offset) => (value << offset) | (value >> (32 - offset)); + } +#endif +} From 9598e1868686d2b39ccd623c58529a3e3b5b8ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 5 Sep 2025 02:02:36 +0200 Subject: [PATCH 04/19] Cleanups --- .../ReadyToRun/InliningInfoNode.cs | 2 +- .../ReadyToRun/InstanceEntryPointTableNode.cs | 2 +- .../InstrumentationDataTableNode.cs | 2 +- .../VersionResilientHashCode.ReadyToRun.cs | 80 ------------------- 4 files changed, 3 insertions(+), 83 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InliningInfoNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InliningInfoNode.cs index 82c19968d977f1..d28bd07e04921c 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InliningInfoNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InliningInfoNode.cs @@ -144,7 +144,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) if (AllowCrossModuleInlines) { // CrossModuleInlineInfo format - hashCode = VersionResilientHashCode.MethodHashCode(inlinee); + hashCode = inlinee.GetHashCode(); } else { diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InstanceEntryPointTableNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InstanceEntryPointTableNode.cs index 265f2155854e48..db63a30fae67a5 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InstanceEntryPointTableNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InstanceEntryPointTableNode.cs @@ -124,7 +124,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) EntryPointVertex entryPointVertex = new EntryPointWithBlobVertex((uint)methodIndex, fixupBlob, signatureBlob); hashtableSection.Place(entryPointVertex); - vertexHashtable.Append(unchecked((uint)VersionResilientHashCode.MethodHashCode(method.Method)), entryPointVertex); + vertexHashtable.Append(unchecked((uint)method.Method.GetHashCode()), entryPointVertex); } MemoryStream hashtableContent = new MemoryStream(); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InstrumentationDataTableNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InstrumentationDataTableNode.cs index 496413247dc90a..323661407e311d 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InstrumentationDataTableNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InstrumentationDataTableNode.cs @@ -285,7 +285,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) PgoInstrumentedDataWithSignatureBlobVertex pgoDataVertex = new PgoInstrumentedDataWithSignatureBlobVertex(signatureBlob, 0, instrumentationDataBlob); hashtableSection.Place(pgoDataVertex); - vertexHashtable.Append(unchecked((uint)VersionResilientHashCode.MethodHashCode(method)), pgoDataVertex); + vertexHashtable.Append(unchecked((uint)method.GetHashCode()), pgoDataVertex); } MemoryStream hashtableContent = new MemoryStream(); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs index f7a9d844ddd2f6..efa3464797ce87 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/VersionResilientHashCode.ReadyToRun.cs @@ -15,86 +15,6 @@ namespace Internal /// internal static partial class VersionResilientHashCode { - /// - /// CoreCLR 3-parameter GetVersionResilientTypeHashCode - /// - /// Type to hash - public static int TypeTableHashCode(DefType type) - { - int hashcode = 0; - do - { - hashcode ^= NameHashCode(type.U8Namespace, type.U8Name); - type = type.ContainingType; - } - while (type != null); - return hashcode; - } - - /// - /// CoreCLR 1-parameter GetVersionResilientTypeHashCode - /// - /// Type to hash - public static int TypeHashCode(TypeDesc type) - { - if (type.GetTypeDefinition() is DefType defType) - { - int hashcode = NameHashCode(defType.U8Namespace, defType.U8Name); - DefType containingType = defType.ContainingType; - if (containingType != null) - { - hashcode = NestedTypeHashCode(TypeHashCode(containingType), hashcode); - } - if (type.HasInstantiation && !type.IsGenericDefinition) - { - return GenericInstanceHashCode(hashcode, type.Instantiation); - } - else - { - return hashcode; - } - } - - if (type is ArrayType arrayType) - { - return ArrayTypeHashCode(TypeHashCode(arrayType.ElementType), arrayType.Rank); - } - - if (type is PointerType pointerType) - { - return PointerTypeHashCode(TypeHashCode(pointerType.ParameterType)); - } - - if (type is ByRefType byRefType) - { - return ByrefTypeHashCode(TypeHashCode(byRefType.ParameterType)); - } - - throw new NotImplementedException(); - } - - /// - /// CoreCLR GetVersionResilientMethodHashCode - /// - /// Method to hash - public static int MethodHashCode(MethodDesc method) - { - int hashCode = TypeHashCode(method.OwningType); - int methodNameHashCode = NameHashCode(method.U8Name); - - // Todo: Add signature to hash. - if (method.HasInstantiation && !method.IsGenericMethodDefinition) - { - hashCode ^= GenericInstanceHashCode(methodNameHashCode, method.Instantiation); - } - else - { - hashCode ^= methodNameHashCode; - } - - return hashCode; - } - public static int ModuleNameHashCode(ModuleDesc module) { IAssemblyDesc assembly = module.Assembly; From a4e1336ee9b646812f7db5eac294275216655aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 5 Sep 2025 08:35:05 +0200 Subject: [PATCH 05/19] Stop using DefType.Name --- .../ExceptionTypeNameFormatter.Runtime.cs | 4 +- .../Compiler/Dataflow/TypeExtensions.cs | 33 ++++++++++++--- .../Common/Compiler/Dataflow/TypeProxy.cs | 4 +- .../Common/Compiler/DisplayNameHelpers.cs | 8 ++-- .../Compiler/HardwareIntrinsicHelpers.cs | 6 +-- .../Common/Compiler/InstructionSetSupport.cs | 10 ++--- .../Compiler/Int128FieldLayoutAlgorithm.cs | 8 ++-- .../Common/Compiler/ProcessLinkerXmlBase.cs | 8 ++-- .../Compiler/VectorFieldLayoutAlgorithm.cs | 21 +++++----- .../Internal/Runtime/EETypeBuilderHelpers.cs | 8 ++-- .../tools/Common/JitInterface/CorInfoImpl.cs | 25 +++++++----- .../JitInterface/CorInfoInstructionSet.cs | 10 ++--- .../JitInterface/JitTypeNameFormatter.cs | 6 +-- .../TypeSystem/Canon/CanonTypes.Diagnostic.cs | 8 ++-- .../Common/CastingHelper.TypeEquivalence.cs | 9 +++-- .../Common/DefType.Dummy.Diagnostic.cs | 4 +- .../tools/Common/TypeSystem/Common/DefType.cs | 4 ++ .../Common/MetadataTypeSystemContext.cs | 5 ++- .../TypeSystem/Common/TypeSystemHelpers.cs | 4 +- .../CustomAttributeTypeNameFormatter.cs | 6 +-- .../ExceptionTypeNameFormatter.Metadata.cs | 4 +- .../Ecma/CustomAttributeTypeProvider.cs | 4 +- .../TypeSystem/Ecma/EcmaType.Diagnostic.cs | 4 +- .../Ecma/EcmaType.TypeEquivalence.cs | 6 +-- .../tools/Common/TypeSystem/Ecma/EcmaType.cs | 2 +- .../Common/TypeSystem/IL/ILDisassembler.cs | 6 +-- .../TypeSystem/IL/NativeAotILProvider.cs | 26 ++++++------ .../IL/Stubs/InterlockedIntrinsics.cs | 4 +- .../IL/Stubs/RuntimeHelpersIntrinsics.cs | 6 +-- .../TypeSystem/IL/Stubs/StreamIntrinsics.cs | 4 +- .../IL/Stubs/StructMarshallingThunk.cs | 2 +- .../TypeSystem/IL/Stubs/UnsafeIntrinsics.cs | 2 +- .../TypeSystem/Interop/IL/MarshalHelpers.cs | 4 +- .../Common/TypeSystem/Interop/InteropTypes.cs | 40 ++++++++++--------- .../Interop/UnmanagedCallingConventions.cs | 4 +- .../TypeSystemMetadataEmitter.cs | 4 +- .../SwiftLoweringTests.cs | 5 ++- .../Compiler/Compilation.cs | 14 +++---- ...pilerTypeSystemContext.ValueTypeMethods.cs | 2 +- .../Dataflow/CompilerGeneratedCallGraph.cs | 4 +- .../Dataflow/CompilerGeneratedState.cs | 28 ++++++------- .../Compiler/Dataflow/FlowAnnotations.cs | 8 ++-- .../Compiler/Dataflow/HandleCallAction.cs | 2 +- .../CallingConventionConverterKey.cs | 4 +- .../CodeBasedDependencyAlgorithm.cs | 8 ++-- .../InlineableStringsResourceNode.cs | 4 +- .../Compiler/DescriptorMarker.cs | 2 +- ...mentationSignatureGenerator.PartVisitor.cs | 10 ++--- .../Logging/DocumentationSignatureParser.cs | 6 ++- .../Compiler/SubstitutedILProvider.cs | 6 +-- .../Compiler/SubstitutionProvider.cs | 4 +- .../Compiler/TypeMapManager.cs | 17 ++++---- .../Compiler/TypePreinit.cs | 19 ++++----- .../Compiler/UsageBasedInteropStubManager.cs | 4 +- .../Compiler/VectorOfTFieldLayoutAlgorithm.cs | 4 +- .../IL/ILImporter.Scanner.cs | 14 ++++--- .../IL/TypeEqualityPatternAnalyzer.cs | 10 +++-- .../Metadata/Transform.CustomAttribute.cs | 4 +- .../ILCompiler/Metadata/Transform.Type.cs | 14 +++---- .../Compiler/ReadyToRunCompilerContext.cs | 2 +- .../Compiler/ReadyToRunXmlRootProvider.cs | 3 +- .../IBC/MIbcProfileParser.cs | 4 +- .../IL/ReadyToRunILProvider.cs | 12 +++--- .../ObjectWriter/TypeString.cs | 6 +-- .../TestCasesRunner/AssemblyChecker.cs | 2 +- .../MemberAssertionsCollector.cs | 4 +- .../TestCasesRunner/ResultChecker.cs | 2 +- .../DocumentationSignatureParserTests.cs | 2 +- .../SignatureTests.cs | 2 +- .../SyntheticVirtualOverrideTests.cs | 8 ++-- .../TypeEquivalenceTests.cs | 2 +- .../VirtualFunctionOverrideTests.cs | 2 +- src/coreclr/tools/aot/ILCompiler/Program.cs | 2 +- .../TraceRuntimeDescToTypeSystemDesc.cs | 2 +- .../TypeRefTypeSystemType.cs | 14 +++++-- 75 files changed, 326 insertions(+), 249 deletions(-) diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/ExceptionTypeNameFormatter.Runtime.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/ExceptionTypeNameFormatter.Runtime.cs index d9398074cd9d0a..bec841f6dcd692 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/ExceptionTypeNameFormatter.Runtime.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/ExceptionTypeNameFormatter.Runtime.cs @@ -10,7 +10,7 @@ private static string GetTypeName(DefType type) if (type is NoMetadata.NoMetadataType) return ((NoMetadata.NoMetadataType)type).NameForDiagnostics; - return type.Name; + return type.GetName(); } private static string GetTypeNamespace(DefType type) @@ -18,7 +18,7 @@ private static string GetTypeNamespace(DefType type) if (type is NoMetadata.NoMetadataType) return ((NoMetadata.NoMetadataType)type).NamespaceForDiagnostics; - return type.Namespace; + return type.GetNamespace(); } } } diff --git a/src/coreclr/tools/Common/Compiler/Dataflow/TypeExtensions.cs b/src/coreclr/tools/Common/Compiler/Dataflow/TypeExtensions.cs index db0a6384ac78a2..1fc95c63517752 100644 --- a/src/coreclr/tools/Common/Compiler/Dataflow/TypeExtensions.cs +++ b/src/coreclr/tools/Common/Compiler/Dataflow/TypeExtensions.cs @@ -16,7 +16,7 @@ internal static class TypeExtensions { public static bool IsTypeOf(this TypeDesc type, string ns, string name) { - return type is MetadataType mdType && mdType.Name == name && mdType.Namespace == ns; + return type is MetadataType mdType && mdType.U8Name.StringEquals(name) && mdType.U8Namespace.StringEquals(ns); } public static bool IsTypeOf(this TypeDesc type, string fullTypeName) @@ -24,17 +24,19 @@ public static bool IsTypeOf(this TypeDesc type, string fullTypeName) if (type is not MetadataType metadataType) return false; + string metadataTypeName = metadataType.GetName(); + var name = fullTypeName.AsSpan(); - if (metadataType.Name.Length + 1 > name.Length) + if (metadataTypeName.Length + 1 > name.Length) return false; - if (!name.Slice(name.Length - metadataType.Name.Length).Equals(metadataType.Name.AsSpan(), StringComparison.Ordinal)) + if (!name.Slice(name.Length - metadataTypeName.Length).Equals(metadataTypeName.AsSpan(), StringComparison.Ordinal)) return false; - if (name[name.Length - metadataType.Name.Length - 1] != '.') + if (name[name.Length - metadataTypeName.Length - 1] != '.') return false; - return name.Slice(0, name.Length - metadataType.Name.Length - 1).Equals(metadataType.Namespace, StringComparison.Ordinal); + return name.Slice(0, name.Length - metadataTypeName.Length - 1).Equals(metadataType.GetNamespace(), StringComparison.Ordinal); } public static bool IsTypeOf(this TypeDesc type, ILLinkSharedWellKnownType wellKnownType) => @@ -43,12 +45,31 @@ public static bool IsTypeOf(this TypeDesc type, ILLinkSharedWellKnownType wellKn ILLinkSharedWellKnownType.System_String => type.IsWellKnownType(TypeSystemWellKnownType.String), ILLinkSharedWellKnownType.System_Object => type.IsWellKnownType(TypeSystemWellKnownType.Object), ILLinkSharedWellKnownType.System_Void => type.IsWellKnownType(TypeSystemWellKnownType.Void), - _ => wellKnownType == WellKnownTypeExtensions.GetWellKnownType((type as MetadataType)?.Namespace ?? string.Empty, ((type as MetadataType)?.Name) ?? string.Empty) + _ => wellKnownType == WellKnownTypeExtensions.GetWellKnownType((type as MetadataType)?.GetNamespace() ?? string.Empty, ((type as MetadataType)?.GetName()) ?? string.Empty) }; public static bool IsDeclaredOnType(this MethodDesc method, string fullTypeName) { return method.OwningType.IsTypeOf(fullTypeName); } + + public static bool StringEquals(this ReadOnlySpan utf8bytes, string value) + { + if (utf8bytes.Length < value.Length) + return false; + + for (int i = 0; i < value.Length; i++) + { + int ch = utf8bytes[i]; + if (ch > 0x7F) + return System.Text.Encoding.UTF8.GetString(utf8bytes) == value; + + // We are assuming here that valid UTF8 encoded byte > 0x7F cannot map to a character with code point <= 0x7F + if (ch != value[i]) + return false; + } + + return utf8bytes.Length == value.Length; // All char ANSI, all matching + } } } diff --git a/src/coreclr/tools/Common/Compiler/Dataflow/TypeProxy.cs b/src/coreclr/tools/Common/Compiler/Dataflow/TypeProxy.cs index 35943c4c58c434..9fb5b6b576a9c1 100644 --- a/src/coreclr/tools/Common/Compiler/Dataflow/TypeProxy.cs +++ b/src/coreclr/tools/Common/Compiler/Dataflow/TypeProxy.cs @@ -34,9 +34,9 @@ internal partial ImmutableArray GetGenericParameters() public TypeDesc Type { get; } - public string Name { get => Type is MetadataType metadataType ? metadataType.Name : string.Empty; } + public string Name { get => Type is MetadataType metadataType ? metadataType.GetName() : string.Empty; } - public string? Namespace { get => Type is MetadataType metadataType ? metadataType.Namespace : null; } + public string? Namespace { get => Type is MetadataType metadataType ? metadataType.GetNamespace() : null; } public bool IsTypeOf(string @namespace, string name) => Type.IsTypeOf(@namespace, name); diff --git a/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs b/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs index 3dac7c151b6fe6..e2f78cc7b6888a 100644 --- a/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs +++ b/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs @@ -35,7 +35,7 @@ public static string GetDisplayName(this MethodDesc method) if (method.IsConstructor && method.OwningType is DefType defType) { - sb.Append(defType.Name); + sb.Append(defType.GetName()); } #if !READYTORUN else if (method.GetPropertyForAccessor() is PropertyPseudoDesc property) @@ -234,7 +234,7 @@ protected override Unit AppendNameForInstantiatedType(StringBuilder sb, DefType protected override Unit AppendNameForNamespaceType(StringBuilder sb, DefType type, FormatOptions options) { NamespaceQualify(sb, type, options); - sb.Append(type.Name); + sb.Append(type.GetName()); return default; } @@ -242,7 +242,7 @@ protected override Unit AppendNameForNestedType(StringBuilder sb, DefType nested { AppendName(sb, containingType, options); sb.Append('.'); - sb.Append(nestedType.Name); + sb.Append(nestedType.GetName()); return default; } @@ -251,7 +251,7 @@ private static void NamespaceQualify(StringBuilder sb, DefType type, FormatOptio { if ((options & FormatOptions.NamespaceQualify) != 0) { - string ns = type.Namespace; + string ns = type.GetNamespace(); if (!string.IsNullOrEmpty(ns)) { sb.Append(ns); diff --git a/src/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.cs b/src/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.cs index 5280bd5b0d1578..f668798cb8595b 100644 --- a/src/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.cs +++ b/src/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.cs @@ -23,9 +23,9 @@ public static bool IsHardwareIntrinsic(MethodDesc method) { var owningMdType = (MetadataType)owningType; DefType containingType = owningMdType.ContainingType; - string ns = containingType?.ContainingType?.Namespace ?? - containingType?.Namespace ?? - owningMdType.Namespace; + string ns = containingType?.ContainingType?.GetNamespace() ?? + containingType?.GetNamespace() ?? + owningMdType.GetNamespace(); return method.Context.Target.Architecture switch { TargetArchitecture.ARM64 => ns == "System.Runtime.Intrinsics.Arm", diff --git a/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs b/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs index 0c41654a3bdad5..d844e83a021795 100644 --- a/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs +++ b/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs @@ -61,7 +61,7 @@ public static string GetHardwareIntrinsicId(TargetArchitecture architecture, Typ return ""; // 64-bit ISA variants are not included in the mapping dictionary, so we use the containing type instead - if (potentialType.Name is "X64" or "Arm64") + if (potentialType.U8Name.SequenceEqual("X64"u8) || potentialType.U8Name.SequenceEqual("Arm64"u8)) { if (architecture is TargetArchitecture.X64 or TargetArchitecture.ARM64) potentialType = (MetadataType)potentialType.ContainingType; @@ -73,18 +73,18 @@ public static string GetHardwareIntrinsicId(TargetArchitecture architecture, Typ string suffix = ""; while (potentialType.ContainingType is MetadataType containingType) { - suffix = $"_{potentialType.Name}{suffix}"; + suffix = $"_{potentialType.GetName()}{suffix}"; potentialType = containingType; } if (architecture is TargetArchitecture.X64 or TargetArchitecture.X86) { - if (potentialType.Namespace != "System.Runtime.Intrinsics.X86") + if (!potentialType.U8Namespace.SequenceEqual("System.Runtime.Intrinsics.X86"u8)) return ""; } else if (architecture is TargetArchitecture.ARM64 or TargetArchitecture.ARM) { - if (potentialType.Namespace != "System.Runtime.Intrinsics.Arm") + if (!potentialType.U8Namespace.SequenceEqual("System.Runtime.Intrinsics.Arm"u8)) return ""; } else if (architecture is TargetArchitecture.LoongArch64) @@ -100,7 +100,7 @@ public static string GetHardwareIntrinsicId(TargetArchitecture architecture, Typ throw new InternalCompilerErrorException($"Unknown architecture '{architecture}'"); } - return potentialType.Name + suffix; + return potentialType.GetName() + suffix; } public SimdVectorLength GetVectorTSimdVector() diff --git a/src/coreclr/tools/Common/Compiler/Int128FieldLayoutAlgorithm.cs b/src/coreclr/tools/Common/Compiler/Int128FieldLayoutAlgorithm.cs index a78446d5967ae4..63fc8522d8cb7f 100644 --- a/src/coreclr/tools/Common/Compiler/Int128FieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/Common/Compiler/Int128FieldLayoutAlgorithm.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -23,7 +25,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp { Debug.Assert(IsIntegerType(defType)); - string name = defType.Name; + string name = defType.GetName(); Debug.Assert((name == "Int128") || (name == "UInt128")); ComputedInstanceFieldLayout layoutFromMetadata = _fallbackAlgorithm.ComputeInstanceLayout(defType, layoutKind); @@ -82,8 +84,8 @@ public override ValueTypeShapeCharacteristics ComputeValueTypeShapeCharacteristi public static bool IsIntegerType(DefType type) { return type.IsIntrinsic - && type.Namespace == "System" - && ((type.Name == "Int128") || (type.Name == "UInt128")); + && type.U8Namespace.SequenceEqual("System"u8) + && (type.U8Name.SequenceEqual("Int128"u8) || type.U8Name.SequenceEqual("UInt128"u8)); } } } diff --git a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs index 9290e23086dedf..d63cb22667f7f0 100644 --- a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs +++ b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs @@ -642,20 +642,20 @@ protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType } protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) { - if (!string.IsNullOrEmpty(type.Namespace)) + if (!type.U8Namespace.IsEmpty) { - sb.Append(type.Namespace); + sb.Append(type.GetNamespace()); sb.Append('.'); } - sb.Append(type.Name); + sb.Append(type.GetName()); } protected override void AppendNameForNestedType(StringBuilder sb, DefType nestedType, DefType containingType) { AppendName(sb, containingType); sb.Append('/'); - sb.Append(nestedType.Name); + sb.Append(nestedType.GetName()); } #if false diff --git a/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs b/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs index 15d22e79fe8f3b..0ba5fa2cb29993 100644 --- a/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -27,12 +29,11 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp LayoutInt alignment; - string name = defType.Name; - if (name == "Vector64`1") + if (defType.U8Name.SequenceEqual("Vector64`1"u8)) { alignment = new LayoutInt(8); } - else if (name == "Vector128`1") + else if (defType.U8Name.SequenceEqual("Vector128`1"u8)) { if (defType.Context.Target.Architecture == TargetArchitecture.ARM) { @@ -44,7 +45,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp alignment = new LayoutInt(16); } } - else if (name == "Vector256`1") + else if (defType.U8Name.SequenceEqual("Vector256`1"u8)) { if (defType.Context.Target.Architecture == TargetArchitecture.ARM) { @@ -77,7 +78,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp } else { - Debug.Assert(name == "Vector512`1"); + Debug.Assert(defType.U8Name.SequenceEqual("Vector512`1"u8)); if (defType.Context.Target.Architecture == TargetArchitecture.ARM) { @@ -165,11 +166,11 @@ public override ValueTypeShapeCharacteristics ComputeValueTypeShapeCharacteristi public static bool IsVectorType(DefType type) { return type.IsIntrinsic && - type.Namespace == "System.Runtime.Intrinsics" && - ((type.Name == "Vector64`1") || - (type.Name == "Vector128`1") || - (type.Name == "Vector256`1") || - (type.Name == "Vector512`1")); + type.U8Namespace.SequenceEqual("System.Runtime.Intrinsics"u8) && + (type.U8Name.SequenceEqual("Vector64`1"u8) || + type.U8Name.SequenceEqual("Vector128`1"u8) || + type.U8Name.SequenceEqual("Vector256`1"u8) || + type.U8Name.SequenceEqual("Vector512`1"u8)); } } } diff --git a/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs b/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs index fc082980fefbec..00a124a380a9be 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs @@ -187,8 +187,8 @@ public static ushort ComputeFlagsEx(TypeDesc type) if (type is MetadataType mdType && mdType.Module == mdType.Context.SystemModule && - mdType.Name is "WeakReference" or "WeakReference`1" && - mdType.Namespace == "System") + (mdType.U8Name.SequenceEqual("WeakReference"u8) || mdType.U8Name.SequenceEqual("WeakReference`1"u8)) && + mdType.U8Namespace.SequenceEqual("System"u8)) { flagsEx |= (ushort)EETypeFlagsEx.HasEagerFinalizerFlag; } @@ -273,8 +273,8 @@ private static bool HasCriticalFinalizer(TypeDesc type) if (type is MetadataType mdType && mdType.Module == mdType.Context.SystemModule && - mdType.Name == "CriticalFinalizerObject" && - mdType.Namespace == "System.Runtime.ConstrainedExecution") + mdType.U8Name.SequenceEqual("CriticalFinalizerObject"u8) && + mdType.U8Namespace.SequenceEqual("System.Runtime.ConstrainedExecution"u8)) return true; type = type.BaseType; diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index e6fd0d4f7f80e0..a48890b59d5b26 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -2021,8 +2021,8 @@ private CorInfoType asCorInfoType(CORINFO_CLASS_STRUCT_* cls) else if (type is MetadataType mdType) { if (namespaceName != null) - *namespaceName = (byte*)GetPin(StringToUTF8(mdType.Namespace)); - return (byte*)GetPin(StringToUTF8(mdType.Name)); + *namespaceName = (byte*)GetPin(SpanToPinnableBytes(mdType.U8Namespace)); + return (byte*)GetPin(SpanToPinnableBytes(mdType.U8Name)); } if (namespaceName != null) @@ -2503,8 +2503,8 @@ private GetTypeLayoutResult GetTypeLayoutHelper(MetadataType type, uint parentIn // not care about since they are considered primitives by the JIT. if (type.IsIntrinsic) { - string ns = type.Namespace; - if (ns == "System.Runtime.Intrinsics" || ns == "System.Numerics") + ReadOnlySpan ns = type.U8Namespace; + if (ns.SequenceEqual("System.Runtime.Intrinsics"u8) || ns.SequenceEqual("System.Numerics"u8)) { parNode->simdTypeHnd = ObjectToHandle(type); if (parentIndex != uint.MaxValue) @@ -3174,7 +3174,7 @@ private static CORINFO_FIELD_ACCESSOR getFieldIntrinsic(FieldDesc field) { return CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INTRINSIC_EMPTY_STRING; } - else if (owningType.Name == "BitConverter" && owningType.Namespace == "System" && + else if (owningType.U8Name.SequenceEqual("BitConverter"u8) && owningType.U8Namespace.SequenceEqual("System"u8) && field.Name == "IsLittleEndian") { return CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN; @@ -3391,6 +3391,13 @@ private static byte[] StringToUTF8(string s) return bytes; } + private static byte[] SpanToPinnableBytes(ReadOnlySpan s) + { + byte[] bytes = new byte[s.Length + 1]; + s.CopyTo(bytes); + return bytes; + } + private nuint printMethodName(CORINFO_METHOD_STRUCT_* ftn, byte* buffer, nuint bufferSize, nuint* requiredBufferSize) { MethodDesc method = HandleToObject(ftn); @@ -3407,8 +3414,8 @@ private static string getMethodNameFromMetadataImpl(MethodDesc method, out strin MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - className = owningType.Name; - namespaceName = owningType.Namespace; + className = owningType.GetName(); + namespaceName = owningType.GetNamespace(); // Query enclosingClassName when the method is in a nested class // and get the namespace of enclosing classes (nested class's namespace is empty) @@ -3419,8 +3426,8 @@ private static string getMethodNameFromMetadataImpl(MethodDesc method, out strin if (containingType == null) break; - enclosingClassName[i] = containingType.Name; - namespaceName = containingType.Namespace; + enclosingClassName[i] = containingType.GetName(); + namespaceName = containingType.GetNamespace(); } } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs b/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs index 8a24639960115d..0837d5347f149b 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs @@ -1306,15 +1306,15 @@ public static InstructionSet LookupPlatformIntrinsicInstructionSet(TargetArchite if (metadataType == null) return InstructionSet.ILLEGAL; - string namespaceName = metadataType.Namespace; - string typeName = metadataType.Name; + string namespaceName = metadataType.GetNamespace(); + string typeName = metadataType.GetName(); string nestedTypeName = null; while (metadataType.ContainingType != null) { var enclosingType = (MetadataType)metadataType.ContainingType; - namespaceName = enclosingType.Namespace; - nestedTypeName = nestedTypeName is null ? metadataType.Name : $"{metadataType.Name}_{nestedTypeName}"; - typeName = enclosingType.Name; + namespaceName = enclosingType.GetNamespace(); + nestedTypeName = nestedTypeName is null ? metadataType.GetName() : $"{metadataType.GetName()}_{nestedTypeName}"; + typeName = enclosingType.GetName(); metadataType = enclosingType; } diff --git a/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs b/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs index be76a1cded83d4..2aa4497e5f9206 100644 --- a/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs +++ b/src/coreclr/tools/Common/JitInterface/JitTypeNameFormatter.cs @@ -79,20 +79,20 @@ protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) { - string ns = type.Namespace; + string ns = type.GetNamespace(); if (ns.Length > 0) { sb.Append(ns); sb.Append('.'); } - sb.Append(type.Name); + sb.Append(type.GetName()); } protected override void AppendNameForNestedType(StringBuilder sb, DefType nestedType, DefType containingType) { AppendName(sb, containingType); sb.Append('+'); - sb.Append(nestedType.Name); + sb.Append(nestedType.GetName()); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs index 0bd21802de7cfc..e8a22139765f68 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.Diagnostic.cs @@ -9,14 +9,14 @@ public override string DiagnosticName { get { - return Name; + return GetName(); } } public override string DiagnosticNamespace { get { - return Namespace; + return GetNamespace(); } } } @@ -27,14 +27,14 @@ public override string DiagnosticName { get { - return Name; + return GetName(); } } public override string DiagnosticNamespace { get { - return Namespace; + return GetNamespace(); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs b/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs index a757df953fea38..e20cb63fe1eac7 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs @@ -1,10 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Debug = System.Diagnostics.Debug; +using System; using System.Collections.Generic; + using Internal.TypeSystem.Ecma; +using Debug = System.Diagnostics.Debug; + namespace Internal.TypeSystem { public static partial class CastingHelper @@ -125,10 +128,10 @@ static bool IsEquivalentTo_TypeDefinition(MetadataType type1, MetadataType type2 if (!data1.Equals(data2)) return false; - if (type1.Name != type2.Name) + if (!type1.U8Name.SequenceEqual(type2.U8Name)) return false; - if (type1.Namespace != type2.Namespace) + if (!type1.U8Namespace.SequenceEqual(type2.U8Namespace)) return false; var containingType1 = (MetadataType)type1.ContainingType; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/DefType.Dummy.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Common/DefType.Dummy.Diagnostic.cs index 1acdbd8731b6a0..5da904f76e1688 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/DefType.Dummy.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/DefType.Dummy.Diagnostic.cs @@ -9,11 +9,11 @@ public abstract partial class DefType /// /// Gets the Name of a type. This must not throw /// - public string DiagnosticName => Name; + public string DiagnosticName => GetName(); /// /// Gets the Namespace of a type. This must not throw /// - public string DiagnosticNamespace => Namespace; + public string DiagnosticNamespace => GetNamespace(); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs b/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs index 948f090fb4e6c1..60d1ac0562d506 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs @@ -18,6 +18,8 @@ public abstract partial class DefType : TypeDesc public virtual ReadOnlySpan U8Namespace => []; + public string GetNamespace() => System.Text.Encoding.UTF8.GetString(U8Namespace); + /// /// Gets the name of the type as represented in the metadata. /// @@ -25,6 +27,8 @@ public abstract partial class DefType : TypeDesc public virtual ReadOnlySpan U8Name => []; + public string GetName() => System.Text.Encoding.UTF8.GetString(U8Name); + /// /// Gets the containing type of this type or null if the type is not nested. /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs index 2e04cfb85c8edf..2a71ef8a71def4 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using Debug = System.Diagnostics.Debug; @@ -105,8 +106,8 @@ protected internal sealed override bool IsIDynamicInterfaceCastableInterface(Def { MetadataType t = (MetadataType)type; return t.Module == SystemModule - && t.Name == "IDynamicInterfaceCastable" - && t.Namespace == "System.Runtime.InteropServices"; + && t.U8Name.SequenceEqual("IDynamicInterfaceCastable"u8) + && t.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs index 29f3c6e6f2acf8..70fdf0d431bf6b 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs @@ -166,8 +166,8 @@ public static MethodDesc FindMethodOnTypeWithMatchingTypicalMethod(this TypeDesc /// public static string GetFullName(this DefType metadataType) { - string ns = metadataType.Namespace; - return ns.Length > 0 ? string.Concat(ns, ".", metadataType.Name) : metadataType.Name; + string ns = metadataType.GetNamespace(); + return ns.Length > 0 ? string.Concat(ns, ".", metadataType.GetName()) : metadataType.GetName(); } /// diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameFormatter.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameFormatter.cs index 67ee949b835402..423709c4c10678 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameFormatter.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameFormatter.cs @@ -129,13 +129,13 @@ protected override IAssemblyDesc AppendNameForInstantiatedType(StringBuilder sb, protected override IAssemblyDesc AppendNameForNamespaceType(StringBuilder sb, DefType type, bool assemblyQualify) { - string ns = type.Namespace; + string ns = type.GetNamespace(); if (ns.Length > 0) { AppendEscapedIdentifier(sb, ns); sb.Append('.'); } - AppendEscapedIdentifier(sb, type.Name); + AppendEscapedIdentifier(sb, type.GetName()); if (type is MetadataType mdType) { @@ -156,7 +156,7 @@ protected override IAssemblyDesc AppendNameForNestedType(StringBuilder sb, DefTy sb.Append('+'); - AppendEscapedIdentifier(sb, nestedType.Name); + AppendEscapedIdentifier(sb, nestedType.GetName()); if (assemblyQualify) AppendAssemblyName(sb, homeAssembly); diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/ExceptionTypeNameFormatter.Metadata.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/ExceptionTypeNameFormatter.Metadata.cs index 79a6da8f59a456..893bc6a1e96cec 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/ExceptionTypeNameFormatter.Metadata.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/ExceptionTypeNameFormatter.Metadata.cs @@ -8,12 +8,12 @@ public partial class ExceptionTypeNameFormatter { private static string GetTypeName(DefType type) { - return type.Name; + return type.GetName(); } private static string GetTypeNamespace(DefType type) { - return type.Namespace; + return type.GetNamespace(); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs index 0b1390765a7dcc..43c366e5e4da8f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs @@ -88,9 +88,9 @@ public bool IsSystemType(TypeDesc type) { var metadataType = type as MetadataType; return metadataType != null - && metadataType.Name == "Type" + && metadataType.U8Name.SequenceEqual("Type"u8) && metadataType.Module == _module.Context.SystemModule - && metadataType.Namespace == "System"; + && metadataType.U8Namespace.SequenceEqual("System"u8); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Diagnostic.cs index d991a3f9b283d4..fa765d81a0ac2c 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Diagnostic.cs @@ -17,7 +17,7 @@ public override string DiagnosticName { try { - return Name; + return GetName(); } catch { @@ -31,7 +31,7 @@ public override string DiagnosticNamespace { try { - return Namespace; + return GetNamespace(); } catch { diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.TypeEquivalence.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.TypeEquivalence.cs index b7fb3327a2655d..30da82af59367f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.TypeEquivalence.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.TypeEquivalence.cs @@ -41,10 +41,10 @@ private TypeIdentifierData ComputeTypeIdentifierFromGuids() return null; string scope = (string)guidAttribute.Value.FixedArguments[0].Value; - string name = this.Name; + string name = this.GetName(); - if (this.Namespace != null) - name = this.Namespace + "." + name; + if (this.U8Namespace.Length > 0) + name = this.GetNamespace() + "." + name; return new TypeIdentifierData(scope, name); } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs index f3cd3bdb4f0218..0c8eb573dc784c 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs @@ -157,7 +157,7 @@ private MetadataType InitializeBaseType() if (type == null) { // PREFER: "new TypeSystemException.TypeLoadException(ExceptionStringID.ClassLoadBadFormat, this)" but the metadata is too broken - ThrowHelper.ThrowTypeLoadException(Namespace, Name, Module); + ThrowHelper.ThrowTypeLoadException(GetNamespace(), GetName(), Module); } _baseType = type; return type; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs b/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs index cb71913d0232c3..1aef1f567f51ac 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs @@ -614,20 +614,20 @@ public void AppendNameForNamespaceTypeWithoutAliases(StringBuilder sb, DefType t sb.Append(']'); } - string ns = type.Namespace; + string ns = type.GetNamespace(); if (ns.Length > 0) { sb.Append(ns); sb.Append('.'); } - sb.Append(type.Name); + sb.Append(type.GetName()); } protected override void AppendNameForNestedType(StringBuilder sb, DefType nestedType, DefType containingType) { AppendName(sb, containingType); sb.Append('/'); - sb.Append(nestedType.Name); + sb.Append(nestedType.GetName()); } } #endregion diff --git a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs index b692bf826636fb..e4089bb366a059 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs @@ -44,29 +44,29 @@ private static MethodIL TryGetIntrinsicMethodIL(MethodDesc method) if (owningType == null) return null; - switch (owningType.Name) + switch (owningType.GetName()) { case "Unsafe": { - if (owningType.Namespace == "System.Runtime.CompilerServices") + if (owningType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) return UnsafeIntrinsics.EmitIL(method); } break; case "Debug": { - if (owningType.Namespace == "System.Diagnostics" && method.Name == "DebugBreak") + if (owningType.U8Namespace.SequenceEqual("System.Diagnostics"u8) && method.Name == "DebugBreak") return new ILStubMethodIL(method, new byte[] { (byte)ILOpcode.break_, (byte)ILOpcode.ret }, Array.Empty(), null); } break; case "RuntimeAugments": { - if (owningType.Namespace == "Internal.Runtime.Augments" && method.Name == "GetCanonType") + if (owningType.U8Namespace.SequenceEqual("Internal.Runtime.Augments"u8) && method.Name == "GetCanonType") return GetCanonTypeIntrinsic.EmitIL(method); } break; case "MethodTable": { - if (owningType.Namespace == "Internal.Runtime" && method.Name == "get_SupportsRelativePointers") + if (owningType.U8Namespace.SequenceEqual("Internal.Runtime"u8) && method.Name == "get_SupportsRelativePointers") { ILOpcode value = method.Context.Target.SupportsRelativePointers ? ILOpcode.ldc_i4_1 : ILOpcode.ldc_i4_0; @@ -76,7 +76,7 @@ private static MethodIL TryGetIntrinsicMethodIL(MethodDesc method) break; case "Stream": { - if (owningType.Namespace == "System.IO") + if (owningType.U8Namespace.SequenceEqual("System.IO"u8)) return StreamIntrinsics.EmitIL(method); } break; @@ -100,11 +100,11 @@ private static MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc metho string methodName = method.Name; - switch (owningType.Name) + switch (owningType.GetName()) { case "Interlocked": { - if (owningType.Namespace == "System.Threading") + if (owningType.U8Namespace.SequenceEqual("System.Threading"u8)) return InterlockedIntrinsics.EmitIL(method); } break; @@ -132,25 +132,25 @@ private static MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc metho break; case "RuntimeHelpers": { - if (owningType.Namespace == "System.Runtime.CompilerServices") + if (owningType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) return RuntimeHelpersIntrinsics.EmitIL(method); } break; case "Comparer`1": { - if (methodName == "Create" && owningType.Namespace == "System.Collections.Generic") + if (methodName == "Create" && owningType.U8Namespace.SequenceEqual("System.Collections.Generic"u8)) return ComparerIntrinsics.EmitComparerCreate(method); } break; case "EqualityComparer`1": { - if (methodName == "Create" && owningType.Namespace == "System.Collections.Generic") + if (methodName == "Create" && owningType.U8Namespace.SequenceEqual("System.Collections.Generic"u8)) return ComparerIntrinsics.EmitEqualityComparerCreate(method); } break; case "ComparerHelpers": { - if (owningType.Namespace != "Internal.IntrinsicSupport") + if (!owningType.U8Namespace.SequenceEqual("Internal.IntrinsicSupport"u8)) return null; if (methodName == "EnumOnlyCompare") @@ -184,7 +184,7 @@ private static MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc metho break; case "EqualityComparerHelpers": { - if (owningType.Namespace != "Internal.IntrinsicSupport") + if (!owningType.U8Namespace.SequenceEqual("Internal.IntrinsicSupport"u8)) return null; if (methodName == "EnumOnlyEquals") diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs index c5aa13bd3ddf11..506592be2c2348 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -18,7 +20,7 @@ public static MethodIL EmitIL( #endif // READYTORUN MethodDesc method) { - Debug.Assert(((MetadataType)method.OwningType).Name == "Interlocked"); + Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("Interlocked"u8)); Debug.Assert(!method.IsGenericMethodDefinition); if (method.HasInstantiation && method.Name == "CompareExchange") diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index ad0670d36f7e94..ccbab79c7c9625 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -16,7 +16,7 @@ public static class RuntimeHelpersIntrinsics { public static MethodIL EmitIL(MethodDesc method) { - Debug.Assert(((MetadataType)method.OwningType).Name == "RuntimeHelpers"); + Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("RuntimeHelpers"u8)); string methodName = method.Name; // All the methods handled below are per-instantiation generic methods @@ -58,8 +58,8 @@ public static MethodIL EmitIL(MethodDesc method) if (elementType is MetadataType mdType) { if (mdType.Module == mdType.Context.SystemModule && - mdType.Namespace == "System.Text" && - mdType.Name == "Rune") + mdType.U8Namespace.SequenceEqual("System.Text"u8) && + mdType.U8Name.SequenceEqual("Rune"u8)) { result = true; } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs index c9e65cc40fa9e0..c2ce861de369db 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -14,7 +16,7 @@ public static class StreamIntrinsics { public static MethodIL EmitIL(MethodDesc method) { - Debug.Assert(((MetadataType)method.OwningType).Name == "Stream"); + Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("Stream"u8)); bool isRead = method.Name == "HasOverriddenBeginEndRead"; if (!isRead && method.Name != "HasOverriddenBeginEndWrite") diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs index 8bc6bec60c9132..9cb7f55b6ad023 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs @@ -334,7 +334,7 @@ public override MethodIL EmitIL() } catch (NotSupportedException) { - string message = "Struct '" + ((MetadataType)ManagedType).Name + + string message = "Struct '" + ((MetadataType)ManagedType).GetName() + "' requires marshalling that is not yet supported by this compiler."; return MarshalHelpers.EmitExceptionBody(message, this); } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs index 2b90323728049f..ce5e310672c5de 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs @@ -16,7 +16,7 @@ public static class UnsafeIntrinsics { public static MethodIL EmitIL(MethodDesc method) { - Debug.Assert(((MetadataType)method.OwningType).Name == "Unsafe"); + Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("Unsafe"u8)); switch (method.Name) { diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs index 565a890b2de7b3..4759e0e2a8a12f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs @@ -202,8 +202,8 @@ private static bool HasCopyConstructorCustomModifier(int? parameterIndex, if (customModifierType == null) continue; - if ((customModifierType.Namespace == "System.Runtime.CompilerServices" && customModifierType.Name == "IsCopyConstructed") || - (customModifierType.Namespace == "Microsoft.VisualC" && customModifierType.Name == "NeedsCopyConstructorModifier")) + if ((customModifierType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) && customModifierType.U8Name.SequenceEqual("IsCopyConstructed"u8)) || + (customModifierType.U8Namespace.SequenceEqual("Microsoft.VisualC"u8) && customModifierType.U8Name.SequenceEqual("NeedsCopyConstructorModifier"u8))) { return true; } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs b/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs index 247e09e7f77e13..66103c6c9c0f7e 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Internal.IL; namespace Internal.TypeSystem.Interop @@ -77,92 +79,92 @@ public static bool IsCriticalHandle(TypeSystemContext context, TypeDesc type) return IsOrDerivesFromType(type, GetCriticalHandle(context)); } - private static bool IsCoreNamedType(TypeSystemContext context, TypeDesc type, string @namespace, string name) + private static bool IsCoreNamedType(TypeSystemContext context, TypeDesc type, ReadOnlySpan @namespace, ReadOnlySpan name) { return type is MetadataType mdType && - mdType.Name == name && - mdType.Namespace == @namespace && + mdType.U8Name.SequenceEqual(name) && + mdType.U8Namespace.SequenceEqual(@namespace) && mdType.Module == context.SystemModule; } public static bool IsHandleRef(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System.Runtime.InteropServices", "HandleRef"); + return IsCoreNamedType(context, type, "System.Runtime.InteropServices"u8, "HandleRef"u8); } public static bool IsSystemDateTime(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System", "DateTime"); + return IsCoreNamedType(context, type, "System"u8, "DateTime"u8); } public static bool IsStringBuilder(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System.Text", "StringBuilder"); + return IsCoreNamedType(context, type, "System.Text"u8, "StringBuilder"u8); } public static bool IsSystemDecimal(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System", "Decimal"); + return IsCoreNamedType(context, type, "System"u8, "Decimal"u8); } public static bool IsSystemDelegate(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System", "Delegate"); + return IsCoreNamedType(context, type, "System"u8, "Delegate"u8); } public static bool IsSystemMulticastDelegate(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System", "MulticastDelegate"); + return IsCoreNamedType(context, type, "System"u8, "MulticastDelegate"u8); } public static bool IsSystemGuid(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System", "Guid"); + return IsCoreNamedType(context, type, "System"u8, "Guid"u8); } public static bool IsSystemArgIterator(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System", "ArgIterator"); + return IsCoreNamedType(context, type, "System"u8, "ArgIterator"u8); } public static bool IsSystemSpan(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System", "Span`1"); + return IsCoreNamedType(context, type, "System"u8, "Span`1"u8); } public static bool IsSystemReadOnlySpan(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System", "ReadOnlySpan`1"); + return IsCoreNamedType(context, type, "System"u8, "ReadOnlySpan`1"u8); } public static bool IsSystemNullable(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System", "Nullable`1"); + return IsCoreNamedType(context, type, "System"u8, "Nullable`1"u8); } public static bool IsSystemRuntimeIntrinsicsVector64T(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector64`1"); + return IsCoreNamedType(context, type, "System.Runtime.Intrinsics"u8, "Vector64`1"u8); } public static bool IsSystemRuntimeIntrinsicsVector128T(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector128`1"); + return IsCoreNamedType(context, type, "System.Runtime.Intrinsics"u8, "Vector128`1"u8); } public static bool IsSystemRuntimeIntrinsicsVector256T(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector256`1"); + return IsCoreNamedType(context, type, "System.Runtime.Intrinsics"u8, "Vector256`1"u8); } public static bool IsSystemRuntimeIntrinsicsVector512T(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector512`1"); + return IsCoreNamedType(context, type, "System.Runtime.Intrinsics"u8, "Vector512`1"u8); } public static bool IsSystemNumericsVectorT(TypeSystemContext context, TypeDesc type) { - return IsCoreNamedType(context, type, "System.Numerics", "Vector`1"); + return IsCoreNamedType(context, type, "System.Numerics"u8, "Vector`1"u8); } private static bool IsOrDerivesFromType(TypeDesc type, MetadataType targetType) diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs b/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs index 98cdb658a42248..a67ff236256678 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs @@ -189,10 +189,10 @@ private static UnmanagedCallingConventions GetUnmanagedCallingConventionFromAttr private static UnmanagedCallingConventions AccumulateCallingConventions(UnmanagedCallingConventions existing, MetadataType newConvention) { - if (newConvention.Namespace != "System.Runtime.CompilerServices") + if (!newConvention.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) return existing; - UnmanagedCallingConventions? addedCallConv = newConvention.Name switch + UnmanagedCallingConventions? addedCallConv = newConvention.GetName() switch { "CallConvCdecl" => UnmanagedCallingConventions.Cdecl, "CallConvStdcall" => UnmanagedCallingConventions.Stdcall, diff --git a/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs b/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs index 77d31895e7b134..8a81964b1402b8 100644 --- a/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs @@ -213,8 +213,8 @@ public EntityHandle GetTypeRef(TypeDesc type) if (type.IsTypeDefinition && type is MetadataType metadataType) { // Make a typeref - StringHandle typeName = _metadataBuilder.GetOrAddString(metadataType.Name); - StringHandle typeNamespace = metadataType.Namespace != null ? _metadataBuilder.GetOrAddString(metadataType.Namespace) : default(StringHandle); + StringHandle typeName = _metadataBuilder.GetOrAddString(metadataType.GetName()); + StringHandle typeNamespace = metadataType.U8Namespace.Length > 0 ? _metadataBuilder.GetOrAddString(metadataType.GetNamespace()) : default(StringHandle); EntityHandle resolutionScope; if (metadataType.ContainingType == null) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/SwiftLoweringTests.cs b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/SwiftLoweringTests.cs index 21122fec7ffd20..bcd93162c92c1b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/SwiftLoweringTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/SwiftLoweringTests.cs @@ -45,7 +45,8 @@ public static IEnumerable DiscoverSwiftTypes() var testModule = context.GetModuleForSimpleName("ILCompiler.Compiler.Tests.Assets"); foreach (var type in testModule.GetAllTypes()) { - if (type is EcmaType { Namespace: "ILCompiler.Compiler.Tests.Assets.SwiftTypes", IsValueType: true } ecmaType + if (type is EcmaType { IsValueType: true } ecmaType + && ecmaType.U8Namespace.SequenceEqual("ILCompiler.Compiler.Tests.Assets.SwiftTypes"u8) && ecmaType.GetDecodedCustomAttribute("ILCompiler.Compiler.Tests.Assets.SwiftTypes", "ExpectedLoweringAttribute") is { } expectedLoweringAttribute) { // By default, we assume that our lowered representation is meant to be naturally aligned. @@ -96,7 +97,7 @@ public static IEnumerable DiscoverSwiftTypes() } } } - yield return new object[] { type.Name, type, expected }; + yield return new object[] { type.GetName(), type, expected }; } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs index 1d46b96d22ea7c..83505068f3d1d0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs @@ -175,9 +175,9 @@ public MethodDesc ExpandIntrinsicForCallsite(MethodDesc intrinsicMethod, MethodD if (intrinsicOwningType.Module != TypeSystemContext.SystemModule) return intrinsicMethod; - if (intrinsicOwningType.Name == "Type" && intrinsicOwningType.Namespace == "System") + if (intrinsicOwningType.U8Name.SequenceEqual("Type"u8) && intrinsicOwningType.U8Namespace.SequenceEqual("System"u8)) { - if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.Name == "GetType") + if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.U8Name.SequenceEqual("GetType"u8)) { ModuleDesc callsiteModule = (callsiteMethod.OwningType as MetadataType)?.Module; if (callsiteModule != null) @@ -187,7 +187,7 @@ public MethodDesc ExpandIntrinsicForCallsite(MethodDesc intrinsicMethod, MethodD } } } - else if (intrinsicOwningType.Name == "Assembly" && intrinsicOwningType.Namespace == "System.Reflection") + else if (intrinsicOwningType.U8Name.SequenceEqual("Assembly"u8) && intrinsicOwningType.U8Namespace.SequenceEqual("System.Reflection"u8)) { if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.Name == "GetExecutingAssembly") { @@ -199,9 +199,9 @@ public MethodDesc ExpandIntrinsicForCallsite(MethodDesc intrinsicMethod, MethodD } } } - else if (intrinsicOwningType.Name == "MethodBase" && intrinsicOwningType.Namespace == "System.Reflection") + else if (intrinsicOwningType.U8Name.SequenceEqual("MethodBase"u8) && intrinsicOwningType.U8Namespace.SequenceEqual("System.Reflection"u8)) { - if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.Name == "GetCurrentMethod") + if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.U8Name.SequenceEqual("GetCurrentMethod"u8)) { return _methodBaseGetCurrentMethodThunks.GetHelper(callsiteMethod).InstantiateAsOpen(); } @@ -451,11 +451,11 @@ public bool IsFatPointerCandidate(MethodDesc containingMethod, MethodSignature s if (containingMethod.OwningType is MetadataType owningType) { // RawCalliHelper is a way for the class library to opt out of fat calls - if (owningType.Name == "RawCalliHelper") + if (owningType.U8Name.SequenceEqual("RawCalliHelper"u8)) return false; // Delegate invocation never needs fat calls - if (owningType.IsDelegate && containingMethod.Name == "Invoke") + if (owningType.IsDelegate && containingMethod.U8Name.SequenceEqual("Invoke"u8)) return false; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs index 12d00e34571bd5..31fd0489f89919 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs @@ -103,7 +103,7 @@ private bool RequiresValueTypeGetFieldHelperMethod(MetadataType valueType) return false; // ValueTuples override Equals/GetHashCode and don't have a `base.GetHashCode` call. So avoid the infrastructure. - if (valueType.Module == SystemModule && valueType.Name.StartsWith("ValueTuple`", StringComparison.Ordinal) && valueType.Namespace == "System") + if (valueType.Module == SystemModule && valueType.U8Name.StartsWith("ValueTuple`"u8) && valueType.U8Namespace.SequenceEqual("System"u8)) return false; return !_typeStateHashtable.GetOrCreateValue(valueType).CanCompareValueTypeBits; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs index 365ed545d7791c..99b9fd3cf9a565 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs @@ -38,7 +38,7 @@ public void TrackCall(MethodDesc fromMethod, DefType toType) { Debug.Assert(fromMethod.IsTypicalMethodDefinition); Debug.Assert(toType.IsTypeDefinition); - Debug.Assert(CompilerGeneratedNames.IsStateMachineType(toType.Name)); + Debug.Assert(CompilerGeneratedNames.IsStateMachineType(toType.GetName())); TrackCallInternal(fromMethod, toType); } @@ -46,7 +46,7 @@ public void TrackCall(DefType fromType, MethodDesc toMethod) { Debug.Assert(fromType.IsTypeDefinition); Debug.Assert(toMethod.IsTypicalMethodDefinition); - Debug.Assert(CompilerGeneratedNames.IsStateMachineType(fromType.Name)); + Debug.Assert(CompilerGeneratedNames.IsStateMachineType(fromType.GetName())); Debug.Assert(CompilerGeneratedNames.IsLambdaOrLocalFunction(toMethod.Name)); TrackCallInternal(fromType, toMethod); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs index a4360d9a33a52e..533fa5883b0a3d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs @@ -111,7 +111,7 @@ internal void LogWarnings(Logger? logger) internal TypeCache(MetadataType type, ILProvider ilProvider) { Debug.Assert(type == type.GetTypeDefinition()); - Debug.Assert(!CompilerGeneratedNames.IsStateMachineOrDisplayClass(type.Name)); + Debug.Assert(!CompilerGeneratedNames.IsStateMachineOrDisplayClass(type.GetName())); Type = type; @@ -132,7 +132,7 @@ void ProcessMethod(MethodDesc method) { Debug.Assert(method == method.GetTypicalMethodDefinition()); - bool isStateMachineMember = CompilerGeneratedNames.IsStateMachineType(((MetadataType)method.OwningType).Name); + bool isStateMachineMember = CompilerGeneratedNames.IsStateMachineType(((MetadataType)method.OwningType).GetName()); if (!CompilerGeneratedNames.IsLambdaOrLocalFunction(method.Name)) { if (!isStateMachineMember) @@ -177,7 +177,7 @@ void ProcessMethod(MethodDesc method) referencedMethod.OwningType is MetadataType generatedType && // Don't consider calls in the same/nested type, like inside a static constructor !IsSameOrNestedType(method.OwningType, generatedType) && - CompilerGeneratedNames.IsLambdaDisplayClass(generatedType.Name)) + CompilerGeneratedNames.IsLambdaDisplayClass(generatedType.GetName())) { Debug.Assert(generatedType.IsTypeDefinition); @@ -218,7 +218,7 @@ referencedMethod.OwningType is MetadataType generatedType && if (field.OwningType is MetadataType generatedType && // Don't consider field accesses in the same/nested type, like inside a static constructor !IsSameOrNestedType(method.OwningType, generatedType) && - CompilerGeneratedNames.IsLambdaDisplayClass(generatedType.Name)) + CompilerGeneratedNames.IsLambdaDisplayClass(generatedType.GetName())) { Debug.Assert(generatedType.IsTypeDefinition); @@ -243,7 +243,7 @@ referencedMethod.OwningType is MetadataType generatedType && if (TryGetStateMachineType(method, out MetadataType? stateMachineType)) { Debug.Assert(stateMachineType.ContainingType == type || - (CompilerGeneratedNames.IsStateMachineOrDisplayClass(stateMachineType.ContainingType.Name) && + (CompilerGeneratedNames.IsStateMachineOrDisplayClass(stateMachineType.ContainingType.GetName()) && stateMachineType.ContainingType.ContainingType == type)); Debug.Assert(stateMachineType == stateMachineType.GetTypeDefinition()); @@ -334,7 +334,7 @@ static bool IsSameOrNestedType(TypeDesc type, TypeDesc potentialOuterType) // are represented by the state machine type itself. // We are already tracking the association of the state machine type to the user code method // above, so no need to track it here. - Debug.Assert(CompilerGeneratedNames.IsStateMachineType(stateMachineType.Name)); + Debug.Assert(CompilerGeneratedNames.IsStateMachineType(stateMachineType.GetName())); break; default: throw new InvalidOperationException(); @@ -386,7 +386,7 @@ void MapGeneratedTypeTypeParameters( MetadataType generatedType, Dictionary generatedTypeToTypeArgs) { - Debug.Assert(CompilerGeneratedNames.IsStateMachineOrDisplayClass(generatedType.Name)); + Debug.Assert(CompilerGeneratedNames.IsStateMachineOrDisplayClass(generatedType.GetName())); Debug.Assert(generatedType == generatedType.GetTypeDefinition()); var typeInfo = generatedTypeToTypeArgs[generatedType]; @@ -426,7 +426,7 @@ void MapGeneratedTypeTypeParameters( else { // Must be a type ref - if (method.OwningType is not MetadataType owningType || !CompilerGeneratedNames.IsStateMachineOrDisplayClass(owningType.Name)) + if (method.OwningType is not MetadataType owningType || !CompilerGeneratedNames.IsStateMachineOrDisplayClass(owningType.GetName())) { userAttrs = param; } @@ -567,7 +567,7 @@ private static IEnumerable GetCompilerGeneratedNestedTypes(Metadat { foreach (var nestedType in type.GetNestedTypes()) { - if (!CompilerGeneratedNames.IsStateMachineOrDisplayClass(nestedType.Name)) + if (!CompilerGeneratedNames.IsStateMachineOrDisplayClass(nestedType.GetName())) continue; yield return nestedType; @@ -579,10 +579,10 @@ private static IEnumerable GetCompilerGeneratedNestedTypes(Metadat public static bool IsHoistedLocal(FieldDesc field) { - if (CompilerGeneratedNames.IsLambdaDisplayClass(field.OwningType.Name)) + if (CompilerGeneratedNames.IsLambdaDisplayClass(field.OwningType.GetName())) return true; - if (CompilerGeneratedNames.IsStateMachineType(field.OwningType.Name)) + if (CompilerGeneratedNames.IsStateMachineType(field.OwningType.GetName())) { // Don't track the "current" field which is used for state machine return values, // because this can be expensive to track. @@ -601,7 +601,7 @@ public static bool IsNestedFunctionOrStateMachineMember(TypeSystemEntity member) if (member.GetOwningType() is not MetadataType declaringType) return false; - return CompilerGeneratedNames.IsStateMachineType(declaringType.Name); + return CompilerGeneratedNames.IsStateMachineType(declaringType.GetName()); } public static bool TryGetStateMachineType(MethodDesc method, [NotNullWhen(true)] out MetadataType? stateMachineType) @@ -631,7 +631,7 @@ public static bool TryGetStateMachineType(MethodDesc method, [NotNullWhen(true)] // State machines can be emitted into display classes, so we may also need to go one more level up. // To avoid depending on implementation details, we go up until we see a non-compiler-generated type. // This is the counterpart to GetCompilerGeneratedNestedTypes. - while (userType != null && CompilerGeneratedNames.IsStateMachineOrDisplayClass(userType.Name)) + while (userType != null && CompilerGeneratedNames.IsStateMachineOrDisplayClass(userType.GetName())) userType = userType.ContainingType as MetadataType; if (userType is null) @@ -676,7 +676,7 @@ public bool TryGetCompilerGeneratedCalleesForUserMethod(MethodDesc method, [NotN public IReadOnlyList? GetGeneratedTypeAttributes(MetadataType type) { MetadataType generatedType = (MetadataType)type.GetTypeDefinition(); - Debug.Assert(CompilerGeneratedNames.IsStateMachineOrDisplayClass(generatedType.Name)); + Debug.Assert(CompilerGeneratedNames.IsStateMachineOrDisplayClass(generatedType.GetName())); // Avoid the heuristics for .NET10+, where DynamicallyAccessedMembers flows to generated code // because it is annotated with CompilerLoweringPreserveAttribute. diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs index 737d99d93be908..a9be70fdf3f9e1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs @@ -270,16 +270,16 @@ public static bool IsTypeInterestingForDataflow(TypeDesc type) foreach (var intf in type.RuntimeInterfaces) { - if (intf.Name == "IReflect" && intf.Namespace == "System.Reflection") + if (intf.U8Name.SequenceEqual("IReflect"u8) && intf.U8Namespace.SequenceEqual("System.Reflection"u8)) return true; } - if (metadataType.Name == "IReflect" && metadataType.Namespace == "System.Reflection") + if (metadataType.U8Name.SequenceEqual("IReflect"u8) && metadataType.U8Namespace.SequenceEqual("System.Reflection"u8)) return true; do { - if (metadataType.Name == "Type" && metadataType.Namespace == "System") + if (metadataType.U8Name.SequenceEqual("Type"u8) && metadataType.U8Namespace.SequenceEqual("System"u8)) return true; } while ((metadataType = metadataType.MetadataBaseType) != null); @@ -642,7 +642,7 @@ protected override TypeAnnotations CreateValueFromKey(TypeDesc key) private IReadOnlyList? GetGeneratedTypeAttributes(EcmaType typeDef) { - if (!CompilerGeneratedNames.IsStateMachineOrDisplayClass(typeDef.Name)) + if (!CompilerGeneratedNames.IsStateMachineOrDisplayClass(typeDef.GetName())) { return null; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs index 7469d7b0256476..953c8208411b0c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs @@ -663,7 +663,7 @@ private partial IEnumerable GetMethodsOnTypeHie private partial IEnumerable GetNestedTypesOnType(TypeProxy type, string name, BindingFlags? bindingFlags) { - foreach (var nestedType in type.Type.GetNestedTypesOnType(t => t.Name == name, bindingFlags)) + foreach (var nestedType in type.Type.GetNestedTypesOnType(t => t.U8Name.StringEquals(name), bindingFlags)) yield return new SystemTypeValue(new TypeProxy(nestedType)); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CallingConventionConverterKey.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CallingConventionConverterKey.cs index eb5933b3e2b37a..2933176ecb8df5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CallingConventionConverterKey.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CallingConventionConverterKey.cs @@ -164,12 +164,12 @@ protected override void AppendNameForNestedType(StringBuilder sb, DefType nested private static string GetTypeName(DefType type) { - return type.Name; + return type.GetName(); } private static string GetTypeNamespace(DefType type) { - return type.Namespace; + return type.GetNamespace(); } private static char[] s_escapedChars = new char[] { ',', '=', '"', ']', '[', '*', '&', '+', '\\' }; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs index df54d26e3199a7..fc3f7b17bd0b99 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Internal.IL; using Internal.TypeSystem; @@ -34,16 +36,16 @@ public static void AddDependenciesDueToMethodCodePresence(ref DependencyList dep case "Create": if (method.IsSharedByGenericInstantiations && owningType.Module == factory.TypeSystemContext.SystemModule - && owningType.Namespace == "System.Collections.Generic") + && owningType.U8Namespace.SequenceEqual("System.Collections.Generic"u8)) { TypeDesc[] templateDependencies = null; - if (owningType.Name == "Comparer`1") + if (owningType.U8Name.SequenceEqual("Comparer`1"u8)) { templateDependencies = Internal.IL.Stubs.ComparerIntrinsics.GetPotentialComparersForType( owningType.Instantiation[0]); } - else if (owningType.Name == "EqualityComparer`1") + else if (owningType.U8Name.SequenceEqual("EqualityComparer`1"u8)) { templateDependencies = Internal.IL.Stubs.ComparerIntrinsics.GetPotentialEqualityComparersForType( owningType.Instantiation[0]); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs index b696088108bee8..e44b58e048a771 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs @@ -20,7 +20,9 @@ internal sealed class InlineableStringsResourceNode : DependencyNodeCore U8ResourceAccessorTypeName => "SR"u8; public const string ResourceAccessorTypeNamespace = "System"; + public static ReadOnlySpan U8ResourceAccessorTypeNamespace => "System"u8; public const string ResourceAccessorGetStringMethodName = "GetResourceString"; public InlineableStringsResourceNode(EcmaModule module) @@ -61,7 +63,7 @@ public static bool IsInlineableStringsResource(EcmaModule module, string resourc public static void AddDependenciesDueToResourceStringUse(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { if (method.Name == ResourceAccessorGetStringMethodName && method.OwningType is MetadataType mdType - && mdType.Name == ResourceAccessorTypeName && mdType.Namespace == ResourceAccessorTypeNamespace) + && mdType.U8Name.SequenceEqual(U8ResourceAccessorTypeName) && mdType.U8Namespace.SequenceEqual(U8ResourceAccessorTypeNamespace)) { dependencies ??= new DependencyList(); dependencies.Add(factory.InlineableStringResource((EcmaModule)mdType.Module), "Using the System.SR class"); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs index 32514dccc5eee6..498e40ad3cc29a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs @@ -77,7 +77,7 @@ private void ProcessNamespaces(ModuleDesc assembly, XPathNavigator nav) bool foundMatch = false; foreach (DefType type in assembly.GetAllTypes()) { - if (type.Namespace != fullname) + if (!type.U8Namespace.StringEquals(fullname)) continue; foundMatch = true; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureGenerator.PartVisitor.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureGenerator.PartVisitor.cs index 5caa8cc8675454..04022d5613a35a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureGenerator.PartVisitor.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureGenerator.PartVisitor.cs @@ -149,15 +149,15 @@ protected override void AppendNameForNestedType(StringBuilder sb, DefType nested { AppendName(sb, InstantiateContainingType(nestedType)); sb.Append('.'); - sb.Append(nestedType.Name); + sb.Append(nestedType.GetName()); } protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) { - string @namespace = type.Namespace; + string @namespace = type.GetNamespace(); if (!string.IsNullOrEmpty(@namespace)) sb.Append(@namespace).Append('.'); - sb.Append(type.Name); + sb.Append(type.GetName()); } protected override void AppendNameForInstantiatedType(StringBuilder builder, DefType type) @@ -172,12 +172,12 @@ protected override void AppendNameForInstantiatedType(StringBuilder builder, Def } else { - string @namespace = type.Namespace; + string @namespace = type.GetNamespace(); if (!string.IsNullOrEmpty(@namespace)) builder.Append(@namespace).Append('.'); } - string unmangledName = type.Name; + string unmangledName = type.GetName(); int totalArity = type.Instantiation.Length; int nestedArity = totalArity - containingArity; string expectedSuffix = $"`{nestedArity}"; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs index 706b9bc1e62fdf..597f963fad78ee 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs @@ -7,6 +7,8 @@ using System.Linq; using System.Text; +using ILCompiler.Dataflow; + using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -555,8 +557,8 @@ private static void GetMatchingTypes(ModuleDesc module, TypeDesc declaringType, foreach (var nestedType in mdDeclaringType.GetNestedTypes()) { - Debug.Assert(string.IsNullOrEmpty(nestedType.Namespace)); - if (nestedType.Name != name) + Debug.Assert(nestedType.U8Namespace.IsEmpty); + if (!nestedType.U8Name.StringEquals(name)) continue; // Compute arity counting only the newly-introduced generic parameters diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs index d455183bb0b5ae..1599709c3da09c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs @@ -414,8 +414,8 @@ public MethodIL GetMethodILWithInlinedSubstitutions(MethodIL method) { var callee = method.GetObject(reader.ReadILToken(), NotFoundBehavior.ReturnNull) as EcmaMethod; if (callee != null && callee.IsSpecialName && callee.OwningType is EcmaType calleeType - && calleeType.Name == InlineableStringsResourceNode.ResourceAccessorTypeName - && calleeType.Namespace == InlineableStringsResourceNode.ResourceAccessorTypeNamespace + && calleeType.U8Name.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeName) + && calleeType.U8Namespace.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeNamespace) && callee.Signature is { Length: 0, IsStatic: true } && callee.Name.StartsWith("get_", StringComparison.Ordinal)) { @@ -824,7 +824,7 @@ private bool TryGetConstantArgument(MethodIL methodIL, byte[] body, OpcodeFlags[ } else if (method.IsIntrinsic && method.Name is "get_IsValueType" or "get_IsEnum" && method.OwningType is MetadataType mdt - && mdt.Name == "Type" && mdt.Namespace == "System" && mdt.Module == mdt.Context.SystemModule + && mdt.U8Name.SequenceEqual("Type"u8) && mdt.U8Namespace.SequenceEqual("System"u8) && mdt.Module == mdt.Context.SystemModule && TryExpandTypeIs(methodIL, body, flags, currentOffset, method.Name, out constant)) { return true; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs index 27fc440647812f..25576292aff809 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs @@ -73,9 +73,9 @@ private bool TryGetFeatureCheckValue(EcmaMethod method, out bool value) if (featureGuardAttribute.FixedArguments is not [CustomAttributeTypedArgument { Value: EcmaType featureType }]) continue; - if (featureType.Namespace == "System.Diagnostics.CodeAnalysis") + if (featureType.U8Namespace.SequenceEqual("System.Diagnostics.CodeAnalysis"u8)) { - switch (featureType.Name) + switch (featureType.GetName()) { case "RequiresAssemblyFilesAttribute": case "RequiresUnreferencedCodeAttribute": diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapManager.cs index b4392aead3d712..fa5be49b78713e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapManager.cs @@ -32,14 +32,17 @@ public enum TypeMapAttributeKind public static TypeMapAttributeKind LookupTypeMapType(TypeDesc attrType) { - TypeDesc typeDef = attrType.GetTypeDefinition(); - return typeDef switch + var typeDef = attrType.GetTypeDefinition() as MetadataType; + if (typeDef != null && typeDef.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8)) { - MetadataType { Namespace: "System.Runtime.InteropServices", Name: "TypeMapAssemblyTargetAttribute`1", Instantiation.Length: 1 } => TypeMapAttributeKind.TypeMapAssemblyTarget, - MetadataType { Namespace: "System.Runtime.InteropServices", Name: "TypeMapAttribute`1", Instantiation.Length: 1 } => TypeMapAttributeKind.TypeMap, - MetadataType { Namespace: "System.Runtime.InteropServices", Name: "TypeMapAssociationAttribute`1", Instantiation.Length: 1 } => TypeMapAttributeKind.TypeMapAssociation, - _ => TypeMapAttributeKind.None, - }; + if (typeDef.U8Name.SequenceEqual("TypeMapAssemblyTargetAttribute`1"u8)) + return TypeMapAttributeKind.TypeMapAssemblyTarget; + else if (typeDef.U8Name.SequenceEqual("TypeMapAttribute`1"u8)) + return TypeMapAttributeKind.TypeMap; + else if (typeDef.U8Name.SequenceEqual("TypeMapAssociationAttribute`1"u8)) + return TypeMapAttributeKind.TypeMapAssociation; + } + return TypeMapAttributeKind.None; } public virtual void AttachToDependencyGraph(DependencyAnalyzerBase graph) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index 3871f3b059e7bd..4c1d8a4d8015cd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -1825,8 +1825,8 @@ private static bool TryGetSpanElementType(TypeDesc type, bool isReadOnlySpan, ou if (type.IsByRefLike && type is MetadataType maybeSpan && maybeSpan.Module == type.Context.SystemModule - && ((isReadOnlySpan && maybeSpan.Name == "ReadOnlySpan`1") || (!isReadOnlySpan && maybeSpan.Name == "Span`1")) - && maybeSpan.Namespace == "System" + && ((isReadOnlySpan && maybeSpan.U8Name.SequenceEqual("ReadOnlySpan`1"u8)) || (!isReadOnlySpan && maybeSpan.U8Name.SequenceEqual("Span`1"u8))) + && maybeSpan.U8Namespace.SequenceEqual("System"u8) && maybeSpan.Instantiation[0] is MetadataType readOnlySpanElementType) { elementType = readOnlySpanElementType; @@ -1873,7 +1873,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V { case "InitializeArray": if (method.OwningType is MetadataType mdType - && mdType.Name == "RuntimeHelpers" && mdType.Namespace == "System.Runtime.CompilerServices" + && mdType.U8Name.SequenceEqual("RuntimeHelpers"u8) && mdType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) && mdType.Module == mdType.Context.SystemModule && parameters[0] is ArrayInstance array && parameters[1] is RuntimeFieldHandleValue fieldHandle @@ -1886,7 +1886,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V return false; case "CreateSpan": if (method.OwningType is MetadataType createSpanType - && createSpanType.Name == "RuntimeHelpers" && createSpanType.Namespace == "System.Runtime.CompilerServices" + && createSpanType.U8Name.SequenceEqual("RuntimeHelpers"u8) && createSpanType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) && createSpanType.Module == createSpanType.Context.SystemModule && parameters[0] is RuntimeFieldHandleValue createSpanFieldHandle && createSpanFieldHandle.Field.IsStatic && createSpanFieldHandle.Field.HasRva @@ -1926,7 +1926,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V } case "IsReferenceOrContainsReferences" when method.Instantiation.Length == 1 && method.OwningType is MetadataType isReferenceOrContainsReferencesType - && isReferenceOrContainsReferencesType.Name == "RuntimeHelpers" && isReferenceOrContainsReferencesType.Namespace == "System.Runtime.CompilerServices" + && isReferenceOrContainsReferencesType.U8Name.SequenceEqual("RuntimeHelpers"u8) && isReferenceOrContainsReferencesType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) && isReferenceOrContainsReferencesType.Module == method.Context.SystemModule: { bool result = method.Instantiation[0].IsGCPointer || (method.Instantiation[0] is DefType defType && defType.ContainsGCPointers); @@ -1935,7 +1935,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V } case "GetArrayDataReference" when method.Instantiation.Length == 1 && method.OwningType is MetadataType getArrayDataReferenceType - && getArrayDataReferenceType.Name == "MemoryMarshal" && getArrayDataReferenceType.Namespace == "System.Runtime.InteropServices" + && getArrayDataReferenceType.U8Name.SequenceEqual("MemoryMarshal"u8) && getArrayDataReferenceType.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8) && getArrayDataReferenceType.Module == method.Context.SystemModule && parameters[0] is ArrayInstance arrayData && ((ArrayType)arrayData.Type).ElementType == method.Instantiation[0]: @@ -1947,7 +1947,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V static bool IsSystemType(TypeDesc type) => type is MetadataType typeType - && typeType.Name == "Type" && typeType.Namespace == "System" + && typeType.U8Name.SequenceEqual("Type"u8) && typeType.U8Namespace.SequenceEqual("System"u8) && typeType.Module == typeType.Context.SystemModule; return false; @@ -2422,8 +2422,9 @@ public ComInterfaceEntryArrayValue(TypeDesc type, TypeDesc entryType) private static bool IsComInterfaceEntryType(TypeDesc type) => type is MetadataType mdType - && mdType.Name == "ComInterfaceEntry" - && mdType.ContainingType is MetadataType { Name: "ComWrappers", Namespace: "System.Runtime.InteropServices" } comWrappersType + && mdType.U8Name.SequenceEqual("ComInterfaceEntry"u8) + && mdType.ContainingType is MetadataType comWrappersType + && comWrappersType.U8Name.SequenceEqual("ComWrappers"u8) && comWrappersType.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8) && comWrappersType.Module == comWrappersType.Context.SystemModule; public static bool IsCompatible(TypeDesc type, out TypeDesc entryType) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs index e5aea3388a6f1a..2c894fd1c466d0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Internal.IL; using Internal.TypeSystem; using Internal.TypeSystem.Interop; @@ -58,7 +60,7 @@ public override void AddMarshalAPIsGenericDependencies(ref DependencyList depend MetadataType metadataType = owningType as MetadataType; if (metadataType != null && metadataType.Module == factory.TypeSystemContext.SystemModule) { - if (metadataType.Name == "Marshal" && metadataType.Namespace == "System.Runtime.InteropServices") + if (metadataType.U8Name.SequenceEqual("Marshal"u8) && metadataType.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8)) { string methodName = method.Name; if (methodName == "GetFunctionPointerForDelegate" || diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs index 808ce747d9b144..8a077285755c68 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -96,7 +98,7 @@ public override bool ComputeIsUnsafeValueType(DefType type) public static bool IsVectorOfTType(DefType type) { - return type.IsIntrinsic && type.Namespace == "System.Numerics" && type.Name == "Vector`1"; + return type.IsIntrinsic && type.U8Namespace.SequenceEqual("System.Numerics"u8) && type.U8Name.SequenceEqual("Vector`1"u8); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs index 799a17899a6779..fdc894e07a1d5e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Internal.TypeSystem; using Internal.ReadyToRunConstants; @@ -1471,7 +1473,7 @@ private static bool IsTypeGetTypeFromHandle(MethodDesc method) MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.Name == "Type" && owningType.Namespace == "System"; + return owningType.U8Name.SequenceEqual("Type"u8) && owningType.U8Namespace.SequenceEqual("System"u8); } } @@ -1485,7 +1487,7 @@ private static bool IsActivatorDefaultConstructorOf(MethodDesc method) MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.Name == "Activator" && owningType.Namespace == "System"; + return owningType.U8Name.SequenceEqual("Activator"u8) && owningType.U8Namespace.SequenceEqual("System"u8); } } @@ -1499,7 +1501,7 @@ private static bool IsActivatorAllocatorOf(MethodDesc method) MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.Name == "Activator" && owningType.Namespace == "System"; + return owningType.U8Name.SequenceEqual("Activator"u8) && owningType.U8Namespace.SequenceEqual("System"u8); } } @@ -1513,7 +1515,7 @@ private static bool IsEETypePtrOf(MethodDesc method) MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.Name == "MethodTable" && owningType.Namespace == "Internal.Runtime"; + return owningType.U8Name.SequenceEqual("MethodTable"u8) && owningType.U8Namespace.SequenceEqual("Internal.Runtime"u8); } } @@ -1527,7 +1529,7 @@ private static bool IsRuntimeHelpersIsReferenceOrContainsReferences(MethodDesc m MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.Name == "RuntimeHelpers" && owningType.Namespace == "System.Runtime.CompilerServices"; + return owningType.U8Name.SequenceEqual("RuntimeHelpers"u8) && owningType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8); } } @@ -1541,7 +1543,7 @@ private static bool IsMemoryMarshalGetArrayDataReference(MethodDesc method) MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.Name == "MemoryMarshal" && owningType.Namespace == "System.Runtime.InteropServices"; + return owningType.U8Name.SequenceEqual("MemoryMarshal"u8) && owningType.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs index e260ea338ed25f..098c57b549461a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Diagnostics; using Internal.IL; @@ -141,20 +142,23 @@ public void Advance(ILOpcode opcode, in ILReader reader, MethodIL methodIL) throw new UnreachableException(); } + static bool IsSystemType(TypeDesc t) + => t is MetadataType mdType && mdType.U8Name.SequenceEqual("Type"u8) && mdType.U8Namespace.SequenceEqual("System"u8); + static bool IsTypeGetTypeFromHandle(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode == ILOpcode.call && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method && method.IsIntrinsic && method.Name == "GetTypeFromHandle" - && method.OwningType is MetadataType { Name: "Type", Namespace: "System" }; + && IsSystemType(method.OwningType); static bool IsTypeEquals(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode == ILOpcode.call && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method && method.IsIntrinsic && method.Name is "op_Equality" - && method.OwningType is MetadataType { Name: "Type", Namespace: "System" }; + && IsSystemType(method.OwningType); static bool IsTypeInequals(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode == ILOpcode.call && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method && method.IsIntrinsic && method.Name is "op_Inequality" - && method.OwningType is MetadataType { Name: "Type", Namespace: "System" }; + && IsSystemType(method.OwningType); static bool IsObjectGetType(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode is ILOpcode.call or ILOpcode.callvirt && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method diff --git a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs index 311d19d6f73c27..074a31888ca714 100644 --- a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs +++ b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using Internal.Metadata.NativeFormat.Writer; @@ -97,7 +98,8 @@ private static Ecma.SerializationTypeCode TypeDescToSerializationTypeCode(Cts.Ty if (type.IsString) return Ecma.SerializationTypeCode.String; - if (type is not Cts.MetadataType { Name: "Type", Namespace: "System" }) + if (type is not Cts.MetadataType mdType + || !mdType.U8Name.SequenceEqual("Type"u8) || !mdType.U8Namespace.SequenceEqual("System"u8)) throw new UnreachableException(); return Ecma.SerializationTypeCode.Type; diff --git a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Type.cs b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Type.cs index 4ab76e79005da8..acb94b9e0f47d7 100644 --- a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Type.cs +++ b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Type.cs @@ -193,7 +193,7 @@ private TypeReference GetNestedReferenceParent(Cts.MetadataType entity) parentReferenceRecord = new TypeReference { - TypeName = HandleString(containingType.Name), + TypeName = HandleString(containingType.GetName()), }; if (containingType.ContainingType != null) @@ -202,7 +202,7 @@ private TypeReference GetNestedReferenceParent(Cts.MetadataType entity) } else { - parentReferenceRecord.ParentNamespaceOrType = HandleNamespaceReference(containingType.Module, containingType.Namespace); + parentReferenceRecord.ParentNamespaceOrType = HandleNamespaceReference(containingType.Module, containingType.GetNamespace()); } return parentReferenceRecord; @@ -218,10 +218,10 @@ private void InitializeTypeRef(Cts.MetadataType entity, TypeReference record) } else { - record.ParentNamespaceOrType = HandleNamespaceReference(entity.Module, entity.Namespace); + record.ParentNamespaceOrType = HandleNamespaceReference(entity.Module, entity.GetNamespace()); } - record.TypeName = HandleString(entity.Name); + record.TypeName = HandleString(entity.GetName()); } private void InitializeTypeDef(Cts.MetadataType entity, TypeDefinition record) @@ -236,12 +236,12 @@ private void InitializeTypeDef(Cts.MetadataType entity, TypeDefinition record) enclosingType.NestedTypes.Add(record); var namespaceDefinition = - HandleNamespaceDefinition(containingType.Module, entity.ContainingType.Namespace); + HandleNamespaceDefinition(containingType.Module, entity.ContainingType.GetNamespace()); record.NamespaceDefinition = namespaceDefinition; } else { - var namespaceDefinition = HandleNamespaceDefinition(entity.Module, entity.Namespace); + var namespaceDefinition = HandleNamespaceDefinition(entity.Module, entity.GetNamespace()); record.NamespaceDefinition = namespaceDefinition; if (entity.IsModuleType) @@ -255,7 +255,7 @@ private void InitializeTypeDef(Cts.MetadataType entity, TypeDefinition record) } } - record.Name = HandleString(entity.Name); + record.Name = HandleString(entity.GetName()); Cts.ClassLayoutMetadata layoutMetadata = entity.GetClassLayout(); record.Size = checked((uint)layoutMetadata.Size); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs index 2878289e33996c..ada8c227b3f319 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs @@ -314,7 +314,7 @@ public override ValueTypeShapeCharacteristics ComputeValueTypeShapeCharacteristi public static bool IsVectorOfTType(DefType type) { - return type.IsIntrinsic && type.Namespace == "System.Numerics" && type.Name == "Vector`1"; + return type.IsIntrinsic && type.U8Namespace.SequenceEqual("System.Numerics"u8) && type.U8Name.SequenceEqual("Vector`1"u8); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunXmlRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunXmlRootProvider.cs index 4ea3ab2b3b5ca6..cee3ce9ab89056 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunXmlRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunXmlRootProvider.cs @@ -12,6 +12,7 @@ using System.Text; using System.Threading.Tasks; using System.Xml.XPath; +using ILCompiler.Dataflow; using Internal.JitInterface; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -167,7 +168,7 @@ private void ProcessNamespaces(ModuleDesc assembly, XPathNavigator nav) string fullname = GetFullName(namespaceNav); foreach (DefType type in assembly.GetAllTypes()) { - if (type.Namespace != fullname) + if (!type.U8Namespace.StringEquals(fullname)) continue; ProcessType(type, nav); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs index 1f41af63475e20..754dc0fa218b64 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs @@ -640,9 +640,9 @@ public override object GetType(string nameSpace, string name, NotFoundBehavior n { TypeSystemContext context = Context; - if (context.SupportsCanon && (nameSpace == context.CanonType.Namespace) && (name == context.CanonType.Name)) + if (context.SupportsCanon && (nameSpace == context.CanonType.GetNamespace()) && (name == context.CanonType.GetName())) return Context.CanonType; - if (context.SupportsUniversalCanon && (nameSpace == context.UniversalCanonType.Namespace) && (name == context.UniversalCanonType.Name)) + if (context.SupportsUniversalCanon && (nameSpace == context.UniversalCanonType.GetNamespace()) && (name == context.UniversalCanonType.GetName())) return Context.UniversalCanonType; else { diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs index 425ba366f1ef19..4b5f28f73cab0e 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs @@ -75,17 +75,17 @@ private MethodIL TryGetIntrinsicMethodIL(MethodDesc method) if (mdType == null) return null; - if (mdType.Name == "RuntimeHelpers" && mdType.Namespace == "System.Runtime.CompilerServices") + if (mdType.U8Name.SequenceEqual("RuntimeHelpers"u8) && mdType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) { return RuntimeHelpersIntrinsics.EmitIL(method); } - if (mdType.Name == "Unsafe" && mdType.Namespace == "System.Runtime.CompilerServices") + if (mdType.U8Name.SequenceEqual("Unsafe"u8) && mdType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) { return UnsafeIntrinsics.EmitIL(method); } - if (mdType.Name == "InstanceCalliHelper" && mdType.Namespace == "System.Reflection") + if (mdType.U8Name.SequenceEqual("InstanceCalliHelper"u8) && mdType.U8Namespace.SequenceEqual("System.Reflection"u8)) { return InstanceCalliHelperIntrinsics.EmitIL(method); } @@ -104,17 +104,17 @@ private MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc method) if (mdType == null) return null; - if (mdType.Name == "RuntimeHelpers" && mdType.Namespace == "System.Runtime.CompilerServices") + if (mdType.U8Name.SequenceEqual("RuntimeHelpers"u8) && mdType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) { return RuntimeHelpersIntrinsics.EmitIL(method); } - if (mdType.Name == "Activator" && mdType.Namespace == "System") + if (mdType.U8Name.SequenceEqual("Activator"u8) && mdType.U8Namespace.SequenceEqual("System"u8)) { return TryGetIntrinsicMethodILForActivator(method); } - if (mdType.Name == "Interlocked" && mdType.Namespace == "System.Threading") + if (mdType.U8Name.SequenceEqual("Interlocked"u8) && mdType.U8Namespace.SequenceEqual("System.Threading"u8)) { return InterlockedIntrinsics.EmitIL(_compilationModuleGroup, method); } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TypeString.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TypeString.cs index a0644eea58b067..6d40c859fc0788 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TypeString.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TypeString.cs @@ -93,20 +93,20 @@ protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) { - string ns = type.Namespace; + string ns = type.GetNamespace(); if (ns.Length > 0) { sb.Append(ns); sb.Append('.'); } - sb.Append(type.Name); + sb.Append(type.GetName()); } protected override void AppendNameForNestedType(StringBuilder sb, DefType nestedType, DefType containingType) { AppendName(sb, containingType); sb.Append('+'); - sb.Append(nestedType.Name); + sb.Append(nestedType.GetName()); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs index b5de71ed3bb079..9dda881925350a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs @@ -294,7 +294,7 @@ static bool ShouldIncludeType(TypeDesc type) return false; } - if (metadataType.Namespace.StartsWith("Internal")) + if (metadataType.U8Namespace.StartsWith("Internal"u8)) return false; if (metadataType.Module.Assembly is EcmaAssembly asm && asm.Assembly.GetName().Name == "System.Private.CoreLib") diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs index 425ad3d1dbce5c..3eae3ed7509513 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs @@ -79,13 +79,13 @@ private static bool IsMemberAssertion(MetadataType attributeType) if (attributeType == null) return false; - if (attributeType.Namespace != "Mono.Linker.Tests.Cases.Expectations.Assertions") + if (!attributeType.U8Namespace.SequenceEqual("Mono.Linker.Tests.Cases.Expectations.Assertions"u8)) return false; MetadataType t = attributeType; while (t != null) { - if (t.Name == nameof(BaseMemberAssertionAttribute)) + if (t.GetName() == nameof(BaseMemberAssertionAttribute)) return true; t = t.MetadataBaseType; diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs index 1ab13b8ee2efca..03d79d038a7f03 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs @@ -517,7 +517,7 @@ static bool LogMessageHasSameOriginMember(MessageContainer mc, ICustomAttributeP static string? GetMemberName(TypeSystemEntity? entity) => entity switch { - DefType defType => defType.Name, + DefType defType => defType.GetName(), MethodDesc method => method.Name, FieldDesc field => field.Name, _ => null diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/Tests/DocumentationSignatureParserTests.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/Tests/DocumentationSignatureParserTests.cs index 14adc5da7a68e6..0cf4d0b0c55d72 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/Tests/DocumentationSignatureParserTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/Tests/DocumentationSignatureParserTests.cs @@ -23,7 +23,7 @@ public class DocumentationSignatureParserTests public void TestSignatureParsing(TypeSystemEntity member, MemberAssertionsCollector.CustomAttribute customAttribute) { var attributeString = (string)customAttribute.Value.FixedArguments[0].Value!; - switch (customAttribute.AttributeType.Name) + switch (customAttribute.AttributeType.GetName()) { case nameof(ExpectExactlyResolvedDocumentationSignatureAttribute): CheckUniqueParsedString(member, attributeString); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs index 152816f1a5483d..9be46a14869aa1 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs @@ -43,7 +43,7 @@ private static string GetModOptMethodSignatureInfo(MethodSignature signature) sb.Append(data.kind.ToString()); sb.Append(data.index); if (data.type != null) - sb.Append(((MetadataType)data.type).Name); + sb.Append(((MetadataType)data.type).GetName()); else sb.Append(""); } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs index 8379cb230735b0..edd31c33202c4b 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs @@ -143,8 +143,8 @@ protected override IEnumerable GetAllMethods(TypeDesc type) { MetadataType mdType = type as MetadataType; - if (mdType.Name == "StructWithNoEqualsAndGetHashCode" - || mdType.Name == "ClassWithInjectedEqualsAndGetHashCode") + if (mdType.U8Name.SequenceEqual("StructWithNoEqualsAndGetHashCode"u8) + || mdType.U8Name.SequenceEqual("ClassWithInjectedEqualsAndGetHashCode"u8)) { yield return GetEqualsMethod(type); yield return GetGetHashCodeMethod(type); @@ -158,8 +158,8 @@ protected override IEnumerable GetAllVirtualMethods(TypeDesc type) { MetadataType mdType = type as MetadataType; - if (mdType.Name == "StructWithNoEqualsAndGetHashCode" - || mdType.Name == "ClassWithInjectedEqualsAndGetHashCode") + if (mdType.U8Name.SequenceEqual("StructWithNoEqualsAndGetHashCode"u8) + || mdType.U8Name.SequenceEqual("ClassWithInjectedEqualsAndGetHashCode"u8)) { yield return GetEqualsMethod(type); yield return GetGetHashCodeMethod(type); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs index 63b1c0427a5c53..c3f52dfdb6a127 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs @@ -231,7 +231,7 @@ public void TestTypesWhichShouldNotBeLoadable() { foreach (var typePair in GetTypesWhichClaimMatchingTypeIdentifiersInNamespace("TypesWhichDoNotLoad")) { - if (((MetadataType)typePair.Item1).Name.EndsWith("IGNORE")) + if (((MetadataType)typePair.Item1).U8Name.EndsWith("IGNORE"u8)) continue; _logger.WriteLine($"Checking load behavior of {typePair.Item1}"); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs index a078d10305dde8..cb7c8f89be5ebe 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs @@ -454,7 +454,7 @@ public void TestSubImplCovariant(string exactScenarioName, string typeToConstruc MethodDesc resolvedMethod = derivedClass.FindVirtualFunctionTargetMethodOnObjectType(callMethod); this._logger.WriteLine(resolvedMethod.ToString()); - Assert.Equal(typeToConstruct, ((EcmaType)((EcmaMethod)resolvedMethod).OwningType).Name); + Assert.Equal(typeToConstruct, ((EcmaType)((EcmaMethod)resolvedMethod).OwningType).GetName()); baseClass = (MetadataType)baseClass.BaseType; } diff --git a/src/coreclr/tools/aot/ILCompiler/Program.cs b/src/coreclr/tools/aot/ILCompiler/Program.cs index b51d9e8bc5483c..14e54eb31043a8 100644 --- a/src/coreclr/tools/aot/ILCompiler/Program.cs +++ b/src/coreclr/tools/aot/ILCompiler/Program.cs @@ -683,7 +683,7 @@ static bool IsRelatedToInvalidInput(MethodDesc method) // but not scanned, it's usually fine. If it wasn't fine, we would probably crash before getting here. return method.OwningType is MetadataType mdType && mdType.Module == method.Context.SystemModule - && (mdType.Name.EndsWith("Exception") || mdType.Namespace.StartsWith("Internal.Runtime")); + && (mdType.U8Name.EndsWith("Exception"u8) || mdType.U8Namespace.StartsWith("Internal.Runtime"u8)); } // If optimizations are enabled, the results will for sure not match in the other direction due to inlining, etc. diff --git a/src/coreclr/tools/dotnet-pgo/TraceRuntimeDescToTypeSystemDesc.cs b/src/coreclr/tools/dotnet-pgo/TraceRuntimeDescToTypeSystemDesc.cs index 875eb67862a85f..6713489af3980f 100644 --- a/src/coreclr/tools/dotnet-pgo/TraceRuntimeDescToTypeSystemDesc.cs +++ b/src/coreclr/tools/dotnet-pgo/TraceRuntimeDescToTypeSystemDesc.cs @@ -426,7 +426,7 @@ public TypeDesc ResolveTypeHandle(long handle, ref bool dependsOnKnownNonLoadabl } else { - if ((uninstantiatedType.Name == "__Canon") && uninstantiatedType.Namespace == "System" && (uninstantiatedType.Module == uninstantiatedType.Context.SystemModule)) + if ((uninstantiatedType.U8Name.SequenceEqual("__Canon"u8)) && uninstantiatedType.U8Namespace.SequenceEqual("System"u8) && (uninstantiatedType.Module == uninstantiatedType.Context.SystemModule)) { tinfo.Type = uninstantiatedType.Context.CanonType; } diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs index f0e56ece0f14db..2283f42486f71f 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs @@ -178,9 +178,9 @@ public override MetadataType MetadataBaseType public override DefType[] ExplicitlyImplementedInterfaces => Array.Empty(); - public override string DiagnosticName => Name; + public override string DiagnosticName => GetName(); - public override string DiagnosticNamespace => Namespace; + public override string DiagnosticNamespace => GetNamespace(); public override TypeSystemContext Context => Module.Context; @@ -188,7 +188,15 @@ public override MetadataType MetadataBaseType public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name) => throw new NotImplementedException(); public override ClassLayoutMetadata GetClassLayout() => throw new NotImplementedException(); - public override int GetHashCode() => (Namespace != null) ? HashCode.Combine(Namespace, Name, Module) : HashCode.Combine(Name, Module); + public override int GetHashCode() + { + var hash = new HashCode(); + hash.AddBytes(U8Namespace); + hash.AddBytes(U8Name); + hash.Add(Module); + return hash.ToHashCode(); + } + public override MetadataType GetNestedType(string name) { TypeRefTypeSystemType type = null; From f45a8e1b3521925ad44a2adb3470f4fc414a8c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 5 Sep 2025 11:26:19 +0200 Subject: [PATCH 06/19] Update DefType.cs --- .../tools/Common/TypeSystem/Common/DefType.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs b/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs index 60d1ac0562d506..bb27d3293b9f30 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace Internal.TypeSystem { @@ -18,7 +20,11 @@ public abstract partial class DefType : TypeDesc public virtual ReadOnlySpan U8Namespace => []; - public string GetNamespace() => System.Text.Encoding.UTF8.GetString(U8Namespace); + public string GetNamespace() => System.Text.Encoding.UTF8.GetString(U8Namespace +#if NETSTANDARD + .ToArray() +#endif + ); /// /// Gets the name of the type as represented in the metadata. @@ -27,7 +33,11 @@ public abstract partial class DefType : TypeDesc public virtual ReadOnlySpan U8Name => []; - public string GetName() => System.Text.Encoding.UTF8.GetString(U8Name); + public string GetName() => System.Text.Encoding.UTF8.GetString(U8Name +#if NETSTANDARD + .ToArray() +#endif + ); /// /// Gets the containing type of this type or null if the type is not nested. From 31300947fabe79874f90892eccdc0076cc63ef20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 5 Sep 2025 14:04:10 +0200 Subject: [PATCH 07/19] Update MetadataTypeHashingAlgorithms.cs --- .../Metadata/NativeFormat/MetadataTypeHashingAlgorithms.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MetadataTypeHashingAlgorithms.cs b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MetadataTypeHashingAlgorithms.cs index b33671b5de4f8c..f3aadf30039222 100644 --- a/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MetadataTypeHashingAlgorithms.cs +++ b/src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MetadataTypeHashingAlgorithms.cs @@ -58,7 +58,10 @@ public static int ComputeHashCode(this TypeDefinitionHandle typeDefHandle, Metad TypeDefinition typeDef = reader.GetTypeDefinition(typeDefHandle); HashCodeBuilder builder = new HashCodeBuilder(""u8); - AppendNamespaceHashCode(ref builder, typeDef.NamespaceDefinition, reader, appendDot: false); + + if (!typeDef.Flags.IsNested()) + AppendNamespaceHashCode(ref builder, typeDef.NamespaceDefinition, reader, appendDot: false); + int nameHashCode = VersionResilientHashCode.NameHashCode(reader.ReadStringAsBytes(typeDef.Name)); int hashCode = VersionResilientHashCode.NameHashCode(builder.ToHashCode(), nameHashCode); From d349e3544f59c6fa79e77e5619f1201b9c544fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 5 Sep 2025 16:58:34 +0200 Subject: [PATCH 08/19] Stop using MethodDesc.Name --- .../TypeLoaderEnvironment.GVMResolution.cs | 4 +- .../MethodForInstantiatedType.Runtime.cs | 2 +- .../Internal/TypeSystem/RuntimeMethodDesc.cs | 2 +- .../Common/Compiler/Dataflow/MethodProxy.cs | 2 +- .../Common/Compiler/DisplayNameHelpers.cs | 2 +- .../Common/Compiler/NativeAotNameMangler.cs | 4 +- .../Common/Compiler/ProcessLinkerXmlBase.cs | 4 +- .../tools/Common/JitInterface/CorInfoImpl.cs | 10 ++--- .../TypeSystem/Canon/CanonTypes.Metadata.cs | 2 +- .../Common/ArrayMethod.Diagnostic.cs | 2 +- .../Common/InstantiatedType.MethodImpls.cs | 4 +- .../Common/MetadataType.MethodImpls.cs | 4 +- .../Common/MetadataVirtualMethodAlgorithm.cs | 14 +++---- .../Common/MethodDesc.Dummy.Diagnostic.cs | 2 +- .../Common/TypeSystem/Common/MethodDesc.cs | 13 ++++++- .../TypeSystem/Common/ThrowHelper.Common.cs | 2 +- .../Common/TypeSystem/Common/TypeDesc.cs | 4 +- .../Common/TypeWithRepeatedFields.cs | 2 +- .../TypeSystem/Ecma/EcmaMethod.Diagnostic.cs | 2 +- .../Common/TypeSystem/Ecma/EcmaMethod.cs | 4 +- .../TypeSystem/Ecma/EcmaType.MethodImpls.cs | 37 +++++++------------ .../Common/TypeSystem/IL/ILDisassembler.cs | 2 +- .../Common/TypeSystem/IL/MethodILDebugView.cs | 2 +- .../TypeSystem/IL/NativeAotILProvider.cs | 8 ++-- .../IL/Stubs/DelegateMethodILEmitter.cs | 8 ++-- .../TypeSystem/IL/Stubs/DelegateThunks.cs | 2 +- .../IL/Stubs/InterlockedIntrinsics.cs | 2 +- .../IL/Stubs/RuntimeHelpersIntrinsics.cs | 3 +- .../TypeSystem/IL/Stubs/StreamIntrinsics.cs | 4 +- .../TypeSystem/IL/Stubs/UnsafeIntrinsics.cs | 2 +- .../Common/TypeSystem/IL/UnsafeAccessors.cs | 4 +- .../TypeSystem/Interop/IL/InlineArrayType.cs | 4 +- .../TypeSystem/Interop/IL/NativeStructType.cs | 2 +- .../Interop/IL/PInvokeDelegateWrapper.cs | 2 +- .../TypeSystemMetadataEmitter.cs | 2 +- .../Compiler/Compilation.cs | 2 +- .../CompilerTypeSystemContext.BoxedTypes.cs | 2 +- .../CompilerTypeSystemContext.EnumMethods.cs | 5 ++- ...ilerTypeSystemContext.GeneratedAssembly.cs | 2 +- .../Dataflow/CompilerGeneratedCallGraph.cs | 4 +- .../Dataflow/CompilerGeneratedState.cs | 8 ++-- .../Compiler/Dataflow/HandleCallAction.cs | 2 +- .../Compiler/Dataflow/InterproceduralState.cs | 2 +- .../Compiler/Dataflow/MethodBodyScanner.cs | 2 +- .../CodeBasedDependencyAlgorithm.cs | 2 +- .../Compiler/DependencyAnalysis/EETypeNode.cs | 6 +-- .../InlineableStringsResourceNode.cs | 3 +- .../DependencyAnalysis/VTableSliceNode.cs | 4 +- .../Compiler/HardwareIntrinsicHelpers.Aot.cs | 2 +- ...semblyGeneratingMethodDebugInfoProvider.cs | 2 +- .../Logging/DocumentationSignatureParser.cs | 2 +- .../Compiler/MetadataManager.cs | 2 +- .../Compiler/NoMetadataBlockingPolicy.cs | 4 +- .../Compiler/SubstitutedILProvider.cs | 10 ++--- .../Compiler/SubstitutionProvider.cs | 4 +- .../Compiler/TypeMapMetadata.cs | 4 +- .../Compiler/TypePreinit.cs | 6 +-- .../Compiler/UsageBasedInteropStubManager.cs | 2 +- .../Compiler/UserDefinedTypeDescriptor.cs | 2 +- .../IL/ILImporter.Scanner.cs | 18 ++++----- .../IL/TypeEqualityPatternAnalyzer.cs | 8 ++-- .../ILCompiler/Metadata/Transform.Method.cs | 4 +- .../ReadyToRun/TypeFixupSignature.cs | 2 +- .../ReadyToRun/TypeValidationChecker.cs | 4 +- .../Compiler/ProfileDataManager.cs | 2 +- .../IBC/IBCProfileParser.cs | 4 +- .../IL/ReadyToRunILProvider.cs | 2 +- .../IL/Stubs/InstanceCalliHelperIntrinsics.cs | 2 +- .../JitInterface/CorInfoImpl.ReadyToRun.cs | 12 +++--- .../ObjectWriter/OutputInfoBuilder.cs | 2 +- .../JitInterface/CorInfoImpl.RyuJit.cs | 2 +- .../ILCompilerTestPInvokePolicy.cs | 2 +- .../TestCasesRunner/ResultChecker.cs | 2 +- .../GenericTypeAndMethodTests.cs | 12 +++--- .../InterfacesTests.cs | 4 +- .../SignatureTests.cs | 20 +++++----- .../SyntheticVirtualOverrideTests.cs | 32 ++++++++-------- .../VirtualFunctionOverrideTests.cs | 10 ++--- .../ILCompiler/ConfigurablePInvokePolicy.cs | 2 +- .../aot/ILCompiler/ILCompilerRootCommand.cs | 2 +- .../tools/aot/ILCompiler/RdXmlRootProvider.cs | 2 +- src/coreclr/tools/aot/crossgen2/Program.cs | 8 ++-- src/coreclr/tools/dotnet-pgo/Program.cs | 2 +- .../TypeRefTypeSystemMethod.cs | 2 + .../TypeRefTypeSystemType.cs | 2 +- 85 files changed, 214 insertions(+), 203 deletions(-) diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.GVMResolution.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.GVMResolution.cs index 1b6d16fa3ffd1c..c1485184aa0391 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.GVMResolution.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.GVMResolution.cs @@ -106,7 +106,7 @@ internal static InstantiatedMethod GVMLookupForSlotWorker(DefType targetType, In sb.AppendLine(); sb.AppendLine("Declaring type: " + GetTypeNameDebug(slotMethod.OwningType)); sb.AppendLine("Target type: " + GetTypeNameDebug(targetType)); - sb.AppendLine("Method name: " + slotMethod.Name); + sb.AppendLine("Method name: " + slotMethod.GetName()); sb.AppendLine("Instantiation:"); for (int i = 0; i < slotMethod.Instantiation.Length; i++) { @@ -134,7 +134,7 @@ internal unsafe IntPtr ResolveGenericVirtualMethodTarget(RuntimeTypeHandle type, sb.AppendLine("Failed to create generic virtual method implementation"); sb.AppendLine(); sb.AppendLine("Declaring type: " + GetTypeNameDebug(result.OwningType)); - sb.AppendLine("Method name: " + result.Name); + sb.AppendLine("Method name: " + result.GetName()); sb.AppendLine("Instantiation:"); for (int i = 0; i < result.Instantiation.Length; i++) { diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/MethodForInstantiatedType.Runtime.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/MethodForInstantiatedType.Runtime.cs index 2d3e9c99281cf3..d66289fbbc3354 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/MethodForInstantiatedType.Runtime.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/MethodForInstantiatedType.Runtime.cs @@ -21,7 +21,7 @@ public override MethodNameAndSignature NameAndSignature #if DEBUG public override string ToString() { - return OwningType.ToString() + "." + Name; + return OwningType.ToString() + "." + GetName(); } #endif } diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs index 27e14806db0a09..d563bc9be61ffb 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs @@ -171,7 +171,7 @@ public override bool HasCustomAttribute(string attributeNamespace, string attrib public override string ToString() { - string result = OwningType.ToString() + ".Method(" + Name + ")"; + string result = OwningType.ToString() + ".Method(" + GetName() + ")"; return result; } #endif diff --git a/src/coreclr/tools/Common/Compiler/Dataflow/MethodProxy.cs b/src/coreclr/tools/Common/Compiler/Dataflow/MethodProxy.cs index e0883f5eca8efc..d73e62dec788d2 100644 --- a/src/coreclr/tools/Common/Compiler/Dataflow/MethodProxy.cs +++ b/src/coreclr/tools/Common/Compiler/Dataflow/MethodProxy.cs @@ -19,7 +19,7 @@ namespace ILLink.Shared.TypeSystemProxy public readonly MethodDesc Method; - public string Name { get => Method.Name; } + public string Name { get => Method.GetName(); } public string GetDisplayName() => Method.GetDisplayName(); diff --git a/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs b/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs index e2f78cc7b6888a..816697d673795f 100644 --- a/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs +++ b/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs @@ -70,7 +70,7 @@ public static string GetDisplayName(this MethodDesc method) #endif else { - sb.Append(method.Name); + sb.Append(method.GetName()); } if (method.HasInstantiation) diff --git a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs index 66f9e02a54f64b..923e1ebdb76a3a 100644 --- a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs +++ b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs @@ -421,7 +421,7 @@ private Utf8String ComputeUnqualifiedMangledMethodName(MethodDesc method) { foreach (var m in method.OwningType.GetMethods()) { - string name = SanitizeName(m.Name); + string name = SanitizeName(m.GetName()); name = DisambiguateName(name, deduplicator); deduplicator.Add(name); @@ -480,7 +480,7 @@ private Utf8String ComputeUnqualifiedMangledMethodName(MethodDesc method) else { // Assume that Name is unique for all other methods - utf8MangledName = new Utf8String(SanitizeName(method.Name)); + utf8MangledName = new Utf8String(SanitizeName(method.GetName())); } } diff --git a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs index d63cb22667f7f0..7843c718aadb66 100644 --- a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs +++ b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs @@ -367,7 +367,7 @@ protected virtual void ProcessMethod(TypeDesc type, XPathNavigator nav, object? bool foundMatch = false; foreach (MethodDesc method in type.GetAllMethods()) { - if (name == method.Name) + if (method.U8Name.StringEquals(name)) { foundMatch = true; ProcessMethod(type, method, nav, customData); @@ -532,7 +532,7 @@ public static string GetMethodSignature(MethodDesc meth, bool includeGenericPara StringBuilder sb = new StringBuilder(); CecilTypeNameFormatter.Instance.AppendName(sb, meth.Signature.ReturnType); sb.Append(' '); - sb.Append(meth.Name); + sb.Append(meth.GetName()); if (includeGenericParameters && meth.HasInstantiation) { sb.Append('`'); diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index a48890b59d5b26..1be5a75e284b41 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -1127,7 +1127,7 @@ private uint getMethodAttribsInternal(MethodDesc method) result |= CorInfoFlag.CORINFO_FLG_FORCEINLINE; } - if (method.OwningType.IsDelegate && method.Name == "Invoke") + if (method.OwningType.IsDelegate && method.U8Name.SequenceEqual("Invoke"u8)) { // This is now used to emit efficient invoke code for any delegate invoke, // including multicast. @@ -1724,7 +1724,7 @@ private static object ResolveTokenInScope(MethodILScope methodIL, object typeOrM Debug.Assert((methodContext.HasInstantiation && !owningMethod.HasInstantiation) || (!methodContext.HasInstantiation && !owningMethod.HasInstantiation) || methodContext.GetTypicalMethodDefinition() == owningMethod.GetTypicalMethodDefinition() || - (owningMethod.Name == "CreateDefaultInstance" && methodContext.Name == "CreateInstance")); + (owningMethod.U8Name.SequenceEqual("CreateDefaultInstance"u8) && methodContext.U8Name.SequenceEqual("CreateInstance"u8))); Debug.Assert(methodContext.OwningType.HasSameTypeDefinition(owningMethod.OwningType)); typeInst = methodContext.OwningType.Instantiation; methodInst = methodContext.Instantiation; @@ -3401,7 +3401,7 @@ private static byte[] SpanToPinnableBytes(ReadOnlySpan s) private nuint printMethodName(CORINFO_METHOD_STRUCT_* ftn, byte* buffer, nuint bufferSize, nuint* requiredBufferSize) { MethodDesc method = HandleToObject(ftn); - return PrintFromUtf16(method.Name, buffer, bufferSize, requiredBufferSize); + return PrintFromUtf16(method.GetName(), buffer, bufferSize, requiredBufferSize); } private static string getMethodNameFromMetadataImpl(MethodDesc method, out string className, out string namespaceName, string[] enclosingClassName) @@ -3409,7 +3409,7 @@ private static string getMethodNameFromMetadataImpl(MethodDesc method, out strin className = null; namespaceName = null; - string result = method.Name; + string result = method.GetName(); MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -4450,7 +4450,7 @@ private bool notifyInstructionSetUsage(InstructionSet instructionSet, bool suppo // We want explicitly implemented ISimdVector APIs to still be expanded where possible // but, they all prefix the qualified name of the interface first, so we'll check for that and // skip the prefix before trying to resolve the method. - ReadOnlySpan methodName = MethodBeingCompiled.Name.AsSpan(); + ReadOnlySpan methodName = MethodBeingCompiled.GetName().AsSpan(); if (methodName.StartsWith("System.Runtime.Intrinsics.ISimdVector false; - public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name) + public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan name) { return null; } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ArrayMethod.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Common/ArrayMethod.Diagnostic.cs index 571c6cecb8a1bf..7988c2a005611d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ArrayMethod.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ArrayMethod.Diagnostic.cs @@ -10,7 +10,7 @@ public override string DiagnosticName get { // The ArrayMethod.Name property is guaranteed to not throw - return Name; + return GetName(); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.MethodImpls.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.MethodImpls.cs index c8d4f91ad5d4ca..eddc665f515de5 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.MethodImpls.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.MethodImpls.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + namespace Internal.TypeSystem { // Implementation of MethodImpl api surface implemented without metadata access. @@ -45,7 +47,7 @@ protected override MethodImplRecord[] ComputeVirtualMethodImplsForType() return InstantiateMethodImpls(uninstMethodImpls); } - public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name) + public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan name) { MethodImplRecord[] uninstMethodImpls = _typeDef.FindMethodsImplWithMatchingDeclName(name); return InstantiateMethodImpls(uninstMethodImpls); diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.MethodImpls.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.MethodImpls.cs index 17871fee717515..466bb801f42c50 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.MethodImpls.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.MethodImpls.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + namespace Internal.TypeSystem { public struct MethodImplRecord @@ -44,6 +46,6 @@ public MethodImplRecord[] VirtualMethodImplsForType /// /// /// - public abstract MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name); + public abstract MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan name); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs index f0eae5441d0c28..0e96ab273249f8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs @@ -280,7 +280,7 @@ private static MethodDesc FindImplFromDeclFromMethodImpls(MetadataType type, Met if (decl.OwningType.IsInterface) return FindInterfaceImplFromDeclFromMethodImpls(type, decl); - MethodImplRecord[] foundMethodImpls = type.FindMethodsImplWithMatchingDeclName(decl.Name); + MethodImplRecord[] foundMethodImpls = type.FindMethodsImplWithMatchingDeclName(decl.U8Name); if (foundMethodImpls == null) return null; @@ -307,7 +307,7 @@ private static MethodDesc FindInterfaceImplFromDeclFromMethodImpls(MetadataType { Debug.Assert(decl.OwningType.IsInterface); - MethodImplRecord[] foundMethodImpls = type.FindMethodsImplWithMatchingDeclName(decl.Name); + MethodImplRecord[] foundMethodImpls = type.FindMethodsImplWithMatchingDeclName(decl.U8Name); if (foundMethodImpls == null) return null; @@ -333,7 +333,7 @@ private static MethodDesc FindInterfaceImplFromDeclFromMethodImpls(MetadataType { MetadataType typeDefinition = (MetadataType)type.GetTypeDefinition(); DefType[] interfacesOnDefinition = typeDefinition.RuntimeInterfaces; - MethodImplRecord[] foundMethodImplsOnDefinition = typeDefinition.FindMethodsImplWithMatchingDeclName(decl.Name); + MethodImplRecord[] foundMethodImplsOnDefinition = typeDefinition.FindMethodsImplWithMatchingDeclName(decl.U8Name); Debug.Assert(foundMethodImplsOnDefinition.Length == foundMethodImpls.Length); int bestInterfaceIndex = int.MaxValue; @@ -377,14 +377,14 @@ private static bool IsInterfaceExplicitlyImplementedOnType(MetadataType type, Me /// private static MethodDesc FindMatchingVirtualMethodOnTypeByNameAndSig(MethodDesc targetMethod, DefType currentType, bool reverseMethodSearch, Func nameSigMatchMethodIsValidCandidate) { - string name = targetMethod.Name; + ReadOnlySpan name = targetMethod.U8Name; MethodSignature sig = targetMethod.Signature; MethodDesc implMethod = null; MethodDesc implMethodEquivalent = null; foreach (MethodDesc candidate in currentType.GetAllVirtualMethods()) { - if (candidate.Name == name) + if (candidate.U8Name.SequenceEqual(name)) { if (candidate.Signature.EquivalentTo(sig)) { @@ -881,7 +881,7 @@ private static DefaultInterfaceMethodResolution ResolveInterfaceMethodToDefaultI else if (Array.IndexOf(runtimeInterface.RuntimeInterfaces, interfaceMethodOwningType) != -1) { // This interface might provide a default implementation - MethodImplRecord[] possibleImpls = runtimeInterface.FindMethodsImplWithMatchingDeclName(interfaceMethod.Name); + MethodImplRecord[] possibleImpls = runtimeInterface.FindMethodsImplWithMatchingDeclName(interfaceMethod.U8Name); if (possibleImpls != null) { foreach (MethodImplRecord implRecord in possibleImpls) @@ -1078,7 +1078,7 @@ private static MethodDesc TryResolveVirtualStaticMethodOnThisType(MetadataType c { Debug.Assert(interfaceMethod.Signature.IsStatic); - MethodImplRecord[] possibleImpls = constrainedType.FindMethodsImplWithMatchingDeclName(interfaceMethod.Name); + MethodImplRecord[] possibleImpls = constrainedType.FindMethodsImplWithMatchingDeclName(interfaceMethod.U8Name); if (possibleImpls == null) return null; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.Dummy.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.Dummy.Diagnostic.cs index 8e7b7b84de4655..b33b07f62093a8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.Dummy.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.Dummy.Diagnostic.cs @@ -6,6 +6,6 @@ namespace Internal.TypeSystem // Dummy implementation of diagnostic names that just forwards to Name public partial class MethodDesc { - public string DiagnosticName => Name; + public string DiagnosticName => GetName(); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs index d4e97bf64df521..526d83f289b17f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs @@ -557,7 +557,7 @@ public bool IsConstructor { // TODO: Precise check // TODO: Cache? - return this.Name == ".ctor"; + return this.U8Name.SequenceEqual(".ctor"u8); } } @@ -603,6 +603,15 @@ public virtual ReadOnlySpan U8Name } } + public string GetName() + { + return System.Text.Encoding.UTF8.GetString(U8Name +#if NETSTANDARD + .ToArray() +#endif + ); + } + /// /// Gets a value indicating whether the method is virtual. /// @@ -718,7 +727,7 @@ public bool IsFinalizer get { TypeDesc owningType = OwningType; - return (owningType.IsObject && Name == "Finalize") || (owningType.HasFinalizer && owningType.GetFinalizer() == this); + return (owningType.IsObject && U8Name.SequenceEqual("Finalize"u8)) || (owningType.HasFinalizer && owningType.GetFinalizer() == this); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ThrowHelper.Common.cs b/src/coreclr/tools/Common/TypeSystem/Common/ThrowHelper.Common.cs index 62a6382bb592ec..6c4b08b6b10608 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ThrowHelper.Common.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ThrowHelper.Common.cs @@ -91,7 +91,7 @@ public static string Field(TypeDesc owningType, string fieldName) public static string Method(MethodDesc method) { - return Method(method.OwningType, method.Name, method.Signature); + return Method(method.OwningType, method.GetName(), method.Signature); } public static string Method(TypeDesc owningType, string methodName, MethodSignature signature) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs index c390e9eba5bb11..7e4277e008ce4a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs @@ -536,7 +536,7 @@ public virtual MethodDesc GetMethod(string name, MethodSignature signature, Inst { foreach (var method in GetMethods()) { - if (method.Name == name) + if (method.GetName() == name) { if (signature == null || signature.Equals(method.Signature.ApplySubstitution(substitution))) return method; @@ -549,7 +549,7 @@ public virtual MethodDesc GetMethodWithEquivalentSignature(string name, MethodSi { foreach (var method in GetMethods()) { - if (method.Name == name) + if (method.GetName() == name) { if (signature == null || signature.EquivalentTo(method.Signature.ApplySubstitution(substitution))) return method; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs index e64480fc3db127..6377088d211394 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs @@ -86,7 +86,7 @@ public override IEnumerable GetFields() public override IEnumerable GetNestedTypes() => (IEnumerable)EmptyTypes; public override MetadataType GetNestedType(string name) => null; public override int GetInlineArrayLength() => MetadataType.GetInlineArrayLength(); - public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name) => MetadataType.FindMethodsImplWithMatchingDeclName(name); + public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan name) => MetadataType.FindMethodsImplWithMatchingDeclName(name); public override int GetHashCode() => MetadataType.GetHashCode(); protected override MethodImplRecord[] ComputeVirtualMethodImplsForType() => Array.Empty(); diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.Diagnostic.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.Diagnostic.cs index fbcb9b97db5b29..13021913c2a893 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.Diagnostic.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.Diagnostic.cs @@ -13,7 +13,7 @@ public override string DiagnosticName { try { - return Name; + return GetName(); } catch { diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index e37648aa562668..95b374ad5b38f6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -349,7 +349,7 @@ public override bool IsDefaultConstructor return attributes.IsRuntimeSpecialName() && attributes.IsPublic() && Signature.Length == 0 - && Name == ".ctor" + && U8Name.SequenceEqual(".ctor"u8) && !_type.IsAbstract; } } @@ -366,7 +366,7 @@ public override bool IsStaticConstructor { get { - return Attributes.IsRuntimeSpecialName() && Name == ".cctor"; + return Attributes.IsRuntimeSpecialName() && U8Name.SequenceEqual(".cctor"u8); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs index e7e7ccb14b9c7f..883d91e8685d9f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using System.Reflection.Metadata; using Debug = System.Diagnostics.Debug; @@ -12,10 +13,9 @@ namespace Internal.TypeSystem.Ecma public sealed partial class EcmaType : MetadataType { // Virtual function related functionality - public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string declName) + public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan declName) { MetadataReader metadataReader = _module.MetadataReader; - var stringComparer = metadataReader.StringComparer; ArrayBuilder foundRecords = default(ArrayBuilder); foreach (var methodImplHandle in _typeDefinition.GetMethodImplementations()) @@ -33,30 +33,21 @@ public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string de methodDeclHandleKind = methodDeclCheckHandle.Kind; } - bool foundRecord = false; - - switch (methodDeclHandleKind) + StringHandle foundDeclNameHandle = methodDeclHandleKind switch { - case HandleKind.MethodDefinition: - if (stringComparer.Equals(metadataReader.GetMethodDefinition((MethodDefinitionHandle)methodDeclCheckHandle).Name, declName)) - { - foundRecord = true; - } - break; - - case HandleKind.MemberReference: - if (stringComparer.Equals(metadataReader.GetMemberReference((MemberReferenceHandle)methodDeclCheckHandle).Name, declName)) - { - foundRecord = true; - } - break; - - default: - Debug.Fail("unexpected methodDeclHandleKind"); - break; + HandleKind.MethodDefinition => metadataReader.GetMethodDefinition((MethodDefinitionHandle)methodDeclCheckHandle).Name, + HandleKind.MemberReference => metadataReader.GetMemberReference((MemberReferenceHandle)methodDeclCheckHandle).Name, + _ => default + }; + + BlobReader foundDeclNameReader = metadataReader.GetBlobReader(foundDeclNameHandle); + ReadOnlySpan foundDeclName; + unsafe + { + foundDeclName = new ReadOnlySpan(foundDeclNameReader.StartPointer, foundDeclNameReader.Length); } - if (foundRecord) + if (declName.SequenceEqual(foundDeclName)) { MethodImplRecord newRecord = new MethodImplRecord( (MethodDesc)_module.GetObject(methodImpl.MethodDeclaration), diff --git a/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs b/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs index 1aef1f567f51ac..4da12f548a6364 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs @@ -87,7 +87,7 @@ private void AppendMethodSignature(StringBuilder sb, MethodDesc method) sb.Append(' '); AppendOwningType(sb, method.OwningType); sb.Append("::"); - sb.Append(method.Name); + sb.Append(method.GetName()); if (method.HasInstantiation) { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/MethodILDebugView.cs b/src/coreclr/tools/Common/TypeSystem/IL/MethodILDebugView.cs index 28b9818c3af1ef..79179d7a3c1460 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/MethodILDebugView.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/MethodILDebugView.cs @@ -34,7 +34,7 @@ public string Disassembly sb.Append("instance "); disasm.AppendType(sb, owningMethod.Signature.ReturnType); sb.Append(' '); - sb.Append(owningMethod.Name); + sb.Append(owningMethod.GetName()); if (owningMethod.HasInstantiation) { sb.Append('<'); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs index e4089bb366a059..ae2d4b926c3002 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs @@ -54,19 +54,19 @@ private static MethodIL TryGetIntrinsicMethodIL(MethodDesc method) break; case "Debug": { - if (owningType.U8Namespace.SequenceEqual("System.Diagnostics"u8) && method.Name == "DebugBreak") + if (owningType.U8Namespace.SequenceEqual("System.Diagnostics"u8) && method.U8Name.SequenceEqual("DebugBreak"u8)) return new ILStubMethodIL(method, new byte[] { (byte)ILOpcode.break_, (byte)ILOpcode.ret }, Array.Empty(), null); } break; case "RuntimeAugments": { - if (owningType.U8Namespace.SequenceEqual("Internal.Runtime.Augments"u8) && method.Name == "GetCanonType") + if (owningType.U8Namespace.SequenceEqual("Internal.Runtime.Augments"u8) && method.U8Name.SequenceEqual("GetCanonType"u8)) return GetCanonTypeIntrinsic.EmitIL(method); } break; case "MethodTable": { - if (owningType.U8Namespace.SequenceEqual("Internal.Runtime"u8) && method.Name == "get_SupportsRelativePointers") + if (owningType.U8Namespace.SequenceEqual("Internal.Runtime"u8) && method.U8Name.SequenceEqual("get_SupportsRelativePointers"u8)) { ILOpcode value = method.Context.Target.SupportsRelativePointers ? ILOpcode.ldc_i4_1 : ILOpcode.ldc_i4_0; @@ -98,7 +98,7 @@ private static MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc metho if (owningType == null) return null; - string methodName = method.Name; + string methodName = method.GetName(); switch (owningType.GetName()) { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs index 72b192214f4a63..5b4ca0026ffe76 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -15,7 +17,7 @@ public static MethodIL EmitIL(MethodDesc method) Debug.Assert(method.OwningType.IsTypeDefinition); Debug.Assert(method.IsRuntimeImplemented); - if (method.Name == "BeginInvoke" || method.Name == "EndInvoke") + if (method.U8Name.SequenceEqual("BeginInvoke"u8) || method.U8Name.SequenceEqual("EndInvoke"u8)) { // BeginInvoke and EndInvoke are not supported on .NET Core ILEmitter emit = new ILEmitter(); @@ -25,7 +27,7 @@ public static MethodIL EmitIL(MethodDesc method) return emit.Link(method); } - if (method.Name == ".ctor") + if (method.U8Name.SequenceEqual(".ctor"u8)) { // We only support delegate creation if the IL follows the delegate creation verifiability requirements // described in ECMA-335 III.4.21 (newobj - create a new object). The codegen is expected to @@ -40,7 +42,7 @@ public static MethodIL EmitIL(MethodDesc method) return emit.Link(method); } - if (method.Name == "Invoke") + if (method.U8Name.SequenceEqual("Invoke"u8)) { TypeSystemContext context = method.Context; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs index 57838cbb8b25bf..4d90e37a6bf5b7 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs @@ -85,7 +85,7 @@ public sealed override string DiagnosticName { get { - return Name; + return GetName(); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs index 506592be2c2348..47205e908d2350 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs @@ -23,7 +23,7 @@ public static MethodIL EmitIL( Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("Interlocked"u8)); Debug.Assert(!method.IsGenericMethodDefinition); - if (method.HasInstantiation && method.Name == "CompareExchange") + if (method.HasInstantiation && method.U8Name.SequenceEqual("CompareExchange"u8)) { #if READYTORUN // Check to see if the tokens needed to describe the CompareExchange are naturally present within diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index ccbab79c7c9625..1a164e8a723e10 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -17,7 +17,6 @@ public static class RuntimeHelpersIntrinsics public static MethodIL EmitIL(MethodDesc method) { Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("RuntimeHelpers"u8)); - string methodName = method.Name; // All the methods handled below are per-instantiation generic methods if (method.Instantiation.Length != 1 || method.IsTypicalMethodDefinition) @@ -30,7 +29,7 @@ public static MethodIL EmitIL(MethodDesc method) return null; bool result; - if (methodName == "IsBitwiseEquatable") + if (method.U8Name.SequenceEqual("IsBitwiseEquatable"u8)) { // Ideally we could detect automatically whether a type is trivially equatable // (i.e., its operator == could be implemented via memcmp). But for now we'll diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs index c2ce861de369db..14fa1a818224dc 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs @@ -18,8 +18,8 @@ public static MethodIL EmitIL(MethodDesc method) { Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("Stream"u8)); - bool isRead = method.Name == "HasOverriddenBeginEndRead"; - if (!isRead && method.Name != "HasOverriddenBeginEndWrite") + bool isRead = method.U8Name.SequenceEqual("HasOverriddenBeginEndRead"u8); + if (!isRead && !method.U8Name.SequenceEqual("HasOverriddenBeginEndWrite"u8)) return null; TypeDesc streamClass = method.OwningType; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs index ce5e310672c5de..142ddc2e961043 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs @@ -18,7 +18,7 @@ public static MethodIL EmitIL(MethodDesc method) { Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("Unsafe"u8)); - switch (method.Name) + switch (method.GetName()) { case "AsPointer": return new ILStubMethodIL(method, new byte[] { (byte)ILOpcode.ldarg_0, (byte)ILOpcode.conv_u, (byte)ILOpcode.ret }, Array.Empty(), null); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs b/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs index b6be413b9baa14..01548bd75deafd 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs @@ -206,7 +206,7 @@ private static bool TryParseUnsafeAccessorAttribute(MethodDesc method, CustomAtt // as empty at the use site. if (kind is not UnsafeAccessorKind.Constructor) { - name = method.Name; + name = method.GetName(); } } @@ -434,7 +434,7 @@ private static SetTargetResult TrySetTargetMethod(ref GenerationContext context, } // Check for matching name - if (!md.Name.Equals(name)) + if (!md.GetName().Equals(name)) { continue; } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs index 1b3dd481ccdbe6..0a257327d7edab 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs @@ -215,7 +215,7 @@ protected override MethodImplRecord[] ComputeVirtualMethodImplsForType() return Array.Empty(); } - public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name) + public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan name) { return Array.Empty(); } @@ -369,7 +369,7 @@ public override string DiagnosticName { get { - return Name; + return GetName(); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs index 71228880a7d480..be56340ad6d5f0 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs @@ -288,7 +288,7 @@ protected override MethodImplRecord[] ComputeVirtualMethodImplsForType() return Array.Empty(); } - public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name) + public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan name) { return Array.Empty(); } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs index 63b37838aa531b..9533591d4384ac 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs @@ -198,7 +198,7 @@ protected override MethodImplRecord[] ComputeVirtualMethodImplsForType() return Array.Empty(); } - public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name) + public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan name) { return Array.Empty(); } diff --git a/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs b/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs index 8a81964b1402b8..725158e1cb6a0f 100644 --- a/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs @@ -316,7 +316,7 @@ public EntityHandle GetMethodRef(MethodDesc method) else { EntityHandle typeHandle = GetTypeRef(method.OwningType); - StringHandle methodName = _metadataBuilder.GetOrAddString(method.Name); + StringHandle methodName = _metadataBuilder.GetOrAddString(method.GetName()); var sig = method.GetTypicalMethodDefinition().Signature; var sigBlob = GetMethodSignatureBlobHandle(sig); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs index 83505068f3d1d0..a9e0dcaf657b0a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs @@ -189,7 +189,7 @@ public MethodDesc ExpandIntrinsicForCallsite(MethodDesc intrinsicMethod, MethodD } else if (intrinsicOwningType.U8Name.SequenceEqual("Assembly"u8) && intrinsicOwningType.U8Namespace.SequenceEqual("System.Reflection"u8)) { - if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.Name == "GetExecutingAssembly") + if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.U8Name.SequenceEqual("GetExecutingAssembly"u8)) { ModuleDesc callsiteModule = (callsiteMethod.OwningType as MetadataType)?.Module; if (callsiteModule != null) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs index 268ae4a6d47c72..f657504df424f6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs @@ -308,7 +308,7 @@ public BoxedValueType(ModuleDesc owningModule, MetadataType valuetype) public override IEnumerable GetNestedTypes() => Array.Empty(); public override MetadataType GetNestedType(string name) => null; protected override MethodImplRecord[] ComputeVirtualMethodImplsForType() => Array.Empty(); - public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name) => Array.Empty(); + public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan name) => Array.Empty(); public override int GetHashCode() => VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs index 283153caae470d..fbfcc44cdcf221 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using Internal.TypeSystem; @@ -56,9 +57,9 @@ public MethodDesc TryResolveConstrainedEnumMethod(TypeDesc enumType, MethodDesc EnumInfo info = _enumInfoHashtable.GetOrCreateValue(enumTypeDefinition); MethodDesc resolvedMethod; - if (virtualMethod.Name == "Equals") + if (virtualMethod.U8Name.SequenceEqual("Equals"u8)) resolvedMethod = info.EqualsMethod; - else if (virtualMethod.Name == "GetHashCode") + else if (virtualMethod.U8Name.SequenceEqual("GetHashCode"u8)) resolvedMethod = info.GetHashCodeMethod; else return null; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs index 483293cd0eea3e..132e53d0897b8f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs @@ -192,7 +192,7 @@ protected override MethodImplRecord[] ComputeVirtualMethodImplsForType() return Array.Empty(); } - public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name) + public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan name) { return Array.Empty(); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs index 99b9fd3cf9a565..9487630d540181 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedCallGraph.cs @@ -30,7 +30,7 @@ public void TrackCall(MethodDesc fromMethod, MethodDesc toMethod) { Debug.Assert(fromMethod.IsTypicalMethodDefinition); Debug.Assert(toMethod.IsTypicalMethodDefinition); - Debug.Assert(CompilerGeneratedNames.IsLambdaOrLocalFunction(toMethod.Name)); + Debug.Assert(CompilerGeneratedNames.IsLambdaOrLocalFunction(toMethod.GetName())); TrackCallInternal(fromMethod, toMethod); } @@ -47,7 +47,7 @@ public void TrackCall(DefType fromType, MethodDesc toMethod) Debug.Assert(fromType.IsTypeDefinition); Debug.Assert(toMethod.IsTypicalMethodDefinition); Debug.Assert(CompilerGeneratedNames.IsStateMachineType(fromType.GetName())); - Debug.Assert(CompilerGeneratedNames.IsLambdaOrLocalFunction(toMethod.Name)); + Debug.Assert(CompilerGeneratedNames.IsLambdaOrLocalFunction(toMethod.GetName())); TrackCallInternal(fromType, toMethod); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs index 533fa5883b0a3d..e2cd1b8c881963 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs @@ -133,7 +133,7 @@ void ProcessMethod(MethodDesc method) Debug.Assert(method == method.GetTypicalMethodDefinition()); bool isStateMachineMember = CompilerGeneratedNames.IsStateMachineType(((MetadataType)method.OwningType).GetName()); - if (!CompilerGeneratedNames.IsLambdaOrLocalFunction(method.Name)) + if (!CompilerGeneratedNames.IsLambdaOrLocalFunction(method.GetName())) { if (!isStateMachineMember) { @@ -190,7 +190,7 @@ referencedMethod.OwningType is MetadataType generatedType && continue; } - if (!CompilerGeneratedNames.IsLambdaOrLocalFunction(referencedMethod.Name)) + if (!CompilerGeneratedNames.IsLambdaOrLocalFunction(referencedMethod.GetName())) continue; if (isStateMachineMember) @@ -319,7 +319,7 @@ static bool IsSameOrNestedType(TypeDesc type, TypeDesc potentialOuterType) switch (compilerGeneratedMember) { case MethodDesc nestedFunction: - Debug.Assert(CompilerGeneratedNames.IsLambdaOrLocalFunction(nestedFunction.Name)); + Debug.Assert(CompilerGeneratedNames.IsLambdaOrLocalFunction(nestedFunction.GetName())); // Nested functions get suppressions from the user method only. _compilerGeneratedMethodToUserCodeMethod ??= new Dictionary(); if (!_compilerGeneratedMethodToUserCodeMethod.TryAdd(nestedFunction, userDefinedMethod)) @@ -595,7 +595,7 @@ public static bool IsHoistedLocal(FieldDesc field) // "Nested function" refers to lambdas and local functions. public static bool IsNestedFunctionOrStateMachineMember(TypeSystemEntity member) { - if (member is MethodDesc method && CompilerGeneratedNames.IsLambdaOrLocalFunction(method.Name)) + if (member is MethodDesc method && CompilerGeneratedNames.IsLambdaOrLocalFunction(method.GetName())) return true; if (member.GetOwningType() is not MetadataType declaringType) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs index 953c8208411b0c..51f2f01774b977 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs @@ -657,7 +657,7 @@ private partial bool MethodIsTypeConstructor(MethodProxy method) private partial IEnumerable GetMethodsOnTypeHierarchy(TypeProxy type, string name, BindingFlags? bindingFlags) { - foreach (var method in type.Type.GetMethodsOnTypeHierarchy(m => m.Name == name, bindingFlags)) + foreach (var method in type.Type.GetMethodsOnTypeHierarchy(m => m.U8Name.StringEquals(name), bindingFlags)) yield return new SystemReflectionMethodBaseValue(new MethodProxy(method)); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/InterproceduralState.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/InterproceduralState.cs index 71e3518a42bd81..fa64d50aa14fd4 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/InterproceduralState.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/InterproceduralState.cs @@ -78,7 +78,7 @@ public void TrackMethod(MethodIL methodBody) { foreach (var stateMachineMethod in stateMachineType.GetMethods()) { - Debug.Assert(!CompilerGeneratedNames.IsLambdaOrLocalFunction(stateMachineMethod.Name)); + Debug.Assert(!CompilerGeneratedNames.IsLambdaOrLocalFunction(stateMachineMethod.GetName())); if (TryGetMethodBody(stateMachineMethod, out MethodIL? stateMachineMethodBody)) { stateMachineMethodBody = GetInstantiatedMethodIL(stateMachineMethodBody); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs index de156c59833c51..13f1fc80d164d6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs @@ -335,7 +335,7 @@ private static void TrackNestedFunctionReference(MethodDesc referencedMethod, re { MethodDesc method = referencedMethod.GetTypicalMethodDefinition(); - if (!CompilerGeneratedNames.IsLambdaOrLocalFunction(method.Name)) + if (!CompilerGeneratedNames.IsLambdaOrLocalFunction(method.GetName())) return; interproceduralState.TrackMethod(method); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs index fc3f7b17bd0b99..394a76804fffcd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs @@ -27,7 +27,7 @@ public static void AddDependenciesDueToMethodCodePresence(ref DependencyList dep { if (method.OwningType is MetadataType owningType) { - string name = method.Name; + string name = method.GetName(); switch (name) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs index d6ff866e7d0af5..c74c80463278bc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs @@ -974,7 +974,7 @@ private void OutputVirtualSlots(NodeFactory factory, ref ObjectDataBuilder objDa // Object.Finalize shouldn't get a virtual slot. Finalizer is stored in an optional field // instead: most MethodTable don't have a finalizer, but all EETypes contain Object's vtable. // This lets us save a pointer (+reloc) on most EETypes. - Debug.Assert(!declType.IsObject || declMethod.Name != "Finalize"); + Debug.Assert(!declType.IsObject || !declMethod.U8Name.SequenceEqual("Finalize"u8)); // No generic virtual methods can appear in the vtable! Debug.Assert(!declMethod.HasInstantiation); @@ -999,8 +999,8 @@ private void OutputVirtualSlots(NodeFactory factory, ref ObjectDataBuilder objDa // We also null out Equals/GetHashCode - that's just a marginal size/startup optimization. if (isAsyncStateMachineValueType) { - if ((declType.IsObject && declMethod.Name is "Equals" or "GetHashCode" && implMethod.OwningType.IsWellKnownType(WellKnownType.ValueType)) - || (declType.IsWellKnownType(WellKnownType.ValueType) && declMethod.Name == ValueTypeGetFieldHelperMethodOverride.MetadataName)) + if ((declType.IsObject && (declMethod.U8Name.SequenceEqual("Equals"u8) || declMethod.U8Name.SequenceEqual("GetHashCode"u8)) && implMethod.OwningType.IsWellKnownType(WellKnownType.ValueType)) + || (declType.IsWellKnownType(WellKnownType.ValueType) && declMethod.U8Name.SequenceEqual(ValueTypeGetFieldHelperMethodOverride.U8MetadataName))) { shouldEmitImpl = false; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs index e44b58e048a771..daafb76daf28ec 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs @@ -24,6 +24,7 @@ internal sealed class InlineableStringsResourceNode : DependencyNodeCore U8ResourceAccessorTypeNamespace => "System"u8; public const string ResourceAccessorGetStringMethodName = "GetResourceString"; + public static ReadOnlySpan U8ResourceAccessorGetStringMethodName => "GetResourceString"u8; public InlineableStringsResourceNode(EcmaModule module) { @@ -62,7 +63,7 @@ public static bool IsInlineableStringsResource(EcmaModule module, string resourc public static void AddDependenciesDueToResourceStringUse(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { - if (method.Name == ResourceAccessorGetStringMethodName && method.OwningType is MetadataType mdType + if (method.U8Name.SequenceEqual(U8ResourceAccessorGetStringMethodName) && method.OwningType is MetadataType mdType && mdType.U8Name.SequenceEqual(U8ResourceAccessorTypeName) && mdType.U8Namespace.SequenceEqual(U8ResourceAccessorTypeNamespace)) { dependencies ??= new DependencyList(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs index d1a4a0dc9b73bb..81480df8b439ca 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs @@ -43,7 +43,7 @@ protected static MethodDesc[] ComputeSlots(TypeDesc type) continue; // Finalizers are called via a field on the MethodTable, not through the VTable - if (isObjectType && method.Name == "Finalize") + if (isObjectType && method.U8Name.SequenceEqual("Finalize"u8)) continue; // Current type doesn't define this slot. @@ -204,7 +204,7 @@ public void AddEntry(MethodDesc virtualMethod) #endif // Finalizers are called via a field on the MethodTable, not through the VTable - if (_type.IsObject && virtualMethod.Name == "Finalize") + if (_type.IsObject && virtualMethod.U8Name.SequenceEqual("Finalize"u8)) return; _usedMethods.Add(virtualMethod); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/HardwareIntrinsicHelpers.Aot.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/HardwareIntrinsicHelpers.Aot.cs index bd4e0a83165571..379b6293fd6ce9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/HardwareIntrinsicHelpers.Aot.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/HardwareIntrinsicHelpers.Aot.cs @@ -16,7 +16,7 @@ public static partial class HardwareIntrinsicHelpers { public static bool IsIsSupportedMethod(MethodDesc method) { - return method.Name == "get_IsSupported"; + return method.U8Name.SequenceEqual("get_IsSupported"u8); } /// diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILAssemblyGeneratingMethodDebugInfoProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILAssemblyGeneratingMethodDebugInfoProvider.cs index 9261a98a8ae385..e7eeb07701e883 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILAssemblyGeneratingMethodDebugInfoProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILAssemblyGeneratingMethodDebugInfoProvider.cs @@ -69,7 +69,7 @@ private SyntheticMethodDebugInformation GetDebugInformation(MethodIL methodIL) _tw.Write("instance "); _tw.Write(fmt.FormatName(owningMethod.Signature.ReturnType)); _tw.Write(" "); - _tw.Write(owningMethod.Name); + _tw.Write(owningMethod.GetName()); if (owningMethod.HasInstantiation) { _tw.Write("<"); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs index 597f963fad78ee..18cb57e30e37e6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs @@ -585,7 +585,7 @@ private static void GetMatchingMethods(string id, ref int index, TypeDesc type, foreach (var method in type.GetMethods()) { index = startIndex; - if (method.Name != memberName) + if (!method.U8Name.StringEquals(memberName)) continue; var methodArity = method.Instantiation.Length; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs index 93a2e79d9df627..70dd93ccd1a0e0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs @@ -890,7 +890,7 @@ protected StackTraceRecordData CreateStackTraceRecord(Metadata.MetadataTransform // In the metadata, we only represent the generic definition MethodDesc methodToGenerateMetadataFor = method.GetTypicalMethodDefinition(); - ConstantStringValue name = (ConstantStringValue)methodToGenerateMetadataFor.Name; + ConstantStringValue name = (ConstantStringValue)methodToGenerateMetadataFor.GetName(); MetadataRecord signature = transform.HandleMethodSignature(methodToGenerateMetadataFor.Signature); MetadataRecord owningType = transform.HandleType(methodToGenerateMetadataFor.OwningType); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs index 67d03fe6874ea4..e9119b78c69b6e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -52,7 +54,7 @@ public override bool IsBlocked(MethodDesc method) return true; // Also don't expose the ValueType.__GetFieldOverride method. - if (ecmaMethod.Name == Internal.IL.Stubs.ValueTypeGetFieldHelperMethodOverride.MetadataName + if (ecmaMethod.U8Name.SequenceEqual(Internal.IL.Stubs.ValueTypeGetFieldHelperMethodOverride.U8MetadataName) && ecmaMethod.OwningType.IsWellKnownType(WellKnownType.ValueType)) return true; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs index 1599709c3da09c..144f86d462c90d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs @@ -417,7 +417,7 @@ public MethodIL GetMethodILWithInlinedSubstitutions(MethodIL method) && calleeType.U8Name.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeName) && calleeType.U8Namespace.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeNamespace) && callee.Signature is { Length: 0, IsStatic: true } - && callee.Name.StartsWith("get_", StringComparison.Ordinal)) + && callee.U8Name.StartsWith("get_"u8)) { flags[offset] |= OpcodeFlags.GetResourceStringCall; hasGetResourceStringCall = true; @@ -822,10 +822,10 @@ private bool TryGetConstantArgument(MethodIL methodIL, byte[] body, OpcodeFlags[ { return true; } - else if (method.IsIntrinsic && method.Name is "get_IsValueType" or "get_IsEnum" + else if (method.IsIntrinsic && (method.U8Name.SequenceEqual("get_IsValueType"u8) || method.U8Name.SequenceEqual("get_IsEnum"u8)) && method.OwningType is MetadataType mdt && mdt.U8Name.SequenceEqual("Type"u8) && mdt.U8Namespace.SequenceEqual("System"u8) && mdt.Module == mdt.Context.SystemModule - && TryExpandTypeIs(methodIL, body, flags, currentOffset, method.Name, out constant)) + && TryExpandTypeIs(methodIL, body, flags, currentOffset, method.GetName(), out constant)) { return true; } @@ -1133,7 +1133,7 @@ private static bool ReadGetTypeFromHandle(ref ILReader reader, MethodIL methodIL MethodDesc method = (MethodDesc)methodIL.GetObject(reader.ReadILToken()); - if (!method.IsIntrinsic || method.Name != "GetTypeFromHandle") + if (!method.IsIntrinsic || !method.U8Name.SequenceEqual("GetTypeFromHandle"u8)) return false; if ((flags[reader.Offset] & OpcodeFlags.BasicBlockStart) != 0) @@ -1147,7 +1147,7 @@ private bool TryGetCharacteristicValue(MethodDesc maybeCharacteristicMethod, out if (maybeCharacteristicMethod.IsIntrinsic && maybeCharacteristicMethod.HasCustomAttribute("System.Runtime.CompilerServices", "AnalysisCharacteristicAttribute")) { - value = _characteristics == null || _characteristics.Contains(maybeCharacteristicMethod.Name); + value = _characteristics == null || _characteristics.Contains(maybeCharacteristicMethod.GetName()); return true; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs index 25576292aff809..d6ab77e0383a9e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs @@ -134,8 +134,8 @@ public bool HasSubstitutedValue(FieldDesc field) internal string GetResourceStringForAccessor(EcmaMethod method) { - Debug.Assert(method.Name.StartsWith("get_", StringComparison.Ordinal)); - string resourceStringName = method.Name.Substring(4); + Debug.Assert(method.U8Name.StartsWith("get_"u8)); + string resourceStringName = System.Text.Encoding.UTF8.GetString(method.U8Name.Slice(4)); Dictionary dict = _hashtable.GetOrCreateValue(method.Module).InlineableResourceStrings; if (dict != null diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs index b62a383915b085..bd561a87e6685c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs @@ -41,12 +41,12 @@ public override MethodIL EmitIL() protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { - return Name.CompareTo(other.Name, StringComparison.Ordinal); + return U8Name.SequenceCompareTo(other.U8Name); } public override bool IsPInvoke => false; - public override string DiagnosticName => Name; + public override string DiagnosticName => GetName(); protected override int ClassCode => 1744789196; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index 4c1d8a4d8015cd..35dc420d903432 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -1869,7 +1869,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V { retVal = default; - switch (method.Name) + switch (method.GetName()) { case "InitializeArray": if (method.OwningType is MetadataType mdType @@ -3260,7 +3260,7 @@ public void WriteContent(ref ObjectDataBuilder builder, ISymbolNode thisNode, No if (_methodPointed.Signature.IsStatic) { - Debug.Assert(creationInfo.Constructor.Method.Name == "InitializeOpenStaticThunk"); + Debug.Assert(creationInfo.Constructor.Method.U8Name.SequenceEqual("InitializeOpenStaticThunk"u8)); // _firstParameter builder.EmitPointerReloc(thisNode); @@ -3277,7 +3277,7 @@ public void WriteContent(ref ObjectDataBuilder builder, ISymbolNode thisNode, No } else { - Debug.Assert(creationInfo.Constructor.Method.Name == "InitializeClosedInstance"); + Debug.Assert(creationInfo.Constructor.Method.U8Name.SequenceEqual("InitializeClosedInstance"u8)); // _firstParameter _firstParameter.WriteFieldData(ref builder, factory); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs index 2c894fd1c466d0..07da091594e157 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs @@ -62,7 +62,7 @@ public override void AddMarshalAPIsGenericDependencies(ref DependencyList depend { if (metadataType.U8Name.SequenceEqual("Marshal"u8) && metadataType.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8)) { - string methodName = method.Name; + string methodName = method.GetName(); if (methodName == "GetFunctionPointerForDelegate" || methodName == "GetDelegateForFunctionPointer" || methodName == "PtrToStructure" || diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs index 6decba09f41ca9..b66832f62cf655 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs @@ -233,7 +233,7 @@ public uint GetMethodFunctionIdTypeIndex(MethodDesc method) descriptor.MemberFunction = GetMethodTypeIndex(method); descriptor.ParentClass = GetTypeIndex(method.OwningType, true); - descriptor.Name = method.Name; + descriptor.Name = method.GetName(); typeIndex = _objectWriter.GetMemberFunctionId(descriptor); _methodIdIndices.Add(method, typeIndex); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs index fdc894e07a1d5e..b872d110d8174d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs @@ -381,7 +381,7 @@ private void ImportCall(ILOpcode opcode, int token) } } - if (method.OwningType.IsDelegate && method.Name == "Invoke" && + if (method.OwningType.IsDelegate && method.U8Name.SequenceEqual("Invoke"u8) && opcode != ILOpcode.ldftn && opcode != ILOpcode.ldvirtftn) { // This call is expanded as an intrinsic; it's not an actual function call. @@ -873,7 +873,7 @@ private void ImportBranch(ILOpcode opcode, BasicBlock target, BasicBlock fallthr && _methodIL.GetObject(reader.ReadILToken()) is MethodDesc { IsIntrinsic: true } intrinsicMethod && intrinsicMethod.HasCustomAttribute("System.Runtime.CompilerServices", "AnalysisCharacteristicAttribute")) { - condition = _factory.AnalysisCharacteristic(intrinsicMethod.Name); + condition = _factory.AnalysisCharacteristic(intrinsicMethod.GetName()); } } @@ -997,7 +997,7 @@ private void ImportLdToken(int token) { if (type.IsCanonicalDefinitionType(CanonicalFormKind.Any)) { - Debug.Assert(_methodIL.OwningMethod.Name == "GetCanonType"); + Debug.Assert(_methodIL.OwningMethod.U8Name.SequenceEqual("GetCanonType"u8)); helperId = ReadyToRunHelperId.NecessaryTypeHandle; } @@ -1468,7 +1468,7 @@ private static void ReportInvalidInstruction(ILOpcode opcode) private static bool IsTypeGetTypeFromHandle(MethodDesc method) { - if (method.IsIntrinsic && method.Name == "GetTypeFromHandle") + if (method.IsIntrinsic && method.U8Name.SequenceEqual("GetTypeFromHandle"u8)) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -1482,7 +1482,7 @@ private static bool IsTypeGetTypeFromHandle(MethodDesc method) private static bool IsActivatorDefaultConstructorOf(MethodDesc method) { - if (method.IsIntrinsic && method.Name == "DefaultConstructorOf" && method.Instantiation.Length == 1) + if (method.IsIntrinsic && method.U8Name.SequenceEqual("DefaultConstructorOf"u8) && method.Instantiation.Length == 1) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -1496,7 +1496,7 @@ private static bool IsActivatorDefaultConstructorOf(MethodDesc method) private static bool IsActivatorAllocatorOf(MethodDesc method) { - if (method.IsIntrinsic && method.Name == "AllocatorOf" && method.Instantiation.Length == 1) + if (method.IsIntrinsic && method.U8Name.SequenceEqual("AllocatorOf"u8) && method.Instantiation.Length == 1) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -1510,7 +1510,7 @@ private static bool IsActivatorAllocatorOf(MethodDesc method) private static bool IsEETypePtrOf(MethodDesc method) { - if (method.IsIntrinsic && method.Name == "Of" && method.Instantiation.Length == 1) + if (method.IsIntrinsic && method.U8Name.SequenceEqual("Of"u8) && method.Instantiation.Length == 1) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -1524,7 +1524,7 @@ private static bool IsEETypePtrOf(MethodDesc method) private static bool IsRuntimeHelpersIsReferenceOrContainsReferences(MethodDesc method) { - if (method.IsIntrinsic && method.Name == "IsReferenceOrContainsReferences" && method.Instantiation.Length == 1) + if (method.IsIntrinsic && method.U8Name.SequenceEqual("IsReferenceOrContainsReferences"u8) && method.Instantiation.Length == 1) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -1538,7 +1538,7 @@ private static bool IsRuntimeHelpersIsReferenceOrContainsReferences(MethodDesc m private static bool IsMemoryMarshalGetArrayDataReference(MethodDesc method) { - if (method.IsIntrinsic && method.Name == "GetArrayDataReference" && method.Instantiation.Length == 1) + if (method.IsIntrinsic && method.U8Name.SequenceEqual("GetArrayDataReference"u8) && method.Instantiation.Length == 1) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs index 098c57b549461a..a9066e2ba5084f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs @@ -147,22 +147,22 @@ static bool IsSystemType(TypeDesc t) static bool IsTypeGetTypeFromHandle(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode == ILOpcode.call && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method - && method.IsIntrinsic && method.Name == "GetTypeFromHandle" + && method.IsIntrinsic && method.U8Name.SequenceEqual("GetTypeFromHandle"u8) && IsSystemType(method.OwningType); static bool IsTypeEquals(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode == ILOpcode.call && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method - && method.IsIntrinsic && method.Name is "op_Equality" + && method.IsIntrinsic && method.U8Name.SequenceEqual("op_Equality"u8) && IsSystemType(method.OwningType); static bool IsTypeInequals(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode == ILOpcode.call && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method - && method.IsIntrinsic && method.Name is "op_Inequality" + && method.IsIntrinsic && method.U8Name.SequenceEqual("op_Inequality"u8) && IsSystemType(method.OwningType); static bool IsObjectGetType(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode is ILOpcode.call or ILOpcode.callvirt && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method - && method.IsIntrinsic && method.Name is "GetType" && method.OwningType.IsObject; + && method.IsIntrinsic && method.U8Name.SequenceEqual("GetType"u8) && method.OwningType.IsObject; static bool IsArgumentOrLocalLoad(ILOpcode opcode) => opcode is (>= ILOpcode.ldloc_0 and <= ILOpcode.ldloc_3) or (>= ILOpcode.ldarg_0 and <= ILOpcode.ldarg_3); diff --git a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Method.cs b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Method.cs index 98845f5b6b2d43..92f30cb3e9cdd2 100644 --- a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Method.cs +++ b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Method.cs @@ -60,7 +60,7 @@ private Method HandleMethodDefinition(Cts.MethodDesc method) private void InitializeMethodDefinition(Cts.MethodDesc entity, Method record) { - record.Name = HandleString(entity.Name); + record.Name = HandleString(entity.GetName()); if (entity.HasInstantiation) { @@ -135,7 +135,7 @@ private MemberReference HandleMethodReference(Cts.MethodDesc method) private void InitializeMethodReference(Cts.MethodDesc entity, MemberReference record) { - record.Name = HandleString(entity.Name); + record.Name = HandleString(entity.GetName()); record.Parent = HandleType(entity.OwningType); record.Signature = HandleMethodSignature(entity.GetTypicalMethodDefinition().Signature); } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeFixupSignature.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeFixupSignature.cs index a32a1a11f5c5f9..afd5b384d912d4 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeFixupSignature.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeFixupSignature.cs @@ -178,7 +178,7 @@ public static void AddDependenciesForAsyncStateMachineBox(ref DependencyList dep if (!method.IsGenericMethodDefinition && factory.CompilationModuleGroup.ContainsMethodBody(method, false)) { - switch (method.Name) + switch (method.GetName()) { case "MoveNext": case ".cctor": diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs index e6ef9cad2c10f9..cb73382e71ef94 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs @@ -161,7 +161,7 @@ Task ValidateTypeWorkerHelper(TypeDesc typeToCheckForSkipValidation) } catch { - AddTypeValidationError(type, $"Signature could not be loaded for method {method.Name}"); + AddTypeValidationError(type, $"Signature could not be loaded for method {method.GetName()}"); return false; } @@ -215,7 +215,7 @@ Task ValidateTypeWorkerHelper(TypeDesc typeToCheckForSkipValidation) { if (methodDef.Attributes.HasFlag(MethodAttributes.RTSpecialName)) { - if ((method.Name != ".cctor") && !method.Name.StartsWith("_VtblGap")) + if (!method.U8Name.SequenceEqual(".cctor"u8) && !method.U8Name.StartsWith("_VtblGap"u8)) { AddTypeValidationError(type, $"Special name method {method} defined on interface"); return false; diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileDataManager.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileDataManager.cs index 66525f5bed5c66..ffc9600597693d 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileDataManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileDataManager.cs @@ -202,7 +202,7 @@ private PgoSchemaElem[] SynthesizeSchema(Compilation comp, MethodDesc method) if (targetMeth.Signature.IsStatic || !targetMeth.IsTypicalMethodDefinition) continue; - bool isDelegateInvoke = targetMeth.OwningType.IsDelegate && targetMeth.Name == "Invoke"; + bool isDelegateInvoke = targetMeth.OwningType.IsDelegate && targetMeth.U8Name.SequenceEqual("Invoke"u8); if (opcode != ILOpcode.callvirt && !isDelegateInvoke) continue; diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs index dfc21b015428ea..4092d8e01e669f 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs @@ -399,7 +399,7 @@ private uint LookupIbcMethodToken(MetadataType methodMetadataType, uint ibcToken var methodEntry = (BlobEntry.ExternalMethodEntry)blobs[new IBCBlobKey(ibcToken, BlobType.ExternalMethodDef)]; var signatureEntry = (BlobEntry.ExternalSignatureEntry)blobs[new IBCBlobKey(methodEntry.SignatureToken, BlobType.ExternalSignatureDef)]; - string methodName = Encoding.UTF8.GetString(methodEntry.Name); + byte[] methodName = methodEntry.Name; var ecmaType = (EcmaType)methodMetadataType.GetTypeDefinition(); @@ -411,7 +411,7 @@ private uint LookupIbcMethodToken(MetadataType methodMetadataType, uint ibcToken foreach (MethodDesc method in ecmaType.GetMethods()) { - if (method.Name == methodName) + if (method.U8Name.SequenceEqual(methodName)) { EcmaMethod ecmaCandidateMethod = method as EcmaMethod; if (ecmaCandidateMethod == null) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs index 4b5f28f73cab0e..4c6bcfee690704 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs @@ -50,7 +50,7 @@ private MethodIL TryGetIntrinsicMethodILForActivator(MethodDesc method) { if (method.Instantiation.Length == 1 && method.Signature.Length == 0 - && method.Name == "CreateInstance") + && method.U8Name.SequenceEqual("CreateInstance"u8)) { TypeDesc type = method.Instantiation[0]; if (type.IsValueType && type.GetParameterlessConstructor() == null) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/InstanceCalliHelperIntrinsics.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/InstanceCalliHelperIntrinsics.cs index 7f188461de7391..91eefcdd4774b5 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/InstanceCalliHelperIntrinsics.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/InstanceCalliHelperIntrinsics.cs @@ -14,7 +14,7 @@ public static MethodIL EmitIL(MethodDesc method) { MethodIL methodIL = EcmaMethodIL.Create((EcmaMethod)method); - if (method.Name.StartsWith("Invoke", StringComparison.Ordinal)) + if (method.U8Name.StartsWith("Invoke"u8)) { methodIL = new ExplicitThisCall(methodIL); } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index a1dc79692155f5..eef401cc9bd678 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -529,9 +529,9 @@ public static bool ShouldSkipCompilation(InstructionSetSupport instructionSetSup } if (methodNeedingCode.OwningType.IsDelegate && ( methodNeedingCode.IsConstructor || - methodNeedingCode.Name == "BeginInvoke" || - methodNeedingCode.Name == "Invoke" || - methodNeedingCode.Name == "EndInvoke")) + methodNeedingCode.U8Name.SequenceEqual("BeginInvoke"u8) || + methodNeedingCode.U8Name.SequenceEqual("Invoke"u8) || + methodNeedingCode.U8Name.SequenceEqual("EndInvoke"u8))) { // Special methods on delegate types return true; @@ -1917,7 +1917,7 @@ private void ceeInfoGetCallInfo( // JIT compilation, and require a runtime lookup for the actual code pointer // to call. - if (constrainedType.IsEnum && originalMethod.Name == "GetHashCode") + if (constrainedType.IsEnum && originalMethod.U8Name.SequenceEqual("GetHashCode"u8)) { MethodDesc methodOnUnderlyingType = constrainedType.UnderlyingType.FindVirtualFunctionTargetMethodOnObjectType(originalMethod); Debug.Assert(methodOnUnderlyingType != null); @@ -2070,8 +2070,8 @@ private void ceeInfoGetCallInfo( // 2) Delegate.Invoke() - since a Delegate is a sealed class as per ECMA spec // 3) JIT intrinsics - since they have pre-defined behavior devirt = targetMethod.OwningType.IsValueType || - (targetMethod.OwningType.IsDelegate && targetMethod.Name == "Invoke") || - (targetMethod.OwningType.IsObject && targetMethod.Name == "GetType"); + (targetMethod.OwningType.IsDelegate && targetMethod.U8Name.SequenceEqual("Invoke"u8)) || + (targetMethod.OwningType.IsObject && targetMethod.U8Name.SequenceEqual("GetType"u8)); callVirtCrossingVersionBubble = true; } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs index 4ffd41349451f9..000f55a111b4cf 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/OutputInfoBuilder.cs @@ -222,7 +222,7 @@ private string FormatMethodName(MethodDesc method, TypeNameFormatter typeNameFor } output.Append(typeNameFormatter.FormatName(method.OwningType)); output.Append("::"); - output.Append(method.Name); + output.Append(method.GetName()); output.Append("("); for (int paramIndex = 0; paramIndex < method.Signature.Length; paramIndex++) { diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs index d3882b864d4f3b..69dd98c62c36ea 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs @@ -1876,7 +1876,7 @@ private void expandRawHandleIntrinsic(ref CORINFO_RESOLVED_TOKEN pResolvedToken, pResult.compileTimeHandle = null; - switch (method.Name) + switch (method.GetName()) { case "Of": ComputeLookup(ref pResolvedToken, method.Instantiation[0], ReadyToRunHelperId.TypeHandle, HandleToObject(callerHandle), ref pResult.lookup); diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ILCompilerTestPInvokePolicy.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ILCompilerTestPInvokePolicy.cs index 5719ee5677b888..44ebae129d11fa 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ILCompilerTestPInvokePolicy.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ILCompilerTestPInvokePolicy.cs @@ -10,7 +10,7 @@ internal sealed class ILCompilerTestPInvokePolicy : PInvokeILEmitterConfiguratio { public override bool GenerateDirectCall(MethodDesc method, out string? externName) { - externName = method.Name; + externName = method.GetName(); return true; } } diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs index 03d79d038a7f03..1f7866a3091b72 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs @@ -518,7 +518,7 @@ static bool LogMessageHasSameOriginMember(MessageContainer mc, ICustomAttributeP static string? GetMemberName(TypeSystemEntity? entity) => entity switch { DefType defType => defType.GetName(), - MethodDesc method => method.Name, + MethodDesc method => method.GetName(), FieldDesc field => field.Name, _ => null }; diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs index 73233b17df43f9..f2c3a0f3b8381d 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs @@ -36,7 +36,7 @@ public void TestInstantiation() Assert.True(t.Instantiation[0].IsTypeDefinition); // Verify that we got a method definition - MethodDesc fooMethod = t.GetMethods().First(m => m.Name == "Foo"); + MethodDesc fooMethod = t.GetMethods().First(m => m.GetName() == "Foo"); Assert.True(fooMethod.IsTypicalMethodDefinition); // Verify that instantiating a method definition has no effect @@ -52,7 +52,7 @@ public void TestInstantiation() Assert.Equal(_context.GetWellKnownType(WellKnownType.Int32), instantiatedType.Instantiation[0]); // Verify that we get an instantiated method with the proper signature - MethodDesc fooInstantiatedMethod = instantiatedType.GetMethods().First(m => m.Name == "Foo"); + MethodDesc fooInstantiatedMethod = instantiatedType.GetMethods().First(m => m.GetName() == "Foo"); Assert.False(fooInstantiatedMethod.IsTypicalMethodDefinition); Assert.Equal(_context.GetWellKnownType(WellKnownType.Int32), fooInstantiatedMethod.Signature.ReturnType); Assert.Same(fooInstantiatedMethod.GetTypicalMethodDefinition(), fooMethod); @@ -72,9 +72,9 @@ public void TestMethodAttributes() MetadataType tDerivedGen = _testModule.GetType("GenericTypes", "DerivedGenericClass`1"); InstantiatedType genOfInt = tGen.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); InstantiatedType derivedGenOfInt = tDerivedGen.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); - MethodDesc fooInstantiatedMethod = genOfInt.GetMethods().First(m => m.Name == "Foo"); - MethodDesc barInstantiatedMethod = genOfInt.GetMethods().First(m => m.Name == "Bar"); - MethodDesc fooDerivedInstantiatedMethod = derivedGenOfInt.GetMethods().First(m => m.Name == "Foo"); + MethodDesc fooInstantiatedMethod = genOfInt.GetMethods().First(m => m.GetName() == "Foo"); + MethodDesc barInstantiatedMethod = genOfInt.GetMethods().First(m => m.GetName() == "Bar"); + MethodDesc fooDerivedInstantiatedMethod = derivedGenOfInt.GetMethods().First(m => m.GetName() == "Foo"); Assert.False(barInstantiatedMethod.IsVirtual); Assert.False(barInstantiatedMethod.IsNewSlot); @@ -99,7 +99,7 @@ public void TestFinalize() MetadataType tDerivedGen = _testModule.GetType("GenericTypes", "DerivedGenericClass`1"); InstantiatedType genOfInt = tGen.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); InstantiatedType derivedGenOfInt = tDerivedGen.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); - MethodDesc finalizeInstantiatedMethod = genOfInt.GetMethods().First(m => m.Name == "Finalize"); + MethodDesc finalizeInstantiatedMethod = genOfInt.GetMethods().First(m => m.GetName() == "Finalize"); Assert.Equal(finalizeInstantiatedMethod, genOfInt.GetFinalizer()); Assert.Equal(finalizeInstantiatedMethod, derivedGenOfInt.GetFinalizer()); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs index 03377d5fb03613..404259918ad198 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs @@ -146,8 +146,8 @@ public void TestInterafaceMethodResolution() MetadataType ifooOfInt = _testModule.GetType("InterfaceArrangements", "IFoo`1").MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); MetadataType ifooOfString = _testModule.GetType("InterfaceArrangements", "IFoo`1").MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.String)); - MethodDesc ifooOfIntMethod = ifooOfInt.GetMethods().Where(m => m.Name == "IMethod").Single(); - MethodDesc ifooOfStringMethod = ifooOfString.GetMethods().Where(m => m.Name == "IMethod").Single(); + MethodDesc ifooOfIntMethod = ifooOfInt.GetMethods().Where(m => m.GetName() == "IMethod").Single(); + MethodDesc ifooOfStringMethod = ifooOfString.GetMethods().Where(m => m.GetName() == "IMethod").Single(); MethodDesc result; diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs index 9be46a14869aa1..90e8bbfcff1cfe 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs @@ -54,7 +54,7 @@ private static string GetModOptMethodSignatureInfo(MethodSignature signature) public void TestSignatureMatches2ModOptsAtStartOfSig() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); - MethodSignature methodWith2ModOptsAtStartOfSig = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method")).Signature; + MethodSignature methodWith2ModOptsAtStartOfSig = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method")).Signature; // All modopts that are at the very beginning of the signature are given index 0.1.1.1 // Both the index and the order in the modopt array are significant for signature comparison @@ -68,7 +68,7 @@ public void TestSignatureMatches2ModOptsAtStartOfSig() public void TestSignatureMatchesModOptAtStartOfSigAndAfterByRef() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); - MethodSignature methodWithModOptAtStartOfSigAndAfterByRef = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method2")).Signature; + MethodSignature methodWithModOptAtStartOfSigAndAfterByRef = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method2")).Signature; // A modopts after an E_T_BYREF will look like 0.1.1.2.1.1 Assert.Equal(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWithModOptAtStartOfSigAndAfterByRef.GetEmbeddedSignatureData()[0].index); @@ -81,7 +81,7 @@ public void TestSignatureMatchesModOptAtStartOfSigAndAfterByRef() public void TestSignatureMatchesModoptOnPointerOrRefModifiedType() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); - MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method3")).Signature; + MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method3")).Signature; Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(0), methodWithModOpt.GetEmbeddedSignatureData()[0].index); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(1), methodWithModOpt.GetEmbeddedSignatureData()[1].index); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(2), methodWithModOpt.GetEmbeddedSignatureData()[2].index); @@ -91,7 +91,7 @@ public void TestSignatureMatchesModoptOnPointerOrRefModifiedType() public void TestSignatureMatchesForArrayShapeDetails() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); - MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method4")).Signature; + MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method4")).Signature; _output.WriteLine($"Found ModOptData '{GetModOptMethodSignatureInfo(methodWithModOpt)}'"); Assert.Equal(7, methodWithModOpt.GetEmbeddedSignatureData().Length); @@ -107,7 +107,7 @@ public void TestSignatureMatchesForArrayShapeDetails_HandlingOfCasesWhichDoNotNe // Test that ensure the typical case (where the loBounds is 0, and the hibounds is unspecified) doesn't produce an // EmbeddedSignatureData, but that other cases do. This isn't a complete test as ilasm won't actually properly generate the metadata for many of these cases MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); - MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method5")).Signature; + MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method5")).Signature; _output.WriteLine($"Found ModOptData '{GetModOptMethodSignatureInfo(methodWithModOpt)}'"); Assert.Equal(2, methodWithModOpt.GetEmbeddedSignatureData().Length); @@ -125,7 +125,7 @@ public void TestSignatureMatches() MetadataType baseClassType = _testModule.GetType("", "BaseClass`2"); - MethodDesc baseClassMethod = baseClassType.GetMethods().Single(m => string.Equals(m.Name, "Method")); + MethodDesc baseClassMethod = baseClassType.GetMethods().Single(m => string.Equals(m.GetName(), "Method")); MethodSignature baseClassMethodSignature = baseClassMethod.Signature; MethodSignatureBuilder matchingSignatureBuilder = new MethodSignatureBuilder(baseClassMethodSignature); matchingSignatureBuilder[0] = aOfAtomType; @@ -133,7 +133,7 @@ public void TestSignatureMatches() MethodSignature matchingSignature = matchingSignatureBuilder.ToSignature(); MetadataType derivedClassType = _testModule.GetType("", "DerivedClass"); - IEnumerable derivedClassMethods = derivedClassType.GetMethods().Where(m => string.Equals(m.Name, "Method")); + IEnumerable derivedClassMethods = derivedClassType.GetMethods().Where(m => string.Equals(m.GetName(), "Method")); IEnumerable matches = derivedClassMethods.Select(m => matchingSignature.Equals(m.Signature)); int matchCount = matches.Select(b => b ? 1 : 0).Sum(); Assert.Equal(1, matchCount); @@ -143,7 +143,7 @@ public void TestSignatureMatches() public void TestSerializedSignatureWithArrayShapes() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); - MethodDesc methodWithInterestingShapes = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method4")); + MethodDesc methodWithInterestingShapes = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method4")); // Create assembly with reference to interesting method TypeSystemMetadataEmitter metadataEmitter = new TypeSystemMetadataEmitter(new AssemblyNameInfo("Lookup"), _context); @@ -164,7 +164,7 @@ public void TestSerializedSignatureWithArrayShapes() var ilLookupModule = (EcmaModule)lookupContext.GetModuleForSimpleName("Lookup"); MethodDesc method4 = ilLookupModule.GetMethod(token); - Assert.Equal("Method4", method4.Name); + Assert.Equal("Method4", method4.GetName()); } @@ -228,7 +228,7 @@ public void TestSerializedSignatureWithReferenceToFieldWithModOpt() public void TestMDArrayFunctionReading() { MetadataType mdArrayFunctionResolutionType = _testModule.GetType("", "MDArrayFunctionResolution"); - MethodDesc methodWithMDArrayUsage = mdArrayFunctionResolutionType.GetMethods().Single(m => string.Equals(m.Name, "MethodWithUseOfMDArrayFunctions")); + MethodDesc methodWithMDArrayUsage = mdArrayFunctionResolutionType.GetMethods().Single(m => string.Equals(m.GetName(), "MethodWithUseOfMDArrayFunctions")); MethodIL methodIL = EcmaMethodIL.Create((EcmaMethod)methodWithMDArrayUsage); ILReader ilReader = new ILReader(methodIL.GetILBytes()); int failures = 0; diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs index edd31c33202c4b..2e0cf0fb4a36c2 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs @@ -37,13 +37,13 @@ public void TestStructEqualsAndGetHashCode() MetadataType t = _testModule.GetType("SyntheticVirtualOverride", "StructWithNoEqualsAndGetHashCode"); - Assert.DoesNotContain(t.GetMethods(), m => m.Name == "Equals"); - Assert.DoesNotContain(t.GetMethods(), m => m.Name == "GetHashCode"); + Assert.DoesNotContain(t.GetMethods(), m => m.GetName() == "Equals"); + Assert.DoesNotContain(t.GetMethods(), m => m.GetName() == "GetHashCode"); List introducedVirtualMethods = new List(t.GetAllMethods().Where(m => m.IsVirtual)); Assert.Equal(2, introducedVirtualMethods.Count); - Assert.Contains(introducedVirtualMethods, m => m.Name == "Equals"); - Assert.Contains(introducedVirtualMethods, m => m.Name == "GetHashCode"); + Assert.Contains(introducedVirtualMethods, m => m.GetName() == "Equals"); + Assert.Contains(introducedVirtualMethods, m => m.GetName() == "GetHashCode"); Assert.All(introducedVirtualMethods, m => { Assert.Same(t, m.OwningType); }); List virtualSlots = new List(t.EnumAllVirtualSlots()); @@ -52,10 +52,10 @@ public void TestStructEqualsAndGetHashCode() List vtable = virtualSlots.Select(t.FindVirtualFunctionTargetMethodOnObjectType).ToList(); - Assert.Contains(vtable, m => m.Name == "Equals" && m.OwningType == t); - Assert.Contains(vtable, m => m.Name == "GetHashCode" && m.OwningType == t); - Assert.Contains(vtable, m => m.Name == "Finalize" && m.OwningType.IsObject); - Assert.Contains(vtable, m => m.Name == "ToString" && m.OwningType.IsObject); + Assert.Contains(vtable, m => m.GetName() == "Equals" && m.OwningType == t); + Assert.Contains(vtable, m => m.GetName() == "GetHashCode" && m.OwningType == t); + Assert.Contains(vtable, m => m.GetName() == "Finalize" && m.OwningType.IsObject); + Assert.Contains(vtable, m => m.GetName() == "ToString" && m.OwningType.IsObject); } [Fact] @@ -75,10 +75,10 @@ public void TestUnoverriddenSyntheticEqualsAndGetHashCode() List vtable = virtualSlots.Select(t.FindVirtualFunctionTargetMethodOnObjectType).ToList(); - Assert.Contains(vtable, m => m.Name == "Equals" && m.OwningType == baseType); - Assert.Contains(vtable, m => m.Name == "GetHashCode" && m.OwningType == baseType); - Assert.Contains(vtable, m => m.Name == "Finalize" && m.OwningType.IsObject); - Assert.Contains(vtable, m => m.Name == "ToString" && m.OwningType.IsObject); + Assert.Contains(vtable, m => m.GetName() == "Equals" && m.OwningType == baseType); + Assert.Contains(vtable, m => m.GetName() == "GetHashCode" && m.OwningType == baseType); + Assert.Contains(vtable, m => m.GetName() == "Finalize" && m.OwningType.IsObject); + Assert.Contains(vtable, m => m.GetName() == "ToString" && m.OwningType.IsObject); } [Fact] @@ -98,10 +98,10 @@ public void TestOverriddenSyntheticEqualsAndGetHashCode() List vtable = virtualSlots.Select(t.FindVirtualFunctionTargetMethodOnObjectType).ToList(); - Assert.Contains(vtable, m => m.Name == "Equals" && m.OwningType == t); - Assert.Contains(vtable, m => m.Name == "GetHashCode" && m.OwningType == t); - Assert.Contains(vtable, m => m.Name == "Finalize" && m.OwningType.IsObject); - Assert.Contains(vtable, m => m.Name == "ToString" && m.OwningType.IsObject); + Assert.Contains(vtable, m => m.GetName() == "Equals" && m.OwningType == t); + Assert.Contains(vtable, m => m.GetName() == "GetHashCode" && m.OwningType == t); + Assert.Contains(vtable, m => m.GetName() == "Finalize" && m.OwningType.IsObject); + Assert.Contains(vtable, m => m.GetName() == "ToString" && m.OwningType.IsObject); } private sealed class SyntheticVirtualOverrideTypeSystemContext : TestTypeSystemContext diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs index cb7c8f89be5ebe..d6e5873eb2e149 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs @@ -48,7 +48,7 @@ public void TestGenericMethodInterfaceMethodImplOverride() foreach(MethodDesc m in interfaceType.GetMethods()) { - if (m.Name == "GenMethod") + if (m.GetName() == "GenMethod") { interfaceMethod = m; break; @@ -60,7 +60,7 @@ public void TestGenericMethodInterfaceMethodImplOverride() MethodDesc expectedVirtualMethod = null; foreach (MethodDesc m in objectType.GetMethods()) { - if (m.Name.Contains("GenMethod")) + if (m.GetName().Contains("GenMethod")) { expectedVirtualMethod = m; break; @@ -211,7 +211,7 @@ public void TestGenericsClassOverrideOfMethodWhereMethodHasBeenMovedFromTheTypeW // it in an ad hoc manner foreach (MethodDesc method in baseType.GetMethods()) { - if (method.Name != "Method") + if (method.GetName() != "Method") continue; if (method.GetTypicalMethodDefinition().Signature[0] == bang2Type) @@ -272,8 +272,8 @@ public void TestExactMethodImplGenericDeclResolutionOnInterfaces() Assert.Equal(bang0Type, md2.GetTypicalMethodDefinition().Signature[1]); ResolveInterfaceDispatch_ForMultiGenericTest(intImplementorType, out md1, out md2); - Assert.Contains("!0,!1", md1.Name); - Assert.Contains("!1,!0", md2.Name); + Assert.Contains("!0,!1", md1.GetName()); + Assert.Contains("!1,!0", md2.GetName()); } [Fact] diff --git a/src/coreclr/tools/aot/ILCompiler/ConfigurablePInvokePolicy.cs b/src/coreclr/tools/aot/ILCompiler/ConfigurablePInvokePolicy.cs index ac6e0a66934ac7..efc90dcde40b83 100644 --- a/src/coreclr/tools/aot/ILCompiler/ConfigurablePInvokePolicy.cs +++ b/src/coreclr/tools/aot/ILCompiler/ConfigurablePInvokePolicy.cs @@ -147,7 +147,7 @@ public override bool GenerateDirectCall(MethodDesc method, out string externName { if (_directPInvokes.TryGetValue(moduleName, out HashSet entrypoints)) { - string entryPointMetadataName = pInvokeMetadata.Name ?? method.Name; + string entryPointMetadataName = pInvokeMetadata.Name ?? method.GetName(); if (entrypoints == null) { diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs index 907176421f3c6d..27cc45605185ca 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs +++ b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs @@ -458,7 +458,7 @@ private static bool DumpReproArguments(CodeGenerationFailedException ex) var formatter = new CustomAttributeTypeNameFormatter((IAssemblyDesc)failingMethod.Context.SystemModule); Console.Write($"--singlemethodtypename \"{formatter.FormatName(failingMethod.OwningType, true)}\""); - Console.Write($" --singlemethodname {failingMethod.Name}"); + Console.Write($" --singlemethodname {failingMethod.GetName()}"); for (int i = 0; i < failingMethod.Instantiation.Length; i++) Console.Write($" --singlemethodgenericarg \"{formatter.FormatName(failingMethod.Instantiation[i], true)}\""); diff --git a/src/coreclr/tools/aot/ILCompiler/RdXmlRootProvider.cs b/src/coreclr/tools/aot/ILCompiler/RdXmlRootProvider.cs index ea8195c2fabfea..5a5d4eab1f7590 100644 --- a/src/coreclr/tools/aot/ILCompiler/RdXmlRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler/RdXmlRootProvider.cs @@ -180,7 +180,7 @@ static bool SignatureMatches(MethodDesc method, List parameter) foreach (var m in containingType.GetMethods()) { var method = m; - if (method.Name != methodName) + if (method.GetName() != methodName) continue; if (instArgs.Count != method.Instantiation.Length) diff --git a/src/coreclr/tools/aot/crossgen2/Program.cs b/src/coreclr/tools/aot/crossgen2/Program.cs index a8afdcb1e98916..1e2c70985ab856 100644 --- a/src/coreclr/tools/aot/crossgen2/Program.cs +++ b/src/coreclr/tools/aot/crossgen2/Program.cs @@ -693,7 +693,7 @@ private MethodDesc CheckAndParseSingleMethodModeArguments(CompilerTypeSystemCont int curIndex = 0; foreach (var searchMethod in owningType.GetMethods()) { - if (searchMethod.Name != singleMethodName) + if (searchMethod.GetName() != singleMethodName) continue; curIndex++; @@ -723,7 +723,7 @@ private MethodDesc CheckAndParseSingleMethodModeArguments(CompilerTypeSystemCont curIndex = 0; foreach (var searchMethod in owningType.GetMethods()) { - if (searchMethod.Name != singleMethodName) + if (searchMethod.GetName() != singleMethodName) continue; curIndex++; @@ -759,12 +759,12 @@ internal static string CreateReproArgumentString(MethodDesc method) var formatter = new CustomAttributeTypeNameFormatter((IAssemblyDesc)method.Context.SystemModule); sb.Append($"--singlemethodtypename \"{formatter.FormatName(method.OwningType, true)}\""); - sb.Append($" --singlemethodname \"{method.Name}\""); + sb.Append($" --singlemethodname \"{method.GetName()}\""); { int curIndex = 0; foreach (var searchMethod in method.OwningType.GetMethods()) { - if (searchMethod.Name != method.Name) + if (!searchMethod.U8Name.SequenceEqual(method.U8Name)) continue; curIndex++; diff --git a/src/coreclr/tools/dotnet-pgo/Program.cs b/src/coreclr/tools/dotnet-pgo/Program.cs index a36fce10d09e1c..a1d6fd403d66fb 100644 --- a/src/coreclr/tools/dotnet-pgo/Program.cs +++ b/src/coreclr/tools/dotnet-pgo/Program.cs @@ -1949,7 +1949,7 @@ private static void GenerateJittraceFile(FileInfo outputFileName, IEnumerable _name; + public override ReadOnlySpan U8Name => System.Text.Encoding.UTF8.GetBytes(Name); + public override Instantiation Instantiation => _instantiation; public override TypeDesc OwningType => _type; diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs index 2283f42486f71f..7e5fee49a7a030 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs @@ -186,7 +186,7 @@ public override MetadataType MetadataBaseType protected override int ClassCode => throw new NotImplementedException(); - public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(string name) => throw new NotImplementedException(); + public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan name) => throw new NotImplementedException(); public override ClassLayoutMetadata GetClassLayout() => throw new NotImplementedException(); public override int GetHashCode() { From 30e9b28794f63be7fe1cc4798c4009894735227b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Sun, 7 Sep 2025 16:54:05 +0200 Subject: [PATCH 09/19] Don't use FieldDesc.Name --- .../Common/Compiler/DisplayNameHelpers.cs | 2 +- .../Common/Compiler/NativeAotNameMangler.cs | 4 +- .../Common/Compiler/ProcessLinkerXmlBase.cs | 4 +- .../tools/Common/JitInterface/CorInfoImpl.cs | 10 ++-- .../TypeSystem/Common/FieldDesc.ToString.cs | 2 +- .../Common/TypeSystem/Common/FieldDesc.cs | 10 ++++ .../Common/ImpliedRepeatedFieldDesc.cs | 2 +- .../Common/TypeSystem/Common/TypeDesc.cs | 2 +- .../Common/TypeSystem/IL/ILDisassembler.cs | 2 +- .../Common/TypeSystem/IL/UnsafeAccessors.cs | 2 +- .../TypeSystemMetadataEmitter.cs | 2 +- .../Compiler/BodySubstitutionParser.cs | 3 +- .../Dataflow/CompilerGeneratedState.cs | 2 +- .../Compiler/Dataflow/FlowAnnotations.cs | 2 +- .../Compiler/Dataflow/HandleCallAction.cs | 2 +- .../StructMarshallingStubMapNode.cs | 2 +- .../Logging/DocumentationSignatureParser.cs | 2 +- .../Compiler/TypePreinit.cs | 12 ++--- .../Compiler/UserDefinedTypeDescriptor.cs | 6 +-- .../IL/ILImporter.Scanner.cs | 4 +- .../ILCompiler/Metadata/Transform.Field.cs | 4 +- .../ReadyToRun/TypeValidationChecker.cs | 2 +- .../Compiler/RuntimeDeterminedTypeHelper.cs | 4 +- .../TestCasesRunner/AssemblyChecker.cs | 2 +- .../TestCasesRunner/ResultChecker.cs | 2 +- .../InstanceFieldLayoutTests.cs | 50 +++++++++---------- .../SignatureTests.cs | 4 +- .../StaticFieldLayoutTests.cs | 32 ++++++------ .../TypeRefTypeSystemField.cs | 1 + 29 files changed, 95 insertions(+), 83 deletions(-) diff --git a/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs b/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs index 816697d673795f..7b5e9a027252cd 100644 --- a/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs +++ b/src/coreclr/tools/Common/Compiler/DisplayNameHelpers.cs @@ -119,7 +119,7 @@ public static string GetDisplayName(this FieldDesc field) { return new StringBuilder(field.OwningType.GetDisplayName()) .Append('.') - .Append(field.Name).ToString(); + .Append(field.GetName()).ToString(); } #if !READYTORUN diff --git a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs index 923e1ebdb76a3a..e37407e35fe66e 100644 --- a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs +++ b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs @@ -517,7 +517,7 @@ private Utf8String ComputeMangledFieldName(FieldDesc field) { foreach (var f in field.OwningType.GetFields()) { - string name = SanitizeName(f.Name); + string name = SanitizeName(f.GetName()); name = DisambiguateName(name, deduplicator); deduplicator.Add(name); @@ -533,7 +533,7 @@ private Utf8String ComputeMangledFieldName(FieldDesc field) } - string mangledName = SanitizeName(field.Name); + string mangledName = SanitizeName(field.GetName()); if (prependTypeName != null) mangledName = prependTypeName + "__" + mangledName; diff --git a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs index 7843c718aadb66..30e6711b0fc2d8 100644 --- a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs +++ b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs @@ -301,7 +301,7 @@ protected virtual void ProcessField(TypeDesc type, XPathNavigator nav) bool foundMatch = false; foreach (FieldDesc field in type.GetFields()) { - if (field.Name == name) + if (field.U8Name.StringEquals(name)) { foundMatch = true; ProcessField(type, field, nav); @@ -325,7 +325,7 @@ protected virtual void ProcessField(TypeDesc type, XPathNavigator nav) { sb.Clear(); CecilTypeNameFormatter.Instance.AppendName(sb, field.FieldType); - if (signature == sb.ToString() + " " + field.Name) + if (signature == sb.ToString() + " " + field.GetName()) return field; } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 1be5a75e284b41..a5d30e4b2f02ba 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -1856,7 +1856,7 @@ private void resolveToken(ref CORINFO_RESOLVED_TOKEN pResolvedToken) // References to literal fields from IL body should never resolve. // The CLR would throw a MissingFieldException while jitting and so should we. if (field.IsLiteral) - ThrowHelper.ThrowMissingFieldException(field.OwningType, field.Name); + ThrowHelper.ThrowMissingFieldException(field.OwningType, field.GetName()); pResolvedToken.hField = ObjectToHandle(field); @@ -3107,7 +3107,7 @@ private CorInfoIsAccessAllowedResult canAccessClass(ref CORINFO_RESOLVED_TOKEN p private nuint printFieldName(CORINFO_FIELD_STRUCT_* fld, byte* buffer, nuint bufferSize, nuint* requiredBufferSize) { FieldDesc field = HandleToObject(fld); - return PrintFromUtf16(field.Name, buffer, bufferSize, requiredBufferSize); + return PrintFromUtf16(field.GetName(), buffer, bufferSize, requiredBufferSize); } #pragma warning disable CA1822 // Mark members as static @@ -3166,16 +3166,16 @@ private static CORINFO_FIELD_ACCESSOR getFieldIntrinsic(FieldDesc field) var owningType = field.OwningType; if ((owningType.IsWellKnownType(WellKnownType.IntPtr) || owningType.IsWellKnownType(WellKnownType.UIntPtr)) && - field.Name == "Zero") + field.U8Name.SequenceEqual("Zero"u8)) { return CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INTRINSIC_ZERO; } - else if (owningType.IsString && field.Name == "Empty") + else if (owningType.IsString && field.U8Name.SequenceEqual("Empty"u8)) { return CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INTRINSIC_EMPTY_STRING; } else if (owningType.U8Name.SequenceEqual("BitConverter"u8) && owningType.U8Namespace.SequenceEqual("System"u8) && - field.Name == "IsLittleEndian") + field.U8Name.SequenceEqual("IsLittleEndian"u8)) { return CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN; } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.ToString.cs b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.ToString.cs index 6d52f349f24c0e..78d22dcc0b98d4 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.ToString.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.ToString.cs @@ -7,7 +7,7 @@ public partial class FieldDesc { public override string ToString() { - return $"{OwningType}.{Name}"; + return $"{OwningType}.{GetName()}"; } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs index d8921e16d672be..767518cb7f04ed 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs @@ -43,6 +43,16 @@ public virtual ReadOnlySpan U8Name } } + public string GetName() + { + return System.Text.Encoding.UTF8.GetString( + U8Name +#if NETSTANDARD + .ToArray() +#endif + ); + } + public abstract DefType OwningType { get; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs index d41c4aa1a78efa..a52e8b83558974 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs @@ -42,7 +42,7 @@ public ImpliedRepeatedFieldDesc(DefType owningType, FieldDesc underlyingFieldDes public override MarshalAsDescriptor GetMarshalAsDescriptor() => _underlyingFieldDesc.GetMarshalAsDescriptor(); - public override string Name => $"{_underlyingFieldDesc.Name}[{FieldIndex}]"; + public override string Name => $"{_underlyingFieldDesc.GetName()}[{FieldIndex}]"; public override ReadOnlySpan U8Name => System.Text.Encoding.UTF8.GetBytes(Name); } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs index 7e4277e008ce4a..0ce79bc35e036b 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs @@ -593,7 +593,7 @@ public virtual FieldDesc GetField(string name) { foreach (var field in GetFields()) { - if (field.Name == name) + if (field.GetName() == name) return field; } return null; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs b/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs index 4da12f548a6364..99660b22c510c3 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/ILDisassembler.cs @@ -141,7 +141,7 @@ private void AppendFieldSignature(StringBuilder sb, FieldDesc field) sb.Append(' '); AppendOwningType(sb, field.OwningType); sb.Append("::"); - sb.Append(field.Name); + sb.Append(field.GetName()); } private static void AppendStringLiteral(StringBuilder sb, string s) diff --git a/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs b/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs index 01548bd75deafd..cd51ba3d930c2e 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs @@ -497,7 +497,7 @@ private static SetTargetResult TrySetTargetField(ref GenerationContext context, } // Validate the name and target type match. - if (fd.Name.Equals(name) + if (fd.GetName().Equals(name) && fieldType == fd.FieldType) { context.TargetField = fd; diff --git a/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs b/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs index 725158e1cb6a0f..037525f3c3bc52 100644 --- a/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs @@ -337,7 +337,7 @@ public EntityHandle GetFieldRef(FieldDesc field) EntityHandle fieldHandle; EntityHandle typeHandle = GetTypeRef((MetadataType)field.OwningType); - StringHandle fieldName = _metadataBuilder.GetOrAddString(field.Name); + StringHandle fieldName = _metadataBuilder.GetOrAddString(field.GetName()); var sigBlob = GetFieldSignatureBlobHandle(field.GetTypicalFieldDefinition()); fieldHandle = _metadataBuilder.AddMemberReference(typeHandle, fieldName, sigBlob); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs index d9f87f6b80ef35..14975d1ee88f1d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs @@ -12,6 +12,7 @@ using System.Globalization; using System.Linq; using ILLink.Shared; +using ILCompiler.Dataflow; namespace ILCompiler { @@ -107,7 +108,7 @@ protected override void ProcessField(TypeDesc type, XPathNavigator fieldNav) if (string.IsNullOrEmpty(name)) return; - var field = type.GetFields().FirstOrDefault(f => f.Name == name); + var field = type.GetFields().FirstOrDefault(f => f.U8Name.StringEquals(name)); if (field == null) { #if !READYTORUN diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs index e2cd1b8c881963..9fa3c89dba4582 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs @@ -586,7 +586,7 @@ public static bool IsHoistedLocal(FieldDesc field) { // Don't track the "current" field which is used for state machine return values, // because this can be expensive to track. - return !CompilerGeneratedNames.IsStateMachineCurrentField(field.Name); + return !CompilerGeneratedNames.IsStateMachineCurrentField(field.GetName()); } return false; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs index a9be70fdf3f9e1..5bce7f7558dbd3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs @@ -994,7 +994,7 @@ internal partial MethodParameterValue GetMethodThisParameterValue(MethodProxy me } internal SingleValue GetFieldValue(FieldDesc field) - => field.Name switch + => field.GetName() switch { "EmptyTypes" when field.OwningType.IsTypeOf(ILLink.Shared.TypeSystemProxy.WellKnownType.System_Type) => ArrayValue.Create(0, field.OwningType), "Empty" when field.OwningType.IsTypeOf(ILLink.Shared.TypeSystemProxy.WellKnownType.System_String) => new KnownStringValue(string.Empty), diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs index 51f2f01774b977..ac3c9770abb468 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs @@ -712,7 +712,7 @@ private partial void MarkEventsOnTypeHierarchy(TypeProxy type, string name, Bind => _reflectionMarker.MarkEventsOnTypeHierarchy(_diagnosticContext.Origin, type.Type, e => e.Name == name, _reason, bindingFlags); private partial void MarkFieldsOnTypeHierarchy(TypeProxy type, string name, BindingFlags? bindingFlags) - => _reflectionMarker.MarkFieldsOnTypeHierarchy(_diagnosticContext.Origin, type.Type, f => f.Name == name, _reason, bindingFlags); + => _reflectionMarker.MarkFieldsOnTypeHierarchy(_diagnosticContext.Origin, type.Type, f => f.U8Name.StringEquals(name), _reason, bindingFlags); private partial void MarkPropertiesOnTypeHierarchy(TypeProxy type, string name, BindingFlags? bindingFlags) => _reflectionMarker.MarkPropertiesOnTypeHierarchy(_diagnosticContext.Origin, type.Type, p => p.Name == name, _reason, bindingFlags); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StructMarshallingStubMapNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StructMarshallingStubMapNode.cs index e62dc8c90c6ace..96d692240de402 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StructMarshallingStubMapNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StructMarshallingStubMapNode.cs @@ -90,7 +90,7 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) for (int i = 0; i < nativeType.Fields.Length; i++) { var row = writer.GetTuple( - writer.GetStringConstant(nativeType.Fields[i].Name), + writer.GetStringConstant(nativeType.Fields[i].GetName()), writer.GetUnsignedConstant((uint)nativeType.Fields[i].Offset.AsInt) ); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs index 18cb57e30e37e6..df89a4bf6b6bb7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs @@ -682,7 +682,7 @@ private static void GetMatchingFields(TypeDesc type, string memberName, List 0 && fieldNameEmit[0] == '<') { if (TryGetGeneratedNameKind(fieldNameEmit, out char kind)) @@ -420,7 +420,7 @@ private uint GetEnumTypeIndex(TypeDesc type) FieldDesc field = fieldsDescriptors[i]; EnumRecordTypeDescriptor recordTypeDescriptor; recordTypeDescriptor.Value = GetEnumRecordValue(field); - recordTypeDescriptor.Name = field.Name; + recordTypeDescriptor.Name = field.GetName(); typeRecords[i] = recordTypeDescriptor; } uint typeIndex = _objectWriter.GetEnumTypeIndex(enumTypeDescriptor, typeRecords); @@ -665,7 +665,7 @@ private uint GetClassTypeIndex(TypeDesc type, bool needsCompleteType) { FieldTypeIndex = fieldTypeIndex, Offset = (ulong)fieldOffsetEmit, - Name = fieldDesc.Name + Name = fieldDesc.GetName() }; if (fieldDesc.IsStatic) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs index b872d110d8174d..339f335d8ea64b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs @@ -1064,7 +1064,7 @@ private void ImportFieldAccess(int token, bool isStatic, bool? write, string rea var canonField = (FieldDesc)_canonMethodIL.GetObject(token); if (field.IsLiteral) - ThrowHelper.ThrowMissingFieldException(field.OwningType, field.Name); + ThrowHelper.ThrowMissingFieldException(field.OwningType, field.GetName()); _compilation.NodeFactory.MetadataManager.GetDependenciesDueToAccess(ref _dependencies, _compilation.NodeFactory, _canonMethodIL, canonField); @@ -1100,7 +1100,7 @@ private void ImportFieldAccess(int token, bool isStatic, bool? write, string rea // References to literal fields from IL body should never resolve. // The CLR would throw a MissingFieldException while jitting and so should we. if (field.IsLiteral) - ThrowHelper.ThrowMissingFieldException(field.OwningType, field.Name); + ThrowHelper.ThrowMissingFieldException(field.OwningType, field.GetName()); ReadyToRunHelperId helperId; if (field.HasRva) diff --git a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Field.cs b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Field.cs index 9c04f3ca3c2144..351e556aa893e7 100644 --- a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Field.cs +++ b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Field.cs @@ -46,7 +46,7 @@ private Field HandleFieldDefinition(Cts.FieldDesc field) private void InitializeFieldDefinition(Cts.FieldDesc entity, Field record) { - record.Name = HandleString(entity.Name); + record.Name = HandleString(entity.GetName()); record.Flags = GetFieldAttributes(entity); var ecmaField = entity as Cts.Ecma.EcmaField; @@ -99,7 +99,7 @@ private MemberReference HandleFieldReference(Cts.FieldDesc field) private void InitializeFieldReference(Cts.FieldDesc entity, MemberReference record) { - record.Name = HandleString(entity.Name); + record.Name = HandleString(entity.GetName()); record.Parent = HandleType(entity.OwningType); record.Signature = new FieldSignature { diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs index cb73382e71ef94..d5ac3c3a01c03b 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs @@ -141,7 +141,7 @@ Task ValidateTypeWorkerHelper(TypeDesc typeToCheckForSkipValidation) // Validate that all fields on the type are both loadable if (!await ValidateTypeWorkerHelper(field.FieldType)) { - AddTypeValidationError(type, $"Field {field.Name}'s type failed validation"); + AddTypeValidationError(type, $"Field {field.GetName()}'s type failed validation"); return false; } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/RuntimeDeterminedTypeHelper.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/RuntimeDeterminedTypeHelper.cs index 2f298d26f34867..b28b4b30937883 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/RuntimeDeterminedTypeHelper.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/RuntimeDeterminedTypeHelper.cs @@ -142,7 +142,7 @@ public static bool Equals(FieldDesc field1, FieldDesc field2) { return field1 == null && field2 == null; } - return field1.Name == field2.Name && + return field1.U8Name.SequenceEqual(field2.U8Name) && RuntimeDeterminedTypeHelper.Equals(field1.OwningType, field2.OwningType) && RuntimeDeterminedTypeHelper.Equals(field1.FieldType, field2.FieldType); } @@ -207,7 +207,7 @@ public static int GetHashCode(FieldDesc field) { return 0; } - return unchecked(GetHashCode(field.OwningType) + 97 * GetHashCode(field.FieldType) + 31 * field.Name.GetHashCode()); + return unchecked(GetHashCode(field.OwningType) + 97 * GetHashCode(field.FieldType) + 31 * field.GetName().GetHashCode()); } public static int GetHashCode(FieldWithToken field) diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs index 9dda881925350a..8e349351d5813e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs @@ -780,7 +780,7 @@ private IEnumerable VerifyMemberBackingField(IMemberDefinition src, Type yield break; } - foreach (var err in VerifyFieldKept(srcField, linkedType?.GetFields()?.FirstOrDefault(l => srcField.Name == l.Name), skipKeptItemsValidation: true)) + foreach (var err in VerifyFieldKept(srcField, linkedType?.GetFields()?.FirstOrDefault(l => srcField.Name == l.GetName()), skipKeptItemsValidation: true)) yield return err; verifiedGeneratedFields.Add(srcField.FullName); linkedMembers.Remove(new AssemblyQualifiedToken(srcField)); diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs index 1f7866a3091b72..d8322d7b5b9296 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ResultChecker.cs @@ -519,7 +519,7 @@ static bool LogMessageHasSameOriginMember(MessageContainer mc, ICustomAttributeP { DefType defType => defType.GetName(), MethodDesc method => method.GetName(), - FieldDesc field => field.Name, + FieldDesc field => field.GetName(), _ => null }; diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs index e2facd9e9923dc..270c2d0c01ae4b 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs @@ -40,13 +40,13 @@ public void TestExplicitLayout() if (field.IsStatic) continue; - if (field.Name == "Bar") + if (field.GetName() == "Bar") { // Bar has explicit offset 4 and is in a class (with S.O size overhead of ) // Therefore it should have offset 4 + 8 = 12 Assert.Equal(12, field.Offset.AsInt); } - else if (field.Name == "Baz") + else if (field.GetName() == "Baz") { // Baz has explicit offset 10. 10 + 8 = 18 Assert.Equal(18, field.Offset.AsInt); @@ -93,13 +93,13 @@ public void TestExplicitTypeLayoutWithInheritance() if (f.IsStatic) continue; - if (f.Name == "Lol") + if (f.GetName() == "Lol") { // First field after base class, with offset 0 so it should lie on the byte count of // the base class = 20 Assert.Equal(20, f.Offset.AsInt); } - else if (f.Name == "Omg") + else if (f.GetName() == "Omg") { // Offset 20 from base class byte count = 40 Assert.Equal(40, f.Offset.AsInt); @@ -147,7 +147,7 @@ public void TestSequentialTypeLayout() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "MyInt": Assert.Equal(0x8, f.Offset.AsInt); @@ -191,7 +191,7 @@ public void TestSequentialTypeLayoutInheritance() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "MyInt2": Assert.Equal(0x28, f.Offset.AsInt); @@ -223,7 +223,7 @@ public void TestSequentialTypeLayoutStruct() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "b1": Assert.Equal(0x0, f.Offset.AsInt); @@ -266,7 +266,7 @@ public void TestSequentialTypeLayoutStructEmbedded() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "MyStruct0": Assert.Equal(0x0, f.Offset.AsInt); @@ -291,7 +291,7 @@ public void TestSequentialTypeLayoutClass16Align() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "vector16Align": Assert.Equal(0x8, f.Offset.AsInt); @@ -313,7 +313,7 @@ public void TestSequentialTypeLayoutClass32Align() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "vector32Align": Assert.Equal(0x8, f.Offset.AsInt); @@ -335,7 +335,7 @@ public void TestSequentialTypeLayoutClass64Align() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "vector64Align": Assert.Equal(0x8, f.Offset.AsInt); @@ -364,7 +364,7 @@ public void TestAutoLayoutStruct() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "MyStructInt": Assert.Equal(0x00, f.Offset.AsInt); @@ -407,7 +407,7 @@ public void TestAutoTypeLayoutClassContainingStructs() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "MyByteArray": Assert.Equal(0x08, f.Offset.AsInt); @@ -470,7 +470,7 @@ public void TestAutoTypeLayoutBaseClass7BytesRemaining() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "MyByteArray1": Assert.Equal(0x08, f.Offset.AsInt); @@ -512,7 +512,7 @@ public void TestAutoTypeLayoutBaseClass4BytesRemaining() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "MyLong1": Assert.Equal(0x08, f.Offset.AsInt); @@ -546,7 +546,7 @@ public void TestAutoTypeLayoutBaseClass3BytesRemaining() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "MyString1": Assert.Equal(0x08, f.Offset.AsInt); @@ -584,7 +584,7 @@ public void TestAutoTypeLayoutOptimizePartial() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "OptBool": Assert.Equal(0x29, f.Offset.AsInt); @@ -630,7 +630,7 @@ public void TestAutoTypeLayoutOptimize7Bools() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "OptBool1": Assert.Equal(0x29, f.Offset.AsInt); @@ -689,7 +689,7 @@ public void TestAutoTypeLayoutOptimizeAlignedFields() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "OptBool1": Assert.Equal(0x29, f.Offset.AsInt); @@ -739,7 +739,7 @@ public void TestAutoTypeLayoutOptimizeLargestField() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "OptInt": Assert.Equal(0x14, f.Offset.AsInt); @@ -779,7 +779,7 @@ public void TestAutoTypeLayoutNoOptimizeMisaligned() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "NoOptString": Assert.Equal(0x18, f.Offset.AsInt); @@ -814,7 +814,7 @@ public void TestAutoTypeLayoutNoOptimizeCharAtSize2Alignment() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "NoOptChar": Assert.Equal(0x16, f.Offset.AsInt); @@ -858,7 +858,7 @@ public void TestAutoTypeLayoutClass16Align() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "vector16Align": Assert.Equal(0x8, f.Offset.AsInt); @@ -880,7 +880,7 @@ public void TestAutoTypeLayoutClass32Align() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "vector32Align": Assert.Equal(0x8, f.Offset.AsInt); @@ -902,7 +902,7 @@ public void TestAutoTypeLayoutClass64Align() if (f.IsStatic) continue; - switch (f.Name) + switch (f.GetName()) { case "vector64Align": Assert.Equal(0x8, f.Offset.AsInt); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs index 90e8bbfcff1cfe..b0c0aa258d2bf6 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs @@ -200,7 +200,7 @@ public void TestSerializedSignatureWithReferenceToFieldWithModOpt() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); - FieldDesc fieldWithModOpt = modOptTester.GetFields().Single(m => string.Equals(m.Name, "fieldWithModOpt")); + FieldDesc fieldWithModOpt = modOptTester.GetFields().Single(m => string.Equals(m.GetName(), "fieldWithModOpt")); // Create assembly with reference to interesting method TypeSystemMetadataEmitter metadataEmitter = new TypeSystemMetadataEmitter(new AssemblyNameInfo("Lookup"), _context); @@ -221,7 +221,7 @@ public void TestSerializedSignatureWithReferenceToFieldWithModOpt() var ilLookupModule = (EcmaModule)lookupContext.GetModuleForSimpleName("Lookup"); FieldDesc fieldFound = ilLookupModule.GetField(token); - Assert.Equal("fieldWithModOpt", fieldFound.Name); + Assert.Equal("fieldWithModOpt", fieldFound.GetName()); } [Fact] diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs index e5855d624672c7..cfbd01648ffc51 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs @@ -36,7 +36,7 @@ public void TestNoPointers() if (!field.IsStatic) continue; - switch (field.Name) + switch (field.GetName()) { case "int1": Assert.Equal(0, field.Offset.AsInt); @@ -48,7 +48,7 @@ public void TestNoPointers() Assert.Equal(6, field.Offset.AsInt); break; default: - throw new Exception(field.Name); + throw new Exception(field.GetName()); } } } @@ -67,13 +67,13 @@ public void TestStillNoPointers() if (!field.IsStatic) continue; - switch (field.Name) + switch (field.GetName()) { case "bool1": Assert.Equal(0, field.Offset.AsInt); break; default: - throw new Exception(field.Name); + throw new Exception(field.GetName()); } } } @@ -92,7 +92,7 @@ public void TestClassNoPointers() if (!field.IsStatic) continue; - switch (field.Name) + switch (field.GetName()) { case "int1": Assert.Equal(0, field.Offset.AsInt); @@ -104,7 +104,7 @@ public void TestClassNoPointers() Assert.Equal(6, field.Offset.AsInt); break; default: - throw new Exception(field.Name); + throw new Exception(field.GetName()); } } } @@ -123,7 +123,7 @@ public void TestHasPointers() if (!field.IsStatic) continue; - switch (field.Name) + switch (field.GetName()) { case "string1": Assert.Equal(8, field.Offset.AsInt); @@ -132,7 +132,7 @@ public void TestHasPointers() Assert.Equal(16, field.Offset.AsInt); break; default: - throw new Exception(field.Name); + throw new Exception(field.GetName()); } } } @@ -151,7 +151,7 @@ public void TestMixPointersAndNonPointers() if (!field.IsStatic) continue; - switch (field.Name) + switch (field.GetName()) { case "string1": Assert.Equal(8, field.Offset.AsInt); @@ -169,7 +169,7 @@ public void TestMixPointersAndNonPointers() Assert.Equal(24, field.Offset.AsInt); break; default: - throw new Exception(field.Name); + throw new Exception(field.GetName()); } } } @@ -189,7 +189,7 @@ public void TestEnsureInheritanceResetsStaticOffsets() if (!field.IsStatic) continue; - switch (field.Name) + switch (field.GetName()) { case "int3": Assert.Equal(0, field.Offset.AsInt); @@ -198,7 +198,7 @@ public void TestEnsureInheritanceResetsStaticOffsets() Assert.Equal(8, field.Offset.AsInt); break; default: - throw new Exception(field.Name); + throw new Exception(field.GetName()); } } } @@ -219,7 +219,7 @@ public void TestLiteralFieldsDontAffectLayout() if (!field.IsStatic) continue; - switch (field.Name) + switch (field.GetName()) { case "IntConstant": case "StringConstant": @@ -233,7 +233,7 @@ public void TestLiteralFieldsDontAffectLayout() Assert.Equal(8, field.Offset.AsInt); break; default: - throw new Exception(field.Name); + throw new Exception(field.GetName()); } } } @@ -253,13 +253,13 @@ public void TestStaticSelfRef() if (!field.IsStatic) continue; - switch (field.Name) + switch (field.GetName()) { case "selfRef1": Assert.Equal(0, field.Offset.AsInt); break; default: - throw new Exception(field.Name); + throw new Exception(field.GetName()); } } } diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs index 3e2d09aec92f8d..d4e3ed40eaf7da 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs @@ -26,6 +26,7 @@ public TypeRefTypeSystemField(TypeRefTypeSystemType type, string name, TypeDesc } public override string Name => _name; + public override ReadOnlySpan U8Name => System.Text.Encoding.UTF8.GetBytes(_name); public override DefType OwningType => _type; public override TypeDesc FieldType => _fieldType; From dbefb557f326176c68af0470b64e086e7ee72e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Sun, 7 Sep 2025 20:59:48 +0200 Subject: [PATCH 10/19] GetMethod/GetField is UTF8 --- .../Internal/Runtime/EETypeBuilderHelpers.cs | 2 +- .../Common/CastingHelper.TypeEquivalence.cs | 4 +- .../TypeSystem/Common/InstantiatedType.cs | 6 +- .../Common/TypeSystem/Common/TypeDesc.cs | 14 +- .../TypeSystem/Common/TypeSystemHelpers.cs | 2 +- .../Common/TypeSystem/Ecma/EcmaAssembly.cs | 5 +- .../tools/Common/TypeSystem/Ecma/EcmaField.cs | 7 +- .../TypeSystem/Ecma/EcmaGenericParameter.cs | 5 +- .../Common/TypeSystem/Ecma/EcmaMethod.cs | 5 +- .../Common/TypeSystem/Ecma/EcmaModule.cs | 6 +- .../TypeSystem/Ecma/EcmaType.MethodImpls.cs | 8 +- .../tools/Common/TypeSystem/Ecma/EcmaType.cs | 27 +-- .../TypeSystem/Ecma/MetadataExtensions.cs | 14 ++ .../Common/TypeSystem/IL/DelegateInfo.cs | 2 +- .../Common/TypeSystem/IL/HelperExtensions.cs | 14 +- .../TypeSystem/IL/NativeAotILProvider.cs | 8 +- .../IL/Stubs/ArrayMethodILEmitter.cs | 18 +- ...AssemblyGetExecutingAssemblyMethodThunk.cs | 2 +- .../Stubs/DelegateMarshallingMethodThunk.cs | 2 +- .../IL/Stubs/DelegateMethodILEmitter.cs | 8 +- .../TypeSystem/IL/Stubs/DelegateThunks.cs | 16 +- .../IL/Stubs/DynamicInvokeMethodThunk.cs | 2 +- .../Common/TypeSystem/IL/Stubs/EnumThunks.cs | 6 +- .../IL/Stubs/ForwardDelegateCreationThunk.cs | 2 +- .../IL/Stubs/InterlockedIntrinsics.cs | 2 +- .../Stubs/MethodBaseGetCurrentMethodThunk.cs | 6 +- .../TypeSystem/IL/Stubs/PInvokeILEmitter.cs | 22 +- .../IL/Stubs/RuntimeHelpersIntrinsics.cs | 2 +- .../TypeSystem/IL/Stubs/StreamIntrinsics.cs | 4 +- .../IL/Stubs/TypeGetTypeMethodThunk.cs | 6 +- .../IL/Stubs/TypeSystemThrowingILEmitter.cs | 18 +- .../ValueTypeGetFieldHelperMethodOverride.cs | 8 +- .../Common/TypeSystem/IL/UnsafeAccessors.cs | 14 +- .../Interop/IL/MarshalHelpers.Aot.cs | 2 +- .../TypeSystem/Interop/IL/Marshaller.Aot.cs | 96 ++++---- .../TypeSystem/Interop/IL/Marshaller.cs | 56 ++--- .../IL/PInvokeDelegateWrapperConstructor.cs | 2 +- .../RuntimeDeterminedType.cs | 4 +- .../tools/ILVerification/ILImporter.Verify.cs | 2 +- .../DependencyGraphTests.cs | 5 +- .../DevirtualizationTests.cs | 6 +- .../Compiler/BodySubstitution.cs | 2 +- .../Compiler/Compilation.cs | 4 +- .../CompilerTypeSystemContext.BoxedTypes.cs | 8 +- .../CompilerTypeSystemContext.EnumMethods.cs | 2 +- ...mpilerTypeSystemContext.InterfaceThunks.cs | 6 +- ...pilerTypeSystemContext.ValueTypeMethods.cs | 4 +- .../Compiler/Dataflow/AttributeDataFlow.cs | 2 +- .../Compiler/DelegateCreationInfo.cs | 12 +- ...CustomAttributeBasedDependencyAlgorithm.cs | 8 +- .../InlineableStringsResourceNode.cs | 2 +- .../DependencyAnalysis/NodeFactory.cs | 4 +- .../ReadyToRunGenericHelperNode.cs | 2 +- .../StringAllocatorMethodNode.cs | 2 +- .../DependencyAnalysis/TentativeMethodNode.cs | 2 +- .../ILCompiler.Compiler/Compiler/JitHelper.cs | 106 ++++----- .../Compiler/LibraryInitializers.cs | 3 +- .../ReachabilityInstrumentationFilter.cs | 2 +- .../ReachabilityInstrumentationProvider.cs | 2 +- .../Compiler/TypePreinit.cs | 10 +- .../Compiler/UsageBasedMetadataManager.cs | 2 +- .../IL/ILImporter.Scanner.cs | 4 +- .../StartupCode/NativeLibraryStartupMethod.cs | 2 +- .../StartupCode/StartupCodeMainMethod.cs | 18 +- .../Compiler/CallChainProfile.cs | 3 +- .../ReadyToRun/TypesTableNode.cs | 9 - .../IBC/MIbcProfileParser.cs | 4 +- .../IL/ReadyToRunILProvider.cs | 2 +- .../JitInterface/CorInfoImpl.RyuJit.cs | 4 +- .../ArchitectureSpecificFieldLayoutTests.cs | 208 +++++++++--------- .../CanonicalizationTests.cs | 64 +++--- .../ConstraintsValidationTest.cs | 4 +- .../GenericTypeAndMethodTests.cs | 16 +- .../ILDisassemblerTests.cs | 2 +- .../StaticFieldLayoutTests.cs | 4 +- .../VirtualFunctionOverrideTests.cs | 35 +-- .../VirtualStaticInterfaceMethodTests.cs | 40 ++-- src/coreclr/tools/aot/ILCompiler/Program.cs | 4 +- .../TypeRefTypeSystemContext.cs | 2 +- .../TypeRefTypeSystemField.cs | 10 +- .../TypeRefTypeSystemMethod.cs | 12 +- .../TypeRefTypeSystemModule.cs | 2 +- .../TypeRefTypeSystemType.cs | 18 +- 83 files changed, 543 insertions(+), 549 deletions(-) diff --git a/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs b/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs index 00a124a380a9be..641526c3e28687 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs @@ -244,7 +244,7 @@ public static ushort ComputeFlagsEx(TypeDesc type) if (type.IsNullable) { - FieldDesc field = type.GetField("value"); + FieldDesc field = type.GetField("value"u8); int nullableValueOffset = field.Offset.AsInt; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs b/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs index e20cb63fe1eac7..62baa9d49b4865 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs @@ -179,8 +179,8 @@ static bool IsEquivalentTo_TypeDefinition(MetadataType type1, MetadataType type2 static bool CompareDelegatesForEquivalence(MetadataType type1, MetadataType type2, StackOverflowProtect visited) { - var invoke1 = type1.GetMethod("Invoke", null); - var invoke2 = type2.GetMethod("Invoke", null); + var invoke1 = type1.GetMethod("Invoke"u8, null); + var invoke2 = type2.GetMethod("Invoke"u8, null); if (invoke1 == null) return false; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs index 82361007da2698..f8e163368d1a34 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs @@ -176,7 +176,7 @@ public override IEnumerable GetVirtualMethods() } // TODO: Substitutions, generics, modopts, ... - public override MethodDesc GetMethod(string name, MethodSignature signature, Instantiation substitution) + public override MethodDesc GetMethod(ReadOnlySpan name, MethodSignature signature, Instantiation substitution) { MethodDesc typicalMethodDef = _typeDef.GetMethod(name, signature, substitution); if (typicalMethodDef == null) @@ -184,7 +184,7 @@ public override MethodDesc GetMethod(string name, MethodSignature signature, Ins return _typeDef.Context.GetMethodForInstantiatedType(typicalMethodDef, this); } - public override MethodDesc GetMethodWithEquivalentSignature(string name, MethodSignature signature, Instantiation substitution) + public override MethodDesc GetMethodWithEquivalentSignature(ReadOnlySpan name, MethodSignature signature, Instantiation substitution) { MethodDesc typicalMethodDef = _typeDef.GetMethodWithEquivalentSignature(name, signature, substitution); if (typicalMethodDef == null) @@ -246,7 +246,7 @@ public override IEnumerable GetFields() } // TODO: Substitutions, generics, modopts, ... - public override FieldDesc GetField(string name) + public override FieldDesc GetField(ReadOnlySpan name) { FieldDesc fieldDef = _typeDef.GetField(name); if (fieldDef == null) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs index 0ce79bc35e036b..0bff0637dec62e 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs @@ -520,7 +520,7 @@ public virtual IEnumerable GetVirtualMethods() /// If signature is not specified and there are multiple matches, the first one /// is returned. Returns null if method not found. /// - public MethodDesc GetMethod(string name, MethodSignature signature) + public MethodDesc GetMethod(ReadOnlySpan name, MethodSignature signature) { return GetMethod(name, signature, default(Instantiation)); } @@ -532,11 +532,11 @@ public MethodDesc GetMethod(string name, MethodSignature signature) /// is returned. If substitution is not null, then substitution will be applied to /// possible target methods before signature comparison. Returns null if method not found. /// - public virtual MethodDesc GetMethod(string name, MethodSignature signature, Instantiation substitution) + public virtual MethodDesc GetMethod(ReadOnlySpan name, MethodSignature signature, Instantiation substitution) { foreach (var method in GetMethods()) { - if (method.GetName() == name) + if (method.U8Name.SequenceEqual(name)) { if (signature == null || signature.Equals(method.Signature.ApplySubstitution(substitution))) return method; @@ -545,11 +545,11 @@ public virtual MethodDesc GetMethod(string name, MethodSignature signature, Inst return null; } - public virtual MethodDesc GetMethodWithEquivalentSignature(string name, MethodSignature signature, Instantiation substitution) + public virtual MethodDesc GetMethodWithEquivalentSignature(ReadOnlySpan name, MethodSignature signature, Instantiation substitution) { foreach (var method in GetMethods()) { - if (method.GetName() == name) + if (method.U8Name.SequenceEqual(name)) { if (signature == null || signature.EquivalentTo(method.Signature.ApplySubstitution(substitution))) return method; @@ -589,11 +589,11 @@ public virtual IEnumerable GetFields() /// // TODO: Substitutions, generics, modopts, ... // TODO: field signature - public virtual FieldDesc GetField(string name) + public virtual FieldDesc GetField(ReadOnlySpan name) { foreach (var field in GetFields()) { - if (field.GetName() == name) + if (field.U8Name.SequenceEqual(name)) return field; } return null; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs index 70fdf0d431bf6b..9e1818e5714bf8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs @@ -89,7 +89,7 @@ public static MethodDesc GetParameterlessConstructor(this TypeDesc type) { // TODO: Do we want check for specialname/rtspecialname? Maybe add another overload on GetMethod? var sig = new MethodSignature(0, 0, type.Context.GetWellKnownType(WellKnownType.Void), TypeDesc.EmptyTypes); - return type.GetMethod(".ctor", sig); + return type.GetMethod(".ctor"u8, sig); } public static bool HasExplicitOrImplicitDefaultConstructor(this TypeDesc type) diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.cs index 881b1500dfe482..c85861b5916818 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaAssembly.cs @@ -62,12 +62,11 @@ public AssemblyNameInfo GetName() return _assemblyName; } - public unsafe ReadOnlySpan Name + public ReadOnlySpan Name { get { - BlobReader blob = MetadataReader.GetBlobReader(_assemblyDefinition.Name); - return new ReadOnlySpan(blob.StartPointer, blob.Length); + return MetadataReader.GetStringBytes(_assemblyDefinition.Name); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs index c7995c0b402405..8409d3d628dfec 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs @@ -278,13 +278,12 @@ public override string Name } } - public override unsafe ReadOnlySpan U8Name + public override ReadOnlySpan U8Name { get { - var metadataReader = MetadataReader; - var blob = metadataReader.GetBlobReader(metadataReader.GetFieldDefinition(_handle).Name); - return new ReadOnlySpan(blob.StartPointer, blob.Length); + MetadataReader reader = MetadataReader; + return reader.GetStringBytes(reader.GetFieldDefinition(_handle).Name); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs index 11f8ba66ebac90..904777ec988c66 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs @@ -62,13 +62,12 @@ public override string Name } } - public override unsafe ReadOnlySpan U8Name + public override ReadOnlySpan U8Name { get { MetadataReader reader = _module.MetadataReader; - BlobReader blob = reader.GetBlobReader(reader.GetGenericParameter(_handle).Name); - return new ReadOnlySpan(blob.StartPointer, blob.Length); + return reader.GetStringBytes(reader.GetGenericParameter(_handle).Name); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index 95b374ad5b38f6..64b6fb005f0620 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -403,13 +403,12 @@ public override string Name } } - public override unsafe ReadOnlySpan U8Name + public override ReadOnlySpan U8Name { get { var metadataReader = MetadataReader; - var blob = metadataReader.GetBlobReader(metadataReader.GetMethodDefinition(_handle).Name); - return new ReadOnlySpan(blob.StartPointer, blob.Length); + return metadataReader.GetStringBytes(metadataReader.GetMethodDefinition(_handle).Name); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs index cd87728b53e852..f32e9a871f2ca8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs @@ -506,7 +506,7 @@ private object ResolveMemberReference(MemberReferenceHandle handle) EcmaSignatureParser parser = new EcmaSignatureParser(this, signatureReader, NotFoundBehavior.ReturnResolutionFailure); - string name = _metadataReader.GetString(memberReference.Name); + ReadOnlySpan name = _metadataReader.GetStringBytes(memberReference.Name); if (parser.IsFieldSignature) { @@ -514,7 +514,7 @@ private object ResolveMemberReference(MemberReferenceHandle handle) if (field != null) return field; - return ResolutionFailure.GetMissingFieldFailure(parentTypeDesc, name); + return ResolutionFailure.GetMissingFieldFailure(parentTypeDesc, System.Text.Encoding.UTF8.GetString(name.ToArray())); } else { @@ -566,7 +566,7 @@ private object ResolveMemberReference(MemberReferenceHandle handle) typeDescToInspect = baseType; } while (typeDescToInspect != null); - return ResolutionFailure.GetMissingMethodFailure(parentTypeDesc, name, sig); + return ResolutionFailure.GetMissingMethodFailure(parentTypeDesc, System.Text.Encoding.UTF8.GetString(name.ToArray()), sig); } } else if (parent is MethodDesc) diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs index 883d91e8685d9f..1fc391456736f6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs @@ -40,13 +40,7 @@ public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlyS _ => default }; - BlobReader foundDeclNameReader = metadataReader.GetBlobReader(foundDeclNameHandle); - ReadOnlySpan foundDeclName; - unsafe - { - foundDeclName = new ReadOnlySpan(foundDeclNameReader.StartPointer, foundDeclNameReader.Length); - } - + ReadOnlySpan foundDeclName = metadataReader.GetStringBytes(foundDeclNameHandle); if (declName.SequenceEqual(foundDeclName)) { MethodImplRecord newRecord = new MethodImplRecord( diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs index 0c8eb573dc784c..ecac3c0c069467 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs @@ -284,12 +284,11 @@ public override string Name } } - public override unsafe ReadOnlySpan U8Name + public override ReadOnlySpan U8Name { get { - BlobReader blob = MetadataReader.GetBlobReader(_typeDefinition.Name); - return new ReadOnlySpan(blob.StartPointer, blob.Length); + return MetadataReader.GetStringBytes(_typeDefinition.Name); } } @@ -310,12 +309,11 @@ public override string Namespace } } - public override unsafe ReadOnlySpan U8Namespace + public override ReadOnlySpan U8Namespace { get { - BlobReader blob = MetadataReader.GetBlobReader(_typeDefinition.Namespace); - return new ReadOnlySpan(blob.StartPointer, blob.Length); + return MetadataReader.GetStringBytes(_typeDefinition.Namespace); } } @@ -338,14 +336,13 @@ public override IEnumerable GetVirtualMethods() } } - public override MethodDesc GetMethod(string name, MethodSignature signature, Instantiation substitution) + public override MethodDesc GetMethod(ReadOnlySpan name, MethodSignature signature, Instantiation substitution) { var metadataReader = this.MetadataReader; - var stringComparer = metadataReader.StringComparer; foreach (var handle in _typeDefinition.GetMethods()) { - if (stringComparer.Equals(metadataReader.GetMethodDefinition(handle).Name, name)) + if (metadataReader.StringEquals(metadataReader.GetMethodDefinition(handle).Name, name)) { var method = _module.GetMethod(handle, this); if (signature == null || signature.Equals(method.Signature.ApplySubstitution(substitution))) @@ -356,14 +353,13 @@ public override MethodDesc GetMethod(string name, MethodSignature signature, Ins return null; } - public override MethodDesc GetMethodWithEquivalentSignature(string name, MethodSignature signature, Instantiation substitution) + public override MethodDesc GetMethodWithEquivalentSignature(ReadOnlySpan name, MethodSignature signature, Instantiation substitution) { var metadataReader = this.MetadataReader; - var stringComparer = metadataReader.StringComparer; foreach (var handle in _typeDefinition.GetMethods()) { - if (stringComparer.Equals(metadataReader.GetMethodDefinition(handle).Name, name)) + if (metadataReader.StringEquals(metadataReader.GetMethodDefinition(handle).Name, name)) { var method = _module.GetMethod(handle, this); if (signature == null || signature.EquivalentTo(method.Signature.ApplySubstitution(substitution))) @@ -433,7 +429,7 @@ public override MethodDesc GetFinalizer() return null; TypeDesc objectType = Context.GetWellKnownType(WellKnownType.Object); - MethodDesc decl = objectType.GetMethod("Finalize", null); + MethodDesc decl = objectType.GetMethod("Finalize"u8, null); if (decl != null) { @@ -483,14 +479,13 @@ public override TypeDesc UnderlyingType } } - public override FieldDesc GetField(string name) + public override FieldDesc GetField(ReadOnlySpan name) { var metadataReader = this.MetadataReader; - var stringComparer = metadataReader.StringComparer; foreach (var handle in _typeDefinition.GetFields()) { - if (stringComparer.Equals(metadataReader.GetFieldDefinition(handle).Name, name)) + if (metadataReader.StringEquals(metadataReader.GetFieldDefinition(handle).Name, name)) { var field = _module.GetField(handle, this); return field; diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs index 54e58b3b696990..a7de9a8374b04a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using System.Reflection; using System.Reflection.Metadata; @@ -310,5 +311,18 @@ public static bool IsPublic(this MethodAttributes flags) { return reader.GetBlobReader(reader.GetMethodDefinition(handle).Name).CurrentPointer; } + + public static unsafe ReadOnlySpan GetStringBytes(this MetadataReader reader, StringHandle handle) + { + BlobReader blobReader = reader.GetBlobReader(handle); + return new ReadOnlySpan(blobReader.CurrentPointer, blobReader.Length); + } + + public static unsafe bool StringEquals(this MetadataReader reader, StringHandle handle, ReadOnlySpan otherString) + { + BlobReader blobReader = reader.GetBlobReader(handle); + ReadOnlySpan thisString = new ReadOnlySpan(blobReader.CurrentPointer, blobReader.Length); + return thisString.SequenceEqual(otherString); + } } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/DelegateInfo.cs b/src/coreclr/tools/Common/TypeSystem/IL/DelegateInfo.cs index 2c06b0f688e494..46f09d338c25d7 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/DelegateInfo.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/DelegateInfo.cs @@ -79,7 +79,7 @@ public MethodDesc InvokeMethod { get { - _invokeMethod ??= _delegateType.GetKnownMethod("Invoke", null); + _invokeMethod ??= _delegateType.GetKnownMethod("Invoke"u8, null); return _invokeMethod; } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs b/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs index a02c9bbf9da982..7c3147ec4452d6 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs @@ -26,20 +26,20 @@ public static MetadataType GetOptionalHelperType(this TypeSystemContext context, return helperType; } - public static MethodDesc GetHelperEntryPoint(this TypeSystemContext context, string typeName, string methodName) + public static MethodDesc GetHelperEntryPoint(this TypeSystemContext context, string typeName, ReadOnlySpan methodName) { MetadataType helperType = context.GetHelperType(typeName); MethodDesc helperMethod = helperType.GetKnownMethod(methodName, null); return helperMethod; } - public static MethodDesc GetCoreLibEntryPoint(this TypeSystemContext context, string namespaceName, string typeName, string methodName, MethodSignature signature) + public static MethodDesc GetCoreLibEntryPoint(this TypeSystemContext context, string namespaceName, string typeName, ReadOnlySpan methodName, MethodSignature signature) { MetadataType owningType = context.SystemModule.GetKnownType(namespaceName, typeName); return owningType.GetKnownMethod(methodName, signature); } - public static MethodDesc GetOptionalHelperEntryPoint(this TypeSystemContext context, string typeName, string methodName) + public static MethodDesc GetOptionalHelperEntryPoint(this TypeSystemContext context, string typeName, ReadOnlySpan methodName) { MetadataType helperType = context.GetOptionalHelperType(typeName); MethodDesc helperMethod = helperType?.GetMethod(methodName, null); @@ -70,12 +70,12 @@ public static void EmitCallThrowHelper(this ILCodeStream codeStream, ILEmitter e /// Retrieves a method on that is well known to the compiler. /// Throws an exception if the method doesn't exist. /// - public static MethodDesc GetKnownMethod(this TypeDesc type, string name, MethodSignature signature) + public static MethodDesc GetKnownMethod(this TypeDesc type, ReadOnlySpan name, MethodSignature signature) { MethodDesc method = type.GetMethod(name, signature); if (method == null) { - throw new InvalidOperationException(string.Format("Expected method '{0}' not found on type '{1}'", name, type)); + throw new InvalidOperationException(string.Format("Expected method '{0}' not found on type '{1}'", System.Text.Encoding.UTF8.GetString(name), type)); } return method; @@ -85,12 +85,12 @@ public static MethodDesc GetKnownMethod(this TypeDesc type, string name, MethodS /// Retrieves a field on that is well known to the compiler. /// Throws an exception if the field doesn't exist. /// - public static FieldDesc GetKnownField(this TypeDesc type, string name) + public static FieldDesc GetKnownField(this TypeDesc type, ReadOnlySpan name) { FieldDesc field = type.GetField(name); if (field == null) { - throw new InvalidOperationException(string.Format("Expected field '{0}' not found on type '{1}'", name, type)); + throw new InvalidOperationException(string.Format("Expected field '{0}' not found on type '{1}'", System.Text.Encoding.UTF8.GetString(name), type)); } return field; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs index ae2d4b926c3002..59b2b69855849a 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs @@ -163,7 +163,7 @@ private static MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc metho TypeDesc underlyingType = elementType.UnderlyingType; TypeDesc returnType = method.Context.GetWellKnownType(WellKnownType.Int32); - MethodDesc underlyingCompareToMethod = underlyingType.GetKnownMethod("CompareTo", + MethodDesc underlyingCompareToMethod = underlyingType.GetKnownMethod("CompareTo"u8, new MethodSignature( MethodSignatureFlags.None, genericParameterCount: 0, @@ -264,14 +264,14 @@ static MethodDesc GetMethodToCall(TypeDesc elementType) MetadataType helperType = context.SystemModule.GetKnownType("Internal.IntrinsicSupport", "EqualityComparerHelpers"); if (elementType.IsEnum) - return helperType.GetKnownMethod("EnumOnlyEquals", null) + return helperType.GetKnownMethod("EnumOnlyEquals"u8, null) .MakeInstantiatedMethod(elementType); if (elementType.IsNullable) { bool? nullableOfEquatable = ComparerIntrinsics.ImplementsIEquatable(elementType.Instantiation[0]); if (nullableOfEquatable.HasValue && nullableOfEquatable.Value) - return helperType.GetKnownMethod("StructOnlyEqualsNullable", null) + return helperType.GetKnownMethod("StructOnlyEqualsNullable"u8, null) .MakeInstantiatedMethod(elementType.Instantiation[0]); return null; // Fallback to default implementation based on EqualityComparer } @@ -279,7 +279,7 @@ static MethodDesc GetMethodToCall(TypeDesc elementType) bool? equatable = ComparerIntrinsics.ImplementsIEquatable(elementType); if (!equatable.HasValue) return null; - return helperType.GetKnownMethod(equatable.Value ? "StructOnlyEqualsIEquatable" : "StructOnlyNormalEquals", null) + return helperType.GetKnownMethod(equatable.Value ? "StructOnlyEqualsIEquatable"u8 : "StructOnlyNormalEquals"u8, null) .MakeInstantiatedMethod(elementType); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs index 69aec3abb713b6..20ca143c9c425c 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs @@ -31,7 +31,7 @@ private ArrayMethodILEmitter(ArrayMethod method) // This helper field is needed to generate proper GC tracking. There is no direct way // to create interior pointer. - _helperFieldToken = _emitter.NewToken(_method.Context.GetWellKnownType(WellKnownType.Object).GetKnownField("m_pEEType")); + _helperFieldToken = _emitter.NewToken(_method.Context.GetWellKnownType(WellKnownType.Object).GetKnownField("m_pEEType"u8)); } private void EmitLoadInteriorAddress(ILCodeStream codeStream, int offset) @@ -94,7 +94,7 @@ private void EmitILForAccessor() if (_method.Kind == ArrayMethodKind.Set) { MethodDesc checkArrayStore = - context.SystemModule.GetKnownType("System.Runtime", "RuntimeImports").GetKnownMethod("RhCheckArrayStore", null); + context.SystemModule.GetKnownType("System.Runtime", "RuntimeImports").GetKnownMethod("RhCheckArrayStore"u8, null); codeStream.EmitLdArg(0); codeStream.EmitLdArg(_rank + argStartOffset); @@ -119,14 +119,14 @@ private void EmitILForAccessor() // MethodTable* actualElementType = this.m_pEEType->RelatedParameterType; // ArrayElementType codeStream.EmitLdArg(0); - codeStream.Emit(ILOpcode.ldfld, _emitter.NewToken(objectType.GetKnownField("m_pEEType"))); + codeStream.Emit(ILOpcode.ldfld, _emitter.NewToken(objectType.GetKnownField("m_pEEType"u8))); codeStream.Emit(ILOpcode.call, - _emitter.NewToken(eetypeType.GetKnownMethod("get_RelatedParameterType", null))); + _emitter.NewToken(eetypeType.GetKnownMethod("get_RelatedParameterType"u8, null))); // MethodTable* expectedElementType = hiddenArg->RelatedParameterType; // ArrayElementType codeStream.EmitLdArg(hiddenArg); codeStream.Emit(ILOpcode.call, - _emitter.NewToken(eetypeType.GetKnownMethod("get_RelatedParameterType", null))); + _emitter.NewToken(eetypeType.GetKnownMethod("get_RelatedParameterType"u8, null))); // if (expectedElementType != actualElementType) // ThrowHelpers.ThrowArrayTypeMismatchException(); @@ -146,9 +146,9 @@ private void EmitILForAccessor() TypeDesc eetypeType = context.SystemModule.GetKnownType("Internal.Runtime", "MethodTable"); codeStream.EmitLdArg(0); - codeStream.Emit(ILOpcode.ldfld, _emitter.NewToken(objectType.GetKnownField("m_pEEType"))); + codeStream.Emit(ILOpcode.ldfld, _emitter.NewToken(objectType.GetKnownField("m_pEEType"u8))); codeStream.Emit(ILOpcode.call, - _emitter.NewToken(eetypeType.GetKnownMethod("get_IsSzArray", null))); + _emitter.NewToken(eetypeType.GetKnownMethod("get_IsSzArray"u8, null))); ILCodeLabel notSzArrayLabel = _emitter.NewCodeLabel(); codeStream.Emit(ILOpcode.brfalse, notSzArrayLabel); @@ -238,13 +238,13 @@ private void EmitILForAccessor() codeStream.EmitLabel(rangeExceptionLabel); // Assumes that there is one "int" pushed on the stack codeStream.Emit(ILOpcode.pop); - MethodDesc throwHelper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowIndexOutOfRangeException"); + MethodDesc throwHelper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowIndexOutOfRangeException"u8); codeStream.EmitCallThrowHelper(_emitter, throwHelper); if (typeMismatchExceptionLabel != null) { codeStream.EmitLabel(typeMismatchExceptionLabel); - codeStream.EmitCallThrowHelper(_emitter, context.GetHelperEntryPoint("ThrowHelpers", "ThrowArrayTypeMismatchException")); + codeStream.EmitCallThrowHelper(_emitter, context.GetHelperEntryPoint("ThrowHelpers", "ThrowArrayTypeMismatchException"u8)); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs index 870e46ae36612e..639a333b87621c 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs @@ -76,7 +76,7 @@ public override MethodIL EmitIL() ILEmitter emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - MethodDesc classlibHelper = Context.GetHelperEntryPoint("ReflectionHelpers", "GetExecutingAssembly"); + MethodDesc classlibHelper = Context.GetHelperEntryPoint("ReflectionHelpers", "GetExecutingAssembly"u8); // Use the global module type as "a type from the assembly that has metadata" // Our reflection policy always makes sure this has metadata. diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs index 215f73bfaf8136..f9000fddf952e3 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs @@ -64,7 +64,7 @@ public DelegateMarshallingMethodThunk(MetadataType delegateType, TypeDesc owning { _owningType = owningType; _delegateType = delegateType; - _invokeMethod = delegateType.GetMethod("Invoke", null); + _invokeMethod = delegateType.GetMethod("Invoke"u8, null); _interopStateManager = interopStateManager; Kind = kind; } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs index 5b4ca0026ffe76..f0640001999c39 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs @@ -22,7 +22,7 @@ public static MethodIL EmitIL(MethodDesc method) // BeginInvoke and EndInvoke are not supported on .NET Core ILEmitter emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - MethodDesc notSupportedExceptionHelper = method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowPlatformNotSupportedException"); + MethodDesc notSupportedExceptionHelper = method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowPlatformNotSupportedException"u8); codeStream.EmitCallThrowHelper(emit, notSupportedExceptionHelper); return emit.Link(method); } @@ -37,7 +37,7 @@ public static MethodIL EmitIL(MethodDesc method) // but it remains to be proven that this is an actual customer scenario. ILEmitter emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - MethodDesc notSupportedExceptionHelper = method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowPlatformNotSupportedException"); + MethodDesc notSupportedExceptionHelper = method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowPlatformNotSupportedException"u8); codeStream.EmitCallThrowHelper(emit, notSupportedExceptionHelper); return emit.Link(method); } @@ -48,8 +48,8 @@ public static MethodIL EmitIL(MethodDesc method) ILEmitter emit = new ILEmitter(); TypeDesc delegateType = context.GetWellKnownType(WellKnownType.MulticastDelegate).BaseType; - FieldDesc firstParameterField = delegateType.GetKnownField("_firstParameter"); - FieldDesc functionPointerField = delegateType.GetKnownField("_functionPointer"); + FieldDesc firstParameterField = delegateType.GetKnownField("_firstParameter"u8); + FieldDesc functionPointerField = delegateType.GetKnownField("_functionPointer"u8); ILCodeStream codeStream = emit.NewCodeStream(); // Store the function pointer into local variable to avoid unnecessary register usage by JIT diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs index 4d90e37a6bf5b7..9b0e456aed1690 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs @@ -69,7 +69,7 @@ protected FieldDesc ExtraFunctionPointerOrDataField { get { - return SystemDelegateType.GetKnownField("_extraFunctionPointerOrData"); + return SystemDelegateType.GetKnownField("_extraFunctionPointerOrData"u8); } } @@ -77,7 +77,7 @@ protected FieldDesc HelperObjectField { get { - return SystemDelegateType.GetKnownField("_helperObject"); + return SystemDelegateType.GetKnownField("_helperObject"u8); } } @@ -166,7 +166,7 @@ public override MethodIL EmitIL(MethodDesc specializedMethod) { var emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - codeStream.EmitCallThrowHelper(emit, Context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedException")); + codeStream.EmitCallThrowHelper(emit, Context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedException"u8)); return emit.Link(specializedMethod); } @@ -220,7 +220,7 @@ public override MethodIL EmitIL() } } - codeStream.Emit(ILOpcode.call, emitter.NewToken(SystemDelegateType.GetKnownMethod("GetActualTargetFunctionPointer", null))); + codeStream.Emit(ILOpcode.call, emitter.NewToken(SystemDelegateType.GetKnownMethod("GetActualTargetFunctionPointer"u8, null))); MethodSignature targetSignature = new MethodSignature(0, 0, Signature.ReturnType, parameters); codeStream.Emit(ILOpcode.calli, emitter.NewToken(targetSignature)); @@ -390,7 +390,7 @@ public override MethodIL EmitIL() codeStream.EmitLdLoc(delegateArrayLocal); codeStream.EmitLdLoc(iteratorLocal); codeStream.Emit(ILOpcode.ldelema, emitter.NewToken(delegateWrapperType)); - codeStream.Emit(ILOpcode.ldfld, emitter.NewToken(delegateWrapperType.GetKnownField("Value"))); + codeStream.Emit(ILOpcode.ldfld, emitter.NewToken(delegateWrapperType.GetKnownField("Value"u8))); // Call the delegate // delegateArrayLocal[iteratorLocal].Value(...) @@ -533,7 +533,7 @@ public override MethodIL EmitIL(MethodDesc specializedMethod) { var emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - codeStream.EmitCallThrowHelper(emit, Context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedException")); + codeStream.EmitCallThrowHelper(emit, Context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedException"u8)); return emit.Link(specializedMethod); } @@ -603,7 +603,7 @@ public override MethodIL EmitIL() } else { - MethodDesc emptyObjectArrayMethod = Context.GetHelperEntryPoint("DelegateHelpers", "GetEmptyObjectArray"); + MethodDesc emptyObjectArrayMethod = Context.GetHelperEntryPoint("DelegateHelpers", "GetEmptyObjectArray"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(emptyObjectArrayMethod)); codeStream.EmitStLoc(argsLocal); } @@ -626,7 +626,7 @@ public override MethodIL EmitIL() codeStream.EmitLdLoc(argsLocal); - MethodDesc invokeMethod = instantiatedFunc.GetKnownMethod("Invoke", null); + MethodDesc invokeMethod = instantiatedFunc.GetKnownMethod("Invoke"u8, null); codeStream.Emit(ILOpcode.callvirt, emitter.NewToken(invokeMethod)); ILLocalVariable retLocal = (ILLocalVariable)(-1); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs index ff0ed65eca13a9..63e5226a4fb98a 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs @@ -145,7 +145,7 @@ public override MethodIL EmitIL() if (_targetSignature.Length != 0) { var fieldByReferenceValueToken = emitter.NewToken( - Context.SystemModule.GetKnownType("System", "ByReference").GetKnownField("Value")); + Context.SystemModule.GetKnownType("System", "ByReference").GetKnownField("Value"u8)); for (int i = 0; i < _targetSignature.Length; i++) { codeStream.EmitLdArg(3); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs index 5466ab78382d4f..ac499460093fe7 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs @@ -29,7 +29,7 @@ private MethodDesc ObjectGetHashCodeMethod { get { - return Context.GetWellKnownType(WellKnownType.Object).GetKnownMethod("GetHashCode", null); + return Context.GetWellKnownType(WellKnownType.Object).GetKnownMethod("GetHashCode"u8, null); } } @@ -128,7 +128,7 @@ private MethodDesc ObjectEqualsMethod { get { - return Context.GetWellKnownType(WellKnownType.Object).GetKnownMethod("Equals", null); + return Context.GetWellKnownType(WellKnownType.Object).GetKnownMethod("Equals"u8, null); } } @@ -213,7 +213,7 @@ public override MethodIL EmitIL() // return ({underlyingtype})this == ({underlyingtype})obj; // PREFER: ILOpcode.unbox, but the codegen for that is pretty bad - codeStream.Emit(ILOpcode.ldflda, emitter.NewToken(Context.GetWellKnownType(WellKnownType.Object).GetKnownField("m_pEEType"))); + codeStream.Emit(ILOpcode.ldflda, emitter.NewToken(Context.GetWellKnownType(WellKnownType.Object).GetKnownField("m_pEEType"u8))); codeStream.EmitLdc(Context.Target.PointerSize); codeStream.Emit(ILOpcode.add); codeStream.EmitLdInd(owningTypeAsOpen); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs index 279fdade1e8da7..7cb97d9a4f22a7 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs @@ -119,7 +119,7 @@ public override MethodIL EmitIL() .GetPInvokeDelegateWrapperMethod(PInvokeDelegateWrapperMethodKind.Invoke))); codeStream.Emit(ILOpcode.newobj, emitter.NewToken( - _delegateType.GetMethod(".ctor", + _delegateType.GetMethod(".ctor"u8, new MethodSignature(MethodSignatureFlags.None, genericParameterCount: 0, returnType: Context.GetWellKnownType(WellKnownType.Void), diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs index 47205e908d2350..bc82ea1668fcc0 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs @@ -56,7 +56,7 @@ public static MethodIL EmitIL( if (ceArgType is not null) { - MethodDesc compareExchangeNonGeneric = method.OwningType.GetKnownMethod("CompareExchange", + MethodDesc compareExchangeNonGeneric = method.OwningType.GetKnownMethod("CompareExchange"u8, new MethodSignature( MethodSignatureFlags.Static, genericParameterCount: 0, diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs index a0682ec3ee5aba..fd28193a43a499 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs @@ -81,14 +81,14 @@ public override MethodIL EmitIL() codeStream.Emit(ILOpcode.ldtoken, emit.NewToken(Method)); - string helperName; + ReadOnlySpan helperName; if (Method.OwningType.HasInstantiation) { codeStream.Emit(ILOpcode.ldtoken, emit.NewToken(Method.OwningType)); - helperName = "GetCurrentMethodGeneric"; + helperName = "GetCurrentMethodGeneric"u8; } else - helperName = "GetCurrentMethodNonGeneric"; + helperName = "GetCurrentMethodNonGeneric"u8; MethodDesc classlibHelper = Context.GetHelperEntryPoint("ReflectionHelpers", helperName); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs index 4621ebc0e465e1..56135dabfa27b3 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs @@ -174,7 +174,7 @@ private void EmitDelegateCall(DelegateMarshallingMethodThunk delegateMethod, PIn fnptrLoadStream.Emit(ILOpcode.call, emitter.NewToken( delegateMethod.Context.GetHelperType("InteropHelpers").GetKnownMethod( - "GetCurrentCalleeOpenStaticDelegateFunctionPointer", null))); + "GetCurrentCalleeOpenStaticDelegateFunctionPointer"u8, null))); ILLocalVariable vDelegateStub = emitter.NewLocal( delegateMethod.Context.GetWellKnownType(WellKnownType.IntPtr)); @@ -192,7 +192,7 @@ private void EmitDelegateCall(DelegateMarshallingMethodThunk delegateMethod, PIn // MethodDesc instantiatedHelper = delegateMethod.Context.GetInstantiatedMethod( delegateMethod.Context.GetHelperType("InteropHelpers") - .GetKnownMethod("GetCurrentCalleeDelegate", null), + .GetKnownMethod("GetCurrentCalleeDelegate"u8, null), new Instantiation((delegateMethod.DelegateType))); fnptrLoadStream.Emit(ILOpcode.call, emitter.NewToken(instantiatedHelper)); @@ -200,7 +200,7 @@ private void EmitDelegateCall(DelegateMarshallingMethodThunk delegateMethod, PIn ILLocalVariable vDelegateStub = emitter.NewLocal(delegateMethod.DelegateType); fnptrLoadStream.EmitStLoc(vDelegateStub); marshallingCodeStream.EmitLdLoc(vDelegateStub); - MethodDesc invokeMethod = delegateMethod.DelegateType.GetKnownMethod("Invoke", null); + MethodDesc invokeMethod = delegateMethod.DelegateType.GetKnownMethod("Invoke"u8, null); callsiteSetupCodeStream.Emit(ILOpcode.callvirt, emitter.NewToken(invokeMethod)); } else if (delegateMethod.Kind == DelegateMarshallingMethodThunkKind.ForwardNativeFunctionWrapper) @@ -209,7 +209,7 @@ private void EmitDelegateCall(DelegateMarshallingMethodThunk delegateMethod, PIn if (_flags.SetLastError) { callsiteSetupCodeStream.Emit(ILOpcode.call, emitter.NewToken( - InteropTypes.GetPInvokeMarshal(context).GetKnownMethod("ClearLastError", null))); + InteropTypes.GetPInvokeMarshal(context).GetKnownMethod("ClearLastError"u8, null))); } // @@ -218,7 +218,7 @@ private void EmitDelegateCall(DelegateMarshallingMethodThunk delegateMethod, PIn fnptrLoadStream.EmitLdArg(0); fnptrLoadStream.Emit(ILOpcode.call, emitter.NewToken(InteropTypes .GetNativeFunctionPointerWrapper(context) - .GetMethod("get_NativeFunctionPointer", null))); + .GetMethod("get_NativeFunctionPointer"u8, null))); var fnPtr = emitter.NewLocal( context.GetWellKnownType(WellKnownType.IntPtr)); @@ -249,7 +249,7 @@ private void EmitDelegateCall(DelegateMarshallingMethodThunk delegateMethod, PIn { callsiteSetupCodeStream.Emit(ILOpcode.call, emitter.NewToken( InteropTypes.GetPInvokeMarshal(context) - .GetKnownMethod("SaveLastError", null))); + .GetKnownMethod("SaveLastError"u8, null))); } } else @@ -280,7 +280,7 @@ private void EmitPInvokeCall(PInvokeILCodeStreams ilCodeStreams) throw new NotSupportedException(); } callsiteSetupCodeStream.Emit(ILOpcode.call, emitter.NewToken( - InteropTypes.GetPInvokeMarshal(context).GetKnownMethod("ClearLastError", null))); + InteropTypes.GetPInvokeMarshal(context).GetKnownMethod("ClearLastError"u8, null))); } for (int i = 1; i < _marshallers.Length; i++) @@ -309,7 +309,7 @@ private void EmitPInvokeCall(PInvokeILCodeStreams ilCodeStreams) fnptrLoadStream.Emit(ILOpcode.ldsflda, emitter.NewToken(lazyDispatchCell)); fnptrLoadStream.Emit(ILOpcode.call, emitter.NewToken(lazyHelperType - .GetKnownMethod("ResolvePInvoke", null))); + .GetKnownMethod("ResolvePInvoke"u8, null))); ILLocalVariable vNativeFunctionPointer = emitter.NewLocal(context .GetWellKnownType(WellKnownType.IntPtr)); @@ -334,7 +334,7 @@ private void EmitPInvokeCall(PInvokeILCodeStreams ilCodeStreams) { callsiteSetupCodeStream.Emit(ILOpcode.call, emitter.NewToken( InteropTypes.GetMarshal(context) - .GetKnownMethod("ThrowExceptionForHR", null))); + .GetKnownMethod("ThrowExceptionForHR"u8, null))); } // if the SetLastError flag is set in DllImport, call the PInvokeMarshal.SaveLastError @@ -343,14 +343,14 @@ private void EmitPInvokeCall(PInvokeILCodeStreams ilCodeStreams) { callsiteSetupCodeStream.Emit(ILOpcode.call, emitter.NewToken( InteropTypes.GetPInvokeMarshal(context) - .GetKnownMethod("SaveLastError", null))); + .GetKnownMethod("SaveLastError"u8, null))); } if (MarshalHelpers.ShouldCheckForPendingException(context.Target, _pInvokeMetadata)) { MetadataType lazyHelperType = context.SystemModule.GetKnownType("System.Runtime.InteropServices.ObjectiveC", "ObjectiveCMarshal"); callsiteSetupCodeStream.Emit(ILOpcode.call, emitter.NewToken(lazyHelperType - .GetKnownMethod("ThrowPendingExceptionObject", null))); + .GetKnownMethod("ThrowPendingExceptionObject"u8, null))); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index 1a164e8a723e10..b09135ccf2bbb4 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -69,7 +69,7 @@ public static MethodIL EmitIL(MethodDesc method) if (equatable.HasValue && !equatable.Value) { // Value type that can use memcmp and that doesn't override object.Equals or implement IEquatable.Equals. - MethodDesc objectEquals = mdType.Context.GetWellKnownType(WellKnownType.Object).GetMethod("Equals", null); + MethodDesc objectEquals = mdType.Context.GetWellKnownType(WellKnownType.Object).GetMethod("Equals"u8, null); result = mdType.FindVirtualFunctionTargetMethodOnObjectType(objectEquals).OwningType != mdType && ComparerIntrinsics.CanCompareValueTypeBits(mdType, objectEquals); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs index 14fa1a818224dc..1624b4f73171d9 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs @@ -23,8 +23,8 @@ public static MethodIL EmitIL(MethodDesc method) return null; TypeDesc streamClass = method.OwningType; - MethodDesc beginMethod = streamClass.GetMethod(isRead ? "BeginRead" : "BeginWrite", null); - MethodDesc endMethod = streamClass.GetMethod(isRead ? "EndRead" : "EndWrite", null); + MethodDesc beginMethod = streamClass.GetMethod(isRead ? "BeginRead"u8 : "BeginWrite"u8, null); + MethodDesc endMethod = streamClass.GetMethod(isRead ? "EndRead"u8 : "EndWrite"u8, null); ILEmitter emitter = new ILEmitter(); ILCodeStream codestream = emitter.NewCodeStream(); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs index 0a577019220b64..6c6f5f45f6f66c 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs @@ -178,12 +178,12 @@ protected override TypeGetTypeMethodThunk CreateValueFromKey(Key key) // We only need 2 helpers to support this. Use the second parameter to pick the right one. - string helperName; + ReadOnlySpan helperName; MethodSignature signature = key.GetTypeOverload.Signature; if (signature.Length > 1 && signature[1].HasInstantiation) - helperName = "ExtensibleGetType"; + helperName = "ExtensibleGetType"u8; else - helperName = "GetType"; + helperName = "GetType"u8; MethodDesc helper = context.GetHelperEntryPoint("ReflectionHelpers", helperName); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeSystemThrowingILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeSystemThrowingILEmitter.cs index 912a0d498152a1..093e9914abc561 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeSystemThrowingILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeSystemThrowingILEmitter.cs @@ -29,24 +29,24 @@ public static MethodIL EmitIL(MethodDesc methodThatShouldThrow, TypeSystemExcept // There are two ThrowTypeLoadException helpers. Find the one which matches the number of // arguments "exception" was initialized with. // - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowTypeLoadException"); + helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowTypeLoadException"u8); if (helper.Signature.Length != exception.Arguments.Count + 1) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowTypeLoadExceptionWithArgument"); + helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowTypeLoadExceptionWithArgument"u8); } } else if (exceptionType == typeof(TypeSystemException.MissingFieldException)) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingFieldException"); + helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingFieldException"u8); } else if (exceptionType == typeof(TypeSystemException.MissingMethodException)) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingMethodException"); + helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingMethodException"u8); } else if (exceptionType == typeof(TypeSystemException.FileNotFoundException)) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowFileNotFoundException"); + helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowFileNotFoundException"u8); } else if (exceptionType == typeof(TypeSystemException.InvalidProgramException)) { @@ -55,20 +55,20 @@ public static MethodIL EmitIL(MethodDesc methodThatShouldThrow, TypeSystemExcept // arguments "exception" was initialized with. // - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramException"); + helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramException"u8); if (helper.Signature.Length != exception.Arguments.Count + 1) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramExceptionWithArgument"); + helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramExceptionWithArgument"u8); } } else if (exceptionType == typeof(TypeSystemException.BadImageFormatException)) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowBadImageFormatException"); + helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowBadImageFormatException"u8); } else if (exceptionType == typeof(TypeSystemException.MarshalDirectiveException)) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowMarshalDirectiveException"); + helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowMarshalDirectiveException"u8); } else { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs index bc429c266a1245..922643be0da383 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs @@ -80,12 +80,12 @@ private MethodIL EmitILCommon(MethodDesc contextMethod) if (_owningType.IsInlineArray) { var stream = emitter.NewCodeStream(); - MethodDesc thrower = Context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedInlineArrayEqualsGetHashCode"); + MethodDesc thrower = Context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedInlineArrayEqualsGetHashCode"u8); stream.EmitCallThrowHelper(emitter, thrower); return emitter.Link(this); } - if (_owningType.IsValueType && ComparerIntrinsics.CanCompareValueTypeBitsUntilOffset(_owningType, Context.GetWellKnownType(WellKnownType.Object).GetMethod("Equals", null), out int lastFieldEndOffset)) + if (_owningType.IsValueType && ComparerIntrinsics.CanCompareValueTypeBitsUntilOffset(_owningType, Context.GetWellKnownType(WellKnownType.Object).GetMethod("Equals"u8, null), out int lastFieldEndOffset)) { var stream = emitter.NewCodeStream(); stream.EmitLdc(-lastFieldEndOffset); @@ -94,12 +94,12 @@ private MethodIL EmitILCommon(MethodDesc contextMethod) } TypeDesc methodTableType = Context.SystemModule.GetKnownType("Internal.Runtime", "MethodTable"); - MethodDesc methodTableOfMethod = methodTableType.GetKnownMethod("Of", null); + MethodDesc methodTableOfMethod = methodTableType.GetKnownMethod("Of"u8, null); var owningType = (MetadataType)_owningType.InstantiateAsOpen(); ILToken rawDataToken = owningType.IsValueType ? default : - emitter.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices", "RawData").GetKnownField("Data")); + emitter.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices", "RawData").GetKnownField("Data"u8)); var switchStream = emitter.NewCodeStream(); var getFieldStream = emitter.NewCodeStream(); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs b/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs index cd51ba3d930c2e..af307307aadae4 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs @@ -812,20 +812,20 @@ private static MethodIL GenerateAccessorSpecificFailure(ref GenerationContext co if (result is SetTargetResult.Ambiguous) { codeStream.EmitLdc((int)ExceptionStringID.AmbiguousMatchUnsafeAccessor); - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowAmbiguousMatchException"); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowAmbiguousMatchException"u8); } else if (result is SetTargetResult.Invalid) { codeStream.EmitLdc((int)ExceptionStringID.InvalidProgramDefault); - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramException"); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramException"u8); } else if (result is SetTargetResult.NotSupported) { - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedException"); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedException"u8); } else if (result is SetTargetResult.MissingType) { - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowUnavailableType"); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowUnavailableType"u8); } else { @@ -834,12 +834,12 @@ private static MethodIL GenerateAccessorSpecificFailure(ref GenerationContext co if (context.Kind == UnsafeAccessorKind.Field || context.Kind == UnsafeAccessorKind.StaticField) { id = ExceptionStringID.MissingField; - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingFieldException"); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingFieldException"u8); } else { id = ExceptionStringID.MissingMethod; - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingMethodException"); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingMethodException"u8); } codeStream.EmitLdc((int)id); @@ -860,7 +860,7 @@ private static MethodIL GenerateAccessorBadImageFailure(MethodDesc method) ILCodeLabel label = emit.NewCodeLabel(); codeStream.EmitLabel(label); codeStream.EmitLdc((int)ExceptionStringID.BadImageFormatGeneric); - MethodDesc thrower = method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowBadImageFormatException"); + MethodDesc thrower = method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowBadImageFormatException"u8); codeStream.Emit(ILOpcode.call, emit.NewToken(thrower)); codeStream.Emit(ILOpcode.br, label); diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.Aot.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.Aot.cs index b5e9d32dff01ce..7a48a5d45c0610 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.Aot.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.Aot.cs @@ -123,7 +123,7 @@ public static MethodIL EmitExceptionBody(string message, MethodDesc method) TypeSystemContext context = method.Context; MethodSignature ctorSignature = new MethodSignature(0, 0, context.GetWellKnownType(WellKnownType.Void), new TypeDesc[] { context.GetWellKnownType(WellKnownType.String) }); - MethodDesc exceptionCtor = InteropTypes.GetMarshalDirectiveException(context).GetKnownMethod(".ctor", ctorSignature); + MethodDesc exceptionCtor = InteropTypes.GetMarshalDirectiveException(context).GetKnownMethod(".ctor"u8, ctorSignature); ILCodeStream codeStream = emitter.NewCodeStream(); codeStream.Emit(ILOpcode.ldstr, emitter.NewToken(message)); diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs index f1fc3547a09a8a..cd347de8b6efa8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs @@ -108,7 +108,7 @@ internal sealed class AnsiCharArrayMarshaller : ArrayMarshaller protected override void AllocManagedToNative(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var helper = Context.GetHelperEntryPoint("InteropHelpers", "AllocMemoryForAnsiCharArray"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "AllocMemoryForAnsiCharArray"u8); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); @@ -120,7 +120,7 @@ protected override void AllocManagedToNative(ILCodeStream codeStream) protected override void TransformManagedToNative(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var helper = Context.GetHelperEntryPoint("InteropHelpers", "WideCharArrayToAnsiCharArray"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "WideCharArrayToAnsiCharArray"u8); LoadManagedValue(codeStream); LoadNativeValue(codeStream); @@ -132,7 +132,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) protected override void TransformNativeToManaged(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var helper = Context.GetHelperEntryPoint("InteropHelpers", "AnsiCharArrayToWideCharArray"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "AnsiCharArrayToWideCharArray"u8); LoadNativeValue(codeStream); LoadManagedValue(codeStream); @@ -145,7 +145,7 @@ internal sealed class AnsiCharMarshaller : Marshaller protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var helper = Context.GetHelperEntryPoint("InteropHelpers", "WideCharToAnsiChar"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "WideCharToAnsiChar"u8); LoadManagedValue(codeStream); codeStream.Emit(PInvokeFlags.BestFitMapping ? ILOpcode.ldc_i4_1 : ILOpcode.ldc_i4_0); @@ -157,7 +157,7 @@ protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream protected override void TransformNativeToManaged(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var helper = Context.GetHelperEntryPoint("InteropHelpers", "AnsiCharToWideChar"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "AnsiCharToWideChar"u8); LoadNativeValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); @@ -184,7 +184,7 @@ internal override bool CleanupRequired internal override void EmitElementCleanup(ILCodeStream codeStream, ILEmitter emitter) { codeStream.Emit(ILOpcode.call, emitter.NewToken( - InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem", null))); + InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem"u8, null))); } protected override void AllocNativeToManaged(ILCodeStream codeStream) @@ -205,7 +205,7 @@ protected override void AllocNativeToManaged(ILCodeStream codeStream) protected override void AllocManagedToNative(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - string helperMethodName = _isAnsi ? "AllocMemoryForAnsiStringBuilder" : "AllocMemoryForUnicodeStringBuilder"; + ReadOnlySpan helperMethodName = _isAnsi ? "AllocMemoryForAnsiStringBuilder"u8 : "AllocMemoryForUnicodeStringBuilder"u8; var helper = Context.GetHelperEntryPoint("InteropHelpers", helperMethodName); LoadManagedValue(codeStream); @@ -217,7 +217,7 @@ protected override void AllocManagedToNative(ILCodeStream codeStream) protected override void TransformManagedToNative(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - string helperMethodName = _isAnsi ? "StringBuilderToAnsiString" : "StringBuilderToUnicodeString"; + ReadOnlySpan helperMethodName = _isAnsi ? "StringBuilderToAnsiString"u8 : "StringBuilderToUnicodeString"u8; var helper = Context.GetHelperEntryPoint("InteropHelpers", helperMethodName); LoadManagedValue(codeStream); @@ -232,7 +232,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) protected override void TransformNativeToManaged(ILCodeStream codeStream) { - string helperMethodName = _isAnsi ? "AnsiStringToStringBuilder" : "UnicodeStringToStringBuilder"; + ReadOnlySpan helperMethodName = _isAnsi ? "AnsiStringToStringBuilder"u8 : "UnicodeStringToStringBuilder"u8; var helper = Context.GetHelperEntryPoint("InteropHelpers", helperMethodName); LoadNativeValue(codeStream); LoadManagedValue(codeStream); @@ -245,7 +245,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken( - InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem", null))); + InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem"u8, null))); } } @@ -254,7 +254,7 @@ internal sealed class HandleRefMarshaller : Marshaller protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream) { LoadManagedAddr(codeStream); - codeStream.Emit(ILOpcode.ldfld, _ilCodeStreams.Emitter.NewToken(InteropTypes.GetHandleRef(Context).GetKnownField("_handle"))); + codeStream.Emit(ILOpcode.ldfld, _ilCodeStreams.Emitter.NewToken(InteropTypes.GetHandleRef(Context).GetKnownField("_handle"u8))); StoreNativeValue(codeStream); } @@ -271,8 +271,8 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) protected override void EmitCleanupManaged(ILCodeStream codeStream) { LoadManagedAddr(codeStream); - codeStream.Emit(ILOpcode.ldfld, _ilCodeStreams.Emitter.NewToken(InteropTypes.GetHandleRef(Context).GetKnownField("_wrapper"))); - codeStream.Emit(ILOpcode.call, _ilCodeStreams.Emitter.NewToken(InteropTypes.GetGC(Context).GetKnownMethod("KeepAlive", null))); + codeStream.Emit(ILOpcode.ldfld, _ilCodeStreams.Emitter.NewToken(InteropTypes.GetHandleRef(Context).GetKnownField("_wrapper"u8))); + codeStream.Emit(ILOpcode.call, _ilCodeStreams.Emitter.NewToken(InteropTypes.GetGC(Context).GetKnownMethod("KeepAlive"u8, null))); } } @@ -618,12 +618,12 @@ protected override bool IsAnsi protected override MethodDesc GetManagedToNativeHelper() { - return Context.GetHelperEntryPoint("InteropHelpers", "StringToByValAnsiString"); + return Context.GetHelperEntryPoint("InteropHelpers", "StringToByValAnsiString"u8); } protected override MethodDesc GetNativeToManagedHelper() { - return Context.GetHelperEntryPoint("InteropHelpers", "ByValAnsiStringToString"); + return Context.GetHelperEntryPoint("InteropHelpers", "ByValAnsiStringToString"u8); } } @@ -639,12 +639,12 @@ protected override bool IsAnsi protected override MethodDesc GetManagedToNativeHelper() { - return Context.GetHelperEntryPoint("InteropHelpers", "StringToUnicodeFixedArray"); + return Context.GetHelperEntryPoint("InteropHelpers", "StringToUnicodeFixedArray"u8); } protected override MethodDesc GetNativeToManagedHelper() { - return Context.GetHelperEntryPoint("InteropHelpers", "UnicodeToStringFixedArray"); + return Context.GetHelperEntryPoint("InteropHelpers", "UnicodeToStringFixedArray"u8); } } @@ -681,8 +681,8 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) codeStream.Emit(ILOpcode.brtrue, lNonNull); codeStream.Emit(ILOpcode.ldtoken, emitter.NewToken(ManagedType)); - codeStream.Emit(ILOpcode.call, emitter.NewToken(InteropTypes.GetType(Context).GetMethod("GetTypeFromHandle", null))); - codeStream.Emit(ILOpcode.call, emitter.NewToken(InteropTypes.GetRuntimeHelpers(Context).GetKnownMethod("GetUninitializedObject", null))); + codeStream.Emit(ILOpcode.call, emitter.NewToken(InteropTypes.GetType(Context).GetMethod("GetTypeFromHandle"u8, null))); + codeStream.Emit(ILOpcode.call, emitter.NewToken(InteropTypes.GetRuntimeHelpers(Context).GetKnownMethod("GetUninitializedObject"u8, null))); StoreManagedValue(codeStream); codeStream.EmitLabel(lNonNull); @@ -735,8 +735,8 @@ protected override void AllocNativeToManaged(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; codeStream.Emit(ILOpcode.ldtoken, emitter.NewToken(ManagedType)); - codeStream.Emit(ILOpcode.call, emitter.NewToken(InteropTypes.GetType(Context).GetMethod("GetTypeFromHandle", null))); - codeStream.Emit(ILOpcode.call, emitter.NewToken(InteropTypes.GetRuntimeHelpers(Context).GetKnownMethod("GetUninitializedObject", null))); + codeStream.Emit(ILOpcode.call, emitter.NewToken(InteropTypes.GetType(Context).GetMethod("GetTypeFromHandle"u8, null))); + codeStream.Emit(ILOpcode.call, emitter.NewToken(InteropTypes.GetRuntimeHelpers(Context).GetKnownMethod("GetUninitializedObject"u8, null))); StoreManagedValue(codeStream); } @@ -815,7 +815,7 @@ protected override void AllocManagedToNative(ILCodeStream codeStream) LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.brfalse, lNull); - MethodDesc getNativeSizeHelper = Context.GetHelperEntryPoint("InteropHelpers", "AsAnyGetNativeSize"); + MethodDesc getNativeSizeHelper = Context.GetHelperEntryPoint("InteropHelpers", "AsAnyGetNativeSize"u8); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken(getNativeSizeHelper)); @@ -842,7 +842,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) LoadManagedValue(codeStream); LoadNativeValue(codeStream); codeStream.Emit(ILOpcode.call, _ilCodeStreams.Emitter.NewToken( - Context.GetHelperEntryPoint("InteropHelpers", "AsAnyMarshalManagedToNative"))); + Context.GetHelperEntryPoint("InteropHelpers", "AsAnyMarshalManagedToNative"u8))); codeStream.EmitLabel(lNull); } @@ -858,7 +858,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) LoadNativeValue(codeStream); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, _ilCodeStreams.Emitter.NewToken( - Context.GetHelperEntryPoint("InteropHelpers", "AsAnyMarshalNativeToManaged"))); + Context.GetHelperEntryPoint("InteropHelpers", "AsAnyMarshalNativeToManaged"u8))); codeStream.EmitLabel(lNull); } @@ -880,7 +880,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) LoadNativeValue(codeStream); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken( - Context.GetHelperEntryPoint("InteropHelpers", "AsAnyCleanupNative"))); + Context.GetHelperEntryPoint("InteropHelpers", "AsAnyCleanupNative"u8))); codeStream.EmitLabel(lNull); } @@ -921,10 +921,10 @@ protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream returnType: Context.GetWellKnownType(WellKnownType.Void), parameters: new TypeDesc[] { int32Type, int16Type, int16Type, byteType, byteType, byteType, byteType, byteType, byteType, byteType, byteType }); MethodDesc guidCtorHandleMethod = - guidType.GetKnownMethod(".ctor", sig); + guidType.GetKnownMethod(".ctor"u8, sig); codeStream.Emit(ILOpcode.newobj, emitter.NewToken(guidCtorHandleMethod)); - MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertManagedComInterfaceToNative"); + MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertManagedComInterfaceToNative"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); } else @@ -934,7 +934,7 @@ protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream throw new NotSupportedException(); } - MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertManagedComInterfaceToIUnknown"); + MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertManagedComInterfaceToIUnknown"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); } @@ -946,7 +946,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); - MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertNativeComInterfaceToManaged"); + MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertNativeComInterfaceToManaged"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -965,7 +965,7 @@ internal sealed class AnsiBSTRStringMarshaller : Marshaller internal override void EmitElementCleanup(ILCodeStream codeStream, ILEmitter emitter) { - var helper = InteropTypes.GetMarshal(Context).GetKnownMethod("FreeBSTR", null); + var helper = InteropTypes.GetMarshal(Context).GetKnownMethod("FreeBSTR"u8, null); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); } protected override void TransformManagedToNative(ILCodeStream codeStream) @@ -973,7 +973,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadManagedValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "StringToAnsiBstrBuffer"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "StringToAnsiBstrBuffer"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreNativeValue(codeStream); @@ -984,7 +984,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "AnsiBstrBufferToString"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "AnsiBstrBufferToString"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -998,7 +998,7 @@ internal sealed class BSTRStringMarshaller : Marshaller internal override void EmitElementCleanup(ILCodeStream codeStream, ILEmitter emitter) { - var helper = InteropTypes.GetMarshal(Context).GetKnownMethod("FreeBSTR", null); + var helper = InteropTypes.GetMarshal(Context).GetKnownMethod("FreeBSTR"u8, null); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); } protected override void TransformManagedToNative(ILCodeStream codeStream) @@ -1006,7 +1006,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadManagedValue(codeStream); - var helper = InteropTypes.GetMarshal(Context).GetKnownMethod("StringToBSTR", null); + var helper = InteropTypes.GetMarshal(Context).GetKnownMethod("StringToBSTR"u8, null); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreNativeValue(codeStream); @@ -1017,7 +1017,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "BstrBufferToString"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "BstrBufferToString"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -1031,7 +1031,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadManagedValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "DateTimeToOleDateTime"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "DateTimeToOleDateTime"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreNativeValue(codeStream); @@ -1042,7 +1042,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "OleDateTimeToDateTime"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "OleDateTimeToDateTime"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -1056,7 +1056,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadManagedValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "DecimalToOleCurrency"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "DecimalToOleCurrency"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreNativeValue(codeStream); @@ -1067,7 +1067,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "OleCurrencyToDecimal"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "OleCurrencyToDecimal"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -1107,7 +1107,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) LoadManagedValue(codeStream); LoadNativeAddr(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertObjectToVariant"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertObjectToVariant"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); } @@ -1122,7 +1122,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) LoadNativeAddr(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "VariantToObject"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "VariantToObject"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -1139,7 +1139,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeAddr(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "CleanupVariant"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "CleanupVariant"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); } } @@ -1164,14 +1164,14 @@ private ILLocalVariable InitializeMarshallerVariable() var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices", "ICustomMarshaler"); var getInstanceMethod = marshallerType.GetMethod( - "GetInstance", + "GetInstance"u8, new MethodSignature(MethodSignatureFlags.Static, 0, customMarshallerType, [ Context.GetWellKnownType(WellKnownType.String) ])); if (ManagedType.IsValueType || ManagedType.IsPointer || ManagedType.IsFunctionPointer) { ThrowHelper.ThrowMarshalDirectiveException(); } - var initializeCustomMarshallerMethod = Context.GetHelperEntryPoint("InteropHelpers", "InitializeCustomMarshaller"); + var initializeCustomMarshallerMethod = Context.GetHelperEntryPoint("InteropHelpers", "InitializeCustomMarshaller"u8); ILEmitter emitter = _ilCodeStreams.Emitter; MarshallerLocalVariable = emitter.NewLocal(customMarshallerType); @@ -1204,7 +1204,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices", "ICustomMarshaler"); ILEmitter emitter = _ilCodeStreams.Emitter; var manageToNativeMethod = customMarshallerType.GetKnownMethod( - "MarshalManagedToNative", + "MarshalManagedToNative"u8, new MethodSignature(MethodSignatureFlags.None, 0, Context.GetWellKnownType(WellKnownType.IntPtr), [ Context.GetWellKnownType(WellKnownType.Object) ])); codeStream.EmitLdLoc(lMarshaller); @@ -1233,7 +1233,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices", "ICustomMarshaler"); ILEmitter emitter = _ilCodeStreams.Emitter; var marshalNativeToManagedMethod = customMarshallerType.GetKnownMethod( - "MarshalNativeToManaged", + "MarshalNativeToManaged"u8, new MethodSignature(MethodSignatureFlags.None, 0, Context.GetWellKnownType(WellKnownType.Object), [ Context.GetWellKnownType(WellKnownType.IntPtr) ])); codeStream.EmitLdLoc(lMarshaller); @@ -1251,7 +1251,7 @@ protected void EmitCleanUpManagedData(ILCodeStream codeStream) // Call CleanUpManagedData on cleanup code stream. var cleanupManagedDataMethod = customMarshallerType.GetKnownMethod( - "CleanUpManagedData", + "CleanUpManagedData"u8, new MethodSignature(MethodSignatureFlags.None, 0, Context.GetWellKnownType(WellKnownType.Void), [ Context.GetWellKnownType(WellKnownType.Object) ])); codeStream.EmitLdLoc(lMarshaller); @@ -1268,7 +1268,7 @@ protected void EmitCleanUpNativeData(ILCodeStream codeStream) // Call CleanUpNativeData on cleanup code stream. var cleanupNativeDataMethod = customMarshallerType.GetKnownMethod( - "CleanUpNativeData", + "CleanUpNativeData"u8, new MethodSignature(MethodSignatureFlags.None, 0, Context.GetWellKnownType(WellKnownType.Void), [ Context.GetWellKnownType(WellKnownType.IntPtr) ])); codeStream.EmitLdLoc(lMarshaller); diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs index 471a9f30a6b182..f9422962e60cf6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs @@ -1115,7 +1115,7 @@ protected override void AllocManagedToNative(ILCodeStream codeStream) codeStream.Emit(ILOpcode.mul_ovf); codeStream.Emit(ILOpcode.call, emitter.NewToken( - InteropTypes.GetMarshal(Context).GetKnownMethod("AllocCoTaskMem", null))); + InteropTypes.GetMarshal(Context).GetKnownMethod("AllocCoTaskMem"u8, null))); StoreNativeValue(codeStream); codeStream.EmitLabel(lNullArray); @@ -1340,7 +1340,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) } LoadNativeValue(codeStream); - codeStream.Emit(ILOpcode.call, emitter.NewToken(InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem", null))); + codeStream.Emit(ILOpcode.call, emitter.NewToken(InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem"u8, null))); codeStream.EmitLabel(lNullArray); } } @@ -1352,7 +1352,7 @@ protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream ILEmitter emitter = _ilCodeStreams.Emitter; ILCodeLabel lNullArray = emitter.NewCodeLabel(); - MethodDesc getArrayDataReferenceGenericMethod = InteropTypes.GetMemoryMarshal(Context).GetKnownMethod("GetArrayDataReference", null); + MethodDesc getArrayDataReferenceGenericMethod = InteropTypes.GetMemoryMarshal(Context).GetKnownMethod("GetArrayDataReference"u8, null); MethodDesc getArrayDataReferenceMethod = getArrayDataReferenceGenericMethod.MakeInstantiatedMethod(ManagedElementType); // Check for null array @@ -1482,7 +1482,7 @@ internal override bool CleanupRequired internal override void EmitElementCleanup(ILCodeStream codeStream, ILEmitter emitter) { codeStream.Emit(ILOpcode.call, emitter.NewToken( - InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem", null))); + InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem"u8, null))); } protected override void TransformManagedToNative(ILCodeStream codeStream) @@ -1520,7 +1520,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken( Context.GetWellKnownType(WellKnownType.String). - GetKnownMethod("GetPinnableReference", null))); + GetKnownMethod("GetPinnableReference"u8, null))); codeStream.EmitStLoc(vPinnedCharRef); codeStream.EmitLdLoc(vPinnedCharRef); codeStream.Emit(ILOpcode.conv_u); @@ -1534,7 +1534,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) } else { - var helper = Context.GetHelperEntryPoint("InteropHelpers", "StringToUnicodeBuffer"); + var helper = Context.GetHelperEntryPoint("InteropHelpers", "StringToUnicodeBuffer"u8); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); @@ -1546,7 +1546,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) protected override void TransformNativeToManaged(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var charPtrConstructor = Context.GetWellKnownType(WellKnownType.String).GetMethod(".ctor", + var charPtrConstructor = Context.GetWellKnownType(WellKnownType.String).GetMethod(".ctor"u8, new MethodSignature( MethodSignatureFlags.None, 0, Context.GetWellKnownType(WellKnownType.Void), new TypeDesc[] { @@ -1570,7 +1570,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) LoadNativeValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken( - InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem", null))); + InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem"u8, null))); codeStream.EmitLabel(lNullCheck); } @@ -1591,7 +1591,7 @@ internal override bool CleanupRequired internal override void EmitElementCleanup(ILCodeStream codeStream, ILEmitter emitter) { codeStream.Emit(ILOpcode.call, emitter.NewToken( - InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem", null))); + InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem"u8, null))); } protected override void TransformManagedToNative(ILCodeStream codeStream) @@ -1602,7 +1602,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) // ANSI marshalling. Allocate a byte array, copy characters // LoadManagedValue(codeStream); - var stringToAnsi = Context.GetHelperEntryPoint("InteropHelpers", "StringToAnsiString"); + var stringToAnsi = Context.GetHelperEntryPoint("InteropHelpers", "StringToAnsiString"u8); codeStream.Emit(PInvokeFlags.BestFitMapping ? ILOpcode.ldc_i4_1 : ILOpcode.ldc_i4_0); codeStream.Emit(PInvokeFlags.ThrowOnUnmappableChar ? ILOpcode.ldc_i4_1 : ILOpcode.ldc_i4_0); @@ -1615,7 +1615,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) protected override void TransformNativeToManaged(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var ansiToString = Context.GetHelperEntryPoint("InteropHelpers", "AnsiStringToString"); + var ansiToString = Context.GetHelperEntryPoint("InteropHelpers", "AnsiStringToString"u8); LoadNativeValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken(ansiToString)); StoreManagedValue(codeStream); @@ -1632,7 +1632,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) LoadNativeValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken( - InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem", null))); + InteropTypes.GetMarshal(Context).GetKnownMethod("FreeCoTaskMem"u8, null))); codeStream.EmitLabel(lNullCheck); } @@ -1655,7 +1655,7 @@ internal override void EmitElementCleanup(ILCodeStream codeStream, ILEmitter emi Debug.Assert(_marshallerInstance is null); codeStream.Emit(ILOpcode.call, emitter.NewToken( - Marshaller.GetKnownMethod("Free", null))); + Marshaller.GetKnownMethod("Free"u8, null))); } protected override void TransformManagedToNative(ILCodeStream codeStream) @@ -1688,18 +1688,18 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) var spanOfByte = Context.SystemModule.GetKnownType("System", "Span`1").MakeInstantiatedType( new TypeDesc[] { Context.GetWellKnownType(WellKnownType.Byte) }); - codeStream.Emit(ILOpcode.newobj, emitter.NewToken(spanOfByte.GetKnownMethod(".ctor", + codeStream.Emit(ILOpcode.newobj, emitter.NewToken(spanOfByte.GetKnownMethod(".ctor"u8, new MethodSignature(0, 0, Context.GetWellKnownType(WellKnownType.Void), new TypeDesc[] { Context.GetWellKnownType(WellKnownType.Void).MakePointerType(), Context.GetWellKnownType(WellKnownType.Int32) })))); - codeStream.Emit(ILOpcode.call, emitter.NewToken(marshallerIn.GetKnownMethod("FromManaged", null))); + codeStream.Emit(ILOpcode.call, emitter.NewToken(marshallerIn.GetKnownMethod("FromManaged"u8, null))); codeStream.EmitLdLoca(_marshallerInstance.Value); - codeStream.Emit(ILOpcode.call, emitter.NewToken(marshallerIn.GetKnownMethod("ToUnmanaged", null))); + codeStream.Emit(ILOpcode.call, emitter.NewToken(marshallerIn.GetKnownMethod("ToUnmanaged"u8, null))); } else { LoadManagedValue(codeStream); - codeStream.Emit(ILOpcode.call, emitter.NewToken(Marshaller.GetKnownMethod("ConvertToUnmanaged", null))); + codeStream.Emit(ILOpcode.call, emitter.NewToken(Marshaller.GetKnownMethod("ConvertToUnmanaged"u8, null))); } StoreNativeValue(codeStream); @@ -1710,7 +1710,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); - codeStream.Emit(ILOpcode.call, emitter.NewToken(Marshaller.GetKnownMethod("ConvertToManaged", null))); + codeStream.Emit(ILOpcode.call, emitter.NewToken(Marshaller.GetKnownMethod("ConvertToManaged"u8, null))); StoreManagedValue(codeStream); } @@ -1722,13 +1722,13 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) { codeStream.EmitLdLoca(_marshallerInstance.Value); codeStream.Emit(ILOpcode.call, emitter.NewToken( - MarshallerIn.GetKnownMethod("Free", null))); + MarshallerIn.GetKnownMethod("Free"u8, null))); } else { LoadNativeValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken( - Marshaller.GetKnownMethod("Free", null))); + Marshaller.GetKnownMethod("Free"u8, null))); } } } @@ -1768,7 +1768,7 @@ protected override void EmitMarshalReturnValueManagedToNative() LoadManagedValue(returnValueMarshallingCodeStream); LoadNativeValue(returnValueMarshallingCodeStream); returnValueMarshallingCodeStream.Emit(ILOpcode.call, emitter.NewToken( - InteropTypes.GetSafeHandle(Context).GetKnownMethod("SetHandle", null))); + InteropTypes.GetSafeHandle(Context).GetKnownMethod("SetHandle"u8, null))); } protected override void EmitMarshalArgumentManagedToNative() @@ -1796,13 +1796,13 @@ protected override void EmitMarshalArgumentManagedToNative() LoadManagedValue(marshallingCodeStream); marshallingCodeStream.EmitLdLoca(vAddRefed); marshallingCodeStream.Emit(ILOpcode.call, emitter.NewToken( - safeHandleType.GetKnownMethod("DangerousAddRef", + safeHandleType.GetKnownMethod("DangerousAddRef"u8, new MethodSignature(0, 0, Context.GetWellKnownType(WellKnownType.Void), new TypeDesc[] { Context.GetWellKnownType(WellKnownType.Boolean).MakeByRefType() })))); LoadManagedValue(marshallingCodeStream); marshallingCodeStream.Emit(ILOpcode.call, emitter.NewToken( - safeHandleType.GetKnownMethod("DangerousGetHandle", + safeHandleType.GetKnownMethod("DangerousGetHandle"u8, new MethodSignature(0, 0, Context.GetWellKnownType(WellKnownType.IntPtr), TypeDesc.EmptyTypes)))); StoreNativeValue(marshallingCodeStream); @@ -1811,7 +1811,7 @@ protected override void EmitMarshalArgumentManagedToNative() cleanupCodeStream.Emit(ILOpcode.brfalse, lNotAddrefed); LoadManagedValue(cleanupCodeStream); cleanupCodeStream.Emit(ILOpcode.call, emitter.NewToken( - safeHandleType.GetKnownMethod("DangerousRelease", + safeHandleType.GetKnownMethod("DangerousRelease"u8, new MethodSignature(0, 0, Context.GetWellKnownType(WellKnownType.Void), TypeDesc.EmptyTypes)))); cleanupCodeStream.EmitLabel(lNotAddrefed); } @@ -1845,7 +1845,7 @@ protected override void EmitMarshalArgumentManagedToNative() cleanupCodeStream.EmitLdLoc(vSafeHandle); LoadNativeValue(cleanupCodeStream); cleanupCodeStream.Emit(ILOpcode.call, emitter.NewToken( - safeHandleType.GetKnownMethod("SetHandle", + safeHandleType.GetKnownMethod("SetHandle"u8, new MethodSignature(0, 0, Context.GetWellKnownType(WellKnownType.Void), new TypeDesc[] { Context.GetWellKnownType(WellKnownType.IntPtr) })))); @@ -1905,7 +1905,7 @@ protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream codeStream.Emit(ILOpcode.brfalse, lNullPointer); codeStream.Emit(ILOpcode.call, _ilCodeStreams.Emitter.NewToken( - InteropTypes.GetMarshal(Context).GetKnownMethod("GetFunctionPointerForDelegate", + InteropTypes.GetMarshal(Context).GetKnownMethod("GetFunctionPointerForDelegate"u8, new MethodSignature(MethodSignatureFlags.Static, 1, Context.GetWellKnownType(WellKnownType.IntPtr), new TypeDesc[] { Context.GetSignatureVariable(0, method: true) } )).MakeInstantiatedMethod(ManagedType))); @@ -1931,7 +1931,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) codeStream.Emit(ILOpcode.brfalse, lNullPointer); codeStream.Emit(ILOpcode.call, _ilCodeStreams.Emitter.NewToken( - InteropTypes.GetMarshal(Context).GetKnownMethod("GetDelegateForFunctionPointer", + InteropTypes.GetMarshal(Context).GetKnownMethod("GetDelegateForFunctionPointer"u8, new MethodSignature(MethodSignatureFlags.Static, 1, Context.GetSignatureVariable(0, method: true), new TypeDesc[] { Context.GetWellKnownType(WellKnownType.IntPtr) } )).MakeInstantiatedMethod(ManagedType))); @@ -1953,7 +1953,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) && MarshallerType == MarshallerType.Argument) { LoadManagedValue(codeStream); - codeStream.Emit(ILOpcode.call, _ilCodeStreams.Emitter.NewToken(InteropTypes.GetGC(Context).GetKnownMethod("KeepAlive", null))); + codeStream.Emit(ILOpcode.call, _ilCodeStreams.Emitter.NewToken(InteropTypes.GetGC(Context).GetKnownMethod("KeepAlive"u8, null))); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs index b65f79f8495488..79cb70e2a227e1 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs @@ -76,7 +76,7 @@ public override MethodIL EmitIL() codeStream.EmitLdArg(0); codeStream.EmitLdArg(1); codeStream.Emit(ILOpcode.call, emitter.NewToken( - InteropTypes.GetNativeFunctionPointerWrapper(Context).GetMethod(".ctor", Signature))); + InteropTypes.GetNativeFunctionPointerWrapper(Context).GetMethod(".ctor"u8, Signature))); codeStream.Emit(ILOpcode.ret); return emitter.Link(this); } diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs index f1d2a68b873d35..436eddebbda37c 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs @@ -138,7 +138,7 @@ public override IEnumerable GetVirtualMethods() } } - public override MethodDesc GetMethod(string name, MethodSignature signature, Instantiation substitution) + public override MethodDesc GetMethod(ReadOnlySpan name, MethodSignature signature, Instantiation substitution) { MethodDesc method = _rawCanonType.GetMethod(name, signature, substitution); if (method == null) @@ -146,7 +146,7 @@ public override MethodDesc GetMethod(string name, MethodSignature signature, Ins return Context.GetMethodForRuntimeDeterminedType(method.GetTypicalMethodDefinition(), this); } - public override MethodDesc GetMethodWithEquivalentSignature(string name, MethodSignature signature, Instantiation substitution) + public override MethodDesc GetMethodWithEquivalentSignature(ReadOnlySpan name, MethodSignature signature, Instantiation substitution) { MethodDesc method = _rawCanonType.GetMethodWithEquivalentSignature(name, signature, substitution); if (method == null) diff --git a/src/coreclr/tools/ILVerification/ILImporter.Verify.cs b/src/coreclr/tools/ILVerification/ILImporter.Verify.cs index 675d420febb1ad..b0f59a1d46e83b 100644 --- a/src/coreclr/tools/ILVerification/ILImporter.Verify.cs +++ b/src/coreclr/tools/ILVerification/ILImporter.Verify.cs @@ -1123,7 +1123,7 @@ void CheckDelegateCreation(StackValue ftn, StackValue obj) bool IsDelegateAssignable(MethodDesc targetMethod, TypeDesc delegateType, TypeDesc firstArg) { - var invokeMethod = delegateType.GetMethod("Invoke", null); + var invokeMethod = delegateType.GetMethod("Invoke"u8, null); if (invokeMethod == null) return false; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DependencyGraphTests.cs b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DependencyGraphTests.cs index d55ac1c07b1474..277f446a334f8a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DependencyGraphTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DependencyGraphTests.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Text; using ILCompiler.Dataflow; using Internal.IL; using Internal.TypeSystem; @@ -49,7 +50,7 @@ public static IEnumerable GetTestMethods() foreach (var type in testModule.GetType("ILCompiler.Compiler.Tests.Assets", "DependencyGraph").GetNestedTypes()) { foundSomethingToCheck = true; - yield return new object[] { type.GetMethod("Entrypoint", null) }; + yield return new object[] { type.GetMethod("Entrypoint"u8, null) }; } Assert.True(foundSomethingToCheck, "No methods to check?"); @@ -130,7 +131,7 @@ private static MethodDesc GetMethodFromAttribute(CustomAttributeValue attr) if (attr.NamedArguments.Length > 0) throw new NotImplementedException(); // TODO: parse sig and instantiation - return ((TypeDesc)attr.FixedArguments[0].Value).GetMethod((string)attr.FixedArguments[1].Value, null); + return ((TypeDesc)attr.FixedArguments[0].Value).GetMethod(Encoding.UTF8.GetBytes((string)attr.FixedArguments[1].Value), null); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DevirtualizationTests.cs b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DevirtualizationTests.cs index d93043f2544fa5..af6ec60abbb2af 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DevirtualizationTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DevirtualizationTests.cs @@ -46,9 +46,9 @@ private DevirtualizationManager GetDevirtualizationManagerFromScan(MethodDesc me public void TestDevirtualizeSimple() { MetadataType testType = _testModule.GetType("Devirtualization", "DevirtualizeSimple"); - DevirtualizationManager scanDevirt = GetDevirtualizationManagerFromScan(testType.GetMethod("Run", null)); + DevirtualizationManager scanDevirt = GetDevirtualizationManagerFromScan(testType.GetMethod("Run"u8, null)); - MethodDesc implMethod = testType.GetNestedType("Derived").GetMethod("Virtual", null); + MethodDesc implMethod = testType.GetNestedType("Derived").GetMethod("Virtual"u8, null); // The impl method should be treated as sealed Assert.True(scanDevirt.IsEffectivelySealed(implMethod)); @@ -62,7 +62,7 @@ public void TestDevirtualizeSimple() public void TestDevirtualizeAbstract() { MetadataType testType = _testModule.GetType("Devirtualization", "DevirtualizeAbstract"); - DevirtualizationManager scanDevirt = GetDevirtualizationManagerFromScan(testType.GetMethod("Run", null)); + DevirtualizationManager scanDevirt = GetDevirtualizationManagerFromScan(testType.GetMethod("Run"u8, null)); Assert.False(scanDevirt.IsEffectivelySealed(testType.GetNestedType("Abstract"))); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs index 6e2ce174ad9acc..17c413147928c4 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs @@ -36,7 +36,7 @@ public MethodIL EmitIL(MethodDesc method) if (_value == Throw) { - codestream.EmitCallThrowHelper(emit, method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowFeatureBodyRemoved")); + codestream.EmitCallThrowHelper(emit, method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowFeatureBodyRemoved"u8)); } else if (_value == null) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs index a9e0dcaf657b0a..18b37a2022c55d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs @@ -295,11 +295,11 @@ public static MethodDesc GetConstructorForCreateInstanceIntrinsic(TypeDesc type) MetadataType activatorType = type.Context.SystemModule.GetKnownType("System", "Activator"); if (type.IsValueType && type.GetParameterlessConstructor() == null) { - ctor = activatorType.GetKnownNestedType("StructWithNoConstructor").GetKnownMethod(".ctor", null); + ctor = activatorType.GetKnownNestedType("StructWithNoConstructor").GetKnownMethod(".ctor"u8, null); } else { - ctor = activatorType.GetKnownMethod("MissingConstructorMethod", null); + ctor = activatorType.GetKnownMethod("MissingConstructorMethod"u8, null); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs index f657504df424f6..dd044bfdfc647f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs @@ -332,7 +332,7 @@ protected override TypeFlags ComputeTypeFlags(TypeFlags mask) return flags; } - public override FieldDesc GetField(string name) + public override FieldDesc GetField(ReadOnlySpan name) { return null; } @@ -447,11 +447,11 @@ public override MethodIL EmitIL() bool isX86 = Context.Target.Architecture == TargetArchitecture.X86; - FieldDesc eeTypeField = Context.GetWellKnownType(WellKnownType.Object).GetKnownField("m_pEEType"); + FieldDesc eeTypeField = Context.GetWellKnownType(WellKnownType.Object).GetKnownField("m_pEEType"u8); // Load ByRef to the field with the value of the boxed valuetype codeStream.EmitLdArg(0); - codeStream.Emit(ILOpcode.ldflda, emit.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices", "RawData").GetField("Data"))); + codeStream.Emit(ILOpcode.ldflda, emit.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices", "RawData").GetField("Data"u8))); if (isX86) { @@ -552,7 +552,7 @@ public override MethodIL EmitIL() // unbox to get a pointer to the value type codeStream.EmitLdArg(0); - codeStream.Emit(ILOpcode.ldflda, emit.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices", "RawData").GetField("Data"))); + codeStream.Emit(ILOpcode.ldflda, emit.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices", "RawData").GetField("Data"u8))); // Load rest of the arguments for (int i = 0; i < _targetMethod.Signature.Length; i++) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs index fbfcc44cdcf221..3ba9caee3abcae 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs @@ -79,7 +79,7 @@ protected virtual IEnumerable GetAllMethodsForEnum(TypeDesc enumType yield break; } - _objectEqualsMethod ??= GetWellKnownType(WellKnownType.Object).GetMethod("Equals", null); + _objectEqualsMethod ??= GetWellKnownType(WellKnownType.Object).GetMethod("Equals"u8, null); // If the classlib doesn't have Object.Equals, we don't need this. if (_objectEqualsMethod == null) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs index 22942ac6b851e1..ce5f589a949059 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs @@ -231,9 +231,9 @@ public override MethodIL EmitIL() ILEmitter emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - FieldDesc eeTypeField = Context.GetWellKnownType(WellKnownType.Object).GetKnownField("m_pEEType"); - MethodDesc getOrdinalInterfaceMethod = Context.GetHelperEntryPoint("SharedCodeHelpers", "GetOrdinalInterface"); - MethodDesc getCurrentContext = Context.GetHelperEntryPoint("SharedCodeHelpers", "GetCurrentSharedThunkContext"); + FieldDesc eeTypeField = Context.GetWellKnownType(WellKnownType.Object).GetKnownField("m_pEEType"u8); + MethodDesc getOrdinalInterfaceMethod = Context.GetHelperEntryPoint("SharedCodeHelpers", "GetOrdinalInterface"u8); + MethodDesc getCurrentContext = Context.GetHelperEntryPoint("SharedCodeHelpers", "GetCurrentSharedThunkContext"u8); bool isX86 = Context.Target.Architecture == TargetArchitecture.X86; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs index 31fd0489f89919..980afe25886494 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs @@ -79,7 +79,7 @@ protected virtual IEnumerable GetAllMethodsForAttribute(TypeDesc att private bool RequiresValueTypeGetFieldHelperMethod(MetadataType valueType) { - _objectEqualsMethod ??= GetWellKnownType(WellKnownType.Object).GetMethod("Equals", null); + _objectEqualsMethod ??= GetWellKnownType(WellKnownType.Object).GetMethod("Equals"u8, null); // If the classlib doesn't have Object.Equals, we don't need this. if (_objectEqualsMethod == null) @@ -119,7 +119,7 @@ public bool IsAsyncStateMachineType(MetadataType type) private bool RequiresAttributeGetFieldHelperMethod(TypeDesc attributeTypeDef) { - _objectEqualsMethod ??= GetWellKnownType(WellKnownType.Object).GetMethod("Equals", null); + _objectEqualsMethod ??= GetWellKnownType(WellKnownType.Object).GetMethod("Equals"u8, null); // If the classlib doesn't have Object.Equals, we don't need this. if (_objectEqualsMethod == null) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/AttributeDataFlow.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/AttributeDataFlow.cs index 40fe1df4b26a18..f45a154dd137dc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/AttributeDataFlow.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/AttributeDataFlow.cs @@ -69,7 +69,7 @@ public AttributeDataFlow(Logger logger, NodeFactory factory, FlowAnnotations ann { if (namedArgument.Kind == CustomAttributeNamedArgumentKind.Field) { - FieldDesc field = attributeType.GetField(namedArgument.Name); + FieldDesc field = attributeType.GetField(System.Text.Encoding.UTF8.GetBytes(namedArgument.Name!)); if (field != null) { ReflectionMethodBodyScanner.CheckAndReportAllRequires(_diagnosticContext, field); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DelegateCreationInfo.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DelegateCreationInfo.cs index 55328e531ec8eb..fa5a5b2eef3477 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DelegateCreationInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DelegateCreationInfo.cs @@ -221,14 +221,14 @@ public static DelegateCreationInfo Create(TypeDesc delegateType, MethodDesc targ if (!closed) { - initMethod = systemDelegate.GetKnownMethod("InitializeOpenStaticThunk", null); + initMethod = systemDelegate.GetKnownMethod("InitializeOpenStaticThunk"u8, null); invokeThunk = delegateInfo.Thunks[DelegateThunkKind.OpenStaticThunk]; } else { // Closed delegate to a static method (i.e. delegate to an extension method that locks the first parameter) invokeThunk = delegateInfo.Thunks[DelegateThunkKind.ClosedStaticThunk]; - initMethod = systemDelegate.GetKnownMethod("InitializeClosedStaticThunk", null); + initMethod = systemDelegate.GetKnownMethod("InitializeClosedStaticThunk"u8, null); } var instantiatedDelegateType = delegateType as InstantiatedType; @@ -248,14 +248,14 @@ public static DelegateCreationInfo Create(TypeDesc delegateType, MethodDesc targ if (!closed) throw new NotImplementedException("Open instance delegates"); - string initializeMethodName = "InitializeClosedInstance"; + ReadOnlySpan initializeMethodName = "InitializeClosedInstance"u8; MethodDesc targetCanonMethod = targetMethod.GetCanonMethodTarget(CanonicalFormKind.Specific); TargetKind kind; if (targetMethod.HasInstantiation) { if (followVirtualDispatch && targetMethod.IsVirtual) { - initializeMethodName = "InitializeClosedInstanceWithGVMResolution"; + initializeMethodName = "InitializeClosedInstanceWithGVMResolution"u8; kind = TargetKind.MethodHandle; } else @@ -266,7 +266,7 @@ public static DelegateCreationInfo Create(TypeDesc delegateType, MethodDesc targ // checks for the fat function pointer case (function pointer + instantiation argument in a single // pointer) and injects an invocation thunk to unwrap the fat function pointer as part of // the invocation if necessary. - initializeMethodName = "InitializeClosedInstanceSlow"; + initializeMethodName = "InitializeClosedInstanceSlow"u8; } kind = TargetKind.ExactCallableAddress; @@ -279,7 +279,7 @@ public static DelegateCreationInfo Create(TypeDesc delegateType, MethodDesc targ if (targetMethod.OwningType.IsInterface) { kind = TargetKind.InterfaceDispatch; - initializeMethodName = "InitializeClosedInstanceToInterface"; + initializeMethodName = "InitializeClosedInstanceToInterface"u8; } else { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs index a83ad7506418b8..6fe0683f9990fc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs @@ -23,11 +23,11 @@ namespace ILCompiler.DependencyAnalysis /// internal static class CustomAttributeBasedDependencyAlgorithm { - private static IMethodNode GetMetadataApiDependency(NodeFactory factory, string entityName, string propertyName) + private static IMethodNode GetMetadataApiDependency(NodeFactory factory, string entityName, ReadOnlySpan propertyName) => factory.MethodEntrypoint(factory.TypeSystemContext.SystemModule.GetType("Internal.Metadata.NativeFormat", entityName).GetMethod(propertyName, null)); private static IMethodNode GetMetadataApiDependency(NodeFactory factory, string entityName) - => GetMetadataApiDependency(factory, entityName, "get_CustomAttributes"); + => GetMetadataApiDependency(factory, entityName, "get_CustomAttributes"u8); public static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyList dependencies, NodeFactory factory, EcmaMethod method) { @@ -114,7 +114,7 @@ public static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyLi AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "ScopeDefinition"), factory, assembly, asmDef.GetCustomAttributes(), assembly); ModuleDefinition moduleDef = assembly.MetadataReader.GetModuleDefinition(); - AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "ScopeDefinition", "get_ModuleCustomAttributes"), factory, assembly, moduleDef.GetCustomAttributes(), assembly); + AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "ScopeDefinition", "get_ModuleCustomAttributes"u8), factory, assembly, moduleDef.GetCustomAttributes(), assembly); } private static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyList dependencies, object condition, NodeFactory factory, EcmaModule module, CustomAttributeHandleCollection attributeHandles, TypeSystemEntity parent) @@ -213,7 +213,7 @@ private static bool AddDependenciesFromCustomAttributeBlob(DependencyList depend private static bool AddDependenciesFromField(DependencyList dependencies, NodeFactory factory, TypeDesc attributeType, string fieldName) { - FieldDesc field = attributeType.GetField(fieldName); + FieldDesc field = attributeType.GetField(System.Text.Encoding.UTF8.GetBytes(fieldName)); if (field is not null) { if (factory.MetadataManager.IsReflectionBlocked(field)) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs index daafb76daf28ec..ebc8e0c3413119 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs @@ -58,7 +58,7 @@ public static bool IsInlineableStringsResource(EcmaModule module, string resourc if (srType == null) return false; - return srType.GetMethod(ResourceAccessorGetStringMethodName, null) != null; + return srType.GetMethod(U8ResourceAccessorGetStringMethodName, null) != null; } public static void AddDependenciesDueToResourceStringUse(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs index 8afd930fb88383..e09f9acf49c051 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs @@ -1293,7 +1293,7 @@ public ISymbolNode HelperEntrypoint(HelperEntrypoint entrypoint) var entry = s_helperEntrypointNames[index]; var type = _context.SystemModule.GetKnownType(entry[0], entry[1]); - var method = type.GetKnownMethod(entry[2], null); + var method = type.GetKnownMethod(System.Text.Encoding.UTF8.GetBytes(entry[2]), null); symbol = MethodEntrypoint(method); @@ -1318,7 +1318,7 @@ public MethodDesc InstanceMethodRemovedHelper { // This helper is optional, but it's fine for this cache to be ineffective if that happens. // Those scenarios are rare and typically deal with small compilations. - return _instanceMethodRemovedHelper ??= TypeSystemContext.GetOptionalHelperEntryPoint("ThrowHelpers", "ThrowInstanceBodyRemoved"); + return _instanceMethodRemovedHelper ??= TypeSystemContext.GetOptionalHelperEntryPoint("ThrowHelpers", "ThrowInstanceBodyRemoved"u8); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunGenericHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunGenericHelperNode.cs index 6bc7560b5d5371..7800b079faa554 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunGenericHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunGenericHelperNode.cs @@ -190,7 +190,7 @@ public IEnumerable InstantiateDependencies(NodeFactory fact private static IMethodNode GetBadSlotHelper(NodeFactory factory) { - return factory.MethodEntrypoint(factory.TypeSystemContext.GetHelperEntryPoint("ThrowHelpers", "ThrowUnavailableType")); + return factory.MethodEntrypoint(factory.TypeSystemContext.GetHelperEntryPoint("ThrowHelpers", "ThrowUnavailableType"u8)); } protected void AppendLookupSignatureMangledName(NameMangler nameMangler, Utf8StringBuilder sb) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StringAllocatorMethodNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StringAllocatorMethodNode.cs index f5d5be045737f9..ff8277f1ea1fa7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StringAllocatorMethodNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StringAllocatorMethodNode.cs @@ -42,7 +42,7 @@ public StringAllocatorMethodNode(MethodDesc constructorMethod) signatureBuilder.Flags = MethodSignatureFlags.Static; signatureBuilder.ReturnType = constructorMethod.OwningType; - _allocationMethod = constructorMethod.OwningType.GetKnownMethod("Ctor", signatureBuilder.ToSignature()); + _allocationMethod = constructorMethod.OwningType.GetKnownMethod("Ctor"u8, signatureBuilder.ToSignature()); _constructorMethod = constructorMethod; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs index f287c57c2e49ec..a2d68a2cd729c4 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs @@ -32,7 +32,7 @@ public TentativeMethodNode(IMethodBodyNode methodNode) protected virtual ISymbolNode GetTarget(NodeFactory factory) { // If the class library doesn't provide this helper, the optimization is disabled. - MethodDesc helper = factory.TypeSystemContext.GetOptionalHelperEntryPoint("ThrowHelpers", "ThrowBodyRemoved"); + MethodDesc helper = factory.TypeSystemContext.GetOptionalHelperEntryPoint("ThrowHelpers", "ThrowBodyRemoved"u8); return helper == null ? RealBody : factory.MethodEntrypoint(helper); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs index 62dc89ddaed302..cd06949a9d3fdd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs @@ -30,31 +30,31 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, break; case ReadyToRunHelper.Overflow: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowOverflowException"); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowOverflowException"u8); break; case ReadyToRunHelper.RngChkFail: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowIndexOutOfRangeException"); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowIndexOutOfRangeException"u8); break; case ReadyToRunHelper.FailFast: mangledName = "RhpFallbackFailFast"; // TODO: Report stack buffer overrun break; case ReadyToRunHelper.ThrowNullRef: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowNullReferenceException"); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowNullReferenceException"u8); break; case ReadyToRunHelper.ThrowDivZero: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowDivideByZeroException"); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowDivideByZeroException"u8); break; case ReadyToRunHelper.ThrowArgumentOutOfRange: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowArgumentOutOfRangeException"); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowArgumentOutOfRangeException"u8); break; case ReadyToRunHelper.ThrowArgument: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowArgumentException"); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowArgumentException"u8); break; case ReadyToRunHelper.ThrowPlatformNotSupported: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowPlatformNotSupportedException"); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowPlatformNotSupportedException"u8); break; case ReadyToRunHelper.ThrowNotImplemented: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotImplementedException"); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotImplementedException"u8); break; case ReadyToRunHelper.DebugBreak: @@ -74,7 +74,7 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, mangledName = context.Target.Architecture == TargetArchitecture.ARM64 ? "RhpCheckedAssignRefArm64" : "RhpCheckedAssignRef"; break; case ReadyToRunHelper.BulkWriteBarrier: - methodDesc = context.GetCoreLibEntryPoint("System", "Buffer", "BulkMoveWithWriteBarrier", null); + methodDesc = context.GetCoreLibEntryPoint("System", "Buffer", "BulkMoveWithWriteBarrier"u8, null); break; case ReadyToRunHelper.ByRefWriteBarrier: mangledName = context.Target.Architecture == TargetArchitecture.ARM64 ? "RhpByRefAssignRefArm64" : "RhpByRefAssignRef"; @@ -117,23 +117,23 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, break; case ReadyToRunHelper.Box: case ReadyToRunHelper.Box_Nullable: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhBox", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhBox"u8, null); break; case ReadyToRunHelper.Unbox: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhUnbox2", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhUnbox2"u8, null); break; case ReadyToRunHelper.Unbox_Nullable: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhUnboxNullable", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhUnboxNullable"u8, null); break; case ReadyToRunHelper.Unbox_TypeTest: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhUnboxTypeTest", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhUnboxTypeTest"u8, null); break; case ReadyToRunHelper.NewMultiDimArr: - methodDesc = context.GetHelperEntryPoint("ArrayHelpers", "NewObjArray"); + methodDesc = context.GetHelperEntryPoint("ArrayHelpers", "NewObjArray"u8); break; case ReadyToRunHelper.NewMultiDimArrRare: - methodDesc = context.GetHelperEntryPoint("ArrayHelpers", "NewObjArrayRare"); + methodDesc = context.GetHelperEntryPoint("ArrayHelpers", "NewObjArrayRare"u8); break; case ReadyToRunHelper.NewArray: @@ -144,36 +144,36 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, break; case ReadyToRunHelper.Stelem_Ref: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "StelemRef", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "StelemRef"u8, null); break; case ReadyToRunHelper.Ldelema_Ref: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "LdelemaRef", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "LdelemaRef"u8, null); break; case ReadyToRunHelper.MemCpy: - methodDesc = context.GetCoreLibEntryPoint("System", "SpanHelpers", "Memmove", null); + methodDesc = context.GetCoreLibEntryPoint("System", "SpanHelpers", "Memmove"u8, null); break; case ReadyToRunHelper.MemSet: - methodDesc = context.GetCoreLibEntryPoint("System", "SpanHelpers", "Fill", null); + methodDesc = context.GetCoreLibEntryPoint("System", "SpanHelpers", "Fill"u8, null); break; case ReadyToRunHelper.MemZero: - methodDesc = context.GetCoreLibEntryPoint("System", "SpanHelpers", "ClearWithoutReferences", null); + methodDesc = context.GetCoreLibEntryPoint("System", "SpanHelpers", "ClearWithoutReferences"u8, null); break; case ReadyToRunHelper.NativeMemSet: mangledName = "memset"; break; case ReadyToRunHelper.GetRuntimeTypeHandle: - methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeTypeHandle"); + methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeTypeHandle"u8); break; case ReadyToRunHelper.GetRuntimeType: - methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeType"); + methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeType"u8); break; case ReadyToRunHelper.GetRuntimeMethodHandle: - methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeMethodHandle"); + methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeMethodHandle"u8); break; case ReadyToRunHelper.GetRuntimeFieldHandle: - methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeFieldHandle"); + methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeFieldHandle"u8); break; case ReadyToRunHelper.Lng2Dbl: @@ -197,16 +197,16 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, break; case ReadyToRunHelper.Dbl2IntOvf: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToInt32Checked", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToInt32Checked"u8, null); break; case ReadyToRunHelper.Dbl2UIntOvf: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToUInt32Checked", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToUInt32Checked"u8, null); break; case ReadyToRunHelper.Dbl2LngOvf: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToInt64Checked", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToInt64Checked"u8, null); break; case ReadyToRunHelper.Dbl2ULngOvf: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToUInt64Checked", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToUInt64Checked"u8, null); break; case ReadyToRunHelper.DblRem: @@ -222,42 +222,42 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, case ReadyToRunHelper.LMulOfv: { TypeDesc t = context.GetWellKnownType(WellKnownType.Int64); - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("MultiplyChecked", + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("MultiplyChecked"u8, new MethodSignature(MethodSignatureFlags.Static, 0, t, [t, t])); } break; case ReadyToRunHelper.ULMulOvf: { TypeDesc t = context.GetWellKnownType(WellKnownType.UInt64); - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("MultiplyChecked", + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("MultiplyChecked"u8, new MethodSignature(MethodSignatureFlags.Static, 0, t, [t, t])); } break; case ReadyToRunHelper.Div: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivInt32", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivInt32"u8, null); break; case ReadyToRunHelper.UDiv: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivUInt32", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivUInt32"u8, null); break; case ReadyToRunHelper.LDiv: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivInt64", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivInt64"u8, null); break; case ReadyToRunHelper.ULDiv: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivUInt64", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivUInt64"u8, null); break; case ReadyToRunHelper.Mod: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModInt32", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModInt32"u8, null); break; case ReadyToRunHelper.UMod: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModUInt32", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModUInt32"u8, null); break; case ReadyToRunHelper.LMod: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModInt64", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModInt64"u8, null); break; case ReadyToRunHelper.ULMod: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModUInt64", null); + methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModUInt64"u8, null); break; case ReadyToRunHelper.LRsz: @@ -285,54 +285,54 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, break; case ReadyToRunHelper.CheckCastAny: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastAny", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastAny"u8, null); break; case ReadyToRunHelper.CheckCastInterface: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastInterface", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastInterface"u8, null); break; case ReadyToRunHelper.CheckCastClass: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastClass", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastClass"u8, null); break; case ReadyToRunHelper.CheckCastClassSpecial: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastClassSpecial", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastClassSpecial"u8, null); break; case ReadyToRunHelper.CheckInstanceAny: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfAny", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfAny"u8, null); break; case ReadyToRunHelper.CheckInstanceInterface: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfInterface", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfInterface"u8, null); break; case ReadyToRunHelper.CheckInstanceClass: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfClass", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfClass"u8, null); break; case ReadyToRunHelper.IsInstanceOfException: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfException", null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfException"u8, null); break; case ReadyToRunHelper.MonitorEnter: - methodDesc = context.GetHelperEntryPoint("SynchronizedMethodHelpers", "MonitorEnter"); + methodDesc = context.GetHelperEntryPoint("SynchronizedMethodHelpers", "MonitorEnter"u8); break; case ReadyToRunHelper.MonitorExit: - methodDesc = context.GetHelperEntryPoint("SynchronizedMethodHelpers", "MonitorExit"); + methodDesc = context.GetHelperEntryPoint("SynchronizedMethodHelpers", "MonitorExit"u8); break; case ReadyToRunHelper.GVMLookupForSlot: - methodDesc = context.SystemModule.GetKnownType("System.Runtime", "TypeLoaderExports").GetKnownMethod("GVMLookupForSlot", null); + methodDesc = context.SystemModule.GetKnownType("System.Runtime", "TypeLoaderExports").GetKnownMethod("GVMLookupForSlot"u8, null); break; case ReadyToRunHelper.TypeHandleToRuntimeType: - methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers", "TypeHandleToRuntimeTypeMaybeNull"); + methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers", "TypeHandleToRuntimeTypeMaybeNull"u8); break; case ReadyToRunHelper.GetRefAny: - methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers", "GetRefAny"); + methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers", "GetRefAny"u8); break; case ReadyToRunHelper.TypeHandleToRuntimeTypeHandle: - methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers", "TypeHandleToRuntimeTypeHandleMaybeNull"); + methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers", "TypeHandleToRuntimeTypeHandleMaybeNull"u8); break; case ReadyToRunHelper.GetCurrentManagedThreadId: - methodDesc = context.SystemModule.GetKnownType("System", "Environment").GetKnownMethod("get_CurrentManagedThreadId", null); + methodDesc = context.SystemModule.GetKnownType("System", "Environment").GetKnownMethod("get_CurrentManagedThreadId"u8, null); break; default: diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryInitializers.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryInitializers.cs index 2ecc94f3b0ccfb..a2829acd6ddcb9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryInitializers.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryInitializers.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using Internal.TypeSystem; @@ -16,7 +17,7 @@ public sealed class LibraryInitializers { private const string LibraryInitializerContainerNamespaceName = "Internal.Runtime.CompilerHelpers"; private const string LibraryInitializerContainerTypeName = "LibraryInitializer"; - private const string LibraryInitializerMethodName = "InitializeLibrary"; + private static ReadOnlySpan LibraryInitializerMethodName => "InitializeLibrary"u8; private List _libraryInitializerMethods; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationFilter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationFilter.cs index 2fb613d9521dff..eeae12a6f10edc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationFilter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationFilter.cs @@ -73,7 +73,7 @@ public override MethodIL GetMethodIL(MethodDesc method) // Method not present: stub it out var emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - codeStream.EmitCallThrowHelper(emit, method.Context.SystemModule.GetKnownType("System.Runtime", "InternalCalls").GetKnownMethod("RhpFallbackFailFast", null)); + codeStream.EmitCallThrowHelper(emit, method.Context.SystemModule.GetKnownType("System.Runtime", "InternalCalls").GetKnownMethod("RhpFallbackFailFast"u8, null)); return emit.Link(method); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs index 64db8446ffb60f..b4423a6ba5d0cb 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs @@ -254,7 +254,7 @@ public override MethodIL EmitIL() codeStream.Emit(ILOpcode.ldsflda, dataFieldToken); codeStream.Emit(ILOpcode.ldind_i4); - MethodDesc registerMethod = Context.GetHelperEntryPoint("ReachabilityInstrumentationSupport", "Register"); + MethodDesc registerMethod = Context.GetHelperEntryPoint("ReachabilityInstrumentationSupport", "Register"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(registerMethod)); codeStream.Emit(ILOpcode.ret); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index eb4e488cb2cc8e..f6f8f7bb230443 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -2465,10 +2465,10 @@ public override void WriteFieldData(ref ObjectDataBuilder builder, NodeFactory f { for (int i = 0; i < _targetFields.Length; i++) { - Debug.Assert(_entryType.GetField("IID").Offset.AsInt == 0); + Debug.Assert(_entryType.GetField("IID"u8).Offset.AsInt == 0); builder.EmitBytes(_guidBytes[i]); - Debug.Assert(_entryType.GetField("Vtable").Offset.AsInt == _guidBytes[i].Length); + Debug.Assert(_entryType.GetField("Vtable"u8).Offset.AsInt == _guidBytes[i].Length); if (_targetFields[i] is not FieldDesc targetField) { builder.EmitZeroPointer(); @@ -3431,7 +3431,7 @@ private string ValueAsString { get { - FieldDesc firstCharField = Type.GetField("_firstChar"); + FieldDesc firstCharField = Type.GetField("_firstChar"u8); int startOffset = firstCharField.Offset.AsInt; int length = _value.Length - startOffset - sizeof(char) /* terminating null */; return new string(MemoryMarshal.Cast( @@ -3453,13 +3453,13 @@ private static byte[] ConstructStringInstance(TypeDesc stringType, ReadOnlySpan< + (value.Length * sizeof(char)) /* bytes */ + sizeof(char) /* null terminator */]; - FieldDesc lengthField = stringType.GetField("_stringLength"); + FieldDesc lengthField = stringType.GetField("_stringLength"u8); Debug.Assert(lengthField.FieldType.IsWellKnownType(WellKnownType.Int32) && lengthField.Offset.AsInt == pointerSize); bool success = new FieldAccessor(bytes).TrySetField(lengthField, ValueTypeValue.FromInt32(value.Length)); Debug.Assert(success); - FieldDesc firstCharField = stringType.GetField("_firstChar"); + FieldDesc firstCharField = stringType.GetField("_firstChar"u8); Debug.Assert(firstCharField.FieldType.IsWellKnownType(WellKnownType.Char) && firstCharField.Offset.AsInt == pointerSize + sizeof(int) /* length */); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs index 5b233fe12e627f..f6e3d982ba936d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs @@ -303,7 +303,7 @@ protected override void GetMetadataDependenciesDueToReflectability(ref Dependenc // in places where they assume IL-level trimming (where the method cannot be removed). // We ask for a full reflectable method with its method body instead of just the // metadata. - MethodDesc invokeMethod = type.GetMethod("Invoke", null); + MethodDesc invokeMethod = type.GetMethod("Invoke"u8, null); if (!IsReflectionBlocked(invokeMethod)) { dependencies ??= new DependencyList(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs index 339f335d8ea64b..bdc2609e56e523 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs @@ -157,7 +157,7 @@ public ILImporter(ILScanner compilation, MethodDesc method, MethodIL methodIL = _dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorExit), reason); if (_canonMethod.Signature.IsStatic) { - _dependencies.Add(_compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetSyncFromClassHandle")), reason); + _dependencies.Add(_compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetSyncFromClassHandle"u8)), reason); MethodDesc method = _methodIL.OwningMethod; if (method.OwningType.IsRuntimeDeterminedSubtype) @@ -172,7 +172,7 @@ public ILImporter(ILScanner compilation, MethodDesc method, MethodIL methodIL = if (_canonMethod.IsCanonicalMethod(CanonicalFormKind.Any)) { if (_canonMethod.RequiresInstMethodDescArg()) - _dependencies.Add(_compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetClassFromMethodParam")), reason); + _dependencies.Add(_compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetClassFromMethodParam"u8)), reason); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs index e395e2f2ddc297..b5dd51418b02da 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs @@ -81,7 +81,7 @@ public override MethodIL EmitIL() MetadataType startup = Context.GetOptionalHelperType("StartupCodeHelpers"); // Run module initializers - MethodDesc runModuleInitializers = startup?.GetMethod("RunModuleInitializers", null); + MethodDesc runModuleInitializers = startup?.GetMethod("RunModuleInitializers"u8, null); if (runModuleInitializers != null) { codeStream.Emit(ILOpcode.call, emitter.NewToken(runModuleInitializers)); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs index ebec00cc8a572a..11c7705bb606c2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs @@ -89,9 +89,9 @@ public override MethodIL EmitIL() MetadataType startup = Context.GetOptionalHelperType("StartupCodeHelpers"); // Initialize command line args if the class library supports this - string initArgsName = (Context.Target.OperatingSystem == TargetOS.Windows) - ? "InitializeCommandLineArgsW" - : "InitializeCommandLineArgs"; + ReadOnlySpan initArgsName = (Context.Target.OperatingSystem == TargetOS.Windows) + ? "InitializeCommandLineArgsW"u8 + : "InitializeCommandLineArgs"u8; MethodDesc initArgs = startup?.GetMethod(initArgsName, null); if (initArgs != null) { @@ -101,7 +101,7 @@ public override MethodIL EmitIL() } // Initialize the entrypoint assembly if the class library supports this - MethodDesc initEntryAssembly = startup?.GetMethod("InitializeEntryAssembly", null); + MethodDesc initEntryAssembly = startup?.GetMethod("InitializeEntryAssembly"u8, null); if (initEntryAssembly != null) { ModuleDesc entrypointModule = ((MetadataType)_mainMethod.WrappedMethod.OwningType).Module; @@ -110,7 +110,7 @@ public override MethodIL EmitIL() } // Initialize COM apartment - MethodDesc initApartmentState = startup?.GetMethod("InitializeApartmentState", null); + MethodDesc initApartmentState = startup?.GetMethod("InitializeApartmentState"u8, null); if (initApartmentState != null) { if (_mainMethod.WrappedMethod.HasCustomAttribute("System", "STAThreadAttribute")) @@ -127,7 +127,7 @@ public override MethodIL EmitIL() } // Run module initializers - MethodDesc runModuleInitializers = startup?.GetMethod("RunModuleInitializers", null); + MethodDesc runModuleInitializers = startup?.GetMethod("RunModuleInitializers"u8, null); if (_generateLibraryAndModuleInitializers && runModuleInitializers != null) { codeStream.Emit(ILOpcode.call, emitter.NewToken(runModuleInitializers)); @@ -140,15 +140,15 @@ public override MethodIL EmitIL() if (initArgs == null) throw new Exception("Main() has parameters, but the class library doesn't support them"); - codeStream.Emit(ILOpcode.call, emitter.NewToken(startup.GetKnownMethod("GetMainMethodArguments", null))); + codeStream.Emit(ILOpcode.call, emitter.NewToken(startup.GetKnownMethod("GetMainMethodArguments"u8, null))); } if (Context.Target.IsWindows) codeStream.MarkDebuggerStepInPoint(); codeStream.Emit(ILOpcode.call, emitter.NewToken(_mainMethod)); - MethodDesc setLatchedExitCode = startup?.GetMethod("SetLatchedExitCode", null); - MethodDesc shutdown = startup?.GetMethod("Shutdown", null); + MethodDesc setLatchedExitCode = startup?.GetMethod("SetLatchedExitCode"u8, null); + MethodDesc shutdown = startup?.GetMethod("Shutdown"u8, null); // The class library either supports "advanced shutdown", or doesn't. No half-implementations allowed. Debug.Assert((setLatchedExitCode != null) == (shutdown != null)); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/CallChainProfile.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/CallChainProfile.cs index bc79c183257bc9..eb115b908487a3 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/CallChainProfile.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/CallChainProfile.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; using System.Text.Json; using ILCompiler.IBC; @@ -231,7 +232,7 @@ private MethodDesc ResolveMethodName(CompilerTypeSystemContext context, ModuleDe if (resolvedType != null) { - var resolvedMethod = resolvedType.GetMethod(methodName, null); + var resolvedMethod = resolvedType.GetMethod(Encoding.UTF8.GetBytes(methodName), null); if (resolvedMethod != null) { return resolvedMethod; diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypesTableNode.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypesTableNode.cs index a8f9875d1a6453..eda9941b7d68a0 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypesTableNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypesTableNode.cs @@ -88,13 +88,4 @@ public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) public override int ClassCode => -944318825; } - - file static class MetadataReaderExtensions - { - public static unsafe ReadOnlySpan GetStringBytes(this MetadataReader reader, StringHandle handle) - { - BlobReader blob = reader.GetBlobReader(handle); - return new ReadOnlySpan(blob.StartPointer, blob.Length); - } - } } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs index 754dc0fa218b64..f8083d77f7bcbb 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs @@ -184,7 +184,7 @@ public static ProfileData ParseMIbcFile(TypeSystemContext tsc, PEReader peReader var mibcModule = EcmaModule.Create(tsc, peReader, null, null, new CustomCanonResolver(tsc)); - var assemblyDictionary = (EcmaMethod)mibcModule.GetGlobalModuleType().GetMethod("AssemblyDictionary", null); + var assemblyDictionary = (EcmaMethod)mibcModule.GetGlobalModuleType().GetMethod("AssemblyDictionary"u8, null); IEnumerable loadedMethodProfileData = Enumerable.Empty(); EcmaMethodIL ilBody = EcmaMethodIL.Create(assemblyDictionary); @@ -266,7 +266,7 @@ public static ProfileData ParseMIbcFile(TypeSystemContext tsc, PEReader peReader public static MibcConfig ParseMibcConfig(TypeSystemContext tsc, PEReader pEReader) { EcmaModule mibcModule = EcmaModule.Create(tsc, pEReader, null); - EcmaMethod mibcConfigMth = (EcmaMethod)mibcModule.GetGlobalModuleType().GetMethod(nameof(MibcConfig), null); + EcmaMethod mibcConfigMth = (EcmaMethod)mibcModule.GetGlobalModuleType().GetMethod("MibcConfig"u8, null); if (mibcConfigMth == null) return null; diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs index 4c6bcfee690704..fdfa9c80f239fb 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs @@ -56,7 +56,7 @@ private MethodIL TryGetIntrinsicMethodILForActivator(MethodDesc method) if (type.IsValueType && type.GetParameterlessConstructor() == null) { // Replace the body with implementation that just returns "default" - MethodDesc createDefaultInstance = method.OwningType.GetKnownMethod("CreateDefaultInstance", method.GetTypicalMethodDefinition().Signature); + MethodDesc createDefaultInstance = method.OwningType.GetKnownMethod("CreateDefaultInstance"u8, method.GetTypicalMethodDefinition().Signature); return GetMethodIL(createDefaultInstance.MakeInstantiatedMethod(type)); } } diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs index 69dd98c62c36ea..edb434167da63e 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs @@ -759,9 +759,9 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum) break; case CorInfoHelpFunc.CORINFO_HELP_GETSYNCFROMCLASSHANDLE: - return _compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetSyncFromClassHandle")); + return _compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetSyncFromClassHandle"u8)); case CorInfoHelpFunc.CORINFO_HELP_GETCLASSFROMMETHODPARAM: - return _compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetClassFromMethodParam")); + return _compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetClassFromMethodParam"u8)); case CorInfoHelpFunc.CORINFO_HELP_GVMLOOKUP_FOR_SLOT: id = ReadyToRunHelper.GVMLookupForSlot; diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs index 38a3595f6c085f..294a91e9ed4997 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs @@ -132,29 +132,29 @@ public void TestAlignmentBehavior_LongIntEnumStruct() Assert.Equal(0x20, tARM.InstanceFieldSize.AsInt); Assert.Equal(0x20, tX86.InstanceFieldSize.AsInt); - Assert.Equal(0x0, tX64.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tARM.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tX86.GetField("_1").Offset.AsInt); + Assert.Equal(0x0, tX64.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tARM.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tX86.GetField("_1"u8).Offset.AsInt); - Assert.Equal(0x8, tX64.GetField("_2").Offset.AsInt); - Assert.Equal(0x8, tARM.GetField("_2").Offset.AsInt); - Assert.Equal(0x8, tX86.GetField("_2").Offset.AsInt); + Assert.Equal(0x8, tX64.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x8, tARM.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x8, tX86.GetField("_2"u8).Offset.AsInt); - Assert.Equal(0x10, tX64.GetField("_3").Offset.AsInt); - Assert.Equal(0x10, tARM.GetField("_3").Offset.AsInt); - Assert.Equal(0x10, tX86.GetField("_3").Offset.AsInt); + Assert.Equal(0x10, tX64.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x10, tARM.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x10, tX86.GetField("_3"u8).Offset.AsInt); - Assert.Equal(0x18, tX64.GetField("_4").Offset.AsInt); - Assert.Equal(0x18, tARM.GetField("_4").Offset.AsInt); - Assert.Equal(0x18, tX86.GetField("_4").Offset.AsInt); + Assert.Equal(0x18, tX64.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0x18, tARM.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0x18, tX86.GetField("_4"u8).Offset.AsInt); MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); - Assert.Equal(0x8, tX64FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x8, tX86FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x8, tARMFieldStruct.GetField("_struct").Offset.AsInt); + Assert.Equal(0x8, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x8, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x8, tARMFieldStruct.GetField("_struct"u8).Offset.AsInt); } [Fact] @@ -187,29 +187,29 @@ public void TestAlignmentBehavior_IntShortEnumStruct() Assert.Equal(0x10, tARM.InstanceFieldSize.AsInt); Assert.Equal(0x10, tX86.InstanceFieldSize.AsInt); - Assert.Equal(0x0, tX64.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tARM.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tX86.GetField("_1").Offset.AsInt); + Assert.Equal(0x0, tX64.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tARM.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tX86.GetField("_1"u8).Offset.AsInt); - Assert.Equal(0x4, tX64.GetField("_2").Offset.AsInt); - Assert.Equal(0x4, tARM.GetField("_2").Offset.AsInt); - Assert.Equal(0x4, tX86.GetField("_2").Offset.AsInt); + Assert.Equal(0x4, tX64.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x4, tARM.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x4, tX86.GetField("_2"u8).Offset.AsInt); - Assert.Equal(0x8, tX64.GetField("_3").Offset.AsInt); - Assert.Equal(0x8, tARM.GetField("_3").Offset.AsInt); - Assert.Equal(0x8, tX86.GetField("_3").Offset.AsInt); + Assert.Equal(0x8, tX64.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x8, tARM.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x8, tX86.GetField("_3"u8).Offset.AsInt); - Assert.Equal(0xC, tX64.GetField("_4").Offset.AsInt); - Assert.Equal(0xC, tARM.GetField("_4").Offset.AsInt); - Assert.Equal(0xC, tX86.GetField("_4").Offset.AsInt); + Assert.Equal(0xC, tX64.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0xC, tARM.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0xC, tX86.GetField("_4"u8).Offset.AsInt); MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); - Assert.Equal(0x4, tX64FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x4, tX86FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x4, tARMFieldStruct.GetField("_struct").Offset.AsInt); + Assert.Equal(0x4, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x4, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x4, tARMFieldStruct.GetField("_struct"u8).Offset.AsInt); } @@ -243,29 +243,29 @@ public void TestAlignmentBehavior_ShortByteEnumStruct() Assert.Equal(0x8, tARM.InstanceFieldSize.AsInt); Assert.Equal(0x8, tX86.InstanceFieldSize.AsInt); - Assert.Equal(0x0, tX64.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tARM.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tX86.GetField("_1").Offset.AsInt); + Assert.Equal(0x0, tX64.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tARM.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tX86.GetField("_1"u8).Offset.AsInt); - Assert.Equal(0x2, tX64.GetField("_2").Offset.AsInt); - Assert.Equal(0x2, tARM.GetField("_2").Offset.AsInt); - Assert.Equal(0x2, tX86.GetField("_2").Offset.AsInt); + Assert.Equal(0x2, tX64.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x2, tARM.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x2, tX86.GetField("_2"u8).Offset.AsInt); - Assert.Equal(0x4, tX64.GetField("_3").Offset.AsInt); - Assert.Equal(0x4, tARM.GetField("_3").Offset.AsInt); - Assert.Equal(0x4, tX86.GetField("_3").Offset.AsInt); + Assert.Equal(0x4, tX64.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x4, tARM.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x4, tX86.GetField("_3"u8).Offset.AsInt); - Assert.Equal(0x6, tX64.GetField("_4").Offset.AsInt); - Assert.Equal(0x6, tARM.GetField("_4").Offset.AsInt); - Assert.Equal(0x6, tX86.GetField("_4").Offset.AsInt); + Assert.Equal(0x6, tX64.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0x6, tARM.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0x6, tX86.GetField("_4"u8).Offset.AsInt); MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); - Assert.Equal(0x2, tX64FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x2, tX86FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x2, tARMFieldStruct.GetField("_struct").Offset.AsInt); + Assert.Equal(0x2, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x2, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x2, tARMFieldStruct.GetField("_struct"u8).Offset.AsInt); } [Fact] @@ -298,29 +298,29 @@ public void TestAlignmentBehavior_LongIntEnumStructAuto() Assert.Equal(0x18, tARM.InstanceFieldSize.AsInt); Assert.Equal(0x18, tX86.InstanceFieldSize.AsInt); - Assert.Equal(0x0, tX64.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tARM.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tX86.GetField("_1").Offset.AsInt); + Assert.Equal(0x0, tX64.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tARM.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tX86.GetField("_1"u8).Offset.AsInt); - Assert.Equal(0x10, tX64.GetField("_2").Offset.AsInt); - Assert.Equal(0x10, tARM.GetField("_2").Offset.AsInt); - Assert.Equal(0x10, tX86.GetField("_2").Offset.AsInt); + Assert.Equal(0x10, tX64.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x10, tARM.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x10, tX86.GetField("_2"u8).Offset.AsInt); - Assert.Equal(0x8, tX64.GetField("_3").Offset.AsInt); - Assert.Equal(0x8, tARM.GetField("_3").Offset.AsInt); - Assert.Equal(0x8, tX86.GetField("_3").Offset.AsInt); + Assert.Equal(0x8, tX64.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x8, tARM.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x8, tX86.GetField("_3"u8).Offset.AsInt); - Assert.Equal(0x14, tX64.GetField("_4").Offset.AsInt); - Assert.Equal(0x14, tARM.GetField("_4").Offset.AsInt); - Assert.Equal(0x14, tX86.GetField("_4").Offset.AsInt); + Assert.Equal(0x14, tX64.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0x14, tARM.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0x14, tX86.GetField("_4"u8).Offset.AsInt); MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); - Assert.Equal(0x8, tX64FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x4, tX86FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x8, tARMFieldStruct.GetField("_struct").Offset.AsInt); + Assert.Equal(0x8, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x4, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x8, tARMFieldStruct.GetField("_struct"u8).Offset.AsInt); } [Fact] @@ -353,29 +353,29 @@ public void TestAlignmentBehavior_IntShortEnumStructAuto() Assert.Equal(0xC, tARM.InstanceFieldSize.AsInt); Assert.Equal(0xC, tX86.InstanceFieldSize.AsInt); - Assert.Equal(0x0, tX64.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tARM.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tX86.GetField("_1").Offset.AsInt); + Assert.Equal(0x0, tX64.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tARM.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tX86.GetField("_1"u8).Offset.AsInt); - Assert.Equal(0x8, tX64.GetField("_2").Offset.AsInt); - Assert.Equal(0x8, tARM.GetField("_2").Offset.AsInt); - Assert.Equal(0x8, tX86.GetField("_2").Offset.AsInt); + Assert.Equal(0x8, tX64.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x8, tARM.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x8, tX86.GetField("_2"u8).Offset.AsInt); - Assert.Equal(0x4, tX64.GetField("_3").Offset.AsInt); - Assert.Equal(0x4, tARM.GetField("_3").Offset.AsInt); - Assert.Equal(0x4, tX86.GetField("_3").Offset.AsInt); + Assert.Equal(0x4, tX64.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x4, tARM.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x4, tX86.GetField("_3"u8).Offset.AsInt); - Assert.Equal(0xA, tX64.GetField("_4").Offset.AsInt); - Assert.Equal(0xA, tARM.GetField("_4").Offset.AsInt); - Assert.Equal(0xA, tX86.GetField("_4").Offset.AsInt); + Assert.Equal(0xA, tX64.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0xA, tARM.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0xA, tX86.GetField("_4"u8).Offset.AsInt); MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); - Assert.Equal(0x8, tX64FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x4, tX86FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x4, tARMFieldStruct.GetField("_struct").Offset.AsInt); + Assert.Equal(0x8, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x4, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x4, tARMFieldStruct.GetField("_struct"u8).Offset.AsInt); } @@ -409,29 +409,29 @@ public void TestAlignmentBehavior_ShortByteEnumStructAuto() Assert.Equal(0x8, tARM.InstanceFieldSize.AsInt); Assert.Equal(0x8, tX86.InstanceFieldSize.AsInt); - Assert.Equal(0x0, tX64.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tARM.GetField("_1").Offset.AsInt); - Assert.Equal(0x0, tX86.GetField("_1").Offset.AsInt); + Assert.Equal(0x0, tX64.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tARM.GetField("_1"u8).Offset.AsInt); + Assert.Equal(0x0, tX86.GetField("_1"u8).Offset.AsInt); - Assert.Equal(0x4, tX64.GetField("_2").Offset.AsInt); - Assert.Equal(0x4, tARM.GetField("_2").Offset.AsInt); - Assert.Equal(0x4, tX86.GetField("_2").Offset.AsInt); + Assert.Equal(0x4, tX64.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x4, tARM.GetField("_2"u8).Offset.AsInt); + Assert.Equal(0x4, tX86.GetField("_2"u8).Offset.AsInt); - Assert.Equal(0x2, tX64.GetField("_3").Offset.AsInt); - Assert.Equal(0x2, tARM.GetField("_3").Offset.AsInt); - Assert.Equal(0x2, tX86.GetField("_3").Offset.AsInt); + Assert.Equal(0x2, tX64.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x2, tARM.GetField("_3"u8).Offset.AsInt); + Assert.Equal(0x2, tX86.GetField("_3"u8).Offset.AsInt); - Assert.Equal(0x5, tX64.GetField("_4").Offset.AsInt); - Assert.Equal(0x5, tARM.GetField("_4").Offset.AsInt); - Assert.Equal(0x5, tX86.GetField("_4").Offset.AsInt); + Assert.Equal(0x5, tX64.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0x5, tARM.GetField("_4"u8).Offset.AsInt); + Assert.Equal(0x5, tX86.GetField("_4"u8).Offset.AsInt); MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); - Assert.Equal(0x8, tX64FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x4, tX86FieldStruct.GetField("_struct").Offset.AsInt); - Assert.Equal(0x4, tARMFieldStruct.GetField("_struct").Offset.AsInt); + Assert.Equal(0x8, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x4, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); + Assert.Equal(0x4, tARMFieldStruct.GetField("_struct"u8).Offset.AsInt); } [Fact] @@ -452,13 +452,13 @@ public void TestAlignmentBehavior_StructStructByte_StructByteAuto() Assert.Equal(0x2, tARM.InstanceFieldSize.AsInt); Assert.Equal(0x2, tX86.InstanceFieldSize.AsInt); - Assert.Equal(0x0, tX64.GetField("fld1").Offset.AsInt); - Assert.Equal(0x0, tARM.GetField("fld1").Offset.AsInt); - Assert.Equal(0x0, tX86.GetField("fld1").Offset.AsInt); + Assert.Equal(0x0, tX64.GetField("fld1"u8).Offset.AsInt); + Assert.Equal(0x0, tARM.GetField("fld1"u8).Offset.AsInt); + Assert.Equal(0x0, tX86.GetField("fld1"u8).Offset.AsInt); - Assert.Equal(0x1, tX64.GetField("fld2").Offset.AsInt); - Assert.Equal(0x1, tARM.GetField("fld2").Offset.AsInt); - Assert.Equal(0x1, tX86.GetField("fld2").Offset.AsInt); + Assert.Equal(0x1, tX64.GetField("fld2"u8).Offset.AsInt); + Assert.Equal(0x1, tARM.GetField("fld2"u8).Offset.AsInt); + Assert.Equal(0x1, tX86.GetField("fld2"u8).Offset.AsInt); } [Theory] @@ -486,13 +486,13 @@ public void TestAlignmentBehavior_AutoAlignmentRules(string wrapperType, int[] a Assert.Equal(size[1], tARM.InstanceFieldSize.AsInt); Assert.Equal(size[2], tX86.InstanceFieldSize.AsInt); - Assert.Equal(0x0, tX64.GetField("fld1").Offset.AsInt); - Assert.Equal(0x0, tARM.GetField("fld1").Offset.AsInt); - Assert.Equal(0x0, tX86.GetField("fld1").Offset.AsInt); + Assert.Equal(0x0, tX64.GetField("fld1"u8).Offset.AsInt); + Assert.Equal(0x0, tARM.GetField("fld1"u8).Offset.AsInt); + Assert.Equal(0x0, tX86.GetField("fld1"u8).Offset.AsInt); - Assert.Equal(alignment[0], tX64.GetField("fld2").Offset.AsInt); - Assert.Equal(alignment[1], tARM.GetField("fld2").Offset.AsInt); - Assert.Equal(alignment[2], tX86.GetField("fld2").Offset.AsInt); + Assert.Equal(alignment[0], tX64.GetField("fld2"u8).Offset.AsInt); + Assert.Equal(alignment[1], tARM.GetField("fld2"u8).Offset.AsInt); + Assert.Equal(alignment[2], tX86.GetField("fld2"u8).Offset.AsInt); } [Theory] @@ -541,8 +541,8 @@ public void TestAlignmentBehavior_AutoAlignmentRulesWithOSDependence(string wrap Assert.Equal(alignment, type.InstanceFieldAlignment.AsInt); Assert.Equal(size, type.InstanceFieldSize.AsInt); - Assert.Equal(0x0, type.GetField("fld1").Offset.AsInt); - Assert.Equal(alignment, type.GetField("fld2").Offset.AsInt); + Assert.Equal(0x0, type.GetField("fld1"u8).Offset.AsInt); + Assert.Equal(alignment, type.GetField("fld2"u8).Offset.AsInt); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs index c42cacbe3bfe42..f8421105a5a7a2 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs @@ -205,47 +205,47 @@ public void TestMethodsOnGenericTypes(CanonicalizationMode algorithmType) var referenceOverReference = _genericReferenceType.MakeInstantiatedType(_referenceType); var referenceOverOtherReference = _genericReferenceType.MakeInstantiatedType(_otherReferenceType); Assert.NotSame( - referenceOverReference.GetMethod("Method", null), - referenceOverOtherReference.GetMethod("Method", null)); + referenceOverReference.GetMethod("Method"u8, null), + referenceOverOtherReference.GetMethod("Method"u8, null)); Assert.Same( - referenceOverReference.GetMethod("Method", null).GetCanonMethodTarget(CanonicalFormKind.Specific), - referenceOverOtherReference.GetMethod("Method", null).GetCanonMethodTarget(CanonicalFormKind.Specific)); + referenceOverReference.GetMethod("Method"u8, null).GetCanonMethodTarget(CanonicalFormKind.Specific), + referenceOverOtherReference.GetMethod("Method"u8, null).GetCanonMethodTarget(CanonicalFormKind.Specific)); Assert.Same( - referenceOverReference.GetMethod("Method", null).GetCanonMethodTarget(CanonicalFormKind.Universal), - referenceOverOtherReference.GetMethod("Method", null).GetCanonMethodTarget(CanonicalFormKind.Universal)); + referenceOverReference.GetMethod("Method"u8, null).GetCanonMethodTarget(CanonicalFormKind.Universal), + referenceOverOtherReference.GetMethod("Method"u8, null).GetCanonMethodTarget(CanonicalFormKind.Universal)); var referenceOverStruct = _genericReferenceType.MakeInstantiatedType(_structType); Assert.NotSame( - referenceOverReference.GetMethod("Method", null).GetCanonMethodTarget(CanonicalFormKind.Specific), - referenceOverStruct.GetMethod("Method", null).GetCanonMethodTarget(CanonicalFormKind.Specific)); + referenceOverReference.GetMethod("Method"u8, null).GetCanonMethodTarget(CanonicalFormKind.Specific), + referenceOverStruct.GetMethod("Method"u8, null).GetCanonMethodTarget(CanonicalFormKind.Specific)); Assert.Same( - referenceOverReference.GetMethod("Method", null).GetCanonMethodTarget(CanonicalFormKind.Universal), - referenceOverStruct.GetMethod("Method", null).GetCanonMethodTarget(CanonicalFormKind.Universal)); + referenceOverReference.GetMethod("Method"u8, null).GetCanonMethodTarget(CanonicalFormKind.Universal), + referenceOverStruct.GetMethod("Method"u8, null).GetCanonMethodTarget(CanonicalFormKind.Universal)); Assert.Same( - referenceOverReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Specific), - referenceOverOtherReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_otherReferenceType).GetCanonMethodTarget(CanonicalFormKind.Specific)); + referenceOverReference.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Specific), + referenceOverOtherReference.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_otherReferenceType).GetCanonMethodTarget(CanonicalFormKind.Specific)); Assert.Same( - referenceOverReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Universal), - referenceOverOtherReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_otherReferenceType).GetCanonMethodTarget(CanonicalFormKind.Universal)); + referenceOverReference.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Universal), + referenceOverOtherReference.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_otherReferenceType).GetCanonMethodTarget(CanonicalFormKind.Universal)); Assert.NotSame( - referenceOverReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Specific), - referenceOverOtherReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_structType).GetCanonMethodTarget(CanonicalFormKind.Specific)); + referenceOverReference.GetMethod("GenericMethodu8"u8, null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Specific), + referenceOverOtherReference.GetMethod("GenericMethodu8"u8, null).MakeInstantiatedMethod(_structType).GetCanonMethodTarget(CanonicalFormKind.Specific)); Assert.Same( - referenceOverReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Universal), - referenceOverOtherReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_structType).GetCanonMethodTarget(CanonicalFormKind.Universal)); + referenceOverReference.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Universal), + referenceOverOtherReference.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_structType).GetCanonMethodTarget(CanonicalFormKind.Universal)); Assert.NotSame( - referenceOverStruct.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Specific), - referenceOverOtherReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_structType).GetCanonMethodTarget(CanonicalFormKind.Specific)); + referenceOverStruct.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Specific), + referenceOverOtherReference.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_structType).GetCanonMethodTarget(CanonicalFormKind.Specific)); Assert.Same( - referenceOverStruct.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Universal), - referenceOverOtherReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_structType).GetCanonMethodTarget(CanonicalFormKind.Universal)); + referenceOverStruct.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_referenceType).GetCanonMethodTarget(CanonicalFormKind.Universal), + referenceOverOtherReference.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_structType).GetCanonMethodTarget(CanonicalFormKind.Universal)); Assert.NotSame( - referenceOverReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_structType), - referenceOverReference.GetMethod("GenericMethod", null).MakeInstantiatedMethod(_structType).GetCanonMethodTarget(CanonicalFormKind.Specific)); + referenceOverReference.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_structType), + referenceOverReference.GetMethod("GenericMethod"u8, null).MakeInstantiatedMethod(_structType).GetCanonMethodTarget(CanonicalFormKind.Specific)); } [Theory] @@ -259,20 +259,20 @@ public void TestArrayMethods(CanonicalizationMode algorithmType) var arrayOfOtherReferenceType = _otherReferenceType.MakeArrayType(1); Assert.Same( - arrayOfReferenceType.GetMethod("Set", null).GetCanonMethodTarget(CanonicalFormKind.Specific), - arrayOfOtherReferenceType.GetMethod("Set", null).GetCanonMethodTarget(CanonicalFormKind.Specific)); + arrayOfReferenceType.GetMethod("Set"u8, null).GetCanonMethodTarget(CanonicalFormKind.Specific), + arrayOfOtherReferenceType.GetMethod("Set"u8, null).GetCanonMethodTarget(CanonicalFormKind.Specific)); Assert.Same( - arrayOfReferenceType.GetMethod("Set", null).GetCanonMethodTarget(CanonicalFormKind.Universal), - arrayOfOtherReferenceType.GetMethod("Set", null).GetCanonMethodTarget(CanonicalFormKind.Universal)); + arrayOfReferenceType.GetMethod("Set"u8, null).GetCanonMethodTarget(CanonicalFormKind.Universal), + arrayOfOtherReferenceType.GetMethod("Set"u8, null).GetCanonMethodTarget(CanonicalFormKind.Universal)); var arrayOfStruct = _structType.MakeArrayType(1); Assert.NotSame( - arrayOfReferenceType.GetMethod("Set", null).GetCanonMethodTarget(CanonicalFormKind.Specific), - arrayOfStruct.GetMethod("Set", null).GetCanonMethodTarget(CanonicalFormKind.Specific)); + arrayOfReferenceType.GetMethod("Set"u8, null).GetCanonMethodTarget(CanonicalFormKind.Specific), + arrayOfStruct.GetMethod("Set"u8, null).GetCanonMethodTarget(CanonicalFormKind.Specific)); Assert.Same( - arrayOfReferenceType.GetMethod("Set", null).GetCanonMethodTarget(CanonicalFormKind.Universal), - arrayOfStruct.GetMethod("Set", null).GetCanonMethodTarget(CanonicalFormKind.Universal)); + arrayOfReferenceType.GetMethod("Set"u8, null).GetCanonMethodTarget(CanonicalFormKind.Universal), + arrayOfStruct.GetMethod("Set"u8, null).GetCanonMethodTarget(CanonicalFormKind.Universal)); } [Theory] diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs index 555504eecad05b..8e50761b8eda53 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs @@ -72,8 +72,8 @@ public ConstraintsValidationTest() _multipleConstraintsType = _testModule.GetType("GenericConstraints", "MultipleConstraints`2"); _genericMethodsType = _testModule.GetType("GenericConstraints", "GenericMethods"); - _simpleGenericConstraintMethod = _genericMethodsType.GetMethod("SimpleGenericConstraintMethod", null); - _complexGenericConstraintMethod = _genericMethodsType.GetMethod("ComplexGenericConstraintMethod", null); + _simpleGenericConstraintMethod = _genericMethodsType.GetMethod("SimpleGenericConstraintMethod"u8, null); + _complexGenericConstraintMethod = _genericMethodsType.GetMethod("ComplexGenericConstraintMethod"u8, null); } [Fact] diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs index f2c3a0f3b8381d..aa2388be5b2cde 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs @@ -114,7 +114,7 @@ public void TestMethodLookup() MetadataType t = _testModule.GetType("GenericTypes", "GenericClass`1").MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); MethodSignature sig = new MethodSignature(MethodSignatureFlags.None, 0, _context.GetSignatureVariable(0, false), System.Array.Empty()); - MethodDesc fooMethod = t.GetMethod("Foo", sig); + MethodDesc fooMethod = t.GetMethod("Foo"u8, sig); Assert.NotNull(fooMethod); } @@ -222,19 +222,19 @@ public void TestConstructedMethodAdjustment() MetadataType genericOpenType = _testModule.GetType("GenericTypes", "TwoParamGenericClass`2"); MetadataType nonGenericType = _testModule.GetType("GenericTypes", "NonGenericClass"); - MethodDesc genericOnNonGeneric = nonGenericType.GetMethod("GenericFunction", null); + MethodDesc genericOnNonGeneric = nonGenericType.GetMethod("GenericFunction"u8, null); InstantiatedType genericIntString = genericOpenType.MakeInstantiatedType(intType, stringType); InstantiatedType genericCharString = genericOpenType.MakeInstantiatedType(charType, stringType); InstantiatedType genericCharObject = genericOpenType.MakeInstantiatedType(charType, objectType); - MethodDesc nonGenericOnGenericIntString = genericIntString.GetMethod("NonGenericFunction", null); - MethodDesc nonGenericOnGenericCharString = genericCharString.GetMethod("NonGenericFunction", null); - MethodDesc nonGenericOnGenericCharObject = genericCharObject.GetMethod("NonGenericFunction", null); + MethodDesc nonGenericOnGenericIntString = genericIntString.GetMethod("NonGenericFunction"u8, null); + MethodDesc nonGenericOnGenericCharString = genericCharString.GetMethod("NonGenericFunction"u8, null); + MethodDesc nonGenericOnGenericCharObject = genericCharObject.GetMethod("NonGenericFunction"u8, null); - MethodDesc genericIntStringOnGenericIntString = genericIntString.GetMethod("GenericFunction", null).MakeInstantiatedMethod(intType, stringType); - MethodDesc genericCharStringOnGenericCharString = genericCharString.GetMethod("GenericFunction", null).MakeInstantiatedMethod(charType, stringType); - MethodDesc genericCharObjectOnGenericCharObject = genericCharObject.GetMethod("GenericFunction", null).MakeInstantiatedMethod(charType, objectType); + MethodDesc genericIntStringOnGenericIntString = genericIntString.GetMethod("GenericFunction"u8, null).MakeInstantiatedMethod(intType, stringType); + MethodDesc genericCharStringOnGenericCharString = genericCharString.GetMethod("GenericFunction"u8, null).MakeInstantiatedMethod(charType, stringType); + MethodDesc genericCharObjectOnGenericCharObject = genericCharObject.GetMethod("GenericFunction"u8, null).MakeInstantiatedMethod(charType, objectType); MethodDesc genericIntStringOnNonGeneric = genericOnNonGeneric.MakeInstantiatedMethod(intType, stringType); MethodDesc genericCharStringOnNonGeneric = genericOnNonGeneric.MakeInstantiatedMethod(charType, stringType); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILDisassemblerTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILDisassemblerTests.cs index 45881020f622ae..a132e85493b9f3 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILDisassemblerTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILDisassemblerTests.cs @@ -29,7 +29,7 @@ public ILDisassemblerTests() public void TestGenericNameFormatting() { MetadataType testClass = _testModule.GetType("ILDisassembler", "TestGenericClass`1"); - EcmaMethod testMethod = (EcmaMethod)testClass.GetMethod("TestMethod", null); + EcmaMethod testMethod = (EcmaMethod)testClass.GetMethod("TestMethod"u8, null); EcmaMethodIL methodIL = EcmaMethodIL.Create(testMethod); Dictionary interestingLines = new Dictionary diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs index cfbd01648ffc51..d6ce5d3b8b5a8d 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs @@ -273,7 +273,7 @@ public void TestRvaStatics() var ilModule = _context.GetModuleForSimpleName("ILTestAssembly"); var t = ilModule.GetType("StaticFieldLayout", "RvaStatics"); - var field = t.GetField("StaticInitedInt"); + var field = t.GetField("StaticInitedInt"u8); Assert.True(field.HasRva); @@ -295,7 +295,7 @@ public void TestFunctionPointer() var ilModule = _context.GetModuleForSimpleName("ILTestAssembly"); var t = ilModule.GetType("StaticFieldLayout", "FunctionPointerType"); - var field = t.GetField("StaticMethodField"); + var field = t.GetField("StaticMethodField"u8); Assert.Equal(8, field.Offset.AsInt); Assert.False(field.HasGCStaticBase); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs index d6e5873eb2e149..eb431f82c5e4c7 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Linq; using System.Reflection; +using System.Text; using Internal.IL; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -77,11 +78,11 @@ public void TestVirtualDispatchOnGenericType() // Verifies that virtual dispatch to a non-generic method on a generic instantiation works DefType objectType = _context.GetWellKnownType(WellKnownType.Object); MethodSignature toStringSig = new MethodSignature(MethodSignatureFlags.None, 0, _stringType, Array.Empty()); - MethodDesc objectToString = objectType.GetMethod("ToString", toStringSig); + MethodDesc objectToString = objectType.GetMethod("ToString"u8, toStringSig); Assert.NotNull(objectToString); MetadataType openTestType = _testModule.GetType("VirtualFunctionOverride", "SimpleGeneric`1"); InstantiatedType testInstance = openTestType.MakeInstantiatedType(objectType); - MethodDesc targetOnInstance = testInstance.GetMethod("ToString", toStringSig); + MethodDesc targetOnInstance = testInstance.GetMethod("ToString"u8, toStringSig); MethodDesc targetMethod = testInstance.FindVirtualFunctionTargetMethodOnObjectType(objectToString); Assert.Equal(targetOnInstance, targetMethod); @@ -94,13 +95,13 @@ public void TestVirtualDispatchOnGenericTypeWithOverload() MetadataType derivedInstance = openDerived.MakeInstantiatedType(_stringType); MetadataType baseInstance = (MetadataType)derivedInstance.BaseType; - MethodDesc baseNongenericOverload = baseInstance.GetMethod("MyMethod", new MethodSignature(MethodSignatureFlags.None, 0, _voidType, new TypeDesc[] { _stringType })); - MethodDesc derivedNongenericOverload = derivedInstance.GetMethod("MyMethod", new MethodSignature(MethodSignatureFlags.None, 0, _voidType, new TypeDesc[] { _stringType })); + MethodDesc baseNongenericOverload = baseInstance.GetMethod("MyMethod"u8, new MethodSignature(MethodSignatureFlags.None, 0, _voidType, new TypeDesc[] { _stringType })); + MethodDesc derivedNongenericOverload = derivedInstance.GetMethod("MyMethod"u8, new MethodSignature(MethodSignatureFlags.None, 0, _voidType, new TypeDesc[] { _stringType })); MethodDesc nongenericTargetOverload = derivedInstance.FindVirtualFunctionTargetMethodOnObjectType(baseNongenericOverload); Assert.Equal(derivedNongenericOverload, nongenericTargetOverload); - MethodDesc baseGenericOverload = baseInstance.GetMethod("MyMethod", new MethodSignature(MethodSignatureFlags.None, 0, _voidType, new TypeDesc[] { _context.GetSignatureVariable(0, false) })); - MethodDesc derivedGenericOverload = derivedInstance.GetMethod("MyMethod", new MethodSignature(MethodSignatureFlags.None, 0, _voidType, new TypeDesc[] { _context.GetSignatureVariable(0, false) })); + MethodDesc baseGenericOverload = baseInstance.GetMethod("MyMethod"u8, new MethodSignature(MethodSignatureFlags.None, 0, _voidType, new TypeDesc[] { _context.GetSignatureVariable(0, false) })); + MethodDesc derivedGenericOverload = derivedInstance.GetMethod("MyMethod"u8, new MethodSignature(MethodSignatureFlags.None, 0, _voidType, new TypeDesc[] { _context.GetSignatureVariable(0, false) })); MethodDesc genericTargetOverload = derivedInstance.FindVirtualFunctionTargetMethodOnObjectType(baseGenericOverload); Assert.Equal(derivedGenericOverload, genericTargetOverload); } @@ -110,7 +111,7 @@ public void TestFinalizeOverrideChecking() { MetadataType classWithFinalizer = _testModule.GetType("VirtualFunctionOverride", "ClassWithFinalizer"); DefType objectType = _testModule.Context.GetWellKnownType(WellKnownType.Object); - MethodDesc finalizeMethod = objectType.GetMethod("Finalize", new MethodSignature(MethodSignatureFlags.None, 0, _voidType, Array.Empty())); + MethodDesc finalizeMethod = objectType.GetMethod("Finalize"u8, new MethodSignature(MethodSignatureFlags.None, 0, _voidType, Array.Empty())); MethodDesc actualFinalizer = classWithFinalizer.FindVirtualFunctionTargetMethodOnObjectType(finalizeMethod); Assert.NotNull(actualFinalizer); @@ -127,9 +128,9 @@ public void TestExplicitOverride() var ilModule = _context.GetModuleForSimpleName("ILTestAssembly"); var explicitOverrideClass = ilModule.GetType("VirtualFunctionOverride", "ExplicitOverride"); - var myGetHashCodeMethod = explicitOverrideClass.GetMethod("MyGetHashCode", null); + var myGetHashCodeMethod = explicitOverrideClass.GetMethod("MyGetHashCode"u8, null); - var objectGetHashCodeMethod = _context.GetWellKnownType(WellKnownType.Object).GetMethod("GetHashCode", null); + var objectGetHashCodeMethod = _context.GetWellKnownType(WellKnownType.Object).GetMethod("GetHashCode"u8, null); var foundOverride = explicitOverrideClass.FindVirtualFunctionTargetMethodOnObjectType(objectGetHashCodeMethod); @@ -143,7 +144,7 @@ public void TestFindBaseUnificationGroup() var ilModule = _context.GetModuleForSimpleName("ILTestAssembly"); MetadataType myDerived2Type = ilModule.GetType("VirtualFunctionOverride", "MyDerived2"); Assert.NotNull(myDerived2Type); - MethodDesc method = myDerived2Type.GetMethod("get_foo", null); + MethodDesc method = myDerived2Type.GetMethod("get_foo"u8, null); Assert.NotNull(method); MethodDesc virtualMethod = algo.FindVirtualFunctionTargetMethodOnObjectType(method, myDerived2Type); @@ -167,13 +168,13 @@ public void TestGenericsOverrideOfSpecificMethodWhereSubstitutionsAreNecessaryTo var stringType = _context.GetWellKnownType(WellKnownType.String); MethodSignature sigBang0Bang1 = new MethodSignature(0, 0, stringType, new TypeDesc[] { myGenericTypeInstantiatedOverBang0ByRef, myGenericTypeInstantiatedOverBang1ByRef }); - MethodDesc baseMethod0_1 = baseType.GetMethod("Method", sigBang0Bang1); + MethodDesc baseMethod0_1 = baseType.GetMethod("Method"u8, sigBang0Bang1); MethodDesc virtualMethodBang0Bang1 = algo.FindVirtualFunctionTargetMethodOnObjectType(baseMethod0_1, myDerivedType); Assert.Equal(virtualMethodBang0Bang1.OwningType, myDerivedType); MethodSignature sigBang1Bang0 = new MethodSignature(0, 0, stringType, new TypeDesc[] { myGenericTypeInstantiatedOverBang1ByRef, myGenericTypeInstantiatedOverBang0ByRef }); - MethodDesc baseMethod1_0 = baseType.GetMethod("Method", sigBang1Bang0); + MethodDesc baseMethod1_0 = baseType.GetMethod("Method"u8, sigBang1Bang0); MethodDesc virtualMethodBang1Bang0 = algo.FindVirtualFunctionTargetMethodOnObjectType(baseMethod1_0, myDerivedType); Assert.Equal(virtualMethodBang1Bang0.OwningType, baseType); @@ -201,7 +202,7 @@ public void TestGenericsClassOverrideOfMethodWhereMethodHasBeenMovedFromTheTypeW var bang2Type = _context.GetSignatureVariable(2, false); MethodSignature sigBang0Bang1 = new MethodSignature(0, 0, stringType, new TypeDesc[] { bang0Type, bang1Type }); - MethodDesc baseMethod0_1 = baseType.GetMethod("Method", sigBang0Bang1); + MethodDesc baseMethod0_1 = baseType.GetMethod("Method"u8, sigBang0Bang1); MethodDesc virtualMethodBang0Bang1 = algo.FindVirtualFunctionTargetMethodOnObjectType(baseMethod0_1, myDerivedType); Assert.Equal(virtualMethodBang0Bang1.OwningType, baseType); @@ -236,9 +237,9 @@ private void ResolveInterfaceDispatch_ForMultiGenericTest(MetadataType type, out MethodSignature sigBang1Bang0 = new MethodSignature(0, 0, stringType, new TypeDesc[] { bang1Type, bang0Type }); var iMultiGeneric = type.ExplicitlyImplementedInterfaces.First(); - var method0_1 = iMultiGeneric.GetMethod("Func", sigBang0Bang1); + var method0_1 = iMultiGeneric.GetMethod("Func"u8, sigBang0Bang1); Assert.NotNull(method0_1); - var method1_0 = iMultiGeneric.GetMethod("Func", sigBang1Bang0); + var method1_0 = iMultiGeneric.GetMethod("Func"u8, sigBang1Bang0); Assert.NotNull(method1_0); md1 = algo.ResolveInterfaceMethodToVirtualMethodOnType(method0_1, type); @@ -415,7 +416,7 @@ public void TestPreserveBaseOverridesBehavior(string exactScenarioName, string s (string typeToCallNamespace, string typeToCallTypeName) = SplitIntoNameAndNamespace(typeOfMethodToCallOn); var typeToCall = ilModule.GetType(typeToCallNamespace, typeToCallTypeName); - MethodDesc callMethod = typeToCall.GetMethod(methodName, null); + MethodDesc callMethod = typeToCall.GetMethod(Encoding.UTF8.GetBytes(methodName), null); Assert.NotNull(callMethod); MethodDesc resolvedMethod = constructedType.FindVirtualFunctionTargetMethodOnObjectType(callMethod); @@ -447,7 +448,7 @@ public void TestSubImplCovariant(string exactScenarioName, string typeToConstruc { this._logger.WriteLine("-----"); this._logger.WriteLine(baseClass.ToString()); - MethodDesc callMethod = baseClass.GetMethod("FromType", null); + MethodDesc callMethod = baseClass.GetMethod("FromType"u8, null); this._logger.WriteLine(callMethod.ToString()); Assert.NotNull(callMethod); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualStaticInterfaceMethodTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualStaticInterfaceMethodTests.cs index 3553f8adb332ec..a4963e9cce0ef1 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualStaticInterfaceMethodTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualStaticInterfaceMethodTests.cs @@ -30,32 +30,32 @@ public static IEnumerable VariantTestData() MetadataType genericVariantWithHiddenBase = testModule.GetType("VirtualStaticInterfaceMethods", "GenericVariantWithHiddenBase"); MetadataType genericVariantWithHiddenDerived = testModule.GetType("VirtualStaticInterfaceMethods", "GenericVariantWithHiddenDerived`1"); - MethodDesc iSimpleMethod = iSimple.GetMethod("WhichMethod", null); - MethodDesc iVariantBaseMethod = iVariant.MakeInstantiatedType(@base).GetMethod("WhichMethod", null); - MethodDesc iVariantMidMethod = iVariant.MakeInstantiatedType(mid).GetMethod("WhichMethod", null); - MethodDesc iVariantDerivedMethod = iVariant.MakeInstantiatedType(derived).GetMethod("WhichMethod", null); + MethodDesc iSimpleMethod = iSimple.GetMethod("WhichMethod"u8, null); + MethodDesc iVariantBaseMethod = iVariant.MakeInstantiatedType(@base).GetMethod("WhichMethod"u8, null); + MethodDesc iVariantMidMethod = iVariant.MakeInstantiatedType(mid).GetMethod("WhichMethod"u8, null); + MethodDesc iVariantDerivedMethod = iVariant.MakeInstantiatedType(derived).GetMethod("WhichMethod"u8, null); - yield return new object[] { simple, iSimpleMethod, simple.GetMethod("WhichMethod", null) }; + yield return new object[] { simple, iSimpleMethod, simple.GetMethod("WhichMethod"u8, null) }; - yield return new object[] { simpleVariant, iVariantBaseMethod, simpleVariant.GetMethod("WhichMethod", null) }; - yield return new object[] { simpleVariant, iVariantDerivedMethod, simpleVariant.GetMethod("WhichMethod", null) }; + yield return new object[] { simpleVariant, iVariantBaseMethod, simpleVariant.GetMethod("WhichMethod"u8, null) }; + yield return new object[] { simpleVariant, iVariantDerivedMethod, simpleVariant.GetMethod("WhichMethod"u8, null) }; - yield return new object[] { simpleVariantTwice, iVariantBaseMethod, simpleVariantTwice.GetMethod("WhichMethod", new MethodSignature(MethodSignatureFlags.Static, 0, context.GetWellKnownType(WellKnownType.String), new TypeDesc[] { @base })) }; - yield return new object[] { simpleVariantTwice, iVariantMidMethod, simpleVariantTwice.GetMethod("WhichMethod", new MethodSignature(MethodSignatureFlags.Static, 0, context.GetWellKnownType(WellKnownType.String), new TypeDesc[] { mid })) }; - yield return new object[] { simpleVariantTwice, iVariantDerivedMethod, simpleVariantTwice.GetMethod("WhichMethod", new MethodSignature(MethodSignatureFlags.Static, 0, context.GetWellKnownType(WellKnownType.String), new TypeDesc[] { @base })) }; + yield return new object[] { simpleVariantTwice, iVariantBaseMethod, simpleVariantTwice.GetMethod("WhichMethod"u8, new MethodSignature(MethodSignatureFlags.Static, 0, context.GetWellKnownType(WellKnownType.String), new TypeDesc[] { @base })) }; + yield return new object[] { simpleVariantTwice, iVariantMidMethod, simpleVariantTwice.GetMethod("WhichMethod"u8, new MethodSignature(MethodSignatureFlags.Static, 0, context.GetWellKnownType(WellKnownType.String), new TypeDesc[] { mid })) }; + yield return new object[] { simpleVariantTwice, iVariantDerivedMethod, simpleVariantTwice.GetMethod("WhichMethod"u8, new MethodSignature(MethodSignatureFlags.Static, 0, context.GetWellKnownType(WellKnownType.String), new TypeDesc[] { @base })) }; - yield return new object[] { variantWithInheritanceDerived, iVariantBaseMethod, variantWithInheritanceDerived.GetMethod("WhichMethod", null) }; - yield return new object[] { variantWithInheritanceDerived, iVariantMidMethod, variantWithInheritanceDerived.GetMethod("WhichMethod", null) }; - yield return new object[] { variantWithInheritanceDerived, iVariantDerivedMethod, variantWithInheritanceDerived.GetMethod("WhichMethod", null) }; + yield return new object[] { variantWithInheritanceDerived, iVariantBaseMethod, variantWithInheritanceDerived.GetMethod("WhichMethod"u8, null) }; + yield return new object[] { variantWithInheritanceDerived, iVariantMidMethod, variantWithInheritanceDerived.GetMethod("WhichMethod"u8, null) }; + yield return new object[] { variantWithInheritanceDerived, iVariantDerivedMethod, variantWithInheritanceDerived.GetMethod("WhichMethod"u8, null) }; - yield return new object[] { genericVariantWithInheritanceDerived.MakeInstantiatedType(@base), iVariantBaseMethod, genericVariantWithInheritanceDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod", null) }; - yield return new object[] { genericVariantWithInheritanceDerived.MakeInstantiatedType(@base), iVariantMidMethod, genericVariantWithInheritanceDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod", null) }; - yield return new object[] { genericVariantWithInheritanceDerived.MakeInstantiatedType(mid), iVariantMidMethod, genericVariantWithInheritanceDerived.MakeInstantiatedType(mid).GetMethod("WhichMethod", null) }; + yield return new object[] { genericVariantWithInheritanceDerived.MakeInstantiatedType(@base), iVariantBaseMethod, genericVariantWithInheritanceDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod"u8, null) }; + yield return new object[] { genericVariantWithInheritanceDerived.MakeInstantiatedType(@base), iVariantMidMethod, genericVariantWithInheritanceDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod"u8, null) }; + yield return new object[] { genericVariantWithInheritanceDerived.MakeInstantiatedType(mid), iVariantMidMethod, genericVariantWithInheritanceDerived.MakeInstantiatedType(mid).GetMethod("WhichMethod"u8, null) }; - yield return new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(@base), iVariantBaseMethod, genericVariantWithHiddenDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod", null) }; - yield return new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(@base), iVariantMidMethod, genericVariantWithHiddenDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod", null) }; - yield return new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(mid), iVariantMidMethod, genericVariantWithHiddenDerived.MakeInstantiatedType(mid).GetMethod("WhichMethod", null) }; - yield return new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(derived), iVariantMidMethod, genericVariantWithHiddenBase.GetMethod("WhichMethod", null) }; + yield return new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(@base), iVariantBaseMethod, genericVariantWithHiddenDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod"u8, null) }; + yield return new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(@base), iVariantMidMethod, genericVariantWithHiddenDerived.MakeInstantiatedType(@base).GetMethod("WhichMethod"u8, null) }; + yield return new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(mid), iVariantMidMethod, genericVariantWithHiddenDerived.MakeInstantiatedType(mid).GetMethod("WhichMethod"u8, null) }; + yield return new object[] { genericVariantWithHiddenDerived.MakeInstantiatedType(derived), iVariantMidMethod, genericVariantWithHiddenBase.GetMethod("WhichMethod"u8, null) }; } [Theory] diff --git a/src/coreclr/tools/aot/ILCompiler/Program.cs b/src/coreclr/tools/aot/ILCompiler/Program.cs index 14e54eb31043a8..d2892de5c66cf2 100644 --- a/src/coreclr/tools/aot/ILCompiler/Program.cs +++ b/src/coreclr/tools/aot/ILCompiler/Program.cs @@ -349,7 +349,7 @@ public int Run() // assume invalid code is present. Scanner may not detect all invalid code that RyuJIT detect. // If they disagree, we won't know how the vtable of InvalidProgramException should look like // and that would be a compiler crash. - MethodDesc throwInvalidProgramMethod = typeSystemContext.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramException"); + MethodDesc throwInvalidProgramMethod = typeSystemContext.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramException"u8); compilationRoots.Add( new GenericRootProvider(throwInvalidProgramMethod, (MethodDesc method, IRootingServiceProvider rooter) => rooter.AddCompilationRoot(method, "Invalid IL insurance"))); @@ -767,7 +767,7 @@ private MethodDesc CheckAndParseSingleMethodModeArguments(CompilerTypeSystemCont TypeDesc owningType = FindType(context, singleMethodTypeName); // TODO: allow specifying signature to distinguish overloads - MethodDesc method = owningType.GetMethod(singleMethodName, null); + MethodDesc method = owningType.GetMethod(Encoding.UTF8.GetBytes(singleMethodName), null); if (method == null) throw new CommandLineException($"Method '{singleMethodName}' not found in '{singleMethodTypeName}'"); diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemContext.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemContext.cs index 6c496e90d68482..741f924c1aa30f 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemContext.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemContext.cs @@ -144,7 +144,7 @@ public TypeRefTypeSystemContext(IEnumerable refReaders) } EcmaSignatureParser ecmaSigParse = new EcmaSignatureParser(this, ResolveTypeRefForPeInfo, peInfo.reader.GetBlobReader(memberRef.Signature), NotFoundBehavior.ReturnNull); - string name = peInfo.reader.GetString(memberRef.Name); + ReadOnlySpan name = peInfo.reader.GetStringBytes(memberRef.Name); if (memberRef.GetKind() == MemberReferenceKind.Method) { diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs index d4e3ed40eaf7da..72aada80d93ddf 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs @@ -13,20 +13,20 @@ namespace Microsoft.Diagnostics.Tools.Pgo.TypeRefTypeSystem class TypeRefTypeSystemField : FieldDesc { TypeRefTypeSystemType _type; - string _name; + byte[] _name; TypeDesc _fieldType; EmbeddedSignatureData[] _embeddedSignatureData; - public TypeRefTypeSystemField(TypeRefTypeSystemType type, string name, TypeDesc fieldType, EmbeddedSignatureData[] embeddedSigData) + public TypeRefTypeSystemField(TypeRefTypeSystemType type, ReadOnlySpan name, TypeDesc fieldType, EmbeddedSignatureData[] embeddedSigData) { _type = type; - _name = name; + _name = name.ToArray(); _fieldType = fieldType; _embeddedSignatureData = embeddedSigData; } - public override string Name => _name; - public override ReadOnlySpan U8Name => System.Text.Encoding.UTF8.GetBytes(_name); + public override string Name => System.Text.Encoding.UTF8.GetString(U8Name); + public override ReadOnlySpan U8Name => _name; public override DefType OwningType => _type; public override TypeDesc FieldType => _fieldType; diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemMethod.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemMethod.cs index ad8fdc35f7d31e..cae606c67bc44a 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemMethod.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemMethod.cs @@ -13,14 +13,14 @@ namespace Microsoft.Diagnostics.Tools.Pgo.TypeRefTypeSystem class TypeRefTypeSystemMethod : MethodDesc { TypeRefTypeSystemType _type; - string _name; + byte[] _name; MethodSignature _signature; Instantiation _instantiation; - public TypeRefTypeSystemMethod(TypeRefTypeSystemType type, string name, MethodSignature signature) + public TypeRefTypeSystemMethod(TypeRefTypeSystemType type, ReadOnlySpan name, MethodSignature signature) { _type = type; - _name = name; + _name = name.ToArray(); _signature = signature; if (signature.GenericParameterCount == 0) { @@ -37,9 +37,9 @@ public TypeRefTypeSystemMethod(TypeRefTypeSystemType type, string name, MethodSi } } - public override string Name => _name; + public override string Name => System.Text.Encoding.UTF8.GetString(U8Name); - public override ReadOnlySpan U8Name => System.Text.Encoding.UTF8.GetBytes(Name); + public override ReadOnlySpan U8Name => _name; public override Instantiation Instantiation => _instantiation; @@ -47,7 +47,7 @@ public TypeRefTypeSystemMethod(TypeRefTypeSystemType type, string name, MethodSi public override MethodSignature Signature => _signature; - public override string DiagnosticName => _name; + public override string DiagnosticName => GetName(); public override TypeSystemContext Context => OwningType.Context; diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs index b6ada5a0e49e8a..bb41a53ba4a16b 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs @@ -28,7 +28,7 @@ public TypeRefTypeSystemType GetOrAddType(string nameSpace, string name) TypeRefTypeSystemType type = GetTypeInternal(nameSpace, name); if (type == null) { - type = new TypeRefTypeSystemType(nameSpace, name, this); + type = new TypeRefTypeSystemType(nameSpace == null ? null : System.Text.Encoding.UTF8.GetBytes(nameSpace), name == null ? null : System.Text.Encoding.UTF8.GetBytes(name), this); Dictionary nameToTypeDictionary = _nonNamespacedTypes; if (!String.IsNullOrEmpty(nameSpace)) diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs index 7e5fee49a7a030..6977f31a924b99 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs @@ -23,17 +23,17 @@ class TypeRefTypeSystemType : MetadataType Dictionary _nestedType; TypeRefTypeSystemType _containingType; - public TypeRefTypeSystemType(string nameSpace, string name, TypeRefTypeSystemModule module) + public TypeRefTypeSystemType(ReadOnlySpan nameSpace, ReadOnlySpan name, TypeRefTypeSystemModule module) { - _namespace = string.IsNullOrEmpty(nameSpace) ? [] : Encoding.UTF8.GetBytes(nameSpace); - _name = string.IsNullOrEmpty(name) ? [] : Encoding.UTF8.GetBytes(name); + _namespace = nameSpace.ToArray(); + _name = name.ToArray(); _module = module; } - private TypeRefTypeSystemType(string nameSpace, string name, TypeRefTypeSystemType containingType, TypeRefTypeSystemModule module) + private TypeRefTypeSystemType(ReadOnlySpan nameSpace, ReadOnlySpan name, TypeRefTypeSystemType containingType, TypeRefTypeSystemModule module) { - _namespace = string.IsNullOrEmpty(nameSpace) ? [] : Encoding.UTF8.GetBytes(nameSpace); - _name = string.IsNullOrEmpty(name) ? [] : Encoding.UTF8.GetBytes(name); + _namespace = nameSpace.ToArray(); + _name = name.ToArray(); _module = module; _containingType = containingType; } @@ -99,14 +99,14 @@ public TypeRefTypeSystemType GetOrAddNestedType(string name) if (!_nestedType.TryGetValue(name, out TypeRefTypeSystemType type)) { - type = new TypeRefTypeSystemType(null, name, this, _module); + type = new TypeRefTypeSystemType(null, System.Text.Encoding.UTF8.GetBytes(name), this, _module); _nestedType.Add(name, type); } return type; } - public MethodDesc GetOrAddMethod(string name, MethodSignature signature) + public MethodDesc GetOrAddMethod(ReadOnlySpan name, MethodSignature signature) { MethodDesc method = GetMethod(name, signature); @@ -120,7 +120,7 @@ public MethodDesc GetOrAddMethod(string name, MethodSignature signature) return method; } - public FieldDesc GetOrAddField(string name, TypeDesc fieldType, EmbeddedSignatureData[] embeddedSigData) + public FieldDesc GetOrAddField(ReadOnlySpan name, TypeDesc fieldType, EmbeddedSignatureData[] embeddedSigData) { FieldDesc fld = GetField(name); if (fld == null) From 902502004f410bd6b0d968fc7e94b70c62e86e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Sun, 7 Sep 2025 22:38:18 +0200 Subject: [PATCH 11/19] Bug fixes --- .../Compiler/Logging/DocumentationSignatureParser.cs | 2 +- .../aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs index df89a4bf6b6bb7..c6867d18b74199 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs @@ -682,7 +682,7 @@ private static void GetMatchingFields(TypeDesc type, string memberName, List Date: Sun, 7 Sep 2025 22:44:49 +0200 Subject: [PATCH 12/19] GetType is now UTF-8 --- .../Common/Compiler/ProcessLinkerXmlBase.cs | 2 +- .../tools/Common/JitInterface/CorInfoImpl.cs | 4 +- .../Common/MetadataTypeSystemContext.cs | 2 +- .../Common/TypeSystem/Common/ModuleDesc.cs | 5 +- ...impleArrayOfTRuntimeInterfacesAlgorithm.cs | 4 +- .../CustomAttributeTypeNameParser.cs | 4 +- .../Ecma/CustomAttributeTypeProvider.cs | 2 +- .../Common/TypeSystem/Ecma/EcmaModule.cs | 13 ++- .../Common/TypeSystem/IL/HelperExtensions.cs | 17 +-- .../TypeSystem/IL/NativeAotILProvider.cs | 2 +- .../IL/Stubs/ArrayMethodILEmitter.cs | 10 +- ...AssemblyGetExecutingAssemblyMethodThunk.cs | 4 +- .../TypeSystem/IL/Stubs/ComparerIntrinsics.cs | 31 ++--- .../IL/Stubs/DelegateMethodILEmitter.cs | 4 +- .../TypeSystem/IL/Stubs/DelegateThunks.cs | 8 +- .../IL/Stubs/DynamicInvokeMethodThunk.cs | 2 +- .../Stubs/MethodBaseGetCurrentMethodThunk.cs | 4 +- .../TypeSystem/IL/Stubs/PInvokeILEmitter.cs | 8 +- .../IL/Stubs/PInvokeLazyFixupField.cs | 2 +- .../IL/Stubs/TypeGetTypeMethodThunk.cs | 2 +- .../IL/Stubs/TypeSystemThrowingILEmitter.cs | 18 +-- .../ValueTypeGetFieldHelperMethodOverride.cs | 8 +- .../Common/TypeSystem/IL/UnsafeAccessors.cs | 14 +-- .../TypeSystem/Interop/IL/Marshaller.Aot.cs | 72 ++++++------ .../TypeSystem/Interop/IL/Marshaller.cs | 10 +- .../Common/TypeSystem/Interop/InteropTypes.cs | 24 ++-- .../Interop/UnmanagedCallingConventions.cs | 18 +-- .../DependencyGraphTests.cs | 2 +- .../DevirtualizationTests.cs | 4 +- .../Compiler/BodySubstitution.cs | 2 +- .../Compiler/Compilation.cs | 2 +- .../Compiler/CompilerTypeSystemContext.Aot.cs | 10 +- .../CompilerTypeSystemContext.BoxedTypes.cs | 4 +- ...ilerTypeSystemContext.GeneratedAssembly.cs | 2 +- ...mpilerTypeSystemContext.InterfaceThunks.cs | 4 +- ...pilerTypeSystemContext.ValueTypeMethods.cs | 2 +- ...CustomAttributeBasedDependencyAlgorithm.cs | 26 ++--- .../FrozenRuntimeTypeNode.cs | 2 +- .../InlineableStringsResourceNode.cs | 2 +- .../DependencyAnalysis/NodeFactory.cs | 8 +- .../ReadyToRunGenericHelperNode.cs | 2 +- .../DependencyAnalysis/TentativeMethodNode.cs | 2 +- .../ILCompiler.Compiler/Compiler/JitHelper.cs | 106 +++++++++--------- .../Compiler/LibraryInitializers.cs | 4 +- .../Logging/DocumentationSignatureParser.cs | 2 +- .../Compiler/NoMetadataBlockingPolicy.cs | 2 +- .../Compiler/PreinitializationManager.cs | 2 +- .../ReachabilityInstrumentationFilter.cs | 2 +- .../ReachabilityInstrumentationProvider.cs | 2 +- .../Compiler/TypePreinit.cs | 2 +- .../Compiler/UserDefinedTypeDescriptor.cs | 2 +- .../IL/ILImporter.Scanner.cs | 4 +- .../StartupCode/NativeLibraryStartupMethod.cs | 2 +- .../StartupCode/StartupCodeMainMethod.cs | 2 +- .../Metadata/Transform.CustomAttribute.cs | 2 +- .../Compiler/ReadyToRunCompilerContext.cs | 20 ++-- .../IBC/IBCProfileParser.cs | 11 +- .../IBC/MIbcProfileParser.cs | 9 +- .../TypeSystem/Mutable/MutableModule.cs | 2 +- .../JitInterface/CorInfoImpl.RyuJit.cs | 4 +- .../MemberAssertionsCollector.cs | 3 +- .../ArchitectureSpecificFieldLayoutTests.cs | 84 +++++++------- .../CanonicalizationTests.cs | 16 +-- .../CastingTests.cs | 44 ++++---- .../ConstraintsValidationTest.cs | 50 ++++----- .../DefType.FieldLayoutTests.cs | 5 +- .../GCPointerMapTests.cs | 14 +-- .../GenericTypeAndMethodTests.cs | 18 +-- .../ILDisassemblerTests.cs | 2 +- .../InstanceFieldLayoutTests.cs | 104 ++++++++--------- .../InterfacesTests.cs | 36 +++--- .../MarshalUtilsTests.cs | 5 +- .../RuntimeDeterminedTypesTests.cs | 16 +-- .../SignatureTests.cs | 24 ++-- .../StaticFieldLayoutTests.cs | 20 ++-- .../SyntheticVirtualOverrideTests.cs | 10 +- .../TestTypeSystemContext.cs | 2 +- .../TypeEquivalenceTests.cs | 18 +-- .../TypeNameParsingTests.cs | 8 +- .../UniversalGenericFieldLayoutTests.cs | 10 +- .../ValueTypeShapeCharacteristicsTests.cs | 20 ++-- .../VirtualFunctionOverrideTests.cs | 42 +++---- .../VirtualStaticInterfaceMethodTests.cs | 24 ++-- src/coreclr/tools/aot/ILCompiler/Program.cs | 2 +- .../TypeRefTypeSystemModule.cs | 8 +- 85 files changed, 574 insertions(+), 559 deletions(-) diff --git a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs index 30e6711b0fc2d8..dd6a1f8076b7ed 100644 --- a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs +++ b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs @@ -771,7 +771,7 @@ public class CecilCompatibleTypeParser string @namespace, name; SplitFullName(fullName, out @namespace, out name); - return assembly.GetType(@namespace, name, throwIfNotFound: false); + return assembly.GetType(Encoding.UTF8.GetBytes(@namespace), Encoding.UTF8.GetBytes(name), throwIfNotFound: false); } private static MetadataType? GetNestedType(ModuleDesc assembly, string fullName) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index a5d30e4b2f02ba..8cb19511cd87ce 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -1553,7 +1553,7 @@ static CORINFO_RESOLVED_TOKEN CreateResolvedTokenFromMethod(CorInfoImpl jitInter private CORINFO_CLASS_STRUCT_* getSZArrayHelperEnumeratorClass(CORINFO_CLASS_STRUCT_* elemType) { TypeDesc elementType = HandleToObject(elemType); - MetadataType placeholderType = _compilation.TypeSystemContext.SystemModule.GetType("System", "SZGenericArrayEnumerator`1", throwIfNotFound: false); + MetadataType placeholderType = _compilation.TypeSystemContext.SystemModule.GetType("System"u8, "SZGenericArrayEnumerator`1"u8, throwIfNotFound: false); if (placeholderType == null) { return null; @@ -2803,7 +2803,7 @@ private CorInfoInitClassResult initClass(CORINFO_FIELD_STRUCT_* field, CORINFO_M return ObjectToHandle(_compilation.TypeSystemContext.GetWellKnownType(WellKnownType.String)); case CorInfoClassId.CLASSID_RUNTIME_TYPE: - return ObjectToHandle(_compilation.TypeSystemContext.SystemModule.GetKnownType("System", "RuntimeType")); + return ObjectToHandle(_compilation.TypeSystemContext.SystemModule.GetKnownType("System"u8, "RuntimeType"u8)); default: throw new NotImplementedException(); diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs index 2a71ef8a71def4..72f2ab0aa5397f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs @@ -72,7 +72,7 @@ public virtual void SetSystemModule(ModuleDesc systemModule) { // Require System.Object to be present as a minimal sanity check. // The set of required well-known types is not strictly defined since different .NET profiles implement different subsets. - MetadataType type = systemModule.GetType("System", s_wellKnownTypeNames[typeIndex], throwIfNotFound: typeIndex == (int)WellKnownType.Object); + MetadataType type = systemModule.GetType("System"u8, System.Text.Encoding.UTF8.GetBytes(s_wellKnownTypeNames[typeIndex]), throwIfNotFound: typeIndex == (int)WellKnownType.Object); if (type != null) { type.SetWellKnownType((WellKnownType)(typeIndex + 1)); diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ModuleDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/ModuleDesc.cs index d76420e73f2be2..200c26c0bb034d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ModuleDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ModuleDesc.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; #if TYPE_LOADER_IMPLEMENTATION @@ -33,7 +34,7 @@ public ModuleDesc(TypeSystemContext context, IAssemblyDesc assembly) /// /// Gets a type in this module or null. /// - public MetadataType GetType(string nameSpace, string name, bool throwIfNotFound = true) + public MetadataType GetType(ReadOnlySpan nameSpace, ReadOnlySpan name, bool throwIfNotFound = true) { return (MetadataType)GetType(nameSpace, name, throwIfNotFound ? NotFoundBehavior.Throw : NotFoundBehavior.ReturnNull); } @@ -41,7 +42,7 @@ public MetadataType GetType(string nameSpace, string name, bool throwIfNotFound /// /// Gets a type in this module with the specified name, a resolution failure object, or null. /// - public abstract object GetType(string nameSpace, string name, NotFoundBehavior notFoundBehavior); + public abstract object GetType(ReadOnlySpan nameSpace, ReadOnlySpan name, NotFoundBehavior notFoundBehavior); /// /// Gets the global <Module> type. diff --git a/src/coreclr/tools/Common/TypeSystem/Common/SimpleArrayOfTRuntimeInterfacesAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/SimpleArrayOfTRuntimeInterfacesAlgorithm.cs index 166f09fc7deb41..bf169d55d5c971 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/SimpleArrayOfTRuntimeInterfacesAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/SimpleArrayOfTRuntimeInterfacesAlgorithm.cs @@ -26,14 +26,14 @@ public SimpleArrayOfTRuntimeInterfacesAlgorithm(ModuleDesc systemModule) _systemModule = systemModule; // initialize interfaces - _arrayRuntimeInterfaces = _systemModule.GetType("System", "Array")?.RuntimeInterfaces + _arrayRuntimeInterfaces = _systemModule.GetType("System"u8, "Array"u8)?.RuntimeInterfaces ?? Array.Empty(); _genericRuntimeInterfaces = new MetadataType[s_genericRuntimeInterfacesNames.Length]; int count = 0; for (int i = 0; i < s_genericRuntimeInterfacesNames.Length; ++i) { - MetadataType runtimeInterface =_systemModule.GetType("System.Collections.Generic", s_genericRuntimeInterfacesNames[i], throwIfNotFound: false); + MetadataType runtimeInterface =_systemModule.GetType("System.Collections.Generic"u8, System.Text.Encoding.UTF8.GetBytes(s_genericRuntimeInterfacesNames[i]), throwIfNotFound: false); if (runtimeInterface != null) _genericRuntimeInterfaces[count++] = runtimeInterface; }; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs index 8f2eda81f66068..f43f41eeb86bd1 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs @@ -190,7 +190,9 @@ private TypeDesc GetSimpleTypeFromModule(TypeName typeName, ModuleDesc module) return canonType; } - return module.GetType(TypeName.Unescape(typeName.Namespace), TypeName.Unescape(typeName.Name), throwIfNotFound: false); + return module.GetType( + System.Text.Encoding.UTF8.GetBytes(TypeName.Unescape(typeName.Namespace)), + System.Text.Encoding.UTF8.GetBytes(TypeName.Unescape(typeName.Name)), throwIfNotFound: false); } private TypeDesc GetGenericType(TypeName typeName) diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs index 43c366e5e4da8f..d7f4d9ad6a6967 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs @@ -24,7 +24,7 @@ public TypeDesc GetPrimitiveType(PrimitiveTypeCode typeCode) public TypeDesc GetSystemType() { - MetadataType systemType = _module.Context.SystemModule.GetType("System", "Type"); + MetadataType systemType = _module.Context.SystemModule.GetType("System"u8, "Type"u8); return systemType; } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs index f32e9a871f2ca8..b8e393ae6bb34a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs @@ -7,6 +7,7 @@ using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; using System.Reflection.PortableExecutable; +using System.Text; using Debug = System.Diagnostics.Debug; @@ -317,13 +318,13 @@ public bool IsPlatformNeutral return _nameLookupCache = result; } - public sealed override object GetType(string nameSpace, string name, NotFoundBehavior notFoundBehavior) + public sealed override object GetType(ReadOnlySpan nameSpace, ReadOnlySpan name, NotFoundBehavior notFoundBehavior) { var currentModule = this; // src/coreclr/vm/clsload.cpp use the same restriction to detect a loop in the type forwarding. for (int typeForwardingChainSize = 0; typeForwardingChainSize <= 1024; typeForwardingChainSize++) { - if ((currentModule._nameLookupCache ?? currentModule.CreateNameLookupCache()).TryGetValue((name, nameSpace), out EntityHandle foundHandle)) + if ((currentModule._nameLookupCache ?? currentModule.CreateNameLookupCache()).TryGetValue((System.Text.Encoding.UTF8.GetString(name.ToArray()), System.Text.Encoding.UTF8.GetString(nameSpace.ToArray())), out EntityHandle foundHandle)) { if (foundHandle.Kind == HandleKind.TypeDefinition) return currentModule.GetType((TypeDefinitionHandle)foundHandle); @@ -366,7 +367,7 @@ public sealed override object GetType(string nameSpace, string name, NotFoundBeh if (notFoundBehavior != NotFoundBehavior.ReturnNull) { - var failure = ResolutionFailure.GetTypeLoadResolutionFailure(nameSpace, name, this); + var failure = ResolutionFailure.GetTypeLoadResolutionFailure(Encoding.UTF8.GetString(nameSpace.ToArray()), Encoding.UTF8.GetString(name.ToArray()), this); if (notFoundBehavior == NotFoundBehavior.Throw) failure.Throw(); @@ -594,7 +595,7 @@ private object ResolveTypeReference(TypeReferenceHandle handle) if (resolutionScope is ModuleDesc) { - return ((ModuleDesc)(resolutionScope)).GetType(_metadataReader.GetString(typeReference.Namespace), _metadataReader.GetString(typeReference.Name), NotFoundBehavior.ReturnResolutionFailure); + return ((ModuleDesc)(resolutionScope)).GetType(_metadataReader.GetStringBytes(typeReference.Namespace), _metadataReader.GetStringBytes(typeReference.Name), NotFoundBehavior.ReturnResolutionFailure); } else if (resolutionScope is MetadataType) @@ -640,8 +641,8 @@ private object ResolveExportedType(ExportedTypeHandle handle) var implementation = GetObject(exportedType.Implementation, NotFoundBehavior.ReturnResolutionFailure); if (implementation is ModuleDesc module) { - string nameSpace = _metadataReader.GetString(exportedType.Namespace); - string name = _metadataReader.GetString(exportedType.Name); + ReadOnlySpan nameSpace = _metadataReader.GetStringBytes(exportedType.Namespace); + ReadOnlySpan name = _metadataReader.GetStringBytes(exportedType.Name); return module.GetType(nameSpace, name, NotFoundBehavior.ReturnResolutionFailure); } else diff --git a/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs b/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs index 7c3147ec4452d6..52aee2f56a5449 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/HelperExtensions.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Text; using Internal.TypeSystem; using Internal.IL.Stubs; @@ -12,34 +13,34 @@ namespace Internal.IL { internal static class HelperExtensions { - private const string HelperTypesNamespace = "Internal.Runtime.CompilerHelpers"; + private static ReadOnlySpan HelperTypesNamespace => "Internal.Runtime.CompilerHelpers"u8; - public static MetadataType GetHelperType(this TypeSystemContext context, string name) + public static MetadataType GetHelperType(this TypeSystemContext context, ReadOnlySpan name) { MetadataType helperType = context.SystemModule.GetKnownType(HelperTypesNamespace, name); return helperType; } - public static MetadataType GetOptionalHelperType(this TypeSystemContext context, string name) + public static MetadataType GetOptionalHelperType(this TypeSystemContext context, ReadOnlySpan name) { MetadataType helperType = context.SystemModule.GetType(HelperTypesNamespace, name, throwIfNotFound: false); return helperType; } - public static MethodDesc GetHelperEntryPoint(this TypeSystemContext context, string typeName, ReadOnlySpan methodName) + public static MethodDesc GetHelperEntryPoint(this TypeSystemContext context, ReadOnlySpan typeName, ReadOnlySpan methodName) { MetadataType helperType = context.GetHelperType(typeName); MethodDesc helperMethod = helperType.GetKnownMethod(methodName, null); return helperMethod; } - public static MethodDesc GetCoreLibEntryPoint(this TypeSystemContext context, string namespaceName, string typeName, ReadOnlySpan methodName, MethodSignature signature) + public static MethodDesc GetCoreLibEntryPoint(this TypeSystemContext context, ReadOnlySpan namespaceName, ReadOnlySpan typeName, ReadOnlySpan methodName, MethodSignature signature) { MetadataType owningType = context.SystemModule.GetKnownType(namespaceName, typeName); return owningType.GetKnownMethod(methodName, signature); } - public static MethodDesc GetOptionalHelperEntryPoint(this TypeSystemContext context, string typeName, ReadOnlySpan methodName) + public static MethodDesc GetOptionalHelperEntryPoint(this TypeSystemContext context, ReadOnlySpan typeName, ReadOnlySpan methodName) { MetadataType helperType = context.GetOptionalHelperType(typeName); MethodDesc helperMethod = helperType?.GetMethod(methodName, null); @@ -115,14 +116,14 @@ public static MetadataType GetKnownNestedType(this MetadataType type, string nam /// Retrieves a namespace type in that is well known to the compiler. /// Throws an exception if the type doesn't exist. /// - public static MetadataType GetKnownType(this ModuleDesc module, string @namespace, string name) + public static MetadataType GetKnownType(this ModuleDesc module, ReadOnlySpan @namespace, ReadOnlySpan name) { MetadataType type = module.GetType(@namespace, name, throwIfNotFound: false); if (type == null) { throw new InvalidOperationException( string.Format("Expected type '{0}' not found in module '{1}'", - @namespace.Length > 0 ? string.Concat(@namespace, ".", name) : name, + @namespace.Length > 0 ? string.Concat(Encoding.UTF8.GetString(@namespace), ".", Encoding.UTF8.GetString(name)) : Encoding.UTF8.GetString(name), module)); } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs index 59b2b69855849a..9c1e98ba93ae30 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs @@ -261,7 +261,7 @@ private static MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc metho static MethodDesc GetMethodToCall(TypeDesc elementType) { TypeSystemContext context = elementType.Context; - MetadataType helperType = context.SystemModule.GetKnownType("Internal.IntrinsicSupport", "EqualityComparerHelpers"); + MetadataType helperType = context.SystemModule.GetKnownType("Internal.IntrinsicSupport"u8, "EqualityComparerHelpers"u8); if (elementType.IsEnum) return helperType.GetKnownMethod("EnumOnlyEquals"u8, null) diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs index 20ca143c9c425c..b3f272f1e7e292 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ArrayMethodILEmitter.cs @@ -94,7 +94,7 @@ private void EmitILForAccessor() if (_method.Kind == ArrayMethodKind.Set) { MethodDesc checkArrayStore = - context.SystemModule.GetKnownType("System.Runtime", "RuntimeImports").GetKnownMethod("RhCheckArrayStore"u8, null); + context.SystemModule.GetKnownType("System.Runtime"u8, "RuntimeImports"u8).GetKnownMethod("RhCheckArrayStore"u8, null); codeStream.EmitLdArg(0); codeStream.EmitLdArg(_rank + argStartOffset); @@ -104,7 +104,7 @@ private void EmitILForAccessor() else if (_method.Kind == ArrayMethodKind.AddressWithHiddenArg) { TypeDesc objectType = context.GetWellKnownType(WellKnownType.Object); - TypeDesc eetypeType = context.SystemModule.GetKnownType("Internal.Runtime", "MethodTable"); + TypeDesc eetypeType = context.SystemModule.GetKnownType("Internal.Runtime"u8, "MethodTable"u8); typeMismatchExceptionLabel = _emitter.NewCodeLabel(); @@ -143,7 +143,7 @@ private void EmitILForAccessor() if (_rank == 1) { TypeDesc objectType = context.GetWellKnownType(WellKnownType.Object); - TypeDesc eetypeType = context.SystemModule.GetKnownType("Internal.Runtime", "MethodTable"); + TypeDesc eetypeType = context.SystemModule.GetKnownType("Internal.Runtime"u8, "MethodTable"u8); codeStream.EmitLdArg(0); codeStream.Emit(ILOpcode.ldfld, _emitter.NewToken(objectType.GetKnownField("m_pEEType"u8))); @@ -238,13 +238,13 @@ private void EmitILForAccessor() codeStream.EmitLabel(rangeExceptionLabel); // Assumes that there is one "int" pushed on the stack codeStream.Emit(ILOpcode.pop); - MethodDesc throwHelper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowIndexOutOfRangeException"u8); + MethodDesc throwHelper = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowIndexOutOfRangeException"u8); codeStream.EmitCallThrowHelper(_emitter, throwHelper); if (typeMismatchExceptionLabel != null) { codeStream.EmitLabel(typeMismatchExceptionLabel); - codeStream.EmitCallThrowHelper(_emitter, context.GetHelperEntryPoint("ThrowHelpers", "ThrowArrayTypeMismatchException"u8)); + codeStream.EmitCallThrowHelper(_emitter, context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowArrayTypeMismatchException"u8)); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs index 639a333b87621c..349280f168982c 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs @@ -21,7 +21,7 @@ public AssemblyGetExecutingAssemblyMethodThunk(TypeDesc owningType, IAssemblyDes TypeSystemContext context = owningType.Context; Signature = new MethodSignature(MethodSignatureFlags.Static, 0, - context.SystemModule.GetKnownType("System.Reflection", "Assembly"), TypeDesc.EmptyTypes); + context.SystemModule.GetKnownType("System.Reflection"u8, "Assembly"u8), TypeDesc.EmptyTypes); } public override TypeSystemContext Context @@ -76,7 +76,7 @@ public override MethodIL EmitIL() ILEmitter emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - MethodDesc classlibHelper = Context.GetHelperEntryPoint("ReflectionHelpers", "GetExecutingAssembly"u8); + MethodDesc classlibHelper = Context.GetHelperEntryPoint("ReflectionHelpers"u8, "GetExecutingAssembly"u8); // Use the global module type as "a type from the assembly that has metadata" // Our reflection policy always makes sure this has metadata. diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs index 3d2bedf4123e3a..eaa1d056a28e84 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ComparerIntrinsics.cs @@ -90,19 +90,19 @@ private static TypeDesc GetComparerForType(TypeDesc type, string flavor, string if (type.IsNullable) { - return context.SystemModule.GetKnownType("System.Collections.Generic", $"Nullable{flavor}`1") + return context.SystemModule.GetKnownType("System.Collections.Generic"u8, $"Nullable{flavor}`1") .MakeInstantiatedType(type.Instantiation[0]); } if (type.IsString && flavor == "EqualityComparer") { - return context.SystemModule.GetKnownType("System.Collections.Generic", "StringEqualityComparer"); + return context.SystemModule.GetKnownType("System.Collections.Generic"u8, "StringEqualityComparer"u8); } if (type.IsEnum) { // Enums have a specialized comparer that avoids boxing - return context.SystemModule.GetKnownType("System.Collections.Generic", $"Enum{flavor}`1") + return context.SystemModule.GetKnownType("System.Collections.Generic"u8, $"Enum{flavor}`1") .MakeInstantiatedType(type); } @@ -112,7 +112,7 @@ private static TypeDesc GetComparerForType(TypeDesc type, string flavor, string return null; } - return context.SystemModule.GetKnownType("System.Collections.Generic", implementsInterfaceOfSelf.Value ? $"Generic{flavor}`1" : $"Object{flavor}`1") + return context.SystemModule.GetKnownType("System.Collections.Generic"u8, implementsInterfaceOfSelf.Value ? $"Generic{flavor}`1" : $"Object{flavor}`1") .MakeInstantiatedType(type); } @@ -150,16 +150,16 @@ private static TypeDesc[] GetPotentialComparersForTypeCommon(TypeDesc type, stri ArrayBuilder universalComparers = default(ArrayBuilder); - universalComparers.Add(context.SystemModule.GetKnownType("System.Collections.Generic", $"Nullable{flavor}`1") + universalComparers.Add(context.SystemModule.GetKnownType("System.Collections.Generic"u8, $"Nullable{flavor}`1") .MakeInstantiatedType(type)); - universalComparers.Add(context.SystemModule.GetKnownType("System.Collections.Generic", $"Enum{flavor}`1") + universalComparers.Add(context.SystemModule.GetKnownType("System.Collections.Generic"u8, $"Enum{flavor}`1") .MakeInstantiatedType(type)); - universalComparers.Add(context.SystemModule.GetKnownType("System.Collections.Generic", $"Generic{flavor}`1") + universalComparers.Add(context.SystemModule.GetKnownType("System.Collections.Generic"u8, $"Generic{flavor}`1") .MakeInstantiatedType(type)); - universalComparers.Add(context.SystemModule.GetKnownType("System.Collections.Generic", $"Object{flavor}`1") + universalComparers.Add(context.SystemModule.GetKnownType("System.Collections.Generic"u8, $"Object{flavor}`1") .MakeInstantiatedType(type)); return universalComparers.ToArray(); @@ -179,18 +179,18 @@ private static TypeDesc[] GetPotentialComparersForTypeCommon(TypeDesc type, stri return new TypeDesc[] { - context.SystemModule.GetKnownType("System.Collections.Generic", $"Nullable{flavor}`1") + context.SystemModule.GetKnownType("System.Collections.Generic"u8, $"Nullable{flavor}`1") .MakeInstantiatedType(nullableType), - context.SystemModule.GetKnownType("System.Collections.Generic", $"Object{flavor}`1") + context.SystemModule.GetKnownType("System.Collections.Generic"u8, $"Object{flavor}`1") .MakeInstantiatedType(type), }; } return new TypeDesc[] { - context.SystemModule.GetKnownType("System.Collections.Generic", $"Generic{flavor}`1") + context.SystemModule.GetKnownType("System.Collections.Generic"u8, $"Generic{flavor}`1") .MakeInstantiatedType(type), - context.SystemModule.GetKnownType("System.Collections.Generic", $"Object{flavor}`1") + context.SystemModule.GetKnownType("System.Collections.Generic"u8, $"Object{flavor}`1") .MakeInstantiatedType(type), }; } @@ -207,7 +207,7 @@ private static TypeDesc[] GetPotentialComparersForTypeCommon(TypeDesc type, stri Instantiation interfaceInstantiation = implementedInterface.Instantiation; if (interfaceInstantiation.Length == 1) { - interfaceType ??= interfaceType = type.Context.SystemModule.GetKnownType("System", interfaceName); + interfaceType ??= interfaceType = type.Context.SystemModule.GetKnownType("System"u8, interfaceName); if (implementedInterface.GetTypeDefinition() == interfaceType) { @@ -361,6 +361,11 @@ public bool HasGapsBeforeOffset(int offset) return false; } } + } + file static class Extensions + { + public static MetadataType GetKnownType(this ModuleDesc module, ReadOnlySpan @namespace, string name) + => module.GetKnownType(@namespace, System.Text.Encoding.UTF8.GetBytes(name)); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs index f0640001999c39..07189b46f92491 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs @@ -22,7 +22,7 @@ public static MethodIL EmitIL(MethodDesc method) // BeginInvoke and EndInvoke are not supported on .NET Core ILEmitter emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - MethodDesc notSupportedExceptionHelper = method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowPlatformNotSupportedException"u8); + MethodDesc notSupportedExceptionHelper = method.Context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowPlatformNotSupportedException"u8); codeStream.EmitCallThrowHelper(emit, notSupportedExceptionHelper); return emit.Link(method); } @@ -37,7 +37,7 @@ public static MethodIL EmitIL(MethodDesc method) // but it remains to be proven that this is an actual customer scenario. ILEmitter emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - MethodDesc notSupportedExceptionHelper = method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowPlatformNotSupportedException"u8); + MethodDesc notSupportedExceptionHelper = method.Context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowPlatformNotSupportedException"u8); codeStream.EmitCallThrowHelper(emit, notSupportedExceptionHelper); return emit.Link(method); } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs index 9b0e456aed1690..f1463c93f6c7aa 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs @@ -166,7 +166,7 @@ public override MethodIL EmitIL(MethodDesc specializedMethod) { var emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - codeStream.EmitCallThrowHelper(emit, Context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedException"u8)); + codeStream.EmitCallThrowHelper(emit, Context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowNotSupportedException"u8)); return emit.Link(specializedMethod); } @@ -533,7 +533,7 @@ public override MethodIL EmitIL(MethodDesc specializedMethod) { var emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - codeStream.EmitCallThrowHelper(emit, Context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedException"u8)); + codeStream.EmitCallThrowHelper(emit, Context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowNotSupportedException"u8)); return emit.Link(specializedMethod); } @@ -603,7 +603,7 @@ public override MethodIL EmitIL() } else { - MethodDesc emptyObjectArrayMethod = Context.GetHelperEntryPoint("DelegateHelpers", "GetEmptyObjectArray"u8); + MethodDesc emptyObjectArrayMethod = Context.GetHelperEntryPoint("DelegateHelpers"u8, "GetEmptyObjectArray"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(emptyObjectArrayMethod)); codeStream.EmitStLoc(argsLocal); } @@ -619,7 +619,7 @@ public override MethodIL EmitIL() codeStream.EmitLdArg(0); codeStream.Emit(ILOpcode.ldfld, emitter.NewToken(HelperObjectField)); - MetadataType funcType = Context.SystemModule.GetKnownType("System", "Func`2"); + MetadataType funcType = Context.SystemModule.GetKnownType("System"u8, "Func`2"u8); TypeDesc instantiatedFunc = funcType.MakeInstantiatedType(objectArrayType, objectType); codeStream.Emit(ILOpcode.castclass, emitter.NewToken(instantiatedFunc)); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs index 63e5226a4fb98a..6128aa595a1e7d 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs @@ -145,7 +145,7 @@ public override MethodIL EmitIL() if (_targetSignature.Length != 0) { var fieldByReferenceValueToken = emitter.NewToken( - Context.SystemModule.GetKnownType("System", "ByReference").GetKnownField("Value"u8)); + Context.SystemModule.GetKnownType("System"u8, "ByReference"u8).GetKnownField("Value"u8)); for (int i = 0; i < _targetSignature.Length; i++) { codeStream.EmitLdArg(3); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs index fd28193a43a499..c3f0301f0c50c1 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs @@ -21,7 +21,7 @@ public MethodBaseGetCurrentMethodThunk(MethodDesc method) Method = method; Signature = new MethodSignature(MethodSignatureFlags.Static, 0, - Context.SystemModule.GetKnownType("System.Reflection", "MethodBase"), TypeDesc.EmptyTypes); + Context.SystemModule.GetKnownType("System.Reflection"u8, "MethodBase"u8), TypeDesc.EmptyTypes); } public override TypeSystemContext Context @@ -90,7 +90,7 @@ public override MethodIL EmitIL() else helperName = "GetCurrentMethodNonGeneric"u8; - MethodDesc classlibHelper = Context.GetHelperEntryPoint("ReflectionHelpers", helperName); + MethodDesc classlibHelper = Context.GetHelperEntryPoint("ReflectionHelpers"u8, helperName); codeStream.Emit(ILOpcode.call, emit.NewToken(classlibHelper)); codeStream.Emit(ILOpcode.ret); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs index 56135dabfa27b3..adac4052ca6864 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeILEmitter.cs @@ -173,7 +173,7 @@ private void EmitDelegateCall(DelegateMarshallingMethodThunk delegateMethod, PIn MethodSignatureFlags.Static, 0, _marshallers[0].ManagedParameterType, parameters); fnptrLoadStream.Emit(ILOpcode.call, emitter.NewToken( - delegateMethod.Context.GetHelperType("InteropHelpers").GetKnownMethod( + delegateMethod.Context.GetHelperType("InteropHelpers"u8).GetKnownMethod( "GetCurrentCalleeOpenStaticDelegateFunctionPointer"u8, null))); ILLocalVariable vDelegateStub = emitter.NewLocal( @@ -191,7 +191,7 @@ private void EmitDelegateCall(DelegateMarshallingMethodThunk delegateMethod, PIn // which returns the delegate. Do a CallVirt on the invoke method. // MethodDesc instantiatedHelper = delegateMethod.Context.GetInstantiatedMethod( - delegateMethod.Context.GetHelperType("InteropHelpers") + delegateMethod.Context.GetHelperType("InteropHelpers"u8) .GetKnownMethod("GetCurrentCalleeDelegate"u8, null), new Instantiation((delegateMethod.DelegateType))); @@ -304,7 +304,7 @@ private void EmitPInvokeCall(PInvokeILCodeStreams ilCodeStreams) MethodSignatureFlags.Static | MethodSignatureFlags.UnmanagedCallingConvention, 0, nativeReturnType, nativeParameterTypes, _targetMethod.GetPInvokeMethodCallingConventions().EncodeAsEmbeddedSignatureData(context)); - MetadataType lazyHelperType = context.GetHelperType("InteropHelpers"); + MetadataType lazyHelperType = context.GetHelperType("InteropHelpers"u8); FieldDesc lazyDispatchCell = _interopStateManager.GetPInvokeLazyFixupField(_targetMethod, nativeSig); fnptrLoadStream.Emit(ILOpcode.ldsflda, emitter.NewToken(lazyDispatchCell)); @@ -348,7 +348,7 @@ private void EmitPInvokeCall(PInvokeILCodeStreams ilCodeStreams) if (MarshalHelpers.ShouldCheckForPendingException(context.Target, _pInvokeMetadata)) { - MetadataType lazyHelperType = context.SystemModule.GetKnownType("System.Runtime.InteropServices.ObjectiveC", "ObjectiveCMarshal"); + MetadataType lazyHelperType = context.SystemModule.GetKnownType("System.Runtime.InteropServices.ObjectiveC"u8, "ObjectiveCMarshal"u8); callsiteSetupCodeStream.Emit(ILOpcode.call, emitter.NewToken(lazyHelperType .GetKnownMethod("ThrowPendingExceptionObject"u8, null))); } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs index 88ea8f6384b2dd..7aeddde871641a 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs @@ -63,7 +63,7 @@ public override TypeDesc FieldType { get { - return Context.GetHelperType("InteropHelpers").GetNestedType("MethodFixupCell"); + return Context.GetHelperType("InteropHelpers"u8).GetNestedType("MethodFixupCell"); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs index 6c6f5f45f6f66c..d2a3d26ef588ce 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs @@ -185,7 +185,7 @@ protected override TypeGetTypeMethodThunk CreateValueFromKey(Key key) else helperName = "GetType"u8; - MethodDesc helper = context.GetHelperEntryPoint("ReflectionHelpers", helperName); + MethodDesc helper = context.GetHelperEntryPoint("ReflectionHelpers"u8, helperName); return new TypeGetTypeMethodThunk(_parent._owningTypeForThunks, signature, helper, key.DefaultAssemblyName); } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeSystemThrowingILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeSystemThrowingILEmitter.cs index 093e9914abc561..e04df500733789 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeSystemThrowingILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeSystemThrowingILEmitter.cs @@ -29,24 +29,24 @@ public static MethodIL EmitIL(MethodDesc methodThatShouldThrow, TypeSystemExcept // There are two ThrowTypeLoadException helpers. Find the one which matches the number of // arguments "exception" was initialized with. // - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowTypeLoadException"u8); + helper = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowTypeLoadException"u8); if (helper.Signature.Length != exception.Arguments.Count + 1) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowTypeLoadExceptionWithArgument"u8); + helper = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowTypeLoadExceptionWithArgument"u8); } } else if (exceptionType == typeof(TypeSystemException.MissingFieldException)) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingFieldException"u8); + helper = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowMissingFieldException"u8); } else if (exceptionType == typeof(TypeSystemException.MissingMethodException)) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingMethodException"u8); + helper = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowMissingMethodException"u8); } else if (exceptionType == typeof(TypeSystemException.FileNotFoundException)) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowFileNotFoundException"u8); + helper = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowFileNotFoundException"u8); } else if (exceptionType == typeof(TypeSystemException.InvalidProgramException)) { @@ -55,20 +55,20 @@ public static MethodIL EmitIL(MethodDesc methodThatShouldThrow, TypeSystemExcept // arguments "exception" was initialized with. // - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramException"u8); + helper = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowInvalidProgramException"u8); if (helper.Signature.Length != exception.Arguments.Count + 1) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramExceptionWithArgument"u8); + helper = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowInvalidProgramExceptionWithArgument"u8); } } else if (exceptionType == typeof(TypeSystemException.BadImageFormatException)) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowBadImageFormatException"u8); + helper = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowBadImageFormatException"u8); } else if (exceptionType == typeof(TypeSystemException.MarshalDirectiveException)) { - helper = context.GetHelperEntryPoint("ThrowHelpers", "ThrowMarshalDirectiveException"u8); + helper = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowMarshalDirectiveException"u8); } else { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs index 922643be0da383..539ca5491b436f 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs @@ -51,7 +51,7 @@ public override MethodSignature Signature { TypeSystemContext context = _owningType.Context; TypeDesc int32Type = context.GetWellKnownType(WellKnownType.Int32); - TypeDesc eeTypePtrType = context.SystemModule.GetKnownType("Internal.Runtime", "MethodTable").MakePointerType(); + TypeDesc eeTypePtrType = context.SystemModule.GetKnownType("Internal.Runtime"u8, "MethodTable"u8).MakePointerType(); _signature = new MethodSignature(0, 0, int32Type, [ int32Type, eeTypePtrType.MakeByRefType() ]); } @@ -80,7 +80,7 @@ private MethodIL EmitILCommon(MethodDesc contextMethod) if (_owningType.IsInlineArray) { var stream = emitter.NewCodeStream(); - MethodDesc thrower = Context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedInlineArrayEqualsGetHashCode"u8); + MethodDesc thrower = Context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowNotSupportedInlineArrayEqualsGetHashCode"u8); stream.EmitCallThrowHelper(emitter, thrower); return emitter.Link(this); } @@ -93,13 +93,13 @@ private MethodIL EmitILCommon(MethodDesc contextMethod) return emitter.Link(this); } - TypeDesc methodTableType = Context.SystemModule.GetKnownType("Internal.Runtime", "MethodTable"); + TypeDesc methodTableType = Context.SystemModule.GetKnownType("Internal.Runtime"u8, "MethodTable"u8); MethodDesc methodTableOfMethod = methodTableType.GetKnownMethod("Of"u8, null); var owningType = (MetadataType)_owningType.InstantiateAsOpen(); ILToken rawDataToken = owningType.IsValueType ? default : - emitter.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices", "RawData").GetKnownField("Data"u8)); + emitter.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices"u8, "RawData"u8).GetKnownField("Data"u8)); var switchStream = emitter.NewCodeStream(); var getFieldStream = emitter.NewCodeStream(); diff --git a/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs b/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs index af307307aadae4..464105b2395b1a 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/UnsafeAccessors.cs @@ -812,20 +812,20 @@ private static MethodIL GenerateAccessorSpecificFailure(ref GenerationContext co if (result is SetTargetResult.Ambiguous) { codeStream.EmitLdc((int)ExceptionStringID.AmbiguousMatchUnsafeAccessor); - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowAmbiguousMatchException"u8); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowAmbiguousMatchException"u8); } else if (result is SetTargetResult.Invalid) { codeStream.EmitLdc((int)ExceptionStringID.InvalidProgramDefault); - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramException"u8); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowInvalidProgramException"u8); } else if (result is SetTargetResult.NotSupported) { - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowNotSupportedException"u8); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowNotSupportedException"u8); } else if (result is SetTargetResult.MissingType) { - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowUnavailableType"u8); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowUnavailableType"u8); } else { @@ -834,12 +834,12 @@ private static MethodIL GenerateAccessorSpecificFailure(ref GenerationContext co if (context.Kind == UnsafeAccessorKind.Field || context.Kind == UnsafeAccessorKind.StaticField) { id = ExceptionStringID.MissingField; - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingFieldException"u8); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowMissingFieldException"u8); } else { id = ExceptionStringID.MissingMethod; - thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers", "ThrowMissingMethodException"u8); + thrower = typeSysContext.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowMissingMethodException"u8); } codeStream.EmitLdc((int)id); @@ -860,7 +860,7 @@ private static MethodIL GenerateAccessorBadImageFailure(MethodDesc method) ILCodeLabel label = emit.NewCodeLabel(); codeStream.EmitLabel(label); codeStream.EmitLdc((int)ExceptionStringID.BadImageFormatGeneric); - MethodDesc thrower = method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowBadImageFormatException"u8); + MethodDesc thrower = method.Context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowBadImageFormatException"u8); codeStream.Emit(ILOpcode.call, emit.NewToken(thrower)); codeStream.Emit(ILOpcode.br, label); diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs index cd347de8b6efa8..c3e1e4bed9d41e 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs @@ -108,7 +108,7 @@ internal sealed class AnsiCharArrayMarshaller : ArrayMarshaller protected override void AllocManagedToNative(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var helper = Context.GetHelperEntryPoint("InteropHelpers", "AllocMemoryForAnsiCharArray"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "AllocMemoryForAnsiCharArray"u8); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); @@ -120,7 +120,7 @@ protected override void AllocManagedToNative(ILCodeStream codeStream) protected override void TransformManagedToNative(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var helper = Context.GetHelperEntryPoint("InteropHelpers", "WideCharArrayToAnsiCharArray"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "WideCharArrayToAnsiCharArray"u8); LoadManagedValue(codeStream); LoadNativeValue(codeStream); @@ -132,7 +132,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) protected override void TransformNativeToManaged(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var helper = Context.GetHelperEntryPoint("InteropHelpers", "AnsiCharArrayToWideCharArray"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "AnsiCharArrayToWideCharArray"u8); LoadNativeValue(codeStream); LoadManagedValue(codeStream); @@ -145,7 +145,7 @@ internal sealed class AnsiCharMarshaller : Marshaller protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var helper = Context.GetHelperEntryPoint("InteropHelpers", "WideCharToAnsiChar"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "WideCharToAnsiChar"u8); LoadManagedValue(codeStream); codeStream.Emit(PInvokeFlags.BestFitMapping ? ILOpcode.ldc_i4_1 : ILOpcode.ldc_i4_0); @@ -157,7 +157,7 @@ protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream protected override void TransformNativeToManaged(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var helper = Context.GetHelperEntryPoint("InteropHelpers", "AnsiCharToWideChar"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "AnsiCharToWideChar"u8); LoadNativeValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); @@ -206,7 +206,7 @@ protected override void AllocManagedToNative(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; ReadOnlySpan helperMethodName = _isAnsi ? "AllocMemoryForAnsiStringBuilder"u8 : "AllocMemoryForUnicodeStringBuilder"u8; - var helper = Context.GetHelperEntryPoint("InteropHelpers", helperMethodName); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, helperMethodName); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); @@ -218,7 +218,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; ReadOnlySpan helperMethodName = _isAnsi ? "StringBuilderToAnsiString"u8 : "StringBuilderToUnicodeString"u8; - var helper = Context.GetHelperEntryPoint("InteropHelpers", helperMethodName); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, helperMethodName); LoadManagedValue(codeStream); LoadNativeValue(codeStream); @@ -233,7 +233,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) protected override void TransformNativeToManaged(ILCodeStream codeStream) { ReadOnlySpan helperMethodName = _isAnsi ? "AnsiStringToStringBuilder"u8 : "UnicodeStringToStringBuilder"u8; - var helper = Context.GetHelperEntryPoint("InteropHelpers", helperMethodName); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, helperMethodName); LoadNativeValue(codeStream); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, _ilCodeStreams.Emitter.NewToken(helper)); @@ -618,12 +618,12 @@ protected override bool IsAnsi protected override MethodDesc GetManagedToNativeHelper() { - return Context.GetHelperEntryPoint("InteropHelpers", "StringToByValAnsiString"u8); + return Context.GetHelperEntryPoint("InteropHelpers"u8, "StringToByValAnsiString"u8); } protected override MethodDesc GetNativeToManagedHelper() { - return Context.GetHelperEntryPoint("InteropHelpers", "ByValAnsiStringToString"u8); + return Context.GetHelperEntryPoint("InteropHelpers"u8, "ByValAnsiStringToString"u8); } } @@ -639,12 +639,12 @@ protected override bool IsAnsi protected override MethodDesc GetManagedToNativeHelper() { - return Context.GetHelperEntryPoint("InteropHelpers", "StringToUnicodeFixedArray"u8); + return Context.GetHelperEntryPoint("InteropHelpers"u8, "StringToUnicodeFixedArray"u8); } protected override MethodDesc GetNativeToManagedHelper() { - return Context.GetHelperEntryPoint("InteropHelpers", "UnicodeToStringFixedArray"u8); + return Context.GetHelperEntryPoint("InteropHelpers"u8, "UnicodeToStringFixedArray"u8); } } @@ -815,7 +815,7 @@ protected override void AllocManagedToNative(ILCodeStream codeStream) LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.brfalse, lNull); - MethodDesc getNativeSizeHelper = Context.GetHelperEntryPoint("InteropHelpers", "AsAnyGetNativeSize"u8); + MethodDesc getNativeSizeHelper = Context.GetHelperEntryPoint("InteropHelpers"u8, "AsAnyGetNativeSize"u8); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken(getNativeSizeHelper)); @@ -842,7 +842,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) LoadManagedValue(codeStream); LoadNativeValue(codeStream); codeStream.Emit(ILOpcode.call, _ilCodeStreams.Emitter.NewToken( - Context.GetHelperEntryPoint("InteropHelpers", "AsAnyMarshalManagedToNative"u8))); + Context.GetHelperEntryPoint("InteropHelpers"u8, "AsAnyMarshalManagedToNative"u8))); codeStream.EmitLabel(lNull); } @@ -858,7 +858,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) LoadNativeValue(codeStream); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, _ilCodeStreams.Emitter.NewToken( - Context.GetHelperEntryPoint("InteropHelpers", "AsAnyMarshalNativeToManaged"u8))); + Context.GetHelperEntryPoint("InteropHelpers"u8, "AsAnyMarshalNativeToManaged"u8))); codeStream.EmitLabel(lNull); } @@ -880,7 +880,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) LoadNativeValue(codeStream); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken( - Context.GetHelperEntryPoint("InteropHelpers", "AsAnyCleanupNative"u8))); + Context.GetHelperEntryPoint("InteropHelpers"u8, "AsAnyCleanupNative"u8))); codeStream.EmitLabel(lNull); } @@ -911,7 +911,7 @@ protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream for (int i = 8; i < 16; i++) codeStream.EmitLdc(bytes[i]); - MetadataType guidType = Context.SystemModule.GetKnownType("System", "Guid"); + MetadataType guidType = Context.SystemModule.GetKnownType("System"u8, "Guid"u8); var int32Type = Context.GetWellKnownType(WellKnownType.Int32); var int16Type = Context.GetWellKnownType(WellKnownType.Int16); var byteType = Context.GetWellKnownType(WellKnownType.Byte); @@ -924,7 +924,7 @@ protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream guidType.GetKnownMethod(".ctor"u8, sig); codeStream.Emit(ILOpcode.newobj, emitter.NewToken(guidCtorHandleMethod)); - MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertManagedComInterfaceToNative"u8); + MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "ConvertManagedComInterfaceToNative"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); } else @@ -934,7 +934,7 @@ protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream throw new NotSupportedException(); } - MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertManagedComInterfaceToIUnknown"u8); + MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "ConvertManagedComInterfaceToIUnknown"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); } @@ -946,7 +946,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); - MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertNativeComInterfaceToManaged"u8); + MethodDesc helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "ConvertNativeComInterfaceToManaged"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -973,7 +973,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadManagedValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "StringToAnsiBstrBuffer"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "StringToAnsiBstrBuffer"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreNativeValue(codeStream); @@ -984,7 +984,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "AnsiBstrBufferToString"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "AnsiBstrBufferToString"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -1017,7 +1017,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "BstrBufferToString"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "BstrBufferToString"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -1031,7 +1031,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadManagedValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "DateTimeToOleDateTime"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "DateTimeToOleDateTime"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreNativeValue(codeStream); @@ -1042,7 +1042,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "OleDateTimeToDateTime"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "OleDateTimeToDateTime"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -1056,7 +1056,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadManagedValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "DecimalToOleCurrency"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "DecimalToOleCurrency"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreNativeValue(codeStream); @@ -1067,7 +1067,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeValue(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "OleCurrencyToDecimal"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "OleCurrencyToDecimal"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -1107,7 +1107,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) LoadManagedValue(codeStream); LoadNativeAddr(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "ConvertObjectToVariant"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "ConvertObjectToVariant"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); } @@ -1122,7 +1122,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) LoadNativeAddr(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "VariantToObject"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "VariantToObject"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); StoreManagedValue(codeStream); @@ -1139,7 +1139,7 @@ protected override void EmitCleanupManaged(ILCodeStream codeStream) ILEmitter emitter = _ilCodeStreams.Emitter; LoadNativeAddr(codeStream); - var helper = Context.GetHelperEntryPoint("InteropHelpers", "CleanupVariant"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "CleanupVariant"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); } } @@ -1162,7 +1162,7 @@ private ILLocalVariable InitializeMarshallerVariable() ThrowHelper.ThrowTypeLoadException(marshallerType); } - var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices", "ICustomMarshaler"); + var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "ICustomMarshaler"u8); var getInstanceMethod = marshallerType.GetMethod( "GetInstance"u8, new MethodSignature(MethodSignatureFlags.Static, 0, customMarshallerType, [ Context.GetWellKnownType(WellKnownType.String) ])); @@ -1171,7 +1171,7 @@ private ILLocalVariable InitializeMarshallerVariable() ThrowHelper.ThrowMarshalDirectiveException(); } - var initializeCustomMarshallerMethod = Context.GetHelperEntryPoint("InteropHelpers", "InitializeCustomMarshaller"u8); + var initializeCustomMarshallerMethod = Context.GetHelperEntryPoint("InteropHelpers"u8, "InitializeCustomMarshaller"u8); ILEmitter emitter = _ilCodeStreams.Emitter; MarshallerLocalVariable = emitter.NewLocal(customMarshallerType); @@ -1201,7 +1201,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) { var lMarshaller = InitializeMarshallerVariable(); - var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices", "ICustomMarshaler"); + var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "ICustomMarshaler"u8); ILEmitter emitter = _ilCodeStreams.Emitter; var manageToNativeMethod = customMarshallerType.GetKnownMethod( "MarshalManagedToNative"u8, @@ -1230,7 +1230,7 @@ protected override void TransformNativeToManaged(ILCodeStream codeStream) { var lMarshaller = InitializeMarshallerVariable(); - var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices", "ICustomMarshaler"); + var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "ICustomMarshaler"u8); ILEmitter emitter = _ilCodeStreams.Emitter; var marshalNativeToManagedMethod = customMarshallerType.GetKnownMethod( "MarshalNativeToManaged"u8, @@ -1246,7 +1246,7 @@ protected void EmitCleanUpManagedData(ILCodeStream codeStream) { var lMarshaller = InitializeMarshallerVariable(); - var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices", "ICustomMarshaler"); + var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "ICustomMarshaler"u8); ILEmitter emitter = _ilCodeStreams.Emitter; // Call CleanUpManagedData on cleanup code stream. @@ -1263,7 +1263,7 @@ protected void EmitCleanUpNativeData(ILCodeStream codeStream) { var lMarshaller = InitializeMarshallerVariable(); - var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices", "ICustomMarshaler"); + var customMarshallerType = Context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "ICustomMarshaler"u8); ILEmitter emitter = _ilCodeStreams.Emitter; // Call CleanUpNativeData on cleanup code stream. diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs index f9422962e60cf6..3ebef5efc770a2 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs @@ -1534,7 +1534,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) } else { - var helper = Context.GetHelperEntryPoint("InteropHelpers", "StringToUnicodeBuffer"u8); + var helper = Context.GetHelperEntryPoint("InteropHelpers"u8, "StringToUnicodeBuffer"u8); LoadManagedValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken(helper)); @@ -1602,7 +1602,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) // ANSI marshalling. Allocate a byte array, copy characters // LoadManagedValue(codeStream); - var stringToAnsi = Context.GetHelperEntryPoint("InteropHelpers", "StringToAnsiString"u8); + var stringToAnsi = Context.GetHelperEntryPoint("InteropHelpers"u8, "StringToAnsiString"u8); codeStream.Emit(PInvokeFlags.BestFitMapping ? ILOpcode.ldc_i4_1 : ILOpcode.ldc_i4_0); codeStream.Emit(PInvokeFlags.ThrowOnUnmappableChar ? ILOpcode.ldc_i4_1 : ILOpcode.ldc_i4_0); @@ -1615,7 +1615,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) protected override void TransformNativeToManaged(ILCodeStream codeStream) { ILEmitter emitter = _ilCodeStreams.Emitter; - var ansiToString = Context.GetHelperEntryPoint("InteropHelpers", "AnsiStringToString"u8); + var ansiToString = Context.GetHelperEntryPoint("InteropHelpers"u8, "AnsiStringToString"u8); LoadNativeValue(codeStream); codeStream.Emit(ILOpcode.call, emitter.NewToken(ansiToString)); StoreManagedValue(codeStream); @@ -1644,7 +1644,7 @@ internal sealed class UTF8StringMarshaller : Marshaller private ILLocalVariable? _marshallerInstance; - private MetadataType Marshaller => Context.SystemModule.GetKnownType("System.Runtime.InteropServices.Marshalling", "Utf8StringMarshaller"); + private MetadataType Marshaller => Context.SystemModule.GetKnownType("System.Runtime.InteropServices.Marshalling"u8, "Utf8StringMarshaller"u8); private MetadataType MarshallerIn => Marshaller.GetNestedType("ManagedToUnmanagedIn"); @@ -1685,7 +1685,7 @@ protected override void TransformManagedToNative(ILCodeStream codeStream) codeStream.EmitLdLoc(vBuffer); codeStream.EmitLdc(LocalBufferLength); - var spanOfByte = Context.SystemModule.GetKnownType("System", "Span`1").MakeInstantiatedType( + var spanOfByte = Context.SystemModule.GetKnownType("System"u8, "Span`1"u8).MakeInstantiatedType( new TypeDesc[] { Context.GetWellKnownType(WellKnownType.Byte) }); codeStream.Emit(ILOpcode.newobj, emitter.NewToken(spanOfByte.GetKnownMethod(".ctor"u8, diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs b/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs index 66103c6c9c0f7e..e86da4893531e3 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs @@ -11,62 +11,62 @@ public static class InteropTypes { public static MetadataType GetGC(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System", "GC"); + return context.SystemModule.GetKnownType("System"u8, "GC"u8); } public static MetadataType GetType(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System", "Type"); + return context.SystemModule.GetKnownType("System"u8, "Type"u8); } public static MetadataType GetSafeHandle(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "SafeHandle"); + return context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "SafeHandle"u8); } public static MetadataType GetCriticalHandle(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "CriticalHandle"); + return context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "CriticalHandle"u8); } public static MetadataType GetHandleRef(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "HandleRef"); + return context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "HandleRef"u8); } public static MetadataType GetPInvokeMarshal(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "PInvokeMarshal"); + return context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "PInvokeMarshal"u8); } public static MetadataType GetRuntimeHelpers(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System.Runtime.CompilerServices", "RuntimeHelpers"); + return context.SystemModule.GetKnownType("System.Runtime.CompilerServices"u8, "RuntimeHelpers"u8); } public static MetadataType GetMarshal(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "Marshal"); + return context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "Marshal"u8); } public static MetadataType GetMemoryMarshal(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "MemoryMarshal"); + return context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "MemoryMarshal"u8); } public static MetadataType GetNativeFunctionPointerWrapper(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "NativeFunctionPointerWrapper"); + return context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "NativeFunctionPointerWrapper"u8); } public static MetadataType GetMarshalDirectiveException(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "MarshalDirectiveException"); + return context.SystemModule.GetKnownType("System.Runtime.InteropServices"u8, "MarshalDirectiveException"u8); } public static MetadataType GetVariant(TypeSystemContext context) { - return context.SystemModule.GetKnownType("System.Runtime.InteropServices.Marshalling", "ComVariant"); + return context.SystemModule.GetKnownType("System.Runtime.InteropServices.Marshalling"u8, "ComVariant"u8); } public static bool IsSafeHandle(TypeSystemContext context, TypeDesc type) diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs b/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs index a67ff236256678..59183d02b98803 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs @@ -234,31 +234,31 @@ public static EmbeddedSignatureData[] EncodeAsEmbeddedSignatureData(this Unmanag { ret[index++] = CreateCallConvEmbeddedSignatureData(context, convention switch { - UnmanagedCallingConventions.Cdecl => "CallConvCdecl", - UnmanagedCallingConventions.Stdcall => "CallConvStdcall", - UnmanagedCallingConventions.Fastcall => "CallConvFastcall", - UnmanagedCallingConventions.Thiscall => "CallConvThiscall", - UnmanagedCallingConventions.Swift => "CallConvSwift", + UnmanagedCallingConventions.Cdecl => "CallConvCdecl"u8, + UnmanagedCallingConventions.Stdcall => "CallConvStdcall"u8, + UnmanagedCallingConventions.Fastcall => "CallConvFastcall"u8, + UnmanagedCallingConventions.Thiscall => "CallConvThiscall"u8, + UnmanagedCallingConventions.Swift => "CallConvSwift"u8, _ => throw new InvalidProgramException() }); } if ((modifiers & UnmanagedCallingConventions.IsMemberFunction) != 0) - ret[index++] = CreateCallConvEmbeddedSignatureData(context, "CallConvMemberFunction"); + ret[index++] = CreateCallConvEmbeddedSignatureData(context, "CallConvMemberFunction"u8); if ((modifiers & UnmanagedCallingConventions.IsSuppressGcTransition) != 0) - ret[index++] = CreateCallConvEmbeddedSignatureData(context, "CallConvSuppressGCTransition"); + ret[index++] = CreateCallConvEmbeddedSignatureData(context, "CallConvSuppressGCTransition"u8); Debug.Assert(index == count); return ret; - static EmbeddedSignatureData CreateCallConvEmbeddedSignatureData(TypeSystemContext context, string name) + static EmbeddedSignatureData CreateCallConvEmbeddedSignatureData(TypeSystemContext context, ReadOnlySpan name) => new() { index = MethodSignature.IndexOfCustomModifiersOnReturnType, kind = EmbeddedSignatureDataKind.OptionalCustomModifier, - type = context.SystemModule.GetKnownType("System.Runtime.CompilerServices", name) + type = context.SystemModule.GetKnownType("System.Runtime.CompilerServices"u8, name) }; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DependencyGraphTests.cs b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DependencyGraphTests.cs index 277f446a334f8a..6295e9341f6bf3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DependencyGraphTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DependencyGraphTests.cs @@ -47,7 +47,7 @@ public static IEnumerable GetTestMethods() var testModule = context.GetModuleForSimpleName("ILCompiler.Compiler.Tests.Assets"); bool foundSomethingToCheck = false; - foreach (var type in testModule.GetType("ILCompiler.Compiler.Tests.Assets", "DependencyGraph").GetNestedTypes()) + foreach (var type in testModule.GetType("ILCompiler.Compiler.Tests.Assets"u8, "DependencyGraph"u8).GetNestedTypes()) { foundSomethingToCheck = true; yield return new object[] { type.GetMethod("Entrypoint"u8, null) }; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DevirtualizationTests.cs b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DevirtualizationTests.cs index af6ec60abbb2af..9c8ec785a7a5fc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DevirtualizationTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/DevirtualizationTests.cs @@ -45,7 +45,7 @@ private DevirtualizationManager GetDevirtualizationManagerFromScan(MethodDesc me [Fact] public void TestDevirtualizeSimple() { - MetadataType testType = _testModule.GetType("Devirtualization", "DevirtualizeSimple"); + MetadataType testType = _testModule.GetType("Devirtualization"u8, "DevirtualizeSimple"u8); DevirtualizationManager scanDevirt = GetDevirtualizationManagerFromScan(testType.GetMethod("Run"u8, null)); MethodDesc implMethod = testType.GetNestedType("Derived").GetMethod("Virtual"u8, null); @@ -61,7 +61,7 @@ public void TestDevirtualizeSimple() [Fact] public void TestDevirtualizeAbstract() { - MetadataType testType = _testModule.GetType("Devirtualization", "DevirtualizeAbstract"); + MetadataType testType = _testModule.GetType("Devirtualization"u8, "DevirtualizeAbstract"u8); DevirtualizationManager scanDevirt = GetDevirtualizationManagerFromScan(testType.GetMethod("Run"u8, null)); Assert.False(scanDevirt.IsEffectivelySealed(testType.GetNestedType("Abstract"))); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs index 17c413147928c4..354c60b876810d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitution.cs @@ -36,7 +36,7 @@ public MethodIL EmitIL(MethodDesc method) if (_value == Throw) { - codestream.EmitCallThrowHelper(emit, method.Context.GetHelperEntryPoint("ThrowHelpers", "ThrowFeatureBodyRemoved"u8)); + codestream.EmitCallThrowHelper(emit, method.Context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowFeatureBodyRemoved"u8)); } else if (_value == null) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs index 18b37a2022c55d..3e0d48df0f6eab 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs @@ -292,7 +292,7 @@ public static MethodDesc GetConstructorForCreateInstanceIntrinsic(TypeDesc type) MethodDesc ctor = type.GetDefaultConstructor(); if (ctor == null) { - MetadataType activatorType = type.Context.SystemModule.GetKnownType("System", "Activator"); + MetadataType activatorType = type.Context.SystemModule.GetKnownType("System"u8, "Activator"u8); if (type.IsValueType && type.GetParameterlessConstructor() == null) { ctor = activatorType.GetKnownNestedType("StructWithNoConstructor").GetKnownMethod(".ctor"u8, null); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs index beb5658718cf9c..ce21b8e0b8a981 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs @@ -71,7 +71,7 @@ public MetadataType ArrayOfTEnumeratorType { // This type is optional, but it's fine for this cache to be ineffective if that happens. // Those scenarios are rare and typically deal with small compilations. - return _arrayOfTEnumeratorType ??= SystemModule.GetType("System", "SZGenericArrayEnumerator`1", throwIfNotFound: false); + return _arrayOfTEnumeratorType ??= SystemModule.GetType("System"u8, "SZGenericArrayEnumerator`1"u8, throwIfNotFound: false); } } @@ -99,7 +99,7 @@ public bool IsArrayVariantCastable(TypeDesc type) protected override RuntimeInterfacesAlgorithm GetRuntimeInterfacesAlgorithmForNonPointerArrayType(ArrayType type) { - _arrayOfTRuntimeInterfacesAlgorithm ??= new ArrayOfTRuntimeInterfacesAlgorithm(SystemModule.GetKnownType("System", "Array`1")); + _arrayOfTRuntimeInterfacesAlgorithm ??= new ArrayOfTRuntimeInterfacesAlgorithm(SystemModule.GetKnownType("System"u8, "Array`1"u8)); return _arrayOfTRuntimeInterfacesAlgorithm; } @@ -144,7 +144,7 @@ public bool IsGenericArrayInterfaceType(TypeDesc type) if (_arrayOfTInterfaces == null) { - DefType[] implementedInterfaces = SystemModule.GetKnownType("System", "Array`1").ExplicitlyImplementedInterfaces; + DefType[] implementedInterfaces = SystemModule.GetKnownType("System"u8, "Array`1"u8).ExplicitlyImplementedInterfaces; TypeDesc[] interfaceDefinitions = new TypeDesc[implementedInterfaces.Length]; for (int i = 0; i < interfaceDefinitions.Length; i++) interfaceDefinitions[i] = implementedInterfaces[i].GetTypeDefinition(); @@ -201,7 +201,7 @@ protected override IEnumerable GetAllVirtualMethods(TypeDesc type) [MethodImpl(MethodImplOptions.AggressiveInlining)] private IEnumerable GetAllMethods(TypeDesc type, bool virtualOnly) { - MetadataType attributeType = _attributeType ??= SystemModule.GetType("System", "Attribute"); + MetadataType attributeType = _attributeType ??= SystemModule.GetType("System"u8, "Attribute"u8); if (type.IsDelegate) { @@ -258,7 +258,7 @@ internal DefType GetClosestDefType(TypeDesc type) { if (!type.IsArrayTypeWithoutGenericInterfaces()) { - MetadataType arrayShadowType = _arrayOfTType ??= SystemModule.GetType("System", "Array`1"); + MetadataType arrayShadowType = _arrayOfTType ??= SystemModule.GetType("System"u8, "Array`1"u8); return arrayShadowType.MakeInstantiatedType(((ArrayType)type).ElementType); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs index dd044bfdfc647f..18af56877ee1d2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs @@ -451,7 +451,7 @@ public override MethodIL EmitIL() // Load ByRef to the field with the value of the boxed valuetype codeStream.EmitLdArg(0); - codeStream.Emit(ILOpcode.ldflda, emit.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices", "RawData").GetField("Data"u8))); + codeStream.Emit(ILOpcode.ldflda, emit.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices"u8, "RawData"u8).GetField("Data"u8))); if (isX86) { @@ -552,7 +552,7 @@ public override MethodIL EmitIL() // unbox to get a pointer to the value type codeStream.EmitLdArg(0); - codeStream.Emit(ILOpcode.ldflda, emit.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices", "RawData").GetField("Data"u8))); + codeStream.Emit(ILOpcode.ldflda, emit.NewToken(Context.SystemModule.GetKnownType("System.Runtime.CompilerServices"u8, "RawData"u8).GetField("Data"u8))); // Load rest of the arguments for (int i = 0; i < _targetMethod.Signature.Length; i++) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs index 132e53d0897b8f..588e9013e48b3e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs @@ -60,7 +60,7 @@ public AssemblyNameInfo GetName() return new AssemblyNameInfo("System.Private.CompilerGenerated"); } - public override object GetType(string nameSpace, string name, NotFoundBehavior notFoundBehavior) + public override object GetType(ReadOnlySpan nameSpace, ReadOnlySpan name, NotFoundBehavior notFoundBehavior) { Debug.Fail("Resolving a TypeRef in the compiler generated assembly?"); throw new NotImplementedException(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs index ce5f589a949059..dfd392cc10f81c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs @@ -232,8 +232,8 @@ public override MethodIL EmitIL() ILCodeStream codeStream = emit.NewCodeStream(); FieldDesc eeTypeField = Context.GetWellKnownType(WellKnownType.Object).GetKnownField("m_pEEType"u8); - MethodDesc getOrdinalInterfaceMethod = Context.GetHelperEntryPoint("SharedCodeHelpers", "GetOrdinalInterface"u8); - MethodDesc getCurrentContext = Context.GetHelperEntryPoint("SharedCodeHelpers", "GetCurrentSharedThunkContext"u8); + MethodDesc getOrdinalInterfaceMethod = Context.GetHelperEntryPoint("SharedCodeHelpers"u8, "GetOrdinalInterface"u8); + MethodDesc getCurrentContext = Context.GetHelperEntryPoint("SharedCodeHelpers"u8, "GetCurrentSharedThunkContext"u8); bool isX86 = Context.Target.Architecture == TargetArchitecture.X86; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs index 980afe25886494..ecf9c151b5b21b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs @@ -112,7 +112,7 @@ private bool RequiresValueTypeGetFieldHelperMethod(MetadataType valueType) public bool IsAsyncStateMachineType(MetadataType type) { Debug.Assert(type.IsValueType); - _iAsyncStateMachineType ??= SystemModule.GetType("System.Runtime.CompilerServices", "IAsyncStateMachine", throwIfNotFound: false); + _iAsyncStateMachineType ??= SystemModule.GetType("System.Runtime.CompilerServices"u8, "IAsyncStateMachine"u8, throwIfNotFound: false); return type.HasCustomAttribute("System.Runtime.CompilerServices", "CompilerGeneratedAttribute") && Array.IndexOf(type.RuntimeInterfaces, _iAsyncStateMachineType) >= 0; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs index 6fe0683f9990fc..90f5791a82ef48 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CustomAttributeBasedDependencyAlgorithm.cs @@ -23,10 +23,10 @@ namespace ILCompiler.DependencyAnalysis /// internal static class CustomAttributeBasedDependencyAlgorithm { - private static IMethodNode GetMetadataApiDependency(NodeFactory factory, string entityName, ReadOnlySpan propertyName) - => factory.MethodEntrypoint(factory.TypeSystemContext.SystemModule.GetType("Internal.Metadata.NativeFormat", entityName).GetMethod(propertyName, null)); + private static IMethodNode GetMetadataApiDependency(NodeFactory factory, ReadOnlySpan entityName, ReadOnlySpan propertyName) + => factory.MethodEntrypoint(factory.TypeSystemContext.SystemModule.GetType("Internal.Metadata.NativeFormat"u8, entityName).GetMethod(propertyName, null)); - private static IMethodNode GetMetadataApiDependency(NodeFactory factory, string entityName) + private static IMethodNode GetMetadataApiDependency(NodeFactory factory, ReadOnlySpan entityName) => GetMetadataApiDependency(factory, entityName, "get_CustomAttributes"u8); public static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyList dependencies, NodeFactory factory, EcmaMethod method) @@ -36,10 +36,10 @@ public static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyLi MethodDefinition methodDef = reader.GetMethodDefinition(methodHandle); // Handle custom attributes on the method - AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "Method"), factory, method.Module, methodDef.GetCustomAttributes(), method); + AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "Method"u8), factory, method.Module, methodDef.GetCustomAttributes(), method); // Handle custom attributes on method parameters - object parameterCondition = GetMetadataApiDependency(factory, "Parameter"); + object parameterCondition = GetMetadataApiDependency(factory, "Parameter"u8); foreach (ParameterHandle parameterHandle in methodDef.GetParameters()) { Parameter parameter = reader.GetParameter(parameterHandle); @@ -47,7 +47,7 @@ public static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyLi } // Handle custom attributes on generic method parameters - object genericParameterCondition = GetMetadataApiDependency(factory, "GenericParameter"); + object genericParameterCondition = GetMetadataApiDependency(factory, "GenericParameter"u8); foreach (GenericParameterHandle genericParameterHandle in methodDef.GetGenericParameters()) { GenericParameter parameter = reader.GetGenericParameter(genericParameterHandle); @@ -61,7 +61,7 @@ public static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyLi // As a performance optimization, we look for associated events and properties only // if the method is SpecialName. This is required for CLS compliance and compilers we // care about emit accessors like this. - object propertyCondition = GetMetadataApiDependency(factory, "Property"); + object propertyCondition = GetMetadataApiDependency(factory, "Property"u8); if ((methodDef.Attributes & MethodAttributes.SpecialName) != 0) { TypeDefinition declaringType = reader.GetTypeDefinition(methodDef.GetDeclaringType()); @@ -75,7 +75,7 @@ public static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyLi AddDependenciesDueToCustomAttributes(ref dependencies, propertyCondition, factory, method.Module, property.GetCustomAttributes(), new PropertyPseudoDesc((EcmaType)method.OwningType, propertyHandle)); } - object eventCondition = GetMetadataApiDependency(factory, "Event"); + object eventCondition = GetMetadataApiDependency(factory, "Event"u8); foreach (EventDefinitionHandle eventHandle in declaringType.GetEvents()) { EventDefinition @event = reader.GetEventDefinition(eventHandle); @@ -91,10 +91,10 @@ public static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyLi { MetadataReader reader = type.MetadataReader; TypeDefinition typeDef = reader.GetTypeDefinition(type.Handle); - AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "TypeDefinition"), factory, type.EcmaModule, typeDef.GetCustomAttributes(), type); + AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "TypeDefinition"u8), factory, type.EcmaModule, typeDef.GetCustomAttributes(), type); // Handle custom attributes on generic type parameters - object genericParameterCondition = GetMetadataApiDependency(factory, "GenericParameter"); + object genericParameterCondition = GetMetadataApiDependency(factory, "GenericParameter"u8); foreach (GenericParameterHandle genericParameterHandle in typeDef.GetGenericParameters()) { GenericParameter parameter = reader.GetGenericParameter(genericParameterHandle); @@ -105,16 +105,16 @@ public static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyLi public static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyList dependencies, NodeFactory factory, EcmaField field) { FieldDefinition fieldDef = field.MetadataReader.GetFieldDefinition(field.Handle); - AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "Field"), factory, field.Module, fieldDef.GetCustomAttributes(), field); + AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "Field"u8), factory, field.Module, fieldDef.GetCustomAttributes(), field); } public static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyList dependencies, NodeFactory factory, EcmaAssembly assembly) { AssemblyDefinition asmDef = assembly.MetadataReader.GetAssemblyDefinition(); - AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "ScopeDefinition"), factory, assembly, asmDef.GetCustomAttributes(), assembly); + AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "ScopeDefinition"u8), factory, assembly, asmDef.GetCustomAttributes(), assembly); ModuleDefinition moduleDef = assembly.MetadataReader.GetModuleDefinition(); - AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "ScopeDefinition", "get_ModuleCustomAttributes"u8), factory, assembly, moduleDef.GetCustomAttributes(), assembly); + AddDependenciesDueToCustomAttributes(ref dependencies, GetMetadataApiDependency(factory, "ScopeDefinition"u8, "get_ModuleCustomAttributes"u8), factory, assembly, moduleDef.GetCustomAttributes(), assembly); } private static void AddDependenciesDueToCustomAttributes(ref CombinedDependencyList dependencies, object condition, NodeFactory factory, EcmaModule module, CustomAttributeHandleCollection attributeHandles, TypeSystemEntity parent) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenRuntimeTypeNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenRuntimeTypeNode.cs index 4ad226b7a99eb2..b7cdc5f71b4c18 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenRuntimeTypeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FrozenRuntimeTypeNode.cs @@ -52,6 +52,6 @@ public override int CompareToImpl(ISortableNode other, CompilerComparer comparer public override bool IsKnownImmutable => false; - public override DefType ObjectType => _type.Context.SystemModule.GetKnownType("System", "RuntimeType"); + public override DefType ObjectType => _type.Context.SystemModule.GetKnownType("System"u8, "RuntimeType"u8); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs index ebc8e0c3413119..508e8431781ffc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs @@ -54,7 +54,7 @@ public static bool IsInlineableStringsResource(EcmaModule module, string resourc if (resourceName != resourceName1 && resourceName != resourceName2) return false; - MetadataType srType = module.GetType(ResourceAccessorTypeNamespace, ResourceAccessorTypeName, throwIfNotFound: false); + MetadataType srType = module.GetType(U8ResourceAccessorTypeNamespace, U8ResourceAccessorTypeName, throwIfNotFound: false); if (srType == null) return false; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs index e09f9acf49c051..8cea4b6dee9aa9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs @@ -1292,8 +1292,8 @@ public ISymbolNode HelperEntrypoint(HelperEntrypoint entrypoint) { var entry = s_helperEntrypointNames[index]; - var type = _context.SystemModule.GetKnownType(entry[0], entry[1]); - var method = type.GetKnownMethod(System.Text.Encoding.UTF8.GetBytes(entry[2]), null); + var type = _context.SystemModule.GetKnownType(Encoding.UTF8.GetBytes(entry[0]), Encoding.UTF8.GetBytes(entry[1])); + var method = type.GetKnownMethod(Encoding.UTF8.GetBytes(entry[2]), null); symbol = MethodEntrypoint(method); @@ -1307,7 +1307,7 @@ public MetadataType ArrayOfTClass { get { - return _systemArrayOfTClass ??= _context.SystemModule.GetKnownType("System", "Array`1"); + return _systemArrayOfTClass ??= _context.SystemModule.GetKnownType("System"u8, "Array`1"u8); } } @@ -1318,7 +1318,7 @@ public MethodDesc InstanceMethodRemovedHelper { // This helper is optional, but it's fine for this cache to be ineffective if that happens. // Those scenarios are rare and typically deal with small compilations. - return _instanceMethodRemovedHelper ??= TypeSystemContext.GetOptionalHelperEntryPoint("ThrowHelpers", "ThrowInstanceBodyRemoved"u8); + return _instanceMethodRemovedHelper ??= TypeSystemContext.GetOptionalHelperEntryPoint("ThrowHelpers"u8, "ThrowInstanceBodyRemoved"u8); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunGenericHelperNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunGenericHelperNode.cs index 7800b079faa554..3ca290ed29b359 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunGenericHelperNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunGenericHelperNode.cs @@ -190,7 +190,7 @@ public IEnumerable InstantiateDependencies(NodeFactory fact private static IMethodNode GetBadSlotHelper(NodeFactory factory) { - return factory.MethodEntrypoint(factory.TypeSystemContext.GetHelperEntryPoint("ThrowHelpers", "ThrowUnavailableType"u8)); + return factory.MethodEntrypoint(factory.TypeSystemContext.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowUnavailableType"u8)); } protected void AppendLookupSignatureMangledName(NameMangler nameMangler, Utf8StringBuilder sb) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs index a2d68a2cd729c4..8cc6d019ae6414 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TentativeMethodNode.cs @@ -32,7 +32,7 @@ public TentativeMethodNode(IMethodBodyNode methodNode) protected virtual ISymbolNode GetTarget(NodeFactory factory) { // If the class library doesn't provide this helper, the optimization is disabled. - MethodDesc helper = factory.TypeSystemContext.GetOptionalHelperEntryPoint("ThrowHelpers", "ThrowBodyRemoved"u8); + MethodDesc helper = factory.TypeSystemContext.GetOptionalHelperEntryPoint("ThrowHelpers"u8, "ThrowBodyRemoved"u8); return helper == null ? RealBody : factory.MethodEntrypoint(helper); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs index cd06949a9d3fdd..cbd7875bc588f8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/JitHelper.cs @@ -30,31 +30,31 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, break; case ReadyToRunHelper.Overflow: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowOverflowException"u8); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowOverflowException"u8); break; case ReadyToRunHelper.RngChkFail: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowIndexOutOfRangeException"u8); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowIndexOutOfRangeException"u8); break; case ReadyToRunHelper.FailFast: mangledName = "RhpFallbackFailFast"; // TODO: Report stack buffer overrun break; case ReadyToRunHelper.ThrowNullRef: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowNullReferenceException"u8); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowNullReferenceException"u8); break; case ReadyToRunHelper.ThrowDivZero: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowDivideByZeroException"u8); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowDivideByZeroException"u8); break; case ReadyToRunHelper.ThrowArgumentOutOfRange: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowArgumentOutOfRangeException"u8); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowArgumentOutOfRangeException"u8); break; case ReadyToRunHelper.ThrowArgument: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowArgumentException"u8); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowArgumentException"u8); break; case ReadyToRunHelper.ThrowPlatformNotSupported: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowPlatformNotSupportedException"u8); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowPlatformNotSupportedException"u8); break; case ReadyToRunHelper.ThrowNotImplemented: - methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowNotImplementedException"u8); + methodDesc = context.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowNotImplementedException"u8); break; case ReadyToRunHelper.DebugBreak: @@ -74,7 +74,7 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, mangledName = context.Target.Architecture == TargetArchitecture.ARM64 ? "RhpCheckedAssignRefArm64" : "RhpCheckedAssignRef"; break; case ReadyToRunHelper.BulkWriteBarrier: - methodDesc = context.GetCoreLibEntryPoint("System", "Buffer", "BulkMoveWithWriteBarrier"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System"u8, "Buffer"u8, "BulkMoveWithWriteBarrier"u8, null); break; case ReadyToRunHelper.ByRefWriteBarrier: mangledName = context.Target.Architecture == TargetArchitecture.ARM64 ? "RhpByRefAssignRefArm64" : "RhpByRefAssignRef"; @@ -117,23 +117,23 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, break; case ReadyToRunHelper.Box: case ReadyToRunHelper.Box_Nullable: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhBox"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "RuntimeExports"u8, "RhBox"u8, null); break; case ReadyToRunHelper.Unbox: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhUnbox2"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "RuntimeExports"u8, "RhUnbox2"u8, null); break; case ReadyToRunHelper.Unbox_Nullable: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhUnboxNullable"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "RuntimeExports"u8, "RhUnboxNullable"u8, null); break; case ReadyToRunHelper.Unbox_TypeTest: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "RuntimeExports", "RhUnboxTypeTest"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "RuntimeExports"u8, "RhUnboxTypeTest"u8, null); break; case ReadyToRunHelper.NewMultiDimArr: - methodDesc = context.GetHelperEntryPoint("ArrayHelpers", "NewObjArray"u8); + methodDesc = context.GetHelperEntryPoint("ArrayHelpers"u8, "NewObjArray"u8); break; case ReadyToRunHelper.NewMultiDimArrRare: - methodDesc = context.GetHelperEntryPoint("ArrayHelpers", "NewObjArrayRare"u8); + methodDesc = context.GetHelperEntryPoint("ArrayHelpers"u8, "NewObjArrayRare"u8); break; case ReadyToRunHelper.NewArray: @@ -144,36 +144,36 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, break; case ReadyToRunHelper.Stelem_Ref: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "StelemRef"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "TypeCast"u8, "StelemRef"u8, null); break; case ReadyToRunHelper.Ldelema_Ref: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "LdelemaRef"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "TypeCast"u8, "LdelemaRef"u8, null); break; case ReadyToRunHelper.MemCpy: - methodDesc = context.GetCoreLibEntryPoint("System", "SpanHelpers", "Memmove"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System"u8, "SpanHelpers"u8, "Memmove"u8, null); break; case ReadyToRunHelper.MemSet: - methodDesc = context.GetCoreLibEntryPoint("System", "SpanHelpers", "Fill"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System"u8, "SpanHelpers"u8, "Fill"u8, null); break; case ReadyToRunHelper.MemZero: - methodDesc = context.GetCoreLibEntryPoint("System", "SpanHelpers", "ClearWithoutReferences"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System"u8, "SpanHelpers"u8, "ClearWithoutReferences"u8, null); break; case ReadyToRunHelper.NativeMemSet: mangledName = "memset"; break; case ReadyToRunHelper.GetRuntimeTypeHandle: - methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeTypeHandle"u8); + methodDesc = context.GetHelperEntryPoint("LdTokenHelpers"u8, "GetRuntimeTypeHandle"u8); break; case ReadyToRunHelper.GetRuntimeType: - methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeType"u8); + methodDesc = context.GetHelperEntryPoint("LdTokenHelpers"u8, "GetRuntimeType"u8); break; case ReadyToRunHelper.GetRuntimeMethodHandle: - methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeMethodHandle"u8); + methodDesc = context.GetHelperEntryPoint("LdTokenHelpers"u8, "GetRuntimeMethodHandle"u8); break; case ReadyToRunHelper.GetRuntimeFieldHandle: - methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeFieldHandle"u8); + methodDesc = context.GetHelperEntryPoint("LdTokenHelpers"u8, "GetRuntimeFieldHandle"u8); break; case ReadyToRunHelper.Lng2Dbl: @@ -197,16 +197,16 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, break; case ReadyToRunHelper.Dbl2IntOvf: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToInt32Checked"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("ConvertToInt32Checked"u8, null); break; case ReadyToRunHelper.Dbl2UIntOvf: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToUInt32Checked"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("ConvertToUInt32Checked"u8, null); break; case ReadyToRunHelper.Dbl2LngOvf: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToInt64Checked"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("ConvertToInt64Checked"u8, null); break; case ReadyToRunHelper.Dbl2ULngOvf: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ConvertToUInt64Checked"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("ConvertToUInt64Checked"u8, null); break; case ReadyToRunHelper.DblRem: @@ -222,42 +222,42 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, case ReadyToRunHelper.LMulOfv: { TypeDesc t = context.GetWellKnownType(WellKnownType.Int64); - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("MultiplyChecked"u8, + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("MultiplyChecked"u8, new MethodSignature(MethodSignatureFlags.Static, 0, t, [t, t])); } break; case ReadyToRunHelper.ULMulOvf: { TypeDesc t = context.GetWellKnownType(WellKnownType.UInt64); - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("MultiplyChecked"u8, + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("MultiplyChecked"u8, new MethodSignature(MethodSignatureFlags.Static, 0, t, [t, t])); } break; case ReadyToRunHelper.Div: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivInt32"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("DivInt32"u8, null); break; case ReadyToRunHelper.UDiv: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivUInt32"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("DivUInt32"u8, null); break; case ReadyToRunHelper.LDiv: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivInt64"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("DivInt64"u8, null); break; case ReadyToRunHelper.ULDiv: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("DivUInt64"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("DivUInt64"u8, null); break; case ReadyToRunHelper.Mod: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModInt32"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("ModInt32"u8, null); break; case ReadyToRunHelper.UMod: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModUInt32"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("ModUInt32"u8, null); break; case ReadyToRunHelper.LMod: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModInt64"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("ModInt64"u8, null); break; case ReadyToRunHelper.ULMod: - methodDesc = context.SystemModule.GetKnownType("System", "Math").GetKnownMethod("ModUInt64"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Math"u8).GetKnownMethod("ModUInt64"u8, null); break; case ReadyToRunHelper.LRsz: @@ -285,54 +285,54 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, break; case ReadyToRunHelper.CheckCastAny: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastAny"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "TypeCast"u8, "CheckCastAny"u8, null); break; case ReadyToRunHelper.CheckCastInterface: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastInterface"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "TypeCast"u8, "CheckCastInterface"u8, null); break; case ReadyToRunHelper.CheckCastClass: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastClass"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "TypeCast"u8, "CheckCastClass"u8, null); break; case ReadyToRunHelper.CheckCastClassSpecial: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "CheckCastClassSpecial"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "TypeCast"u8, "CheckCastClassSpecial"u8, null); break; case ReadyToRunHelper.CheckInstanceAny: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfAny"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "TypeCast"u8, "IsInstanceOfAny"u8, null); break; case ReadyToRunHelper.CheckInstanceInterface: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfInterface"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "TypeCast"u8, "IsInstanceOfInterface"u8, null); break; case ReadyToRunHelper.CheckInstanceClass: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfClass"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "TypeCast"u8, "IsInstanceOfClass"u8, null); break; case ReadyToRunHelper.IsInstanceOfException: - methodDesc = context.GetCoreLibEntryPoint("System.Runtime", "TypeCast", "IsInstanceOfException"u8, null); + methodDesc = context.GetCoreLibEntryPoint("System.Runtime"u8, "TypeCast"u8, "IsInstanceOfException"u8, null); break; case ReadyToRunHelper.MonitorEnter: - methodDesc = context.GetHelperEntryPoint("SynchronizedMethodHelpers", "MonitorEnter"u8); + methodDesc = context.GetHelperEntryPoint("SynchronizedMethodHelpers"u8, "MonitorEnter"u8); break; case ReadyToRunHelper.MonitorExit: - methodDesc = context.GetHelperEntryPoint("SynchronizedMethodHelpers", "MonitorExit"u8); + methodDesc = context.GetHelperEntryPoint("SynchronizedMethodHelpers"u8, "MonitorExit"u8); break; case ReadyToRunHelper.GVMLookupForSlot: - methodDesc = context.SystemModule.GetKnownType("System.Runtime", "TypeLoaderExports").GetKnownMethod("GVMLookupForSlot"u8, null); + methodDesc = context.SystemModule.GetKnownType("System.Runtime"u8, "TypeLoaderExports"u8).GetKnownMethod("GVMLookupForSlot"u8, null); break; case ReadyToRunHelper.TypeHandleToRuntimeType: - methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers", "TypeHandleToRuntimeTypeMaybeNull"u8); + methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers"u8, "TypeHandleToRuntimeTypeMaybeNull"u8); break; case ReadyToRunHelper.GetRefAny: - methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers", "GetRefAny"u8); + methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers"u8, "GetRefAny"u8); break; case ReadyToRunHelper.TypeHandleToRuntimeTypeHandle: - methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers", "TypeHandleToRuntimeTypeHandleMaybeNull"u8); + methodDesc = context.GetHelperEntryPoint("TypedReferenceHelpers"u8, "TypeHandleToRuntimeTypeHandleMaybeNull"u8); break; case ReadyToRunHelper.GetCurrentManagedThreadId: - methodDesc = context.SystemModule.GetKnownType("System", "Environment").GetKnownMethod("get_CurrentManagedThreadId"u8, null); + methodDesc = context.SystemModule.GetKnownType("System"u8, "Environment"u8).GetKnownMethod("get_CurrentManagedThreadId"u8, null); break; default: diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryInitializers.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryInitializers.cs index a2829acd6ddcb9..5e87f0c0843469 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryInitializers.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LibraryInitializers.cs @@ -15,8 +15,8 @@ namespace ILCompiler /// public sealed class LibraryInitializers { - private const string LibraryInitializerContainerNamespaceName = "Internal.Runtime.CompilerHelpers"; - private const string LibraryInitializerContainerTypeName = "LibraryInitializer"; + private static ReadOnlySpan LibraryInitializerContainerNamespaceName => "Internal.Runtime.CompilerHelpers"u8; + private static ReadOnlySpan LibraryInitializerContainerTypeName => "LibraryInitializer"u8; private static ReadOnlySpan LibraryInitializerMethodName => "InitializeLibrary"u8; private List _libraryInitializerMethods; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs index c6867d18b74199..984902588ed4ee 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs @@ -544,7 +544,7 @@ private static void GetMatchingTypes(ModuleDesc module, TypeDesc declaringType, namepart = name; } - var type = module.GetType(namespacepart, namepart, throwIfNotFound: false); + var type = module.GetType(Encoding.UTF8.GetBytes(namespacepart), Encoding.UTF8.GetBytes(namepart), throwIfNotFound: false); if (type != null) { results.Add(type); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs index e9119b78c69b6e..bdbc33064871ed 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs @@ -30,7 +30,7 @@ public override bool IsBlocked(FieldDesc field) private MetadataType _arrayOfTType; private MetadataType InitializeArrayOfTType(TypeSystemEntity contextEntity) { - _arrayOfTType = contextEntity.Context.SystemModule.GetType("System", "Array`1"); + _arrayOfTType = contextEntity.Context.SystemModule.GetType("System"u8, "Array`1"u8); return _arrayOfTType; } private MetadataType GetArrayOfTType(TypeSystemEntity contextEntity) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/PreinitializationManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/PreinitializationManager.cs index e8b5d1c7221bb5..f885f77bc60894 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/PreinitializationManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/PreinitializationManager.cs @@ -21,7 +21,7 @@ public class PreinitializationManager public PreinitializationManager(TypeSystemContext context, CompilationModuleGroup compilationGroup, ILProvider ilprovider, TypePreinit.TypePreinitializationPolicy policy, ReadOnlyFieldPolicy readOnlyPolicy, FlowAnnotations flowAnnotations) { - _supportsLazyCctors = context.SystemModule.GetType("System.Runtime.CompilerServices", "ClassConstructorRunner", throwIfNotFound: false) != null; + _supportsLazyCctors = context.SystemModule.GetType("System.Runtime.CompilerServices"u8, "ClassConstructorRunner"u8, throwIfNotFound: false) != null; _preinitHashTable = new PreinitializationInfoHashtable(compilationGroup, ilprovider, policy, readOnlyPolicy, flowAnnotations); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationFilter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationFilter.cs index eeae12a6f10edc..f91c0338d4d43d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationFilter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationFilter.cs @@ -73,7 +73,7 @@ public override MethodIL GetMethodIL(MethodDesc method) // Method not present: stub it out var emit = new ILEmitter(); ILCodeStream codeStream = emit.NewCodeStream(); - codeStream.EmitCallThrowHelper(emit, method.Context.SystemModule.GetKnownType("System.Runtime", "InternalCalls").GetKnownMethod("RhpFallbackFailFast"u8, null)); + codeStream.EmitCallThrowHelper(emit, method.Context.SystemModule.GetKnownType("System.Runtime"u8, "InternalCalls"u8).GetKnownMethod("RhpFallbackFailFast"u8, null)); return emit.Link(method); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs index b4423a6ba5d0cb..734f8713dc7ec2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ReachabilityInstrumentationProvider.cs @@ -254,7 +254,7 @@ public override MethodIL EmitIL() codeStream.Emit(ILOpcode.ldsflda, dataFieldToken); codeStream.Emit(ILOpcode.ldind_i4); - MethodDesc registerMethod = Context.GetHelperEntryPoint("ReachabilityInstrumentationSupport", "Register"u8); + MethodDesc registerMethod = Context.GetHelperEntryPoint("ReachabilityInstrumentationSupport"u8, "Register"u8); codeStream.Emit(ILOpcode.call, emitter.NewToken(registerMethod)); codeStream.Emit(ILOpcode.ret); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index f6f8f7bb230443..bb3425ade9d003 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -2862,7 +2862,7 @@ private sealed class RuntimeTypeValue : ReferenceTypeValue public TypeDesc TypeRepresented { get; } public RuntimeTypeValue(TypeDesc type) - : base(type.Context.SystemModule.GetKnownType("System", "RuntimeType")) + : base(type.Context.SystemModule.GetKnownType("System"u8, "RuntimeType"u8)) { TypeRepresented = type; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs index 2cfcac1a367508..9464667df35b67 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs @@ -796,7 +796,7 @@ private void InsertStaticFieldRegionMember(List fieldDescs, Is64Bit = Is64Bit ? 1 : 0, IsConst = 0, IsReference = 0, - ElementType = GetTypeIndex(defType.Context.SystemModule.GetType("Internal.Runtime.CompilerHelpers", "TypeManagerSlot"), true) + ElementType = GetTypeIndex(defType.Context.SystemModule.GetType("Internal.Runtime.CompilerHelpers"u8, "TypeManagerSlot"u8), true) }; var helperFields = new DataFieldDescriptor[] { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs index bdc2609e56e523..01765e1465ba62 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs @@ -157,7 +157,7 @@ public ILImporter(ILScanner compilation, MethodDesc method, MethodIL methodIL = _dependencies.Add(GetHelperEntrypoint(ReadyToRunHelper.MonitorExit), reason); if (_canonMethod.Signature.IsStatic) { - _dependencies.Add(_compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetSyncFromClassHandle"u8)), reason); + _dependencies.Add(_compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers"u8, "GetSyncFromClassHandle"u8)), reason); MethodDesc method = _methodIL.OwningMethod; if (method.OwningType.IsRuntimeDeterminedSubtype) @@ -172,7 +172,7 @@ public ILImporter(ILScanner compilation, MethodDesc method, MethodIL methodIL = if (_canonMethod.IsCanonicalMethod(CanonicalFormKind.Any)) { if (_canonMethod.RequiresInstMethodDescArg()) - _dependencies.Add(_compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetClassFromMethodParam"u8)), reason); + _dependencies.Add(_compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers"u8, "GetClassFromMethodParam"u8)), reason); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs index b5dd51418b02da..1cc0c7da840d2d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs @@ -78,7 +78,7 @@ public override MethodIL EmitIL() } } - MetadataType startup = Context.GetOptionalHelperType("StartupCodeHelpers"); + MetadataType startup = Context.GetOptionalHelperType("StartupCodeHelpers"u8); // Run module initializers MethodDesc runModuleInitializers = startup?.GetMethod("RunModuleInitializers"u8, null); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs index 11c7705bb606c2..ff65ba4bf2c501 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs @@ -86,7 +86,7 @@ public override MethodIL EmitIL() } } - MetadataType startup = Context.GetOptionalHelperType("StartupCodeHelpers"); + MetadataType startup = Context.GetOptionalHelperType("StartupCodeHelpers"u8); // Initialize command line args if the class library supports this ReadOnlySpan initArgsName = (Context.Target.OperatingSystem == TargetOS.Windows) diff --git a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs index 074a31888ca714..6ec6ed18c78412 100644 --- a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs +++ b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs @@ -112,7 +112,7 @@ private static Cts.TypeDesc SerializationTypeToType(Cts.Ecma.EcmaModule module, switch (typeCode) { - case Ecma.SerializationTypeCode.Type: return module.Context.SystemModule.GetType("System", "Type"); + case Ecma.SerializationTypeCode.Type: return module.Context.SystemModule.GetType("System"u8, "Type"u8); case Ecma.SerializationTypeCode.SZArray: return module.Context.GetArrayType(SerializationTypeToType(module, ref valueReader)); case Ecma.SerializationTypeCode.Enum: return Cts.CustomAttributeTypeNameParser.GetTypeByCustomAttributeTypeName(module, valueReader.ReadSerializedString()); case Ecma.SerializationTypeCode.String: return module.Context.GetWellKnownType(Cts.WellKnownType.String); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs index ada8c227b3f319..fcc5d35b1cd7bf 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs @@ -67,13 +67,13 @@ public ReadyToRunCompilerContext( // Only the Arm64 JIT respects the OS rules for vector type abi currently _vectorFieldLayoutAlgorithm = new VectorFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm, (details.Architecture == TargetArchitecture.ARM64) ? true : bubbleIncludesCorelib); - string matchingVectorType = "Unknown"; + ReadOnlySpan matchingVectorType = "Unknown"u8; if (details.MaximumSimdVectorLength == SimdVectorLength.Vector128Bit) - matchingVectorType = "Vector128`1"; + matchingVectorType = "Vector128`1"u8; else if (details.MaximumSimdVectorLength == SimdVectorLength.Vector256Bit) - matchingVectorType = "Vector256`1"; + matchingVectorType = "Vector256`1"u8; else if (details.MaximumSimdVectorLength == SimdVectorLength.Vector512Bit) - matchingVectorType = "Vector512`1"; + matchingVectorType = "Vector512`1"u8; // No architecture has completely stable handling of Vector in the abi (Arm64 may change to SVE) _vectorOfTFieldLayoutAlgorithm = new VectorOfTFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm, _vectorFieldLayoutAlgorithm, matchingVectorType, bubbleIncludesCorelib); @@ -179,7 +179,7 @@ public TypeDesc AsyncStateMachineBoxType { if (_asyncStateMachineBox == null) { - _asyncStateMachineBox = SystemModule.GetType("System.Runtime.CompilerServices", "AsyncTaskMethodBuilder`1").GetNestedType("AsyncStateMachineBox`1"); + _asyncStateMachineBox = SystemModule.GetType("System.Runtime.CompilerServices"u8, "AsyncTaskMethodBuilder`1"u8).GetNestedType("AsyncStateMachineBox`1"); if (_asyncStateMachineBox == null) throw new Exception(); } @@ -196,15 +196,15 @@ internal class VectorOfTFieldLayoutAlgorithm : FieldLayoutAlgorithm { private FieldLayoutAlgorithm _fallbackAlgorithm; private FieldLayoutAlgorithm _vectorFallbackAlgorithm; - private string _similarVectorName; + private byte[] _similarVectorName; private DefType _similarVectorOpenType; private bool _vectorAbiIsStable; - public VectorOfTFieldLayoutAlgorithm(FieldLayoutAlgorithm fallbackAlgorithm, FieldLayoutAlgorithm vectorFallbackAlgorithm, string similarVector, bool vectorAbiIsStable = true) + public VectorOfTFieldLayoutAlgorithm(FieldLayoutAlgorithm fallbackAlgorithm, FieldLayoutAlgorithm vectorFallbackAlgorithm, ReadOnlySpan similarVector, bool vectorAbiIsStable = true) { _fallbackAlgorithm = fallbackAlgorithm; _vectorFallbackAlgorithm = vectorFallbackAlgorithm; - _similarVectorName = similarVector; + _similarVectorName = similarVector.ToArray(); _vectorAbiIsStable = vectorAbiIsStable; } @@ -212,10 +212,10 @@ private DefType GetSimilarVector(DefType vectorOfTType) { if (_similarVectorOpenType == null) { - if (_similarVectorName == "Unknown") + if (_similarVectorName.SequenceEqual("Unknown"u8)) return null; - _similarVectorOpenType = ((MetadataType)vectorOfTType.GetTypeDefinition()).Module.GetType("System.Runtime.Intrinsics", _similarVectorName); + _similarVectorOpenType = ((MetadataType)vectorOfTType.GetTypeDefinition()).Module.GetType("System.Runtime.Intrinsics"u8, _similarVectorName); } return ((MetadataType)_similarVectorOpenType).MakeInstantiatedType(vectorOfTType.Instantiation); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs index 4092d8e01e669f..555d832f15f448 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs @@ -305,8 +305,8 @@ private uint LookupIbcTypeToken(ref EcmaModule externalModule, uint ibcToken, Di var typeEntry = (BlobEntry.ExternalTypeEntry)externalTypeDefBlob; - string typeNamespace = ""; - string typeName = Encoding.UTF8.GetString(typeEntry.Name, 0, typeEntry.Name.Length - 1 /* these strings are null terminated */); + ReadOnlySpan typeNamespace = ""u8; + ReadOnlySpan typeName = new ReadOnlySpan(typeEntry.Name).Slice(0, typeEntry.Name.Length - 1 /* these strings are null terminated */); TypeDefinitionHandle enclosingType = default; if (!Cor.Macros.IsNilToken(typeEntry.NamespaceToken)) { @@ -329,7 +329,7 @@ private uint LookupIbcTypeToken(ref EcmaModule externalModule, uint ibcToken, Di } var namespaceEntry = (BlobEntry.ExternalNamespaceEntry)namespaceEntryBlob; - typeNamespace = Encoding.UTF8.GetString(namespaceEntry.Name, 0, namespaceEntry.Name.Length - 1 /* these strings are null terminated */); + typeNamespace = new ReadOnlySpan(namespaceEntry.Name).Slice(0, namespaceEntry.Name.Length - 1 /* these strings are null terminated */); } else if (!Cor.Macros.IsNilToken(typeEntry.NestedClassToken)) { @@ -378,18 +378,17 @@ private uint LookupIbcTypeToken(ref EcmaModule externalModule, uint ibcToken, Di else { TypeDefinition nestedClassDefinition = externalModule.MetadataReader.GetTypeDefinition(enclosingType); - MetadataStringComparer stringComparer = externalModule.MetadataReader.StringComparer; foreach (TypeDefinitionHandle tdNested in nestedClassDefinition.GetNestedTypes()) { TypeDefinition candidateClassDefinition = externalModule.MetadataReader.GetTypeDefinition(tdNested); - if (stringComparer.Equals(candidateClassDefinition.Name, typeName)) + if (externalModule.MetadataReader.StringEquals(candidateClassDefinition.Name, typeName)) { return (uint)externalModule.MetadataReader.GetToken(tdNested); } } if (_logger.IsVerbose) - _logger.Writer.WriteLine($"Ibc TypeToken {ibcToken:x} unable to find nested type '{typeName}' on type '{externalModule.MetadataReader.GetToken(enclosingType):x}'"); + _logger.Writer.WriteLine($"Ibc TypeToken {ibcToken:x} unable to find nested type '{Encoding.UTF8.GetString(typeName)}' on type '{externalModule.MetadataReader.GetToken(enclosingType):x}'"); return Cor.Macros.RidToToken(0, CorTokenType.mdtTypeDef); // Nil TypeDef token } } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs index f8083d77f7bcbb..1ad6d4bd1d9564 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO.Compression; using System.Reflection.Metadata; +using System.Text; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; @@ -636,19 +637,19 @@ public override MetadataType GetGlobalModuleType() throw new NotImplementedException(); } - public override object GetType(string nameSpace, string name, NotFoundBehavior notFoundBehavior) + public override object GetType(ReadOnlySpan nameSpace, ReadOnlySpan name, NotFoundBehavior notFoundBehavior) { TypeSystemContext context = Context; - if (context.SupportsCanon && (nameSpace == context.CanonType.GetNamespace()) && (name == context.CanonType.GetName())) + if (context.SupportsCanon && nameSpace.SequenceEqual(context.CanonType.U8Namespace) && name.SequenceEqual(context.CanonType.U8Name)) return Context.CanonType; - if (context.SupportsUniversalCanon && (nameSpace == context.UniversalCanonType.GetNamespace()) && (name == context.UniversalCanonType.GetName())) + if (context.SupportsUniversalCanon && nameSpace.SequenceEqual(context.UniversalCanonType.U8Namespace) && name.SequenceEqual(context.UniversalCanonType.U8Name)) return Context.UniversalCanonType; else { if (notFoundBehavior != NotFoundBehavior.ReturnNull) { - var failure = ResolutionFailure.GetTypeLoadResolutionFailure(nameSpace, name, "System.Private.Canon"); + var failure = ResolutionFailure.GetTypeLoadResolutionFailure(Encoding.UTF8.GetString(nameSpace), Encoding.UTF8.GetString(name), "System.Private.Canon"); if (notFoundBehavior == NotFoundBehavior.Throw) failure.Throw(); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/TypeSystem/Mutable/MutableModule.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/TypeSystem/Mutable/MutableModule.cs index c695aa1d97c8af..79c0853b0d817e 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/TypeSystem/Mutable/MutableModule.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/TypeSystem/Mutable/MutableModule.cs @@ -400,7 +400,7 @@ public string GetUserString(UserStringHandle handle) } throw new ArgumentException("Invalid UserStringHandle passed to MutableModule.GetObject"); } - public override object GetType(string nameSpace, string name, NotFoundBehavior notFoundBehavior) => throw new NotImplementedException(); + public override object GetType(ReadOnlySpan nameSpace, ReadOnlySpan name, NotFoundBehavior notFoundBehavior) => throw new NotImplementedException(); public TypeDesc GetType(EntityHandle handle) { TypeDesc type = GetObject(handle, NotFoundBehavior.Throw) as TypeDesc; diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs index edb434167da63e..3c7f75281ebc7d 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs @@ -759,9 +759,9 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum) break; case CorInfoHelpFunc.CORINFO_HELP_GETSYNCFROMCLASSHANDLE: - return _compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetSyncFromClassHandle"u8)); + return _compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers"u8, "GetSyncFromClassHandle"u8)); case CorInfoHelpFunc.CORINFO_HELP_GETCLASSFROMMETHODPARAM: - return _compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers", "GetClassFromMethodParam"u8)); + return _compilation.NodeFactory.MethodEntrypoint(_compilation.NodeFactory.TypeSystemContext.GetHelperEntryPoint("SynchronizedMethodHelpers"u8, "GetClassFromMethodParam"u8)); case CorInfoHelpFunc.CORINFO_HELP_GVMLOOKUP_FOR_SLOT: id = ReadyToRunHelper.GVMLookupForSlot; diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs index 3eae3ed7509513..2da5b5025d0eb1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs @@ -8,6 +8,7 @@ using System.Reflection; using System.Reflection.Metadata; using System.Runtime.Loader; +using System.Text; using ILCompiler; using Internal.IL; using Internal.TypeSystem; @@ -58,7 +59,7 @@ private CompilerTypeSystemContext CreateTypeSystemContext() internal IEnumerable<(TypeSystemEntity member, CustomAttribute ca)> GetMemberAssertions(Type type) { var module = TypeSystemContext.GetModuleFromPath(type.Assembly.Location); - var t = module.GetType(type.Namespace, type.Name, throwIfNotFound: false); + var t = module.GetType(type.Namespace == null ? ""u8 : Encoding.UTF8.GetBytes(type.Namespace), Encoding.UTF8.GetBytes(type.Name), throwIfNotFound: false); if (t == null) throw new InvalidOperationException($"type {type} not found in {module}"); var results = new List<(TypeSystemEntity, CustomAttribute)>(); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs index 294a91e9ed4997..987d49ce274c66 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ArchitectureSpecificFieldLayoutTests.cs @@ -65,9 +65,9 @@ public ArchitectureSpecificFieldLayoutTests() [Fact] public void TestInstanceLayoutDoubleBool() { - MetadataType tX64 = _testModuleX64.GetType("Sequential", "ClassDoubleBool"); - MetadataType tX86 = _testModuleX86.GetType("Sequential", "ClassDoubleBool"); - MetadataType tARM = _testModuleARM.GetType("Sequential", "ClassDoubleBool"); + MetadataType tX64 = _testModuleX64.GetType("Sequential"u8, "ClassDoubleBool"u8); + MetadataType tX86 = _testModuleX86.GetType("Sequential"u8, "ClassDoubleBool"u8); + MetadataType tARM = _testModuleARM.GetType("Sequential"u8, "ClassDoubleBool"u8); Assert.Equal(0x8, tX64.InstanceByteAlignment.AsInt); Assert.Equal(0x8, tARM.InstanceByteAlignment.AsInt); @@ -85,9 +85,9 @@ public void TestInstanceLayoutDoubleBool() [Fact] public void TestInstanceLayoutBoolDoubleBool() { - MetadataType tX64 = _testModuleX64.GetType("Sequential", "ClassBoolDoubleBool"); - MetadataType tX86 = _testModuleX86.GetType("Sequential", "ClassBoolDoubleBool"); - MetadataType tARM = _testModuleARM.GetType("Sequential", "ClassBoolDoubleBool"); + MetadataType tX64 = _testModuleX64.GetType("Sequential"u8, "ClassBoolDoubleBool"u8); + MetadataType tX86 = _testModuleX86.GetType("Sequential"u8, "ClassBoolDoubleBool"u8); + MetadataType tARM = _testModuleARM.GetType("Sequential"u8, "ClassBoolDoubleBool"u8); Assert.Equal(0x8, tX64.InstanceByteAlignment.AsInt); Assert.Equal(0x8, tARM.InstanceByteAlignment.AsInt); @@ -105,8 +105,8 @@ public void TestInstanceLayoutBoolDoubleBool() [Fact] public void TestAlignmentBehavior_LongIntEnumStruct() { - string _namespace = "EnumAlignment"; - string _type = "LongIntEnumStruct"; + ReadOnlySpan _namespace = "EnumAlignment"u8; + ReadOnlySpan _type = "LongIntEnumStruct"u8; MetadataType tX64 = _testModuleX64.GetType(_namespace, _type); MetadataType tX86 = _testModuleX86.GetType(_namespace, _type); @@ -148,9 +148,9 @@ public void TestAlignmentBehavior_LongIntEnumStruct() Assert.Equal(0x18, tARM.GetField("_4"u8).Offset.AsInt); Assert.Equal(0x18, tX86.GetField("_4"u8).Offset.AsInt); - MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); - MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); - MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); + MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, "LongIntEnumStructFieldStruct"u8); + MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, "LongIntEnumStructFieldStruct"u8); + MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, "LongIntEnumStructFieldStruct"u8); Assert.Equal(0x8, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); Assert.Equal(0x8, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); @@ -160,8 +160,8 @@ public void TestAlignmentBehavior_LongIntEnumStruct() [Fact] public void TestAlignmentBehavior_IntShortEnumStruct() { - string _namespace = "EnumAlignment"; - string _type = "IntShortEnumStruct"; + ReadOnlySpan _namespace = "EnumAlignment"u8; + ReadOnlySpan _type = "IntShortEnumStruct"u8; MetadataType tX64 = _testModuleX64.GetType(_namespace, _type); MetadataType tX86 = _testModuleX86.GetType(_namespace, _type); @@ -203,9 +203,9 @@ public void TestAlignmentBehavior_IntShortEnumStruct() Assert.Equal(0xC, tARM.GetField("_4"u8).Offset.AsInt); Assert.Equal(0xC, tX86.GetField("_4"u8).Offset.AsInt); - MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); - MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); - MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); + MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, "IntShortEnumStructFieldStruct"u8); + MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, "IntShortEnumStructFieldStruct"u8); + MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, "IntShortEnumStructFieldStruct"u8); Assert.Equal(0x4, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); Assert.Equal(0x4, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); @@ -216,8 +216,8 @@ public void TestAlignmentBehavior_IntShortEnumStruct() [Fact] public void TestAlignmentBehavior_ShortByteEnumStruct() { - string _namespace = "EnumAlignment"; - string _type = "ShortByteEnumStruct"; + ReadOnlySpan _namespace = "EnumAlignment"u8; + ReadOnlySpan _type = "ShortByteEnumStruct"u8; MetadataType tX64 = _testModuleX64.GetType(_namespace, _type); MetadataType tX86 = _testModuleX86.GetType(_namespace, _type); @@ -259,9 +259,9 @@ public void TestAlignmentBehavior_ShortByteEnumStruct() Assert.Equal(0x6, tARM.GetField("_4"u8).Offset.AsInt); Assert.Equal(0x6, tX86.GetField("_4"u8).Offset.AsInt); - MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); - MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); - MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); + MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, "ShortByteEnumStructFieldStruct"u8); + MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, "ShortByteEnumStructFieldStruct"u8); + MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, "ShortByteEnumStructFieldStruct"u8); Assert.Equal(0x2, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); Assert.Equal(0x2, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); @@ -271,8 +271,8 @@ public void TestAlignmentBehavior_ShortByteEnumStruct() [Fact] public void TestAlignmentBehavior_LongIntEnumStructAuto() { - string _namespace = "EnumAlignment"; - string _type = "LongIntEnumStructAuto"; + ReadOnlySpan _namespace = "EnumAlignment"u8; + ReadOnlySpan _type = "LongIntEnumStructAuto"u8; MetadataType tX64 = _testModuleX64.GetType(_namespace, _type); MetadataType tX86 = _testModuleX86.GetType(_namespace, _type); @@ -314,9 +314,9 @@ public void TestAlignmentBehavior_LongIntEnumStructAuto() Assert.Equal(0x14, tARM.GetField("_4"u8).Offset.AsInt); Assert.Equal(0x14, tX86.GetField("_4"u8).Offset.AsInt); - MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); - MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); - MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); + MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, "LongIntEnumStructAutoFieldStruct"u8); + MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, "LongIntEnumStructAutoFieldStruct"u8); + MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, "LongIntEnumStructAutoFieldStruct"u8); Assert.Equal(0x8, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); Assert.Equal(0x4, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); @@ -326,8 +326,8 @@ public void TestAlignmentBehavior_LongIntEnumStructAuto() [Fact] public void TestAlignmentBehavior_IntShortEnumStructAuto() { - string _namespace = "EnumAlignment"; - string _type = "IntShortEnumStructAuto"; + ReadOnlySpan _namespace = "EnumAlignment"u8; + ReadOnlySpan _type = "IntShortEnumStructAuto"u8; MetadataType tX64 = _testModuleX64.GetType(_namespace, _type); MetadataType tX86 = _testModuleX86.GetType(_namespace, _type); @@ -369,9 +369,9 @@ public void TestAlignmentBehavior_IntShortEnumStructAuto() Assert.Equal(0xA, tARM.GetField("_4"u8).Offset.AsInt); Assert.Equal(0xA, tX86.GetField("_4"u8).Offset.AsInt); - MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); - MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); - MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); + MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, "IntShortEnumStructAutoFieldStruct"u8); + MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, "IntShortEnumStructAutoFieldStruct"u8); + MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, "IntShortEnumStructAutoFieldStruct"u8); Assert.Equal(0x8, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); Assert.Equal(0x4, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); @@ -382,8 +382,8 @@ public void TestAlignmentBehavior_IntShortEnumStructAuto() [Fact] public void TestAlignmentBehavior_ShortByteEnumStructAuto() { - string _namespace = "EnumAlignment"; - string _type = "ShortByteEnumStructAuto"; + ReadOnlySpan _namespace = "EnumAlignment"u8; + ReadOnlySpan _type = "ShortByteEnumStructAuto"u8; MetadataType tX64 = _testModuleX64.GetType(_namespace, _type); MetadataType tX86 = _testModuleX86.GetType(_namespace, _type); @@ -425,9 +425,9 @@ public void TestAlignmentBehavior_ShortByteEnumStructAuto() Assert.Equal(0x5, tARM.GetField("_4"u8).Offset.AsInt); Assert.Equal(0x5, tX86.GetField("_4"u8).Offset.AsInt); - MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, _type + "FieldStruct"); - MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, _type + "FieldStruct"); - MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, _type + "FieldStruct"); + MetadataType tX64FieldStruct = _testModuleX64.GetType(_namespace, "ShortByteEnumStructAutoFieldStruct"u8); + MetadataType tX86FieldStruct = _testModuleX86.GetType(_namespace, "ShortByteEnumStructAutoFieldStruct"u8); + MetadataType tARMFieldStruct = _testModuleARM.GetType(_namespace, "ShortByteEnumStructAutoFieldStruct"u8); Assert.Equal(0x8, tX64FieldStruct.GetField("_struct"u8).Offset.AsInt); Assert.Equal(0x4, tX86FieldStruct.GetField("_struct"u8).Offset.AsInt); @@ -437,8 +437,8 @@ public void TestAlignmentBehavior_ShortByteEnumStructAuto() [Fact] public void TestAlignmentBehavior_StructStructByte_StructByteAuto() { - string _namespace = "Sequential"; - string _type = "StructStructByte_StructByteAuto"; + ReadOnlySpan _namespace = "Sequential"u8; + ReadOnlySpan _type = "StructStructByte_StructByteAuto"u8; MetadataType tX64 = _testModuleX64.GetType(_namespace, _type); MetadataType tX86 = _testModuleX86.GetType(_namespace, _type); @@ -471,8 +471,8 @@ public void TestAlignmentBehavior_StructStructByte_StructByteAuto() [InlineData("StructStructByte_Struct9BytesAuto", new int[] { 8, 4, 4 }, new int[] { 24, 16, 16 })] public void TestAlignmentBehavior_AutoAlignmentRules(string wrapperType, int[] alignment, int[] size) { - string _namespace = "Sequential"; - string _type = wrapperType; + ReadOnlySpan _namespace = "Sequential"u8; + ReadOnlySpan _type = System.Text.Encoding.UTF8.GetBytes(wrapperType); MetadataType tX64 = _testModuleX64.GetType(_namespace, _type); MetadataType tX86 = _testModuleX86.GetType(_namespace, _type); @@ -534,8 +534,8 @@ public void TestAlignmentBehavior_AutoAlignmentRulesWithOSDependence(string wrap throw new Exception(); } - string _namespace = "Sequential"; - string _type = wrapperType; + ReadOnlySpan _namespace = "Sequential"u8; + ReadOnlySpan _type = System.Text.Encoding.UTF8.GetBytes(wrapperType); MetadataType type = testModule.GetType(_namespace, _type); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs index c39b96d7abefb7..db3e8ad70612e0 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CanonicalizationTests.cs @@ -29,14 +29,14 @@ public CanonicalizationTests() _testModule = systemModule; - _referenceType = _testModule.GetType("Canonicalization", "ReferenceType"); - _otherReferenceType = _testModule.GetType("Canonicalization", "OtherReferenceType"); - _structType = _testModule.GetType("Canonicalization", "StructType"); - _otherStructType = _testModule.GetType("Canonicalization", "OtherStructType"); - _genericReferenceType = _testModule.GetType("Canonicalization", "GenericReferenceType`1"); - _genericStructType = _testModule.GetType("Canonicalization", "GenericStructType`1"); - _genericReferenceTypeWithThreeParams = _testModule.GetType("Canonicalization", "GenericReferenceTypeWithThreeParams`3"); - _genericStructTypeWithThreeParams = _testModule.GetType("Canonicalization", "GenericStructTypeWithThreeParams`3"); + _referenceType = _testModule.GetType("Canonicalization"u8, "ReferenceType"u8); + _otherReferenceType = _testModule.GetType("Canonicalization"u8, "OtherReferenceType"u8); + _structType = _testModule.GetType("Canonicalization"u8, "StructType"u8); + _otherStructType = _testModule.GetType("Canonicalization"u8, "OtherStructType"u8); + _genericReferenceType = _testModule.GetType("Canonicalization"u8, "GenericReferenceType`1"u8); + _genericStructType = _testModule.GetType("Canonicalization"u8, "GenericStructType`1"u8); + _genericReferenceTypeWithThreeParams = _testModule.GetType("Canonicalization"u8, "GenericReferenceTypeWithThreeParams`3"u8); + _genericStructTypeWithThreeParams = _testModule.GetType("Canonicalization"u8, "GenericStructTypeWithThreeParams`3"u8); } [Theory] diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs index e4f67f970768f2..5f01443fe99d46 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CastingTests.cs @@ -41,11 +41,11 @@ public void TestCastingInHierarchy() [Fact] public void TestInterfaceCasting() { - TypeDesc iFooType = _testModule.GetType("Casting", "IFoo"); + TypeDesc iFooType = _testModule.GetType("Casting"u8, "IFoo"u8); TypeDesc classImplementingIFooType = - _testModule.GetType("Casting", "ClassImplementingIFoo"); + _testModule.GetType("Casting"u8, "ClassImplementingIFoo"u8); TypeDesc classImplementingIFooIndirectlyType = - _testModule.GetType("Casting", "ClassImplementingIFooIndirectly"); + _testModule.GetType("Casting"u8, "ClassImplementingIFooIndirectly"u8); TypeDesc objectType = _context.GetWellKnownType(WellKnownType.Object); Assert.True(classImplementingIFooType.CanCastTo(iFooType)); @@ -68,9 +68,9 @@ public void TestSameSizeArrayTypeCasting() TypeDesc doubleType = _context.GetWellKnownType(WellKnownType.Double); TypeDesc boolType = _context.GetWellKnownType(WellKnownType.Boolean); - TypeDesc intBasedEnumType = _testModule.GetType("Casting", "IntBasedEnum"); - TypeDesc uintBasedEnumType = _testModule.GetType("Casting", "UIntBasedEnum"); - TypeDesc shortBasedEnumType = _testModule.GetType("Casting", "ShortBasedEnum"); + TypeDesc intBasedEnumType = _testModule.GetType("Casting"u8, "IntBasedEnum"u8); + TypeDesc uintBasedEnumType = _testModule.GetType("Casting"u8, "UIntBasedEnum"u8); + TypeDesc shortBasedEnumType = _testModule.GetType("Casting"u8, "ShortBasedEnum"u8); Assert.True(intType.MakeArrayType().CanCastTo(uintType.MakeArrayType())); Assert.True(intType.MakeArrayType().CanCastTo(uintType.MakeArrayType(1))); @@ -98,9 +98,9 @@ public void TestArrayInterfaceCasting() TypeDesc byteType = _context.GetWellKnownType(WellKnownType.Byte); TypeDesc objectType = _context.GetWellKnownType(WellKnownType.Object); TypeDesc stringType = _context.GetWellKnownType(WellKnownType.String); - TypeDesc intBasedEnumType = _testModule.GetType("Casting", "IntBasedEnum"); - MetadataType iListType = _context.SystemModule.GetType("System.Collections", "IList"); - MetadataType iListOfTType = _context.SystemModule.GetType("System.Collections.Generic", "IList`1"); + TypeDesc intBasedEnumType = _testModule.GetType("Casting"u8, "IntBasedEnum"u8); + MetadataType iListType = _context.SystemModule.GetType("System.Collections"u8, "IList"u8); + MetadataType iListOfTType = _context.SystemModule.GetType("System.Collections.Generic"u8, "IList`1"u8); InstantiatedType iListOfIntType = iListOfTType.MakeInstantiatedType(intType); InstantiatedType iListOfObjectType = iListOfTType.MakeInstantiatedType(objectType); @@ -156,16 +156,16 @@ public void TestArrayCasting() public void TestGenericParameterCasting() { TypeDesc paramWithNoConstraint = - _testModule.GetType("Casting", "ClassWithNoConstraint`1").Instantiation[0]; + _testModule.GetType("Casting"u8, "ClassWithNoConstraint`1"u8).Instantiation[0]; TypeDesc paramWithValueTypeConstraint = - _testModule.GetType("Casting", "ClassWithValueTypeConstraint`1").Instantiation[0]; + _testModule.GetType("Casting"u8, "ClassWithValueTypeConstraint`1"u8).Instantiation[0]; TypeDesc paramWithInterfaceConstraint = - _testModule.GetType("Casting", "ClassWithInterfaceConstraint`1").Instantiation[0]; + _testModule.GetType("Casting"u8, "ClassWithInterfaceConstraint`1"u8).Instantiation[0]; TypeDesc objectType = _context.GetWellKnownType(WellKnownType.Object); TypeDesc valueTypeType = _context.GetWellKnownType(WellKnownType.ValueType); - TypeDesc iFooType = _testModule.GetType("Casting", "IFoo"); - TypeDesc classImplementingIFooType = _testModule.GetType("Casting", "ClassImplementingIFoo"); + TypeDesc iFooType = _testModule.GetType("Casting"u8, "IFoo"u8); + TypeDesc classImplementingIFooType = _testModule.GetType("Casting"u8, "ClassImplementingIFoo"u8); Assert.True(paramWithNoConstraint.CanCastTo(objectType)); Assert.False(paramWithNoConstraint.CanCastTo(valueTypeType)); @@ -193,14 +193,14 @@ public void TestVariantCasting() TypeDesc stringSzArrayType = stringType.MakeArrayType(); MetadataType iEnumerableOfTType = - _context.SystemModule.GetType("System.Collections.Generic", "IEnumerable`1"); + _context.SystemModule.GetType("System.Collections.Generic"u8, "IEnumerable`1"u8); InstantiatedType iEnumerableOfObjectType = iEnumerableOfTType.MakeInstantiatedType(objectType); InstantiatedType iEnumerableOfExceptionType = iEnumerableOfTType.MakeInstantiatedType(exceptionType); Assert.True(stringSzArrayType.CanCastTo(iEnumerableOfObjectType)); Assert.False(stringSzArrayType.CanCastTo(iEnumerableOfExceptionType)); - MetadataType iContravariantOfTType = _testModule.GetType("Casting", "IContravariant`1"); + MetadataType iContravariantOfTType = _testModule.GetType("Casting"u8, "IContravariant`1"u8); InstantiatedType iContravariantOfObjectType = iContravariantOfTType.MakeInstantiatedType(objectType); InstantiatedType iEnumerableOfStringType = iEnumerableOfTType.MakeInstantiatedType(stringType); @@ -221,13 +221,13 @@ public void TestNullableCasting() [Fact] public void TestGenericParameterArrayCasting() { - TypeDesc baseArrayType = _testModule.GetType("Casting", "Base").MakeArrayType(); - TypeDesc iFooArrayType = _testModule.GetType("Casting", "IFoo").MakeArrayType(); + TypeDesc baseArrayType = _testModule.GetType("Casting"u8, "Base"u8).MakeArrayType(); + TypeDesc iFooArrayType = _testModule.GetType("Casting"u8, "IFoo"u8).MakeArrayType(); TypeDesc paramArrayWithBaseClassConstraint = - _testModule.GetType("Casting", "ClassWithBaseClassConstraint`1").Instantiation[0].MakeArrayType(); + _testModule.GetType("Casting"u8, "ClassWithBaseClassConstraint`1"u8).Instantiation[0].MakeArrayType(); TypeDesc paramArrayWithInterfaceConstraint = - _testModule.GetType("Casting", "ClassWithInterfaceConstraint`1").Instantiation[0].MakeArrayType(); + _testModule.GetType("Casting"u8, "ClassWithInterfaceConstraint`1"u8).Instantiation[0].MakeArrayType(); Assert.True(paramArrayWithBaseClassConstraint.CanCastTo(baseArrayType)); Assert.False(paramArrayWithInterfaceConstraint.CanCastTo(iFooArrayType)); @@ -238,8 +238,8 @@ public void TestRecursiveCanCast() { // Tests the stack overflow protection in CanCastTo - TypeDesc classWithRecursiveImplementation = _testModule.GetType("Casting", "ClassWithRecursiveImplementation"); - MetadataType iContravariantOfTType = (MetadataType)_testModule.GetType("Casting", "IContravariant`1"); + TypeDesc classWithRecursiveImplementation = _testModule.GetType("Casting"u8, "ClassWithRecursiveImplementation"u8); + MetadataType iContravariantOfTType = (MetadataType)_testModule.GetType("Casting"u8, "IContravariant`1"u8); TypeDesc testType = iContravariantOfTType.MakeInstantiatedType(classWithRecursiveImplementation); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs index 8e50761b8eda53..a3fb0b75b0b8a6 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs @@ -47,31 +47,31 @@ public ConstraintsValidationTest() _testModule = systemModule; - _iNonGenType = _testModule.GetType("GenericConstraints", "INonGen"); - _iGenType = _testModule.GetType("GenericConstraints", "IGen`1"); - _arg1Type = _testModule.GetType("GenericConstraints", "Arg1"); - _arg2Type = _testModule.GetType("GenericConstraints", "Arg2`1"); - _arg3Type = _testModule.GetType("GenericConstraints", "Arg3`1"); - _structArgWithDefaultCtorType = _testModule.GetType("GenericConstraints", "StructArgWithDefaultCtor"); - _structArgWithoutDefaultCtorType = _testModule.GetType("GenericConstraints", "StructArgWithoutDefaultCtor"); - _classArgWithDefaultCtorType = _testModule.GetType("GenericConstraints", "ClassArgWithDefaultCtor"); - _classArgWithPrivateDefaultCtorType = _testModule.GetType("GenericConstraints", "ClassArgWithPrivateDefaultCtor"); - _abstractClassArgWithDefaultCtorType = _testModule.GetType("GenericConstraints", "AbstractClassArgWithDefaultCtor"); - _classArgWithoutDefaultCtorType = _testModule.GetType("GenericConstraints", "ClassArgWithoutDefaultCtor"); - - _referenceTypeConstraintType = _testModule.GetType("GenericConstraints", "ReferenceTypeConstraint`1"); - _defaultConstructorConstraintType = _testModule.GetType("GenericConstraints", "DefaultConstructorConstraint`1"); - _notNullableValueTypeConstraintType = _testModule.GetType("GenericConstraints", "NotNullableValueTypeConstraint`1"); - _simpleTypeConstraintType = _testModule.GetType("GenericConstraints", "SimpleTypeConstraint`1"); - _doubleSimpleTypeConstraintType = _testModule.GetType("GenericConstraints", "DoubleSimpleTypeConstraint`1"); - _simpleGenericConstraintType = _testModule.GetType("GenericConstraints", "SimpleGenericConstraint`2"); - _complexGenericConstraint1Type = _testModule.GetType("GenericConstraints", "ComplexGenericConstraint1`2"); - _complexGenericConstraint2Type = _testModule.GetType("GenericConstraints", "ComplexGenericConstraint2`2"); - _complexGenericConstraint3Type = _testModule.GetType("GenericConstraints", "ComplexGenericConstraint3`2"); - _complexGenericConstraint4Type = _testModule.GetType("GenericConstraints", "ComplexGenericConstraint4`2"); - _multipleConstraintsType = _testModule.GetType("GenericConstraints", "MultipleConstraints`2"); - - _genericMethodsType = _testModule.GetType("GenericConstraints", "GenericMethods"); + _iNonGenType = _testModule.GetType("GenericConstraints"u8, "INonGen"u8); + _iGenType = _testModule.GetType("GenericConstraints"u8, "IGen`1"u8); + _arg1Type = _testModule.GetType("GenericConstraints"u8, "Arg1"u8); + _arg2Type = _testModule.GetType("GenericConstraints"u8, "Arg2`1"u8); + _arg3Type = _testModule.GetType("GenericConstraints"u8, "Arg3`1"u8); + _structArgWithDefaultCtorType = _testModule.GetType("GenericConstraints"u8, "StructArgWithDefaultCtor"u8); + _structArgWithoutDefaultCtorType = _testModule.GetType("GenericConstraints"u8, "StructArgWithoutDefaultCtor"u8); + _classArgWithDefaultCtorType = _testModule.GetType("GenericConstraints"u8, "ClassArgWithDefaultCtor"u8); + _classArgWithPrivateDefaultCtorType = _testModule.GetType("GenericConstraints"u8, "ClassArgWithPrivateDefaultCtor"u8); + _abstractClassArgWithDefaultCtorType = _testModule.GetType("GenericConstraints"u8, "AbstractClassArgWithDefaultCtor"u8); + _classArgWithoutDefaultCtorType = _testModule.GetType("GenericConstraints"u8, "ClassArgWithoutDefaultCtor"u8); + + _referenceTypeConstraintType = _testModule.GetType("GenericConstraints"u8, "ReferenceTypeConstraint`1"u8); + _defaultConstructorConstraintType = _testModule.GetType("GenericConstraints"u8, "DefaultConstructorConstraint`1"u8); + _notNullableValueTypeConstraintType = _testModule.GetType("GenericConstraints"u8, "NotNullableValueTypeConstraint`1"u8); + _simpleTypeConstraintType = _testModule.GetType("GenericConstraints"u8, "SimpleTypeConstraint`1"u8); + _doubleSimpleTypeConstraintType = _testModule.GetType("GenericConstraints"u8, "DoubleSimpleTypeConstraint`1"u8); + _simpleGenericConstraintType = _testModule.GetType("GenericConstraints"u8, "SimpleGenericConstraint`2"u8); + _complexGenericConstraint1Type = _testModule.GetType("GenericConstraints"u8, "ComplexGenericConstraint1`2"u8); + _complexGenericConstraint2Type = _testModule.GetType("GenericConstraints"u8, "ComplexGenericConstraint2`2"u8); + _complexGenericConstraint3Type = _testModule.GetType("GenericConstraints"u8, "ComplexGenericConstraint3`2"u8); + _complexGenericConstraint4Type = _testModule.GetType("GenericConstraints"u8, "ComplexGenericConstraint4`2"u8); + _multipleConstraintsType = _testModule.GetType("GenericConstraints"u8, "MultipleConstraints`2"u8); + + _genericMethodsType = _testModule.GetType("GenericConstraints"u8, "GenericMethods"u8); _simpleGenericConstraintMethod = _genericMethodsType.GetMethod("SimpleGenericConstraintMethod"u8, null); _complexGenericConstraintMethod = _genericMethodsType.GetMethod("ComplexGenericConstraintMethod"u8, null); } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/DefType.FieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/DefType.FieldLayoutTests.cs index f41f4a7ea63068..b1b6e8309d056e 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/DefType.FieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/DefType.FieldLayoutTests.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Text; using Internal.TypeSystem; using Xunit; @@ -35,7 +36,7 @@ public DefTypeTests() [InlineData("SequentialInt64Base")] public void IsZeroSizedReferenceType_NonEmptyType_ReturnsFalse(string className) { - DefType nonEmptyClass = _testModule.GetType("Marshalling", className); + DefType nonEmptyClass = _testModule.GetType("Marshalling"u8, Encoding.UTF8.GetBytes(className)); Assert.False(nonEmptyClass.IsZeroSizedReferenceType); } @@ -46,7 +47,7 @@ public void IsZeroSizedReferenceType_NonEmptyType_ReturnsFalse(string className) [InlineData("SequentialEmptyBase")] public void IsZeroSizedReferenceType_EmptyType_ReturnsTrue(string className) { - DefType emptyClass = _testModule.GetType("Marshalling", className); + DefType emptyClass = _testModule.GetType("Marshalling"u8, Encoding.UTF8.GetBytes(className)); Assert.True(emptyClass.IsZeroSizedReferenceType); } } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GCPointerMapTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GCPointerMapTests.cs index de3fc50334146c..3c01c0fe82fb02 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GCPointerMapTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GCPointerMapTests.cs @@ -24,13 +24,13 @@ public GCPointerMapTests() [Fact] public void TestInstanceMap() { - MetadataType classWithArrayFields = _testModule.GetType("GCPointerMap", "ClassWithArrayFields"); - MetadataType classWithStringField = _testModule.GetType("GCPointerMap", "ClassWithStringField"); - MetadataType mixedStruct = _testModule.GetType("GCPointerMap", "MixedStruct"); - MetadataType structWithSameGCLayoutAsMixedStruct = _testModule.GetType("GCPointerMap", "StructWithSameGCLayoutAsMixedStruct"); - MetadataType doubleMixedStructLayout = _testModule.GetType("GCPointerMap", "DoubleMixedStructLayout"); - MetadataType explicitlyFarPointer = _testModule.GetType("GCPointerMap", "ExplicitlyFarPointer"); - MetadataType struct32GcPointers = _testModule.GetType("GCPointerMap", "Struct32GcPointers"); + MetadataType classWithArrayFields = _testModule.GetType("GCPointerMap"u8, "ClassWithArrayFields"u8); + MetadataType classWithStringField = _testModule.GetType("GCPointerMap"u8, "ClassWithStringField"u8); + MetadataType mixedStruct = _testModule.GetType("GCPointerMap"u8, "MixedStruct"u8); + MetadataType structWithSameGCLayoutAsMixedStruct = _testModule.GetType("GCPointerMap"u8, "StructWithSameGCLayoutAsMixedStruct"u8); + MetadataType doubleMixedStructLayout = _testModule.GetType("GCPointerMap"u8, "DoubleMixedStructLayout"u8); + MetadataType explicitlyFarPointer = _testModule.GetType("GCPointerMap"u8, "ExplicitlyFarPointer"u8); + MetadataType struct32GcPointers = _testModule.GetType("GCPointerMap"u8, "Struct32GcPointers"u8); { var map = GCPointerMap.FromInstanceLayout(classWithArrayFields); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs index aa2388be5b2cde..2b606296c1d88c 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/GenericTypeAndMethodTests.cs @@ -27,7 +27,7 @@ public GenericMethodTests() [Fact] public void TestInstantiation() { - MetadataType t = _testModule.GetType("GenericTypes", "GenericClass`1"); + MetadataType t = _testModule.GetType("GenericTypes"u8, "GenericClass`1"u8); // Verify that we get just type definitions. Assert.NotNull(t); @@ -68,8 +68,8 @@ public void TestInstantiation() [Fact] public void TestMethodAttributes() { - MetadataType tGen = _testModule.GetType("GenericTypes", "GenericClass`1"); - MetadataType tDerivedGen = _testModule.GetType("GenericTypes", "DerivedGenericClass`1"); + MetadataType tGen = _testModule.GetType("GenericTypes"u8, "GenericClass`1"u8); + MetadataType tDerivedGen = _testModule.GetType("GenericTypes"u8, "DerivedGenericClass`1"u8); InstantiatedType genOfInt = tGen.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); InstantiatedType derivedGenOfInt = tDerivedGen.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); MethodDesc fooInstantiatedMethod = genOfInt.GetMethods().First(m => m.GetName() == "Foo"); @@ -95,8 +95,8 @@ public void TestMethodAttributes() [Fact] public void TestFinalize() { - MetadataType tGen = _testModule.GetType("GenericTypes", "GenericClass`1"); - MetadataType tDerivedGen = _testModule.GetType("GenericTypes", "DerivedGenericClass`1"); + MetadataType tGen = _testModule.GetType("GenericTypes"u8, "GenericClass`1"u8); + MetadataType tDerivedGen = _testModule.GetType("GenericTypes"u8, "DerivedGenericClass`1"u8); InstantiatedType genOfInt = tGen.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); InstantiatedType derivedGenOfInt = tDerivedGen.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); MethodDesc finalizeInstantiatedMethod = genOfInt.GetMethods().First(m => m.GetName() == "Finalize"); @@ -111,7 +111,7 @@ public void TestFinalize() [Fact] public void TestMethodLookup() { - MetadataType t = _testModule.GetType("GenericTypes", "GenericClass`1").MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); + MetadataType t = _testModule.GetType("GenericTypes"u8, "GenericClass`1"u8).MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); MethodSignature sig = new MethodSignature(MethodSignatureFlags.None, 0, _context.GetSignatureVariable(0, false), System.Array.Empty()); MethodDesc fooMethod = t.GetMethod("Foo"u8, sig); @@ -126,7 +126,7 @@ public void TestConstructedTypeAdjustment() TypeDesc charType = _context.GetWellKnownType(WellKnownType.Char); TypeDesc objectType = _context.GetWellKnownType(WellKnownType.Object); - MetadataType genericOpenType = _testModule.GetType("GenericTypes", "TwoParamGenericClass`2"); + MetadataType genericOpenType = _testModule.GetType("GenericTypes"u8, "TwoParamGenericClass`2"u8); InstantiatedType genericOfCharObject = genericOpenType.MakeInstantiatedType(charType, objectType); InstantiatedType genericOfCharString = genericOpenType.MakeInstantiatedType(charType, stringType); @@ -219,8 +219,8 @@ public void TestConstructedMethodAdjustment() TypeDesc charType = _context.GetWellKnownType(WellKnownType.Char); TypeDesc objectType = _context.GetWellKnownType(WellKnownType.Object); - MetadataType genericOpenType = _testModule.GetType("GenericTypes", "TwoParamGenericClass`2"); - MetadataType nonGenericType = _testModule.GetType("GenericTypes", "NonGenericClass"); + MetadataType genericOpenType = _testModule.GetType("GenericTypes"u8, "TwoParamGenericClass`2"u8); + MetadataType nonGenericType = _testModule.GetType("GenericTypes"u8, "NonGenericClass"u8); MethodDesc genericOnNonGeneric = nonGenericType.GetMethod("GenericFunction"u8, null); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILDisassemblerTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILDisassemblerTests.cs index a132e85493b9f3..d54f7c48fb782e 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILDisassemblerTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILDisassemblerTests.cs @@ -28,7 +28,7 @@ public ILDisassemblerTests() [Fact] public void TestGenericNameFormatting() { - MetadataType testClass = _testModule.GetType("ILDisassembler", "TestGenericClass`1"); + MetadataType testClass = _testModule.GetType("ILDisassembler"u8, "TestGenericClass`1"u8); EcmaMethod testMethod = (EcmaMethod)testClass.GetMethod("TestMethod"u8, null); EcmaMethodIL methodIL = EcmaMethodIL.Create(testMethod); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs index 270c2d0c01ae4b..3ef771721bb86a 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InstanceFieldLayoutTests.cs @@ -28,7 +28,7 @@ public InstanceFieldLayoutTests() [Fact] public void TestExplicitLayout() { - MetadataType t = _testModule.GetType("Explicit", "Class1"); + MetadataType t = _testModule.GetType("Explicit"u8, "Class1"u8); // With 64bit, there should be 8 bytes for the System.Object EE data pointer + // 10 bytes up until the offset of the char field + the char size of 2 + we @@ -61,12 +61,12 @@ public void TestExplicitLayout() [Fact] public void TestExplicitLayoutThatIsEmpty() { - var explicitEmptyClassType = _testModule.GetType("Explicit", "ExplicitEmptyClass"); + var explicitEmptyClassType = _testModule.GetType("Explicit"u8, "ExplicitEmptyClass"u8); // ExplicitEmpty class has 8 from System.Object overhead = 8 Assert.Equal(8, explicitEmptyClassType.InstanceByteCount.AsInt); - var explicitEmptyStructType = _testModule.GetType("Explicit", "ExplicitEmptyStruct"); + var explicitEmptyStructType = _testModule.GetType("Explicit"u8, "ExplicitEmptyStruct"u8); // ExplicitEmpty class has 0 bytes in it... so instance field size gets pushed up to 1. Assert.Equal(1, explicitEmptyStructType.InstanceFieldSize.AsInt); @@ -75,14 +75,14 @@ public void TestExplicitLayoutThatIsEmpty() [Fact] public void TestExplicitTypeLayoutWithSize() { - var explicitSizeType = _testModule.GetType("Explicit", "ExplicitSize"); + var explicitSizeType = _testModule.GetType("Explicit"u8, "ExplicitSize"u8); Assert.Equal(32, explicitSizeType.InstanceByteCount.AsInt); } [Fact] public void TestExplicitTypeLayoutWithInheritance() { - MetadataType class2Type = _testModule.GetType("Explicit", "Class2"); + MetadataType class2Type = _testModule.GetType("Explicit"u8, "Class2"u8); // Class1 has size 24 which Class2 inherits from. Class2 adds a byte at offset 20, so + 21 // = 45, rounding up to the next pointer size = 48 @@ -115,12 +115,12 @@ public void TestExplicitTypeLayoutWithInheritance() public void TestInvalidExplicitTypeLayout() { { - DefType type = _testModule.GetType("Explicit", "MisalignedPointer"); + DefType type = _testModule.GetType("Explicit"u8, "MisalignedPointer"u8); Assert.Throws(() => type.ComputeInstanceLayout(InstanceLayoutKind.TypeAndFields)); } { - DefType type = _testModule.GetType("Explicit", "MisalignedByRef"); + DefType type = _testModule.GetType("Explicit"u8, "MisalignedByRef"u8); Assert.Throws(() => type.ComputeInstanceLayout(InstanceLayoutKind.TypeAndFields)); } } @@ -128,7 +128,7 @@ public void TestInvalidExplicitTypeLayout() [Fact] public void TestSequentialTypeLayout() { - MetadataType class1Type = _testModule.GetType("Sequential", "Class1"); + MetadataType class1Type = _testModule.GetType("Sequential"u8, "Class1"u8); // Byte count // Base Class 8 @@ -177,7 +177,7 @@ public void TestSequentialTypeLayout() [Fact] public void TestSequentialTypeLayoutInheritance() { - MetadataType class2Type = _testModule.GetType("Sequential", "Class2"); + MetadataType class2Type = _testModule.GetType("Sequential"u8, "Class2"u8); // Byte count // Base Class 40 @@ -206,7 +206,7 @@ public void TestSequentialTypeLayoutInheritance() [Fact] public void TestSequentialTypeLayoutStruct() { - MetadataType struct0Type = _testModule.GetType("Sequential", "Struct0"); + MetadataType struct0Type = _testModule.GetType("Sequential"u8, "Struct0"u8); // Byte count // bool b1 1 @@ -252,7 +252,7 @@ public void TestSequentialTypeLayoutStruct() // as a value type) and not a pointer size. public void TestSequentialTypeLayoutStructEmbedded() { - MetadataType struct1Type = _testModule.GetType("Sequential", "Struct1"); + MetadataType struct1Type = _testModule.GetType("Sequential"u8, "Struct1"u8); // Byte count // struct MyStruct0 16 @@ -284,7 +284,7 @@ public void TestSequentialTypeLayoutStructEmbedded() [Fact] public void TestSequentialTypeLayoutClass16Align() { - MetadataType classType = _testModule.GetType("Sequential", "Class16Align"); + MetadataType classType = _testModule.GetType("Sequential"u8, "Class16Align"u8); Assert.Equal(0x18, classType.InstanceByteCount.AsInt); foreach (var f in classType.GetFields()) { @@ -306,7 +306,7 @@ public void TestSequentialTypeLayoutClass16Align() [Fact] public void TestSequentialTypeLayoutClass32Align() { - MetadataType classType = _testModule.GetType("Sequential", "Class32Align"); + MetadataType classType = _testModule.GetType("Sequential"u8, "Class32Align"u8); Assert.Equal(0x28, classType.InstanceByteCount.AsInt); foreach (var f in classType.GetFields()) { @@ -328,7 +328,7 @@ public void TestSequentialTypeLayoutClass32Align() [Fact] public void TestSequentialTypeLayoutClass64Align() { - MetadataType classType = _testModule.GetType("Sequential", "Class64Align"); + MetadataType classType = _testModule.GetType("Sequential"u8, "Class64Align"u8); Assert.Equal(0x48, classType.InstanceByteCount.AsInt); foreach (var f in classType.GetFields()) { @@ -350,7 +350,7 @@ public void TestSequentialTypeLayoutClass64Align() [Fact] public void TestAutoLayoutStruct() { - MetadataType structWithIntCharType = _testModule.GetType("Auto", "StructWithIntChar"); + MetadataType structWithIntCharType = _testModule.GetType("Auto"u8, "StructWithIntChar"u8); // Byte count // MyStructInt 4 @@ -382,7 +382,7 @@ public void TestAutoLayoutStruct() [Fact] public void TestAutoTypeLayoutClassContainingStructs() { - MetadataType classContainingStructsType = _testModule.GetType("Auto", "ClassContainingStructs"); + MetadataType classContainingStructsType = _testModule.GetType("Auto"u8, "ClassContainingStructs"u8); // Byte count // Base Class 8 @@ -452,7 +452,7 @@ public void TestAutoTypeLayoutClassContainingStructs() [Fact] public void TestAutoTypeLayoutBaseClass7BytesRemaining() { - MetadataType baseClass7BytesRemainingType = _testModule.GetType("Auto", "BaseClass7BytesRemaining"); + MetadataType baseClass7BytesRemainingType = _testModule.GetType("Auto"u8, "BaseClass7BytesRemaining"u8); // Byte count // Base Class 8 @@ -497,7 +497,7 @@ public void TestAutoTypeLayoutBaseClass7BytesRemaining() [Fact] public void TestAutoTypeLayoutBaseClass4BytesRemaining() { - MetadataType baseClass4BytesRemainingType = _testModule.GetType("Auto", "BaseClass4BytesRemaining"); + MetadataType baseClass4BytesRemainingType = _testModule.GetType("Auto"u8, "BaseClass4BytesRemaining"u8); // Byte count // Base Class 8 @@ -530,7 +530,7 @@ public void TestAutoTypeLayoutBaseClass4BytesRemaining() [Fact] public void TestAutoTypeLayoutBaseClass3BytesRemaining() { - MetadataType baseClass3BytesRemainingType = _testModule.GetType("Auto", "BaseClass3BytesRemaining"); + MetadataType baseClass3BytesRemainingType = _testModule.GetType("Auto"u8, "BaseClass3BytesRemaining"u8); // Byte count // Base Class 8 @@ -567,7 +567,7 @@ public void TestAutoTypeLayoutBaseClass3BytesRemaining() [Fact] public void TestAutoTypeLayoutOptimizePartial() { - MetadataType optimizePartialType = _testModule.GetType("Auto", "OptimizePartial"); + MetadataType optimizePartialType = _testModule.GetType("Auto"u8, "OptimizePartial"u8); // Byte count // Base Class 41 (unaligned) @@ -608,7 +608,7 @@ public void TestAutoTypeLayoutOptimizePartial() [Fact] public void TestAutoTypeLayoutOptimize7Bools() { - MetadataType optimize7BoolsType = _testModule.GetType("Auto", "Optimize7Bools"); + MetadataType optimize7BoolsType = _testModule.GetType("Auto"u8, "Optimize7Bools"u8); // Byte count // Base Class 41 (unaligned) @@ -669,7 +669,7 @@ public void TestAutoTypeLayoutOptimize7Bools() [Fact] public void TestAutoTypeLayoutOptimizeAlignedFields() { - MetadataType optimizeAlignedFieldsType = _testModule.GetType("Auto", "OptimizeAlignedFields"); + MetadataType optimizeAlignedFieldsType = _testModule.GetType("Auto"u8, "OptimizeAlignedFields"u8); // Byte count // Base Class 41 (unaligned) @@ -722,7 +722,7 @@ public void TestAutoTypeLayoutOptimizeAlignedFields() [Fact] public void TestAutoTypeLayoutOptimizeLargestField() { - MetadataType optimizeLargestFieldType = _testModule.GetType("Auto", "OptimizeLargestField"); + MetadataType optimizeLargestFieldType = _testModule.GetType("Auto"u8, "OptimizeLargestField"u8); // Byte count // Base Class 20 (unaligned) @@ -763,7 +763,7 @@ public void TestAutoTypeLayoutOptimizeLargestField() [Fact] public void TestAutoTypeLayoutNoOptimizeMisaligned() { - MetadataType noOptimizeMisalignedType = _testModule.GetType("Auto", "NoOptimizeMisaligned"); + MetadataType noOptimizeMisalignedType = _testModule.GetType("Auto"u8, "NoOptimizeMisaligned"u8); // Byte count // Base Class 21 (unaligned) + 3 byte padding to make class size % pointer size == 0 @@ -800,7 +800,7 @@ public void TestAutoTypeLayoutNoOptimizeMisaligned() [Fact] public void TestAutoTypeLayoutNoOptimizeCharAtSize2Alignment() { - MetadataType noOptimizeCharAtSize2AlignmentType = _testModule.GetType("Auto", "NoOptimizeCharAtSize2Alignment"); + MetadataType noOptimizeCharAtSize2AlignmentType = _testModule.GetType("Auto"u8, "NoOptimizeCharAtSize2Alignment"u8); // Byte count // Base Class 21 (unaligned) + 1 byte padding to align char @@ -843,7 +843,7 @@ public static IEnumerable AutoTypeLayoutMinPackingData() [MemberData(nameof(AutoTypeLayoutMinPackingData))] public void TestAutoTypeLayoutMinPacking(WellKnownType type, int expectedSize) { - MetadataType minPackingType = _testModule.GetType("Auto", "MinPacking`1"); + MetadataType minPackingType = _testModule.GetType("Auto"u8, "MinPacking`1"u8); InstantiatedType inst = minPackingType.MakeInstantiatedType(_context.GetWellKnownType(type)); Assert.Equal(expectedSize, inst.InstanceFieldSize.AsInt); } @@ -851,7 +851,7 @@ public void TestAutoTypeLayoutMinPacking(WellKnownType type, int expectedSize) [Fact] public void TestAutoTypeLayoutClass16Align() { - MetadataType classType = _testModule.GetType("Auto", "Class16Align"); + MetadataType classType = _testModule.GetType("Auto"u8, "Class16Align"u8); Assert.Equal(0x18, classType.InstanceByteCount.AsInt); foreach (var f in classType.GetFields()) { @@ -873,7 +873,7 @@ public void TestAutoTypeLayoutClass16Align() [Fact] public void TestAutoTypeLayoutClass32Align() { - MetadataType classType = _testModule.GetType("Auto", "Class32Align"); + MetadataType classType = _testModule.GetType("Auto"u8, "Class32Align"u8); Assert.Equal(0x28, classType.InstanceByteCount.AsInt); foreach (var f in classType.GetFields()) { @@ -895,7 +895,7 @@ public void TestAutoTypeLayoutClass32Align() [Fact] public void TestAutoTypeLayoutClass64Align() { - MetadataType classType = _testModule.GetType("Auto", "Class64Align"); + MetadataType classType = _testModule.GetType("Auto"u8, "Class64Align"u8); Assert.Equal(0x48, classType.InstanceByteCount.AsInt); foreach (var f in classType.GetFields()) { @@ -917,31 +917,31 @@ public void TestAutoTypeLayoutClass64Align() [Fact] public void TestTypeContainsGCPointers() { - MetadataType type = _testModule.GetType("ContainsGCPointers", "NoPointers"); + MetadataType type = _testModule.GetType("ContainsGCPointers"u8, "NoPointers"u8); Assert.False(type.ContainsGCPointers); - type = _testModule.GetType("ContainsGCPointers", "StillNoPointers"); + type = _testModule.GetType("ContainsGCPointers"u8, "StillNoPointers"u8); Assert.False(type.ContainsGCPointers); - type = _testModule.GetType("ContainsGCPointers", "ClassNoPointers"); + type = _testModule.GetType("ContainsGCPointers"u8, "ClassNoPointers"u8); Assert.False(type.ContainsGCPointers); - type = _testModule.GetType("ContainsGCPointers", "HasPointers"); + type = _testModule.GetType("ContainsGCPointers"u8, "HasPointers"u8); Assert.True(type.ContainsGCPointers); - type = _testModule.GetType("ContainsGCPointers", "FieldHasPointers"); + type = _testModule.GetType("ContainsGCPointers"u8, "FieldHasPointers"u8); Assert.True(type.ContainsGCPointers); - type = _testModule.GetType("ContainsGCPointers", "ClassHasPointers"); + type = _testModule.GetType("ContainsGCPointers"u8, "ClassHasPointers"u8); Assert.True(type.ContainsGCPointers); - type = _testModule.GetType("ContainsGCPointers", "BaseClassHasPointers"); + type = _testModule.GetType("ContainsGCPointers"u8, "BaseClassHasPointers"u8); Assert.True(type.ContainsGCPointers); - type = _testModule.GetType("ContainsGCPointers", "ClassHasIntArray"); + type = _testModule.GetType("ContainsGCPointers"u8, "ClassHasIntArray"u8); Assert.True(type.ContainsGCPointers); - type = _testModule.GetType("ContainsGCPointers", "ClassHasArrayOfClassType"); + type = _testModule.GetType("ContainsGCPointers"u8, "ClassHasArrayOfClassType"u8); Assert.True(type.ContainsGCPointers); } @@ -954,12 +954,12 @@ public void TestByRefLikeTypes() } { - DefType type = _testModule.GetType("IsByRefLike", "ByRefLikeStruct"); + DefType type = _testModule.GetType("IsByRefLike"u8, "ByRefLikeStruct"u8); Assert.True(type.IsByRefLike); } { - DefType type = _testModule.GetType("IsByRefLike", "NotByRefLike"); + DefType type = _testModule.GetType("IsByRefLike"u8, "NotByRefLike"u8); Assert.False(type.IsByRefLike); } } @@ -968,17 +968,17 @@ public void TestByRefLikeTypes() public void TestInvalidByRefLikeTypes() { { - DefType type = _ilTestModule.GetType("IsByRefLike", "InvalidClass1"); + DefType type = _ilTestModule.GetType("IsByRefLike"u8, "InvalidClass1"u8); Assert.Throws(() => type.ComputeInstanceLayout(InstanceLayoutKind.TypeAndFields)); } { - DefType type = _ilTestModule.GetType("IsByRefLike", "InvalidClass2"); + DefType type = _ilTestModule.GetType("IsByRefLike"u8, "InvalidClass2"u8); Assert.Throws(() => type.ComputeInstanceLayout(InstanceLayoutKind.TypeAndFields)); } { - DefType type = _ilTestModule.GetType("IsByRefLike", "InvalidStruct"); + DefType type = _ilTestModule.GetType("IsByRefLike"u8, "InvalidStruct"u8); Assert.Throws(() => type.ComputeInstanceLayout(InstanceLayoutKind.TypeAndFields)); } } @@ -987,50 +987,50 @@ public void TestInvalidByRefLikeTypes() public void TestWrapperAroundVectorTypes() { { - MetadataType type = (MetadataType)_testModule.GetType("System.Runtime.Intrinsics", "Vector128`1"); + MetadataType type = (MetadataType)_testModule.GetType("System.Runtime.Intrinsics"u8, "Vector128`1"u8); MetadataType instantiatedType = type.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Byte)); Assert.Equal(16, instantiatedType.InstanceFieldAlignment.AsInt); } { - MetadataType type = (MetadataType)_testModule.GetType("System.Runtime.Intrinsics", "Vector256`1"); + MetadataType type = (MetadataType)_testModule.GetType("System.Runtime.Intrinsics"u8, "Vector256`1"u8); MetadataType instantiatedType = type.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Byte)); Assert.Equal(32, instantiatedType.InstanceFieldAlignment.AsInt); } { - MetadataType type = (MetadataType)_testModule.GetType("System.Runtime.Intrinsics", "Vector512`1"); + MetadataType type = (MetadataType)_testModule.GetType("System.Runtime.Intrinsics"u8, "Vector512`1"u8); MetadataType instantiatedType = type.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Byte)); Assert.Equal(64, instantiatedType.InstanceFieldAlignment.AsInt); } { - DefType type = _testModule.GetType("Auto", "int8x16x2"); + DefType type = _testModule.GetType("Auto"u8, "int8x16x2"u8); Assert.Equal(16, type.InstanceFieldAlignment.AsInt); } { - DefType type = _testModule.GetType("Auto", "int8x32x2"); + DefType type = _testModule.GetType("Auto"u8, "int8x32x2"u8); Assert.Equal(32, type.InstanceFieldAlignment.AsInt); } { - DefType type = _testModule.GetType("Auto", "int8x64x2"); + DefType type = _testModule.GetType("Auto"u8, "int8x64x2"u8); Assert.Equal(64, type.InstanceFieldAlignment.AsInt); } { - DefType type = _testModule.GetType("Auto", "Wrapper_int8x16x2"); + DefType type = _testModule.GetType("Auto"u8, "Wrapper_int8x16x2"u8); Assert.Equal(16, type.InstanceFieldAlignment.AsInt); } { - DefType type = _testModule.GetType("Auto", "Wrapper_int8x32x2"); + DefType type = _testModule.GetType("Auto"u8, "Wrapper_int8x32x2"u8); Assert.Equal(32, type.InstanceFieldAlignment.AsInt); } { - DefType type = _testModule.GetType("Auto", "Wrapper_int8x64x2"); + DefType type = _testModule.GetType("Auto"u8, "Wrapper_int8x64x2"u8); Assert.Equal(64, type.InstanceFieldAlignment.AsInt); } } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs index 404259918ad198..c7710a9d617be7 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/InterfacesTests.cs @@ -38,7 +38,7 @@ public void TestMultidimensionalArrays() public void TestSingleDimensionalArrays() { DefType systemArrayType = _context.GetWellKnownType(WellKnownType.Array); - MetadataType systemIListOfTType = _testModule.GetType("System.Collections.Generic", "IList`1"); + MetadataType systemIListOfTType = _testModule.GetType("System.Collections.Generic"u8, "IList`1"u8); TypeDesc objectType = _context.GetWellKnownType(WellKnownType.Object); @@ -58,7 +58,7 @@ public void TestSingleDimensionalArrays() [Fact] public void TestNoInterface() { - MetadataType noInterfacesType = _testModule.GetType("InterfaceArrangements", "NoInterfaces"); + MetadataType noInterfacesType = _testModule.GetType("InterfaceArrangements"u8, "NoInterfaces"u8); Assert.Empty(noInterfacesType.RuntimeInterfaces); } @@ -66,8 +66,8 @@ public void TestNoInterface() [Fact] public void TestOneInterface() { - MetadataType oneInterfacesType = _testModule.GetType("InterfaceArrangements", "OneInterface"); - MetadataType i1Type = _testModule.GetType("InterfaceArrangements", "I1"); + MetadataType oneInterfacesType = _testModule.GetType("InterfaceArrangements"u8, "OneInterface"u8); + MetadataType i1Type = _testModule.GetType("InterfaceArrangements"u8, "I1"u8); Assert.Equal(new DefType[] { i1Type }, oneInterfacesType.RuntimeInterfaces); } @@ -77,11 +77,11 @@ public void TestOverlappingInterfacesAtDerivation() { // This test tests that an explicit interface implementation on a type does not cause the // set of runtime interfaces to get extra duplication - MetadataType derivedFromMidType = _testModule.GetType("InterfaceArrangements", "DerivedFromMid"); - MetadataType igen1Type = _testModule.GetType("InterfaceArrangements", "IGen1`1"); + MetadataType derivedFromMidType = _testModule.GetType("InterfaceArrangements"u8, "DerivedFromMid"u8); + MetadataType igen1Type = _testModule.GetType("InterfaceArrangements"u8, "IGen1`1"u8); TypeDesc stringType = _testModule.Context.GetWellKnownType(WellKnownType.String); DefType igen1OfString = igen1Type.MakeInstantiatedType(stringType); - MetadataType i1Type = _testModule.GetType("InterfaceArrangements", "I1"); + MetadataType i1Type = _testModule.GetType("InterfaceArrangements"u8, "I1"u8); Assert.Equal(new DefType[] { igen1OfString, i1Type, igen1OfString }, derivedFromMidType.RuntimeInterfaces); } @@ -91,13 +91,13 @@ public void TestOverlappingGenericInterfaces() { // This test tests that the set of interfaces implemented on a generic type definition // has the same arrangement regardless of instantiation - MetadataType midType = _testModule.GetType("InterfaceArrangements", "Mid`2"); - MetadataType igen1Type = _testModule.GetType("InterfaceArrangements", "IGen1`1"); + MetadataType midType = _testModule.GetType("InterfaceArrangements"u8, "Mid`2"u8); + MetadataType igen1Type = _testModule.GetType("InterfaceArrangements"u8, "IGen1`1"u8); TypeDesc stringType = _testModule.Context.GetWellKnownType(WellKnownType.String); TypeDesc objectType = _testModule.Context.GetWellKnownType(WellKnownType.Object); DefType igen1OfString = igen1Type.MakeInstantiatedType(stringType); DefType igen1OfObject = igen1Type.MakeInstantiatedType(objectType); - MetadataType i1Type = _testModule.GetType("InterfaceArrangements", "I1"); + MetadataType i1Type = _testModule.GetType("InterfaceArrangements"u8, "I1"u8); TypeDesc mid_string_string = midType.MakeInstantiatedType(stringType, stringType); TypeDesc mid_string_object = midType.MakeInstantiatedType(stringType, objectType); @@ -113,8 +113,8 @@ public void TestOverlappingGenericInterfaces() [Fact] public void TestInterfaceRequiresImplementation() { - MetadataType i1Type = _testModule.GetType("InterfaceArrangements", "I1"); - MetadataType i2Type = _testModule.GetType("InterfaceArrangements", "I2"); + MetadataType i1Type = _testModule.GetType("InterfaceArrangements"u8, "I1"u8); + MetadataType i2Type = _testModule.GetType("InterfaceArrangements"u8, "I2"u8); Assert.Empty(i1Type.RuntimeInterfaces); Assert.Equal(i1Type.ExplicitlyImplementedInterfaces, i1Type.RuntimeInterfaces); @@ -126,7 +126,7 @@ public void TestInterfaceRequiresImplementation() [Fact] public void TestPointerArrayInterfaces() { - MetadataType systemArrayType = _testModule.GetType("System", "Array"); + MetadataType systemArrayType = _testModule.GetType("System"u8, "Array"u8); TypeDesc intType = _context.GetWellKnownType(WellKnownType.Int32); TypeDesc intPointerType = _context.GetPointerType(intType); @@ -139,12 +139,12 @@ public void TestPointerArrayInterfaces() [Fact] public void TestInterafaceMethodResolution() { - MetadataType fooType = _testModule.GetType("InterfaceArrangements", "Foo"); - MetadataType derivedType = _testModule.GetType("InterfaceArrangements", "DerivedFromFoo"); - MetadataType superDerivedType = _testModule.GetType("InterfaceArrangements", "SuperDerivedFromFoo"); + MetadataType fooType = _testModule.GetType("InterfaceArrangements"u8, "Foo"u8); + MetadataType derivedType = _testModule.GetType("InterfaceArrangements"u8, "DerivedFromFoo"u8); + MetadataType superDerivedType = _testModule.GetType("InterfaceArrangements"u8, "SuperDerivedFromFoo"u8); - MetadataType ifooOfInt = _testModule.GetType("InterfaceArrangements", "IFoo`1").MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); - MetadataType ifooOfString = _testModule.GetType("InterfaceArrangements", "IFoo`1").MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.String)); + MetadataType ifooOfInt = _testModule.GetType("InterfaceArrangements"u8, "IFoo`1"u8).MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32)); + MetadataType ifooOfString = _testModule.GetType("InterfaceArrangements"u8, "IFoo`1"u8).MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.String)); MethodDesc ifooOfIntMethod = ifooOfInt.GetMethods().Where(m => m.GetName() == "IMethod").Single(); MethodDesc ifooOfStringMethod = ifooOfString.GetMethods().Where(m => m.GetName() == "IMethod").Single(); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/MarshalUtilsTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/MarshalUtilsTests.cs index 3523f5d62f8e14..e3558beede244e 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/MarshalUtilsTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/MarshalUtilsTests.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Text; using Internal.TypeSystem; using Internal.TypeSystem.Interop; @@ -66,7 +67,7 @@ public void IsBlittableType_NonBilittableWellKnownTypes_ReturnsFalse(WellKnownTy [InlineData("ClassWithSequentialInt64Base")] public void IsBlittableType_TypeWithBlittableBase_ReturnsTrue(string className) { - TypeDesc classWithBlittableBase = _testModule.GetType("Marshalling", className); + TypeDesc classWithBlittableBase = _testModule.GetType("Marshalling"u8, Encoding.UTF8.GetBytes(className)); Assert.True(MarshalUtils.IsBlittableType(classWithBlittableBase)); } @@ -76,7 +77,7 @@ public void IsBlittableType_TypeWithBlittableBase_ReturnsTrue(string className) [InlineData("ClassWithSequentialEmptyBase")] public void IsBlittableType_TypeWithEmptyBase_ReturnsTrue(string className) { - TypeDesc classWithEmptyBase = _testModule.GetType("Marshalling", className); + TypeDesc classWithEmptyBase = _testModule.GetType("Marshalling"u8, Encoding.UTF8.GetBytes(className)); Assert.True(MarshalUtils.IsBlittableType(classWithEmptyBase)); } } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/RuntimeDeterminedTypesTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/RuntimeDeterminedTypesTests.cs index 210df8937bfe9e..d3ddf45dc98ff7 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/RuntimeDeterminedTypesTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/RuntimeDeterminedTypesTests.cs @@ -29,14 +29,14 @@ public RuntimeDeterminedTypesTests() _testModule = systemModule; - _referenceType = _testModule.GetType("Canonicalization", "ReferenceType"); - _otherReferenceType = _testModule.GetType("Canonicalization", "OtherReferenceType"); - _structType = _testModule.GetType("Canonicalization", "StructType"); - _otherStructType = _testModule.GetType("Canonicalization", "OtherStructType"); - _genericReferenceType = _testModule.GetType("Canonicalization", "GenericReferenceType`1"); - _genericStructType = _testModule.GetType("Canonicalization", "GenericStructType`1"); - _genericReferenceTypeWithThreeParams = _testModule.GetType("Canonicalization", "GenericReferenceTypeWithThreeParams`3"); - _genericStructTypeWithThreeParams = _testModule.GetType("Canonicalization", "GenericStructTypeWithThreeParams`3"); + _referenceType = _testModule.GetType("Canonicalization"u8, "ReferenceType"u8); + _otherReferenceType = _testModule.GetType("Canonicalization"u8, "OtherReferenceType"u8); + _structType = _testModule.GetType("Canonicalization"u8, "StructType"u8); + _otherStructType = _testModule.GetType("Canonicalization"u8, "OtherStructType"u8); + _genericReferenceType = _testModule.GetType("Canonicalization"u8, "GenericReferenceType`1"u8); + _genericStructType = _testModule.GetType("Canonicalization"u8, "GenericStructType`1"u8); + _genericReferenceTypeWithThreeParams = _testModule.GetType("Canonicalization"u8, "GenericReferenceTypeWithThreeParams`3"u8); + _genericStructTypeWithThreeParams = _testModule.GetType("Canonicalization"u8, "GenericStructTypeWithThreeParams`3"u8); } [Fact] diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs index b0c0aa258d2bf6..2909c2e553c8c3 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs @@ -53,7 +53,7 @@ private static string GetModOptMethodSignatureInfo(MethodSignature signature) [Fact] public void TestSignatureMatches2ModOptsAtStartOfSig() { - MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); + MetadataType modOptTester = _testModule.GetType(""u8, "ModOptTester"u8); MethodSignature methodWith2ModOptsAtStartOfSig = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method")).Signature; // All modopts that are at the very beginning of the signature are given index 0.1.1.1 @@ -67,7 +67,7 @@ public void TestSignatureMatches2ModOptsAtStartOfSig() [Fact] public void TestSignatureMatchesModOptAtStartOfSigAndAfterByRef() { - MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); + MetadataType modOptTester = _testModule.GetType(""u8, "ModOptTester"u8); MethodSignature methodWithModOptAtStartOfSigAndAfterByRef = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method2")).Signature; // A modopts after an E_T_BYREF will look like 0.1.1.2.1.1 @@ -80,7 +80,7 @@ public void TestSignatureMatchesModOptAtStartOfSigAndAfterByRef() [Fact] public void TestSignatureMatchesModoptOnPointerOrRefModifiedType() { - MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); + MetadataType modOptTester = _testModule.GetType(""u8, "ModOptTester"u8); MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method3")).Signature; Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(0), methodWithModOpt.GetEmbeddedSignatureData()[0].index); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(1), methodWithModOpt.GetEmbeddedSignatureData()[1].index); @@ -90,7 +90,7 @@ public void TestSignatureMatchesModoptOnPointerOrRefModifiedType() [Fact] public void TestSignatureMatchesForArrayShapeDetails() { - MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); + MetadataType modOptTester = _testModule.GetType(""u8, "ModOptTester"u8); MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method4")).Signature; _output.WriteLine($"Found ModOptData '{GetModOptMethodSignatureInfo(methodWithModOpt)}'"); @@ -106,7 +106,7 @@ public void TestSignatureMatchesForArrayShapeDetails_HandlingOfCasesWhichDoNotNe { // Test that ensure the typical case (where the loBounds is 0, and the hibounds is unspecified) doesn't produce an // EmbeddedSignatureData, but that other cases do. This isn't a complete test as ilasm won't actually properly generate the metadata for many of these cases - MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); + MetadataType modOptTester = _testModule.GetType(""u8, "ModOptTester"u8); MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method5")).Signature; _output.WriteLine($"Found ModOptData '{GetModOptMethodSignatureInfo(methodWithModOpt)}'"); @@ -119,12 +119,12 @@ public void TestSignatureMatchesForArrayShapeDetails_HandlingOfCasesWhichDoNotNe [Fact] public void TestSignatureMatches() { - MetadataType atomType = _testModule.GetType("", "Atom"); - MetadataType aType = _testModule.GetType("", "A`1"); + MetadataType atomType = _testModule.GetType(""u8, "Atom"u8); + MetadataType aType = _testModule.GetType(""u8, "A`1"u8); MetadataType aOfAtomType = aType.MakeInstantiatedType(new Instantiation(atomType)); - MetadataType baseClassType = _testModule.GetType("", "BaseClass`2"); + MetadataType baseClassType = _testModule.GetType(""u8, "BaseClass`2"u8); MethodDesc baseClassMethod = baseClassType.GetMethods().Single(m => string.Equals(m.GetName(), "Method")); MethodSignature baseClassMethodSignature = baseClassMethod.Signature; MethodSignatureBuilder matchingSignatureBuilder = new MethodSignatureBuilder(baseClassMethodSignature); @@ -132,7 +132,7 @@ public void TestSignatureMatches() matchingSignatureBuilder[1] = atomType; MethodSignature matchingSignature = matchingSignatureBuilder.ToSignature(); - MetadataType derivedClassType = _testModule.GetType("", "DerivedClass"); + MetadataType derivedClassType = _testModule.GetType(""u8, "DerivedClass"u8); IEnumerable derivedClassMethods = derivedClassType.GetMethods().Where(m => string.Equals(m.GetName(), "Method")); IEnumerable matches = derivedClassMethods.Select(m => matchingSignature.Equals(m.Signature)); int matchCount = matches.Select(b => b ? 1 : 0).Sum(); @@ -142,7 +142,7 @@ public void TestSignatureMatches() [Fact] public void TestSerializedSignatureWithArrayShapes() { - MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); + MetadataType modOptTester = _testModule.GetType(""u8, "ModOptTester"u8); MethodDesc methodWithInterestingShapes = modOptTester.GetMethods().Single(m => string.Equals(m.GetName(), "Method4")); // Create assembly with reference to interesting method @@ -199,7 +199,7 @@ public void TestSerializedSignatureWithReferenceToMDIntArray() public void TestSerializedSignatureWithReferenceToFieldWithModOpt() { - MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); + MetadataType modOptTester = _testModule.GetType(""u8, "ModOptTester"u8); FieldDesc fieldWithModOpt = modOptTester.GetFields().Single(m => string.Equals(m.GetName(), "fieldWithModOpt")); // Create assembly with reference to interesting method @@ -227,7 +227,7 @@ public void TestSerializedSignatureWithReferenceToFieldWithModOpt() [Fact] public void TestMDArrayFunctionReading() { - MetadataType mdArrayFunctionResolutionType = _testModule.GetType("", "MDArrayFunctionResolution"); + MetadataType mdArrayFunctionResolutionType = _testModule.GetType(""u8, "MDArrayFunctionResolution"u8); MethodDesc methodWithMDArrayUsage = mdArrayFunctionResolutionType.GetMethods().Single(m => string.Equals(m.GetName(), "MethodWithUseOfMDArrayFunctions")); MethodIL methodIL = EcmaMethodIL.Create((EcmaMethod)methodWithMDArrayUsage); ILReader ilReader = new ILReader(methodIL.GetILBytes()); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs index d6ce5d3b8b5a8d..0135140041ec4b 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/StaticFieldLayoutTests.cs @@ -29,7 +29,7 @@ public StaticFieldLayoutTests() [Fact] public void TestNoPointers() { - MetadataType t = _testModule.GetType("StaticFieldLayout", "NoPointers"); + MetadataType t = _testModule.GetType("StaticFieldLayout"u8, "NoPointers"u8); foreach (var field in t.GetFields()) { @@ -60,7 +60,7 @@ public void TestStillNoPointers() // Test that static offsets ignore instance fields preceding them // - MetadataType t = _testModule.GetType("StaticFieldLayout", "StillNoPointers"); + MetadataType t = _testModule.GetType("StaticFieldLayout"u8, "StillNoPointers"u8); foreach (var field in t.GetFields()) { @@ -85,7 +85,7 @@ public void TestClassNoPointers() // Ensure classes behave the same as structs when containing statics // - MetadataType t = _testModule.GetType("StaticFieldLayout", "ClassNoPointers"); + MetadataType t = _testModule.GetType("StaticFieldLayout"u8, "ClassNoPointers"u8); foreach (var field in t.GetFields()) { @@ -116,7 +116,7 @@ public void TestHasPointers() // Test a struct containing static types with pointers // - MetadataType t = _testModule.GetType("StaticFieldLayout", "HasPointers"); + MetadataType t = _testModule.GetType("StaticFieldLayout"u8, "HasPointers"u8); foreach (var field in t.GetFields()) { @@ -144,7 +144,7 @@ public void TestMixPointersAndNonPointers() // Test that static fields with GC pointers get separate offsets from non-GC fields // - MetadataType t = _testModule.GetType("StaticFieldLayout", "MixPointersAndNonPointers"); + MetadataType t = _testModule.GetType("StaticFieldLayout"u8, "MixPointersAndNonPointers"u8); foreach (var field in t.GetFields()) { @@ -182,7 +182,7 @@ public void TestEnsureInheritanceResetsStaticOffsets() // are again offset from 0 // - MetadataType t = _testModule.GetType("StaticFieldLayout", "EnsureInheritanceResetsStaticOffsets"); + MetadataType t = _testModule.GetType("StaticFieldLayout"u8, "EnsureInheritanceResetsStaticOffsets"u8); foreach (var field in t.GetFields()) { @@ -210,7 +210,7 @@ public void TestLiteralFieldsDontAffectLayout() // Test that literal fields are not laid out. // - MetadataType t = _testModule.GetType("StaticFieldLayout", "LiteralFieldsDontAffectLayout"); + MetadataType t = _testModule.GetType("StaticFieldLayout"u8, "LiteralFieldsDontAffectLayout"u8); Assert.Equal(4, t.GetFields().Count()); @@ -246,7 +246,7 @@ public void TestStaticSelfRef() // going into an infinite loop // - MetadataType t = _testModule.GetType("StaticFieldLayout", "StaticSelfRef"); + MetadataType t = _testModule.GetType("StaticFieldLayout"u8, "StaticSelfRef"u8); foreach (var field in t.GetFields()) { @@ -272,7 +272,7 @@ public void TestRvaStatics() // var ilModule = _context.GetModuleForSimpleName("ILTestAssembly"); - var t = ilModule.GetType("StaticFieldLayout", "RvaStatics"); + var t = ilModule.GetType("StaticFieldLayout"u8, "RvaStatics"u8); var field = t.GetField("StaticInitedInt"u8); Assert.True(field.HasRva); @@ -294,7 +294,7 @@ public void TestFunctionPointer() // var ilModule = _context.GetModuleForSimpleName("ILTestAssembly"); - var t = ilModule.GetType("StaticFieldLayout", "FunctionPointerType"); + var t = ilModule.GetType("StaticFieldLayout"u8, "FunctionPointerType"u8); var field = t.GetField("StaticMethodField"u8); Assert.Equal(8, field.Offset.AsInt); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs index 2e0cf0fb4a36c2..14975628088fd5 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs @@ -35,7 +35,7 @@ public void TestStructEqualsAndGetHashCode() // EqualsAndGetHashCodeProvidingAlgorithm. // - MetadataType t = _testModule.GetType("SyntheticVirtualOverride", "StructWithNoEqualsAndGetHashCode"); + MetadataType t = _testModule.GetType("SyntheticVirtualOverride"u8, "StructWithNoEqualsAndGetHashCode"u8); Assert.DoesNotContain(t.GetMethods(), m => m.GetName() == "Equals"); Assert.DoesNotContain(t.GetMethods(), m => m.GetName() == "GetHashCode"); @@ -66,8 +66,8 @@ public void TestUnoverriddenSyntheticEqualsAndGetHashCode() // derived classes. // - MetadataType baseType = _testModule.GetType("SyntheticVirtualOverride", "ClassWithInjectedEqualsAndGetHashCode"); - MetadataType t = _testModule.GetType("SyntheticVirtualOverride", "ClassNotOverridingEqualsAndGetHashCode"); + MetadataType baseType = _testModule.GetType("SyntheticVirtualOverride"u8, "ClassWithInjectedEqualsAndGetHashCode"u8); + MetadataType t = _testModule.GetType("SyntheticVirtualOverride"u8, "ClassNotOverridingEqualsAndGetHashCode"u8); List virtualSlots = new List(t.EnumAllVirtualSlots()); Assert.All(virtualSlots, s => { Assert.True(s.OwningType.IsObject); }); @@ -89,8 +89,8 @@ public void TestOverriddenSyntheticEqualsAndGetHashCode() // derived classes. // - MetadataType baseType = _testModule.GetType("SyntheticVirtualOverride", "ClassWithInjectedEqualsAndGetHashCode"); - MetadataType t = _testModule.GetType("SyntheticVirtualOverride", "ClassOverridingEqualsAndGetHashCode"); + MetadataType baseType = _testModule.GetType("SyntheticVirtualOverride"u8, "ClassWithInjectedEqualsAndGetHashCode"u8); + MetadataType t = _testModule.GetType("SyntheticVirtualOverride"u8, "ClassOverridingEqualsAndGetHashCode"u8); List virtualSlots = new List(t.EnumAllVirtualSlots()); Assert.All(virtualSlots, s => { Assert.True(s.OwningType.IsObject); }); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestTypeSystemContext.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestTypeSystemContext.cs index 2c36aa24ed0802..093aae228549dd 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestTypeSystemContext.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TestTypeSystemContext.cs @@ -85,7 +85,7 @@ public override FieldLayoutAlgorithm GetLayoutAlgorithmForType(DefType type) protected override RuntimeInterfacesAlgorithm GetRuntimeInterfacesAlgorithmForNonPointerArrayType(ArrayType type) { - _arrayOfTRuntimeInterfacesAlgorithm ??= new ArrayOfTRuntimeInterfacesAlgorithm(SystemModule.GetType("System", "Array`1")); + _arrayOfTRuntimeInterfacesAlgorithm ??= new ArrayOfTRuntimeInterfacesAlgorithm(SystemModule.GetType("System"u8, "Array`1"u8)); return _arrayOfTRuntimeInterfacesAlgorithm; } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs index c3f52dfdb6a127..932a3513d20758 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs @@ -54,15 +54,15 @@ public TypeEquivalenceTests(ITestOutputHelper outputHelper) _testModule1 = (EcmaModule)_context.CreateModuleForSimpleName("TypeEquivalenceAssembly1"); _testModule2 = (EcmaModule)_context.CreateModuleForSimpleName("TypeEquivalenceAssembly2"); - _referenceType = systemModule.GetType("Canonicalization", "ReferenceType"); - _otherReferenceType = systemModule.GetType("Canonicalization", "OtherReferenceType"); - _structType = systemModule.GetType("Canonicalization", "StructType"); - _otherStructType = systemModule.GetType("Canonicalization", "OtherStructType"); - _genericReferenceType = systemModule.GetType("Canonicalization", "GenericReferenceType`1"); - _genericStructType = systemModule.GetType("Canonicalization", "GenericStructType`1"); - _genericReferenceTypeWithThreeParams = systemModule.GetType("Canonicalization", "GenericReferenceTypeWithThreeParams`3"); - _genericStructTypeWithThreeParams = systemModule.GetType("Canonicalization", "GenericStructTypeWithThreeParams`3"); - _interfaceGenericType = systemModule.GetType("Canonicalization", "InterfaceGenericType`1"); + _referenceType = systemModule.GetType("Canonicalization"u8, "ReferenceType"u8); + _otherReferenceType = systemModule.GetType("Canonicalization"u8, "OtherReferenceType"u8); + _structType = systemModule.GetType("Canonicalization"u8, "StructType"u8); + _otherStructType = systemModule.GetType("Canonicalization"u8, "OtherStructType"u8); + _genericReferenceType = systemModule.GetType("Canonicalization"u8, "GenericReferenceType`1"u8); + _genericStructType = systemModule.GetType("Canonicalization"u8, "GenericStructType`1"u8); + _genericReferenceTypeWithThreeParams = systemModule.GetType("Canonicalization"u8, "GenericReferenceTypeWithThreeParams`3"u8); + _genericStructTypeWithThreeParams = systemModule.GetType("Canonicalization"u8, "GenericStructTypeWithThreeParams`3"u8); + _interfaceGenericType = systemModule.GetType("Canonicalization"u8, "InterfaceGenericType`1"u8); } private IEnumerable GetAllNestedTypes(MetadataReader metadataReader, TypeDefinition typeDef) diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs index a426730a784bbd..0dcfc475e0d21a 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeNameParsingTests.cs @@ -31,17 +31,17 @@ public TypeNameParsingTests() _testModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(_testModule); - _simpleType = _testModule.GetType("TypeNameParsing", "Simple"); + _simpleType = _testModule.GetType("TypeNameParsing"u8, "Simple"u8); _nestedType = _simpleType.GetNestedType("Nested"); _nestedTwiceType = _nestedType.GetNestedType("NestedTwice"); - _genericType = _testModule.GetType("TypeNameParsing", "Generic`1"); + _genericType = _testModule.GetType("TypeNameParsing"u8, "Generic`1"u8); _nestedGenericType = _genericType.GetNestedType("NestedGeneric`1"); _nestedNongenericType = _genericType.GetNestedType("NestedNongeneric"); - _veryGenericType = _testModule.GetType("TypeNameParsing", "VeryGeneric`3"); + _veryGenericType = _testModule.GetType("TypeNameParsing"u8, "VeryGeneric`3"u8); - _structType = _testModule.GetType("TypeNameParsing", "Struct"); + _structType = _testModule.GetType("TypeNameParsing"u8, "Struct"u8); _coreAssemblyQualifier = ((IAssemblyDesc)_testModule).GetName().FullName; } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs index 8b430b4d72c651..afab82bc3c4d1f 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/UniversalGenericFieldLayoutTests.cs @@ -246,7 +246,7 @@ public void TestAllFieldsStructUniversalGeneric() testModule = _testModuleX64; context = _contextX64; - tGen = testModule.GetType("GenericTypes", "GenStruct`3"); + tGen = testModule.GetType("GenericTypes"u8, "GenStruct`3"u8); genOfUUU = tGen.MakeInstantiatedType(context.UniversalCanonType, context.UniversalCanonType, context.UniversalCanonType); Assert.Equal(LayoutInt.Indeterminate, genOfUUU.InstanceFieldAlignment); @@ -261,7 +261,7 @@ public void TestAllFieldsStructUniversalGeneric() testModule = _testModuleX86; context = _contextX86; - tGen = testModule.GetType("GenericTypes", "GenStruct`3"); + tGen = testModule.GetType("GenericTypes"u8, "GenStruct`3"u8); genOfUUU = tGen.MakeInstantiatedType(context.UniversalCanonType, context.UniversalCanonType, context.UniversalCanonType); Assert.Equal(LayoutInt.Indeterminate, genOfUUU.InstanceFieldAlignment); @@ -276,7 +276,7 @@ public void TestAllFieldsStructUniversalGeneric() testModule = _testModuleARM; context = _contextARM; - tGen = testModule.GetType("GenericTypes", "GenStruct`3"); + tGen = testModule.GetType("GenericTypes"u8, "GenStruct`3"u8); genOfUUU = tGen.MakeInstantiatedType(context.UniversalCanonType, context.UniversalCanonType, context.UniversalCanonType); Assert.Equal(LayoutInt.Indeterminate, genOfUUU.InstanceFieldAlignment); @@ -292,7 +292,7 @@ public void TestAllFieldsStructUniversalGeneric() private static void TestIndeterminatedNestedStructFieldPerContext(TypeSystemContext context, ModuleDesc testModule, out InstantiatedType genOfIntNestedInt, out InstantiatedType genOfLongNestedInt) { // Given a struct with all field universal, what is the layout? - MetadataType tGen = testModule.GetType("GenericTypes", "GenStruct`3"); + MetadataType tGen = testModule.GetType("GenericTypes"u8, "GenStruct`3"u8); InstantiatedType genOfUUU = tGen.MakeInstantiatedType(context.UniversalCanonType, context.UniversalCanonType, context.UniversalCanonType); genOfIntNestedInt = tGen.MakeInstantiatedType(context.GetWellKnownType(WellKnownType.Int32), genOfUUU, context.GetWellKnownType(WellKnownType.Int32)); genOfLongNestedInt = tGen.MakeInstantiatedType(context.GetWellKnownType(WellKnownType.Int64), genOfUUU, context.GetWellKnownType(WellKnownType.Int32)); @@ -358,7 +358,7 @@ private static void CommonClassLayoutTestBits(ModuleDesc testModule, out InstantiatedType genOfUI, out InstantiatedType genOfUL) { - MetadataType tDerivedGen = testModule.GetType("GenericTypes", "GenDerivedClass`2"); + MetadataType tDerivedGen = testModule.GetType("GenericTypes"u8, "GenDerivedClass`2"u8); genOfIU = tDerivedGen.MakeInstantiatedType(context.GetWellKnownType(WellKnownType.Int32), context.UniversalCanonType); genOfLU = tDerivedGen.MakeInstantiatedType(context.GetWellKnownType(WellKnownType.Int64), context.UniversalCanonType); genOfUU = tDerivedGen.MakeInstantiatedType(context.UniversalCanonType, context.UniversalCanonType); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs index b0f60dca9acd02..d5730ec9fecae2 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ValueTypeShapeCharacteristicsTests.cs @@ -39,15 +39,15 @@ public void TestHfaPrimitives() [Fact] public void TestSimpleHfa() { - var simpleHfaFloatStruct = _testModule.GetType("ValueTypeShapeCharacteristics", "SimpleHfaFloatStruct"); + var simpleHfaFloatStruct = _testModule.GetType("ValueTypeShapeCharacteristics"u8, "SimpleHfaFloatStruct"u8); Assert.True(simpleHfaFloatStruct.IsHomogeneousAggregate); Assert.Equal(Float32Aggregate, simpleHfaFloatStruct.ValueTypeShapeCharacteristics); - var simpleHfaFloatStructWithManyFields = _testModule.GetType("ValueTypeShapeCharacteristics", "SimpleHfaFloatStructWithManyFields"); + var simpleHfaFloatStructWithManyFields = _testModule.GetType("ValueTypeShapeCharacteristics"u8, "SimpleHfaFloatStructWithManyFields"u8); Assert.True(simpleHfaFloatStructWithManyFields.IsHomogeneousAggregate); Assert.Equal(Float32Aggregate, simpleHfaFloatStructWithManyFields.ValueTypeShapeCharacteristics); - var simpleHfaDoubleStruct = _testModule.GetType("ValueTypeShapeCharacteristics", "SimpleHfaDoubleStruct"); + var simpleHfaDoubleStruct = _testModule.GetType("ValueTypeShapeCharacteristics"u8, "SimpleHfaDoubleStruct"u8); Assert.True(simpleHfaDoubleStruct.IsHomogeneousAggregate); Assert.Equal(Float64Aggregate, simpleHfaDoubleStruct.ValueTypeShapeCharacteristics); } @@ -55,11 +55,11 @@ public void TestSimpleHfa() [Fact] public void TestCompositeHfa() { - var compositeHfaFloatStruct = _testModule.GetType("ValueTypeShapeCharacteristics", "CompositeHfaFloatStruct"); + var compositeHfaFloatStruct = _testModule.GetType("ValueTypeShapeCharacteristics"u8, "CompositeHfaFloatStruct"u8); Assert.True(compositeHfaFloatStruct.IsHomogeneousAggregate); Assert.Equal(Float32Aggregate, compositeHfaFloatStruct.ValueTypeShapeCharacteristics); - var compositeHfaDoubleStruct = _testModule.GetType("ValueTypeShapeCharacteristics", "CompositeHfaDoubleStruct"); + var compositeHfaDoubleStruct = _testModule.GetType("ValueTypeShapeCharacteristics"u8, "CompositeHfaDoubleStruct"u8); Assert.True(compositeHfaDoubleStruct.IsHomogeneousAggregate); Assert.Equal(Float64Aggregate, compositeHfaDoubleStruct.ValueTypeShapeCharacteristics); } @@ -67,19 +67,19 @@ public void TestCompositeHfa() [Fact] public void TestHfaNegative() { - var nonHAEmptyStruct = _testModule.GetType("ValueTypeShapeCharacteristics", "NonHAEmptyStruct"); + var nonHAEmptyStruct = _testModule.GetType("ValueTypeShapeCharacteristics"u8, "NonHAEmptyStruct"u8); Assert.False(nonHAEmptyStruct.IsHomogeneousAggregate); - var nonHAStruct = _testModule.GetType("ValueTypeShapeCharacteristics", "NonHAStruct"); + var nonHAStruct = _testModule.GetType("ValueTypeShapeCharacteristics"u8, "NonHAStruct"u8); Assert.False(nonHAStruct.IsHomogeneousAggregate); - var nonHAMixedStruct = _testModule.GetType("ValueTypeShapeCharacteristics", "NonHAMixedStruct"); + var nonHAMixedStruct = _testModule.GetType("ValueTypeShapeCharacteristics"u8, "NonHAMixedStruct"u8); Assert.False(nonHAMixedStruct.IsHomogeneousAggregate); - var nonHACompositeStruct = _testModule.GetType("ValueTypeShapeCharacteristics", "NonHACompositeStruct"); + var nonHACompositeStruct = _testModule.GetType("ValueTypeShapeCharacteristics"u8, "NonHACompositeStruct"u8); Assert.False(nonHACompositeStruct.IsHomogeneousAggregate); - var nonHAStructWithManyFields = _testModule.GetType("ValueTypeShapeCharacteristics", "NonHAStructWithManyFields"); + var nonHAStructWithManyFields = _testModule.GetType("ValueTypeShapeCharacteristics"u8, "NonHAStructWithManyFields"u8); Assert.False(nonHAStructWithManyFields.IsHomogeneousAggregate); var objectType = _context.GetWellKnownType(WellKnownType.Object); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs index eb431f82c5e4c7..b6ddb314c70dfc 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualFunctionOverrideTests.cs @@ -44,7 +44,7 @@ public void TestGenericMethodInterfaceMethodImplOverride() // Ensure MethodImpl based overriding works for MethodSpecs // - MetadataType interfaceType = _testModule.GetType("VirtualFunctionOverride", "IIFaceWithGenericMethod"); + MetadataType interfaceType = _testModule.GetType("VirtualFunctionOverride"u8, "IIFaceWithGenericMethod"u8); MethodDesc interfaceMethod = null; foreach(MethodDesc m in interfaceType.GetMethods()) @@ -57,7 +57,7 @@ public void TestGenericMethodInterfaceMethodImplOverride() } Assert.NotNull(interfaceMethod); - MetadataType objectType = _testModule.GetType("VirtualFunctionOverride", "HasMethodInterfaceOverrideOfGenericMethod"); + MetadataType objectType = _testModule.GetType("VirtualFunctionOverride"u8, "HasMethodInterfaceOverrideOfGenericMethod"u8); MethodDesc expectedVirtualMethod = null; foreach (MethodDesc m in objectType.GetMethods()) { @@ -80,7 +80,7 @@ public void TestVirtualDispatchOnGenericType() MethodSignature toStringSig = new MethodSignature(MethodSignatureFlags.None, 0, _stringType, Array.Empty()); MethodDesc objectToString = objectType.GetMethod("ToString"u8, toStringSig); Assert.NotNull(objectToString); - MetadataType openTestType = _testModule.GetType("VirtualFunctionOverride", "SimpleGeneric`1"); + MetadataType openTestType = _testModule.GetType("VirtualFunctionOverride"u8, "SimpleGeneric`1"u8); InstantiatedType testInstance = openTestType.MakeInstantiatedType(objectType); MethodDesc targetOnInstance = testInstance.GetMethod("ToString"u8, toStringSig); @@ -91,7 +91,7 @@ public void TestVirtualDispatchOnGenericType() [Fact] public void TestVirtualDispatchOnGenericTypeWithOverload() { - MetadataType openDerived = _testModule.GetType("VirtualFunctionOverride", "DerivedGenericWithOverload`1"); + MetadataType openDerived = _testModule.GetType("VirtualFunctionOverride"u8, "DerivedGenericWithOverload`1"u8); MetadataType derivedInstance = openDerived.MakeInstantiatedType(_stringType); MetadataType baseInstance = (MetadataType)derivedInstance.BaseType; @@ -109,7 +109,7 @@ public void TestVirtualDispatchOnGenericTypeWithOverload() [Fact] public void TestFinalizeOverrideChecking() { - MetadataType classWithFinalizer = _testModule.GetType("VirtualFunctionOverride", "ClassWithFinalizer"); + MetadataType classWithFinalizer = _testModule.GetType("VirtualFunctionOverride"u8, "ClassWithFinalizer"u8); DefType objectType = _testModule.Context.GetWellKnownType(WellKnownType.Object); MethodDesc finalizeMethod = objectType.GetMethod("Finalize"u8, new MethodSignature(MethodSignatureFlags.None, 0, _voidType, Array.Empty())); @@ -126,7 +126,7 @@ public void TestExplicitOverride() // var ilModule = _context.GetModuleForSimpleName("ILTestAssembly"); - var explicitOverrideClass = ilModule.GetType("VirtualFunctionOverride", "ExplicitOverride"); + var explicitOverrideClass = ilModule.GetType("VirtualFunctionOverride"u8, "ExplicitOverride"u8); var myGetHashCodeMethod = explicitOverrideClass.GetMethod("MyGetHashCode"u8, null); @@ -142,7 +142,7 @@ public void TestFindBaseUnificationGroup() { var algo = new MetadataVirtualMethodAlgorithm(); var ilModule = _context.GetModuleForSimpleName("ILTestAssembly"); - MetadataType myDerived2Type = ilModule.GetType("VirtualFunctionOverride", "MyDerived2"); + MetadataType myDerived2Type = ilModule.GetType("VirtualFunctionOverride"u8, "MyDerived2"u8); Assert.NotNull(myDerived2Type); MethodDesc method = myDerived2Type.GetMethod("get_foo"u8, null); Assert.NotNull(method); @@ -157,10 +157,10 @@ public void TestGenericsOverrideOfSpecificMethodWhereSubstitutionsAreNecessaryTo { var algo = new MetadataVirtualMethodAlgorithm(); var ilModule = _context.GetModuleForSimpleName("ILTestAssembly"); - MetadataType myDerivedType = ilModule.GetType("MethodImplOverride1", "Derived"); - MetadataType baseType = ilModule.GetType("MethodImplOverride1", "Base`2").MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32), _context.GetWellKnownType(WellKnownType.Int32)); + MetadataType myDerivedType = ilModule.GetType("MethodImplOverride1"u8, "Derived"u8); + MetadataType baseType = ilModule.GetType("MethodImplOverride1"u8, "Base`2"u8).MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Int32), _context.GetWellKnownType(WellKnownType.Int32)); var csModule = _context.GetModuleForSimpleName("CoreTestAssembly"); - var myGenericType = csModule.GetType("GenericTypes", "GenericClass`1"); + var myGenericType = csModule.GetType("GenericTypes"u8, "GenericClass`1"u8); var myGenericTypeInstantiatedOverBang0 = myGenericType.MakeInstantiatedType(_context.GetSignatureVariable(0, false)); var myGenericTypeInstantiatedOverBang0ByRef = myGenericTypeInstantiatedOverBang0.MakeByRefType(); var myGenericTypeInstantiatedOverBang1 = myGenericType.MakeInstantiatedType(_context.GetSignatureVariable(1, false)); @@ -190,12 +190,12 @@ public void TestGenericsClassOverrideOfMethodWhereMethodHasBeenMovedFromTheTypeW var objectType = _context.GetWellKnownType(WellKnownType.Object); var stringType = _context.GetWellKnownType(WellKnownType.String); var intType = _context.GetWellKnownType(WellKnownType.Int32); - var myGenericType = csModule.GetType("GenericTypes", "GenericClass`1"); + var myGenericType = csModule.GetType("GenericTypes"u8, "GenericClass`1"u8); var genericTypeOfInt = myGenericType.MakeInstantiatedType(intType); var doubleArrayType = doubleType.MakeArrayType(); - MetadataType myDerivedType = ilModule.GetType("MethodImplOverride1", "DerivedGenericsShape`1").MakeInstantiatedType(doubleType); - MetadataType baseType = ilModule.GetType("MethodImplOverride1", "BaseTestGenericsShape`4").MakeInstantiatedType(objectType, stringType, genericTypeOfInt, doubleArrayType); + MetadataType myDerivedType = ilModule.GetType("MethodImplOverride1"u8, "DerivedGenericsShape`1"u8).MakeInstantiatedType(doubleType); + MetadataType baseType = ilModule.GetType("MethodImplOverride1"u8, "BaseTestGenericsShape`4"u8).MakeInstantiatedType(objectType, stringType, genericTypeOfInt, doubleArrayType); var bang0Type = _context.GetSignatureVariable(0, false); var bang1Type = _context.GetSignatureVariable(1, false); @@ -256,9 +256,9 @@ public void TestExactMethodImplGenericDeclResolutionOnInterfaces() var bang0Type = _context.GetSignatureVariable(0, false); var bang1Type = _context.GetSignatureVariable(1, false); - var implementorType = ilModule.GetType("MethodImplOverride1", "Implementor`2").MakeInstantiatedType(intType, intType); - var partialIntImplementorType = ilModule.GetType("MethodImplOverride1", "PartialIntImplementor`1").MakeInstantiatedType(intType); - var intImplementorType = ilModule.GetType("MethodImplOverride1", "IntImplementor"); + var implementorType = ilModule.GetType("MethodImplOverride1"u8, "Implementor`2"u8).MakeInstantiatedType(intType, intType); + var partialIntImplementorType = ilModule.GetType("MethodImplOverride1"u8, "PartialIntImplementor`1"u8).MakeInstantiatedType(intType); + var intImplementorType = ilModule.GetType("MethodImplOverride1"u8, "IntImplementor"u8); ResolveInterfaceDispatch_ForMultiGenericTest(implementorType, out var md1, out var md2); Assert.Equal(bang0Type, md1.GetTypicalMethodDefinition().Signature[0]); @@ -280,8 +280,8 @@ public void TestExactMethodImplGenericDeclResolutionOnInterfaces() [Fact] public void TestFunctionPointerOverloads() { - MetadataType baseClass = _testModule.GetType("VirtualFunctionOverride", "FunctionPointerOverloadBase"); - MetadataType derivedClass = _testModule.GetType("VirtualFunctionOverride", "FunctionPointerOverloadDerived"); + MetadataType baseClass = _testModule.GetType("VirtualFunctionOverride"u8, "FunctionPointerOverloadBase"u8); + MetadataType derivedClass = _testModule.GetType("VirtualFunctionOverride"u8, "FunctionPointerOverloadDerived"u8); var resolvedMethods = new List(); foreach (MethodDesc baseMethod in baseClass.GetVirtualMethods()) @@ -411,10 +411,10 @@ public void TestPreserveBaseOverridesBehavior(string exactScenarioName, string s this._logger.WriteLine(exactScenarioName); var ilModule = _context.GetModuleForSimpleName("ILTestAssembly"); (string typeToConstructNamespace, string typeToConstructTypeName) = SplitIntoNameAndNamespace(typeToConstruct); - var constructedType = ilModule.GetType(typeToConstructNamespace, typeToConstructTypeName); + var constructedType = ilModule.GetType(Encoding.UTF8.GetBytes(typeToConstructNamespace), Encoding.UTF8.GetBytes(typeToConstructTypeName)); (string typeToCallNamespace, string typeToCallTypeName) = SplitIntoNameAndNamespace(typeOfMethodToCallOn); - var typeToCall = ilModule.GetType(typeToCallNamespace, typeToCallTypeName); + var typeToCall = ilModule.GetType(Encoding.UTF8.GetBytes(typeToCallNamespace), Encoding.UTF8.GetBytes(typeToCallTypeName)); MethodDesc callMethod = typeToCall.GetMethod(Encoding.UTF8.GetBytes(methodName), null); Assert.NotNull(callMethod); @@ -441,7 +441,7 @@ public void TestSubImplCovariant(string exactScenarioName, string typeToConstruc { this._logger.WriteLine(exactScenarioName); - MetadataType derivedClass = _testModule.GetType("VirtualFunctionOverride", typeToConstruct); + MetadataType derivedClass = _testModule.GetType("VirtualFunctionOverride"u8, Encoding.UTF8.GetBytes(typeToConstruct)); MetadataType baseClass = derivedClass; while (baseClass != baseClass.Context.GetWellKnownType(WellKnownType.Object)) diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualStaticInterfaceMethodTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualStaticInterfaceMethodTests.cs index a4963e9cce0ef1..15f8d5c59abbca 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualStaticInterfaceMethodTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/VirtualStaticInterfaceMethodTests.cs @@ -17,18 +17,18 @@ public static IEnumerable VariantTestData() ModuleDesc testModule = context.CreateModuleForSimpleName("CoreTestAssembly"); context.SetSystemModule(testModule); - MetadataType simple = testModule.GetType("VirtualStaticInterfaceMethods", "Simple"); - MetadataType iSimple = testModule.GetType("VirtualStaticInterfaceMethods", "ISimple"); - MetadataType iVariant = testModule.GetType("VirtualStaticInterfaceMethods", "IVariant`1"); - MetadataType @base = testModule.GetType("VirtualStaticInterfaceMethods", "Base"); - MetadataType mid = testModule.GetType("VirtualStaticInterfaceMethods", "Mid"); - MetadataType derived = testModule.GetType("VirtualStaticInterfaceMethods", "Derived"); - MetadataType simpleVariant = testModule.GetType("VirtualStaticInterfaceMethods", "SimpleVariant"); - MetadataType simpleVariantTwice = testModule.GetType("VirtualStaticInterfaceMethods", "SimpleVariantTwice"); - MetadataType variantWithInheritanceDerived = testModule.GetType("VirtualStaticInterfaceMethods", "VariantWithInheritanceDerived"); - MetadataType genericVariantWithInheritanceDerived = testModule.GetType("VirtualStaticInterfaceMethods", "GenericVariantWithInheritanceDerived`1"); - MetadataType genericVariantWithHiddenBase = testModule.GetType("VirtualStaticInterfaceMethods", "GenericVariantWithHiddenBase"); - MetadataType genericVariantWithHiddenDerived = testModule.GetType("VirtualStaticInterfaceMethods", "GenericVariantWithHiddenDerived`1"); + MetadataType simple = testModule.GetType("VirtualStaticInterfaceMethods"u8, "Simple"u8); + MetadataType iSimple = testModule.GetType("VirtualStaticInterfaceMethods"u8, "ISimple"u8); + MetadataType iVariant = testModule.GetType("VirtualStaticInterfaceMethods"u8, "IVariant`1"u8); + MetadataType @base = testModule.GetType("VirtualStaticInterfaceMethods"u8, "Base"u8); + MetadataType mid = testModule.GetType("VirtualStaticInterfaceMethods"u8, "Mid"u8); + MetadataType derived = testModule.GetType("VirtualStaticInterfaceMethods"u8, "Derived"u8); + MetadataType simpleVariant = testModule.GetType("VirtualStaticInterfaceMethods"u8, "SimpleVariant"u8); + MetadataType simpleVariantTwice = testModule.GetType("VirtualStaticInterfaceMethods"u8, "SimpleVariantTwice"u8); + MetadataType variantWithInheritanceDerived = testModule.GetType("VirtualStaticInterfaceMethods"u8, "VariantWithInheritanceDerived"u8); + MetadataType genericVariantWithInheritanceDerived = testModule.GetType("VirtualStaticInterfaceMethods"u8, "GenericVariantWithInheritanceDerived`1"u8); + MetadataType genericVariantWithHiddenBase = testModule.GetType("VirtualStaticInterfaceMethods"u8, "GenericVariantWithHiddenBase"u8); + MetadataType genericVariantWithHiddenDerived = testModule.GetType("VirtualStaticInterfaceMethods"u8, "GenericVariantWithHiddenDerived`1"u8); MethodDesc iSimpleMethod = iSimple.GetMethod("WhichMethod"u8, null); MethodDesc iVariantBaseMethod = iVariant.MakeInstantiatedType(@base).GetMethod("WhichMethod"u8, null); diff --git a/src/coreclr/tools/aot/ILCompiler/Program.cs b/src/coreclr/tools/aot/ILCompiler/Program.cs index d2892de5c66cf2..9e9403d8a097c2 100644 --- a/src/coreclr/tools/aot/ILCompiler/Program.cs +++ b/src/coreclr/tools/aot/ILCompiler/Program.cs @@ -349,7 +349,7 @@ public int Run() // assume invalid code is present. Scanner may not detect all invalid code that RyuJIT detect. // If they disagree, we won't know how the vtable of InvalidProgramException should look like // and that would be a compiler crash. - MethodDesc throwInvalidProgramMethod = typeSystemContext.GetHelperEntryPoint("ThrowHelpers", "ThrowInvalidProgramException"u8); + MethodDesc throwInvalidProgramMethod = typeSystemContext.GetHelperEntryPoint("ThrowHelpers"u8, "ThrowInvalidProgramException"u8); compilationRoots.Add( new GenericRootProvider(throwInvalidProgramMethod, (MethodDesc method, IRootingServiceProvider rooter) => rooter.AddCompilationRoot(method, "Invalid IL insurance"))); diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs index bb41a53ba4a16b..33cd22881c6bc6 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemModule.cs @@ -73,12 +73,14 @@ private TypeRefTypeSystemType GetTypeInternal(string nameSpace, string name) return type; } - public override object GetType(string nameSpace, string name, NotFoundBehavior notFoundBehavior) + public override object GetType(ReadOnlySpan nameSpace, ReadOnlySpan name, NotFoundBehavior notFoundBehavior) { - MetadataType type = GetTypeInternal(nameSpace, name); + string strns = Encoding.UTF8.GetString(nameSpace); + string strname = Encoding.UTF8.GetString(name); + MetadataType type = GetTypeInternal(strns, strname); if ((type == null) && notFoundBehavior != NotFoundBehavior.ReturnNull) { - ResolutionFailure failure = ResolutionFailure.GetTypeLoadResolutionFailure(nameSpace, name, this); + ResolutionFailure failure = ResolutionFailure.GetTypeLoadResolutionFailure(strns, strname, this); if (notFoundBehavior == NotFoundBehavior.Throw) failure.Throw(); return failure; From b7979009913383a8b7bb0a076df4a41c5d89c7e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Sun, 7 Sep 2025 23:05:37 +0200 Subject: [PATCH 13/19] Delete FieldDesc.Name/MethodDesc.Name --- .../Internal/TypeSystem/RuntimeMethodDesc.cs | 10 +-- .../Common/Compiler/ProcessLinkerXmlBase.cs | 4 +- .../tools/Common/JitInterface/CorInfoImpl.cs | 10 +-- .../Common/TypeSystem/Common/ArrayType.cs | 21 +----- .../Common/TypeSystem/Common/FieldDesc.cs | 12 +--- .../Common/FieldForInstantiatedType.cs | 10 +-- .../Common/ImpliedRepeatedFieldDesc.cs | 4 +- .../TypeSystem/Common/InstantiatedMethod.cs | 12 +--- .../Common/MetadataVirtualMethodAlgorithm.cs | 14 ++-- .../TypeSystem/Common/MethodDelegator.cs | 4 +- .../Common/TypeSystem/Common/MethodDesc.cs | 18 ++--- .../Common/MethodForInstantiatedType.cs | 10 +-- .../Common/TypeSystem/Common/TypeDesc.cs | 6 +- .../TypeSystem/Common/TypeSystemContext.cs | 4 +- .../tools/Common/TypeSystem/Ecma/EcmaField.cs | 25 +------ .../Common/TypeSystem/Ecma/EcmaMethod.cs | 29 +------- .../TypeSystem/IL/NativeAotILProvider.cs | 6 +- ...AssemblyGetExecutingAssemblyMethodThunk.cs | 10 +-- .../IL/Stubs/CalliMarshallingMethodThunk.cs | 10 +-- .../Stubs/DelegateMarshallingMethodThunk.cs | 10 +-- .../IL/Stubs/DelegateMethodILEmitter.cs | 6 +- .../TypeSystem/IL/Stubs/DelegateThunks.cs | 70 ++----------------- .../IL/Stubs/DynamicInvokeMethodThunk.cs | 4 +- .../Common/TypeSystem/IL/Stubs/EnumThunks.cs | 20 +----- .../IL/Stubs/ForwardDelegateCreationThunk.cs | 10 +-- .../IL/Stubs/InterlockedIntrinsics.cs | 2 +- .../Stubs/MethodBaseGetCurrentMethodThunk.cs | 10 +-- .../IL/Stubs/PInvokeLazyFixupField.cs | 10 +-- .../IL/Stubs/PInvokeTargetNativeMethod.cs | 10 +-- .../IL/Stubs/RuntimeHelpersIntrinsics.cs | 2 +- .../TypeSystem/IL/Stubs/StreamIntrinsics.cs | 4 +- .../IL/Stubs/StructMarshallingThunk.cs | 10 +-- .../IL/Stubs/TypeGetTypeMethodThunk.cs | 12 +--- .../ValueTypeGetFieldHelperMethodOverride.cs | 13 +--- .../TypeSystem/Interop/IL/InlineArrayType.cs | 27 +------ .../TypeSystem/Interop/IL/NativeStructType.cs | 10 +-- .../IL/PInvokeDelegateWrapperConstructor.cs | 10 +-- .../MethodForRuntimeDeterminedType.cs | 3 +- .../TypeSystemContext.RuntimeDetermined.cs | 2 +- src/coreclr/tools/ILVerify/Program.cs | 2 +- .../Compiler/BodySubstitutionParser.cs | 2 +- .../Compiler/Compilation.cs | 8 +-- .../CompilerTypeSystemContext.BoxedTypes.cs | 28 ++------ .../CompilerTypeSystemContext.EnumMethods.cs | 4 +- ...mpilerTypeSystemContext.InterfaceThunks.cs | 13 +--- .../Compiler/Dataflow/HandleCallAction.cs | 4 +- .../Compiler/DependencyAnalysis/EETypeNode.cs | 6 +- .../InlineableStringsResourceNode.cs | 2 +- .../DependencyAnalysis/VTableSliceNode.cs | 4 +- .../Compiler/ExternSymbolMappedField.cs | 4 +- .../Compiler/HardwareIntrinsicHelpers.Aot.cs | 2 +- .../Logging/DocumentationSignatureParser.cs | 4 +- .../Compiler/NoMetadataBlockingPolicy.cs | 2 +- .../ReachabilityInstrumentationProvider.cs | 3 +- .../Compiler/SubstitutedILProvider.cs | 6 +- .../Compiler/SubstitutionProvider.cs | 4 +- .../Compiler/TypeMapMetadata.cs | 8 +-- .../Compiler/TypePreinit.cs | 16 ++--- .../IL/ILImporter.Scanner.cs | 16 ++--- .../StartupCode/NativeLibraryStartupMethod.cs | 10 +-- .../StartupCode/StartupCodeMainMethod.cs | 20 +----- .../IL/TypeEqualityPatternAnalyzer.cs | 8 +-- .../ReadyToRun/TypeValidationChecker.cs | 2 +- .../Compiler/ProfileDataManager.cs | 2 +- .../Compiler/RuntimeDeterminedTypeHelper.cs | 2 +- .../IBC/IBCProfileParser.cs | 2 +- .../IL/ReadyToRunILProvider.cs | 2 +- .../IL/Stubs/InstanceCalliHelperIntrinsics.cs | 2 +- .../JitInterface/CorInfoImpl.ReadyToRun.cs | 12 ++-- .../SyntheticVirtualOverrideTests.cs | 12 +--- src/coreclr/tools/aot/crossgen2/Program.cs | 2 +- .../TypeRefTypeSystemField.cs | 3 +- .../TypeRefTypeSystemMethod.cs | 4 +- 73 files changed, 154 insertions(+), 531 deletions(-) diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs index d563bc9be61ffb..3018e7c274dfe8 100644 --- a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs +++ b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/RuntimeMethodDesc.cs @@ -89,15 +89,7 @@ public override MethodNameAndSignature NameAndSignature } } - public override string Name - { - get - { - return NameAndSignature.GetName(); - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs index dd6a1f8076b7ed..c39db4b79a3c40 100644 --- a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs +++ b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs @@ -301,7 +301,7 @@ protected virtual void ProcessField(TypeDesc type, XPathNavigator nav) bool foundMatch = false; foreach (FieldDesc field in type.GetFields()) { - if (field.U8Name.StringEquals(name)) + if (field.Name.StringEquals(name)) { foundMatch = true; ProcessField(type, field, nav); @@ -367,7 +367,7 @@ protected virtual void ProcessMethod(TypeDesc type, XPathNavigator nav, object? bool foundMatch = false; foreach (MethodDesc method in type.GetAllMethods()) { - if (method.U8Name.StringEquals(name)) + if (method.Name.StringEquals(name)) { foundMatch = true; ProcessMethod(type, method, nav, customData); diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 8cb19511cd87ce..758e60704cc17b 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -1127,7 +1127,7 @@ private uint getMethodAttribsInternal(MethodDesc method) result |= CorInfoFlag.CORINFO_FLG_FORCEINLINE; } - if (method.OwningType.IsDelegate && method.U8Name.SequenceEqual("Invoke"u8)) + if (method.OwningType.IsDelegate && method.Name.SequenceEqual("Invoke"u8)) { // This is now used to emit efficient invoke code for any delegate invoke, // including multicast. @@ -1724,7 +1724,7 @@ private static object ResolveTokenInScope(MethodILScope methodIL, object typeOrM Debug.Assert((methodContext.HasInstantiation && !owningMethod.HasInstantiation) || (!methodContext.HasInstantiation && !owningMethod.HasInstantiation) || methodContext.GetTypicalMethodDefinition() == owningMethod.GetTypicalMethodDefinition() || - (owningMethod.U8Name.SequenceEqual("CreateDefaultInstance"u8) && methodContext.U8Name.SequenceEqual("CreateInstance"u8))); + (owningMethod.Name.SequenceEqual("CreateDefaultInstance"u8) && methodContext.Name.SequenceEqual("CreateInstance"u8))); Debug.Assert(methodContext.OwningType.HasSameTypeDefinition(owningMethod.OwningType)); typeInst = methodContext.OwningType.Instantiation; methodInst = methodContext.Instantiation; @@ -3166,16 +3166,16 @@ private static CORINFO_FIELD_ACCESSOR getFieldIntrinsic(FieldDesc field) var owningType = field.OwningType; if ((owningType.IsWellKnownType(WellKnownType.IntPtr) || owningType.IsWellKnownType(WellKnownType.UIntPtr)) && - field.U8Name.SequenceEqual("Zero"u8)) + field.Name.SequenceEqual("Zero"u8)) { return CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INTRINSIC_ZERO; } - else if (owningType.IsString && field.U8Name.SequenceEqual("Empty"u8)) + else if (owningType.IsString && field.Name.SequenceEqual("Empty"u8)) { return CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INTRINSIC_EMPTY_STRING; } else if (owningType.U8Name.SequenceEqual("BitConverter"u8) && owningType.U8Namespace.SequenceEqual("System"u8) && - field.U8Name.SequenceEqual("IsLittleEndian"u8)) + field.Name.SequenceEqual("IsLittleEndian"u8)) { return CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN; } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs b/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs index d80d6a7df16eff..b861f3b1135af5 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ArrayType.cs @@ -299,26 +299,7 @@ public override MethodSignature Signature } } - public override string Name - { - get - { - switch (_kind) - { - case ArrayMethodKind.Get: - return "Get"; - case ArrayMethodKind.Set: - return "Set"; - case ArrayMethodKind.Address: - case ArrayMethodKind.AddressWithHiddenArg: - return "Address"; - default: - return ".ctor"; - } - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs index 767518cb7f04ed..72eda70638052f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FieldDesc.cs @@ -27,15 +27,7 @@ public override bool Equals(object o) return ReferenceEquals(this, o); } - public virtual string Name - { - get - { - return null; - } - } - - public virtual ReadOnlySpan U8Name + public virtual ReadOnlySpan Name { get { @@ -46,7 +38,7 @@ public virtual ReadOnlySpan U8Name public string GetName() { return System.Text.Encoding.UTF8.GetString( - U8Name + Name #if NETSTANDARD .ToArray() #endif diff --git a/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs index 3cfc549e44bc43..ce1440710a97a1 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/FieldForInstantiatedType.cs @@ -34,7 +34,7 @@ public override DefType OwningType } } - public override string Name + public override ReadOnlySpan Name { get { @@ -42,14 +42,6 @@ public override string Name } } - public override ReadOnlySpan U8Name - { - get - { - return _fieldDef.U8Name; - } - } - public override TypeDesc FieldType { get diff --git a/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs index a52e8b83558974..ff263d1a6a25b6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/ImpliedRepeatedFieldDesc.cs @@ -42,8 +42,6 @@ public ImpliedRepeatedFieldDesc(DefType owningType, FieldDesc underlyingFieldDes public override MarshalAsDescriptor GetMarshalAsDescriptor() => _underlyingFieldDesc.GetMarshalAsDescriptor(); - public override string Name => $"{_underlyingFieldDesc.GetName()}[{FieldIndex}]"; - - public override ReadOnlySpan U8Name => System.Text.Encoding.UTF8.GetBytes(Name); + public override ReadOnlySpan Name => System.Text.Encoding.UTF8.GetBytes($"{_underlyingFieldDesc.GetName()}[{FieldIndex}]"); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs index 396ef9ba8d6022..0fd68eef059f82 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs @@ -34,7 +34,7 @@ internal InstantiatedMethod(MethodDesc methodDef, Instantiation instantiation, i protected override int ComputeHashCode() { - return OwningType.GetHashCode() ^ VersionResilientHashCode.GenericInstanceHashCode(VersionResilientHashCode.NameHashCode(U8Name), Instantiation); + return OwningType.GetHashCode() ^ VersionResilientHashCode.GenericInstanceHashCode(VersionResilientHashCode.NameHashCode(Name), Instantiation); } public override TypeSystemContext Context @@ -157,20 +157,12 @@ public override MethodDesc GetTypicalMethodDefinition() return _methodDef.GetTypicalMethodDefinition(); } - public override string Name + public override ReadOnlySpan Name { get { return _methodDef.Name; } } - - public override ReadOnlySpan U8Name - { - get - { - return _methodDef.U8Name; - } - } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs index 0e96ab273249f8..3f0773c6b22a54 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs @@ -280,7 +280,7 @@ private static MethodDesc FindImplFromDeclFromMethodImpls(MetadataType type, Met if (decl.OwningType.IsInterface) return FindInterfaceImplFromDeclFromMethodImpls(type, decl); - MethodImplRecord[] foundMethodImpls = type.FindMethodsImplWithMatchingDeclName(decl.U8Name); + MethodImplRecord[] foundMethodImpls = type.FindMethodsImplWithMatchingDeclName(decl.Name); if (foundMethodImpls == null) return null; @@ -307,7 +307,7 @@ private static MethodDesc FindInterfaceImplFromDeclFromMethodImpls(MetadataType { Debug.Assert(decl.OwningType.IsInterface); - MethodImplRecord[] foundMethodImpls = type.FindMethodsImplWithMatchingDeclName(decl.U8Name); + MethodImplRecord[] foundMethodImpls = type.FindMethodsImplWithMatchingDeclName(decl.Name); if (foundMethodImpls == null) return null; @@ -333,7 +333,7 @@ private static MethodDesc FindInterfaceImplFromDeclFromMethodImpls(MetadataType { MetadataType typeDefinition = (MetadataType)type.GetTypeDefinition(); DefType[] interfacesOnDefinition = typeDefinition.RuntimeInterfaces; - MethodImplRecord[] foundMethodImplsOnDefinition = typeDefinition.FindMethodsImplWithMatchingDeclName(decl.U8Name); + MethodImplRecord[] foundMethodImplsOnDefinition = typeDefinition.FindMethodsImplWithMatchingDeclName(decl.Name); Debug.Assert(foundMethodImplsOnDefinition.Length == foundMethodImpls.Length); int bestInterfaceIndex = int.MaxValue; @@ -377,14 +377,14 @@ private static bool IsInterfaceExplicitlyImplementedOnType(MetadataType type, Me /// private static MethodDesc FindMatchingVirtualMethodOnTypeByNameAndSig(MethodDesc targetMethod, DefType currentType, bool reverseMethodSearch, Func nameSigMatchMethodIsValidCandidate) { - ReadOnlySpan name = targetMethod.U8Name; + ReadOnlySpan name = targetMethod.Name; MethodSignature sig = targetMethod.Signature; MethodDesc implMethod = null; MethodDesc implMethodEquivalent = null; foreach (MethodDesc candidate in currentType.GetAllVirtualMethods()) { - if (candidate.U8Name.SequenceEqual(name)) + if (candidate.Name.SequenceEqual(name)) { if (candidate.Signature.EquivalentTo(sig)) { @@ -881,7 +881,7 @@ private static DefaultInterfaceMethodResolution ResolveInterfaceMethodToDefaultI else if (Array.IndexOf(runtimeInterface.RuntimeInterfaces, interfaceMethodOwningType) != -1) { // This interface might provide a default implementation - MethodImplRecord[] possibleImpls = runtimeInterface.FindMethodsImplWithMatchingDeclName(interfaceMethod.U8Name); + MethodImplRecord[] possibleImpls = runtimeInterface.FindMethodsImplWithMatchingDeclName(interfaceMethod.Name); if (possibleImpls != null) { foreach (MethodImplRecord implRecord in possibleImpls) @@ -1078,7 +1078,7 @@ private static MethodDesc TryResolveVirtualStaticMethodOnThisType(MetadataType c { Debug.Assert(interfaceMethod.Signature.IsStatic); - MethodImplRecord[] possibleImpls = constrainedType.FindMethodsImplWithMatchingDeclName(interfaceMethod.U8Name); + MethodImplRecord[] possibleImpls = constrainedType.FindMethodsImplWithMatchingDeclName(interfaceMethod.Name); if (possibleImpls == null) return null; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs index 956cf0e9a1b9fe..918bb5e62a88a8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs @@ -28,9 +28,7 @@ public MethodDelegator(MethodDesc wrappedMethod) public override bool IsDefaultConstructor => _wrappedMethod.IsDefaultConstructor; public override bool IsStaticConstructor => _wrappedMethod.IsStaticConstructor; - public override string Name => _wrappedMethod.Name; - - public override ReadOnlySpan U8Name => _wrappedMethod.U8Name; + public override ReadOnlySpan Name => _wrappedMethod.Name; public override bool IsVirtual => _wrappedMethod.IsVirtual; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs index 526d83f289b17f..2075c60ea21713 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs @@ -496,7 +496,7 @@ private int AcquireHashCode() /// protected virtual int ComputeHashCode() { - return OwningType.GetHashCode() ^ VersionResilientHashCode.NameHashCode(U8Name); + return OwningType.GetHashCode() ^ VersionResilientHashCode.NameHashCode(Name); } public override bool Equals(object o) @@ -557,7 +557,7 @@ public bool IsConstructor { // TODO: Precise check // TODO: Cache? - return this.U8Name.SequenceEqual(".ctor"u8); + return this.Name.SequenceEqual(".ctor"u8); } } @@ -587,15 +587,7 @@ public virtual bool IsStaticConstructor /// /// Gets the name of the method as specified in the metadata. /// - public virtual string Name - { - get - { - return null; - } - } - - public virtual ReadOnlySpan U8Name + public virtual ReadOnlySpan Name { get { @@ -605,7 +597,7 @@ public virtual ReadOnlySpan U8Name public string GetName() { - return System.Text.Encoding.UTF8.GetString(U8Name + return System.Text.Encoding.UTF8.GetString(Name #if NETSTANDARD .ToArray() #endif @@ -727,7 +719,7 @@ public bool IsFinalizer get { TypeDesc owningType = OwningType; - return (owningType.IsObject && U8Name.SequenceEqual("Finalize"u8)) || (owningType.HasFinalizer && owningType.GetFinalizer() == this); + return (owningType.IsObject && Name.SequenceEqual("Finalize"u8)) || (owningType.HasFinalizer && owningType.GetFinalizer() == this); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs index c4f774b9bbc8e6..4a1cf836e17466 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodForInstantiatedType.cs @@ -145,20 +145,12 @@ public override bool IsStaticConstructor } } - public override string Name + public override ReadOnlySpan Name { get { return _typicalMethodDef.Name; } } - - public override ReadOnlySpan U8Name - { - get - { - return _typicalMethodDef.U8Name; - } - } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs index 0bff0637dec62e..c77106cac6ecb5 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs @@ -536,7 +536,7 @@ public virtual MethodDesc GetMethod(ReadOnlySpan name, MethodSignature sig { foreach (var method in GetMethods()) { - if (method.U8Name.SequenceEqual(name)) + if (method.Name.SequenceEqual(name)) { if (signature == null || signature.Equals(method.Signature.ApplySubstitution(substitution))) return method; @@ -549,7 +549,7 @@ public virtual MethodDesc GetMethodWithEquivalentSignature(ReadOnlySpan na { foreach (var method in GetMethods()) { - if (method.U8Name.SequenceEqual(name)) + if (method.Name.SequenceEqual(name)) { if (signature == null || signature.EquivalentTo(method.Signature.ApplySubstitution(substitution))) return method; @@ -593,7 +593,7 @@ public virtual FieldDesc GetField(ReadOnlySpan name) { foreach (var field in GetFields()) { - if (field.U8Name.SequenceEqual(name)) + if (field.Name.SequenceEqual(name)) return field; } return null; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs index 0aaf611d325a85..2beffd0a47fca0 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemContext.cs @@ -360,7 +360,7 @@ public InstantiatedMethodKey(MethodDesc methodDef, Instantiation instantiation) _methodDef = methodDef; _instantiation = instantiation; _hashcode = methodDef.OwningType.GetHashCode() - ^ VersionResilientHashCode.GenericInstanceHashCode(VersionResilientHashCode.NameHashCode(methodDef.U8Name), instantiation); + ^ VersionResilientHashCode.GenericInstanceHashCode(VersionResilientHashCode.NameHashCode(methodDef.Name), instantiation); } public MethodDesc MethodDef @@ -459,7 +459,7 @@ public MethodForInstantiatedTypeKey(MethodDesc typicalMethodDef, InstantiatedTyp { _typicalMethodDef = typicalMethodDef; _instantiatedType = instantiatedType; - _hashcode = instantiatedType.GetHashCode() ^ VersionResilientHashCode.NameHashCode(typicalMethodDef.U8Name); + _hashcode = instantiatedType.GetHashCode() ^ VersionResilientHashCode.NameHashCode(typicalMethodDef.Name); } public MethodDesc TypicalMethodDef diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs index 8409d3d628dfec..f47742434dad0e 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs @@ -33,17 +33,11 @@ private static class FieldFlags // Cached values private ThreadSafeFlags _fieldFlags; private TypeDesc _fieldType; - private string _name; internal EcmaField(EcmaType type, FieldDefinitionHandle handle) { _type = type; _handle = handle; - -#if DEBUG - // Initialize name eagerly in debug builds for convenience - InitializeName(); -#endif } EntityHandle EcmaModule.IEntityHandleObject.Handle @@ -261,24 +255,7 @@ public FieldAttributes Attributes } } - private string InitializeName() - { - var metadataReader = MetadataReader; - var name = metadataReader.GetString(metadataReader.GetFieldDefinition(_handle).Name); - return (_name = name); - } - - public override string Name - { - get - { - if (_name == null) - return InitializeName(); - return _name; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index 64b6fb005f0620..f7e710645efeda 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -39,18 +39,12 @@ private static class MethodFlags // Cached values private ThreadSafeFlags _methodFlags; private MethodSignature _signature; - private string _name; private TypeDesc[] _genericParameters; // TODO: Optional field? internal EcmaMethod(EcmaType type, MethodDefinitionHandle handle) { _type = type; _handle = handle; - -#if DEBUG - // Initialize name eagerly in debug builds for convenience - InitializeName(); -#endif } EntityHandle EcmaModule.IEntityHandleObject.Handle @@ -349,7 +343,7 @@ public override bool IsDefaultConstructor return attributes.IsRuntimeSpecialName() && attributes.IsPublic() && Signature.Length == 0 - && U8Name.SequenceEqual(".ctor"u8) + && Name.SequenceEqual(".ctor"u8) && !_type.IsAbstract; } } @@ -366,7 +360,7 @@ public override bool IsStaticConstructor { get { - return Attributes.IsRuntimeSpecialName() && U8Name.SequenceEqual(".cctor"u8); + return Attributes.IsRuntimeSpecialName() && Name.SequenceEqual(".cctor"u8); } } @@ -386,24 +380,7 @@ public MethodImplAttributes ImplAttributes } } - private string InitializeName() - { - var metadataReader = MetadataReader; - var name = metadataReader.GetString(metadataReader.GetMethodDefinition(_handle).Name); - return (_name = name); - } - - public override string Name - { - get - { - if (_name == null) - return InitializeName(); - return _name; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs index 9c1e98ba93ae30..5b0406e0ec6530 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs @@ -54,19 +54,19 @@ private static MethodIL TryGetIntrinsicMethodIL(MethodDesc method) break; case "Debug": { - if (owningType.U8Namespace.SequenceEqual("System.Diagnostics"u8) && method.U8Name.SequenceEqual("DebugBreak"u8)) + if (owningType.U8Namespace.SequenceEqual("System.Diagnostics"u8) && method.Name.SequenceEqual("DebugBreak"u8)) return new ILStubMethodIL(method, new byte[] { (byte)ILOpcode.break_, (byte)ILOpcode.ret }, Array.Empty(), null); } break; case "RuntimeAugments": { - if (owningType.U8Namespace.SequenceEqual("Internal.Runtime.Augments"u8) && method.U8Name.SequenceEqual("GetCanonType"u8)) + if (owningType.U8Namespace.SequenceEqual("Internal.Runtime.Augments"u8) && method.Name.SequenceEqual("GetCanonType"u8)) return GetCanonTypeIntrinsic.EmitIL(method); } break; case "MethodTable": { - if (owningType.U8Namespace.SequenceEqual("Internal.Runtime"u8) && method.U8Name.SequenceEqual("get_SupportsRelativePointers"u8)) + if (owningType.U8Namespace.SequenceEqual("Internal.Runtime"u8) && method.Name.SequenceEqual("get_SupportsRelativePointers"u8)) { ILOpcode value = method.Context.Target.SupportsRelativePointers ? ILOpcode.ldc_i4_1 : ILOpcode.ldc_i4_0; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs index 349280f168982c..e9542585b9ef90 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/AssemblyGetExecutingAssemblyMethodThunk.cs @@ -37,15 +37,7 @@ public IAssemblyDesc ExecutingAssembly get; } - public override string Name - { - get - { - return $"GetExecutingAssembly_{ExecutingAssembly.GetName().Name}"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs index 3bc8c8823258bc..25cfcb4a96b02d 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/CalliMarshallingMethodThunk.cs @@ -70,15 +70,7 @@ public override MethodSignature Signature } } - public override string Name - { - get - { - return "CalliMarshallingMethodThunk"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs index f9000fddf952e3..edb10a8d94ee1b 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs @@ -256,15 +256,7 @@ private ReadOnlySpan U8NamePrefix } } - public override string Name - { - get - { - return NamePrefix + "__" + DelegateType.Name; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs index 07189b46f92491..4d926705fa0eea 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMethodILEmitter.cs @@ -17,7 +17,7 @@ public static MethodIL EmitIL(MethodDesc method) Debug.Assert(method.OwningType.IsTypeDefinition); Debug.Assert(method.IsRuntimeImplemented); - if (method.U8Name.SequenceEqual("BeginInvoke"u8) || method.U8Name.SequenceEqual("EndInvoke"u8)) + if (method.Name.SequenceEqual("BeginInvoke"u8) || method.Name.SequenceEqual("EndInvoke"u8)) { // BeginInvoke and EndInvoke are not supported on .NET Core ILEmitter emit = new ILEmitter(); @@ -27,7 +27,7 @@ public static MethodIL EmitIL(MethodDesc method) return emit.Link(method); } - if (method.U8Name.SequenceEqual(".ctor"u8)) + if (method.Name.SequenceEqual(".ctor"u8)) { // We only support delegate creation if the IL follows the delegate creation verifiability requirements // described in ECMA-335 III.4.21 (newobj - create a new object). The codegen is expected to @@ -42,7 +42,7 @@ public static MethodIL EmitIL(MethodDesc method) return emit.Link(method); } - if (method.U8Name.SequenceEqual("Invoke"u8)) + if (method.Name.SequenceEqual("Invoke"u8)) { TypeSystemContext context = method.Context; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs index f1463c93f6c7aa..3b76ab4445c19a 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateThunks.cs @@ -128,15 +128,7 @@ public override MethodIL EmitIL() return emitter.Link(this); } - public override string Name - { - get - { - return "InvokeOpenStaticThunk"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -229,15 +221,7 @@ public override MethodIL EmitIL() return emitter.Link(this); } - public override string Name - { - get - { - return "InvokeOpenInstanceThunk"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -297,15 +281,7 @@ public override MethodIL EmitIL() return emitter.Link(this); } - public override string Name - { - get - { - return "InvokeClosedStaticThunk"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -440,15 +416,7 @@ public override MethodIL EmitIL() return emitter.Link(this); } - public override string Name - { - get - { - return "InvokeMulticastThunk"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -496,15 +464,7 @@ public override MethodIL EmitIL() return emitter.Link(this); } - public override string Name - { - get - { - return "InvokeInstanceClosedOverGenericMethodThunk"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -681,15 +641,7 @@ public override MethodIL EmitIL() return emitter.Link(this); } - public override string Name - { - get - { - return "InvokeObjectArrayThunk"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -806,15 +758,7 @@ public override bool IsVirtual } } - public override string Name - { - get - { - return "GetThunk"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs index 6128aa595a1e7d..fd1dd35bd75d7c 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DynamicInvokeMethodThunk.cs @@ -120,9 +120,7 @@ protected override int ComputeHashCode() return base.ComputeHashCode() ^ _targetSignature.GetHashCode(); } - public override string Name => "DynamicInvoke"; - - public override ReadOnlySpan U8Name => "DynamicInvoke"u8; + public override ReadOnlySpan Name => "DynamicInvoke"u8; public override string DiagnosticName => "DynamicInvoke"; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs index ac499460093fe7..f02bd56d3c786c 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs @@ -57,15 +57,7 @@ public override MethodSignature Signature } } - public override string Name - { - get - { - return "GetHashCode"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -156,15 +148,7 @@ public override MethodSignature Signature } } - public override string Name - { - get - { - return "Equals"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs index 7cb97d9a4f22a7..cfc557988a5c57 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs @@ -62,15 +62,7 @@ public override MethodSignature Signature } } - public override string Name - { - get - { - return "ForwardDelegateCreationStub__" + DelegateType.Name; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs index bc82ea1668fcc0..043a2989b1a55f 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs @@ -23,7 +23,7 @@ public static MethodIL EmitIL( Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("Interlocked"u8)); Debug.Assert(!method.IsGenericMethodDefinition); - if (method.HasInstantiation && method.U8Name.SequenceEqual("CompareExchange"u8)) + if (method.HasInstantiation && method.Name.SequenceEqual("CompareExchange"u8)) { #if READYTORUN // Check to see if the tokens needed to describe the CompareExchange are naturally present within diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs index c3f0301f0c50c1..856b356c20922c 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/MethodBaseGetCurrentMethodThunk.cs @@ -37,7 +37,7 @@ public MethodDesc Method get; } - public override string Name + public override ReadOnlySpan Name { get { @@ -45,14 +45,6 @@ public override string Name } } - public override ReadOnlySpan U8Name - { - get - { - return Method.U8Name; - } - } - public override string DiagnosticName { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs index 7aeddde871641a..eeb74f74215823 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeLazyFixupField.cs @@ -124,20 +124,12 @@ public override bool HasCustomAttribute(string attributeNamespace, string attrib return false; } - public override string Name + public override ReadOnlySpan Name { get { return _targetMethod.Name; } } - - public override ReadOnlySpan U8Name - { - get - { - return _targetMethod.U8Name; - } - } } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs index 9276a182879718..10520bf0266c70 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/PInvokeTargetNativeMethod.cs @@ -54,7 +54,7 @@ public override MethodSignature Signature } } - public override string Name + public override ReadOnlySpan Name { get { @@ -62,14 +62,6 @@ public override string Name } } - public override ReadOnlySpan U8Name - { - get - { - return _declMethod.U8Name; - } - } - public override bool HasCustomAttribute(string attributeNamespace, string attributeName) { return false; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index b09135ccf2bbb4..3f8e77bc9575b4 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -29,7 +29,7 @@ public static MethodIL EmitIL(MethodDesc method) return null; bool result; - if (method.U8Name.SequenceEqual("IsBitwiseEquatable"u8)) + if (method.Name.SequenceEqual("IsBitwiseEquatable"u8)) { // Ideally we could detect automatically whether a type is trivially equatable // (i.e., its operator == could be implemented via memcmp). But for now we'll diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs index 1624b4f73171d9..f0fe60ad728dc0 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs @@ -18,8 +18,8 @@ public static MethodIL EmitIL(MethodDesc method) { Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("Stream"u8)); - bool isRead = method.U8Name.SequenceEqual("HasOverriddenBeginEndRead"u8); - if (!isRead && !method.U8Name.SequenceEqual("HasOverriddenBeginEndWrite"u8)) + bool isRead = method.Name.SequenceEqual("HasOverriddenBeginEndRead"u8); + if (!isRead && !method.Name.SequenceEqual("HasOverriddenBeginEndWrite"u8)) return null; TypeDesc streamClass = method.OwningType; diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs index 9cb7f55b6ad023..d5e34a303baff6 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs @@ -140,15 +140,7 @@ private ReadOnlySpan U8NamePrefix } } - public override string Name - { - get - { - return NamePrefix + "__" + ((MetadataType)ManagedType).Name; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs index d2a3d26ef588ce..1db9b1c2f4231f 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/TypeGetTypeMethodThunk.cs @@ -34,19 +34,11 @@ public override TypeSystemContext Context } } - public override string Name + public override ReadOnlySpan Name { get { - return $"{_helperMethod.Name}_{Signature.Length}_{DefaultAssemblyName}"; - } - } - - public override ReadOnlySpan U8Name - { - get - { - return System.Text.Encoding.UTF8.GetBytes(Name); + return System.Text.Encoding.UTF8.GetBytes($"{_helperMethod.GetName()}_{Signature.Length}_{DefaultAssemblyName}"); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs index 539ca5491b436f..60cb0e0c53ceb6 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs @@ -215,18 +215,9 @@ public override bool IsVirtual } } - internal const string MetadataName = "__GetFieldHelper"; internal static ReadOnlySpan U8MetadataName => "__GetFieldHelper"u8; - public override string Name - { - get - { - return MetadataName; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -238,7 +229,7 @@ public override string DiagnosticName { get { - return MetadataName; + return "__GetFieldHelper"; } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs index 0a257327d7edab..e37f5a886b6087 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs @@ -335,22 +335,7 @@ public override TypeSystemContext Context } } - public override string Name - { - get - { - if (_kind == InlineArrayMethodKind.Getter) - { - return "get_Item"; - } - else - { - return "set_Item"; - } - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -520,15 +505,7 @@ public override bool HasCustomAttribute(string attributeNamespace, string attrib return false; } - public override string Name - { - get - { - return "InlineArrayField"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs index be56340ad6d5f0..9e0ac3c0b9e52f 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs @@ -417,7 +417,7 @@ public override bool HasCustomAttribute(string attributeNamespace, string attrib return false; } - public override string Name + public override ReadOnlySpan Name { get { @@ -425,14 +425,6 @@ public override string Name } } - public override ReadOnlySpan U8Name - { - get - { - return _managedField.U8Name; - } - } - public override LayoutInt MetadataOffset { get diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs index 79cb70e2a227e1..af6817d57d09e6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapperConstructor.cs @@ -22,15 +22,7 @@ public override TypeDesc OwningType get; } - public override string Name - { - get - { - return ".ctor"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs index 77bfde2ff26e6c..5f97f7645ea76e 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/MethodForRuntimeDeterminedType.cs @@ -36,8 +36,7 @@ internal MethodForRuntimeDeterminedType(MethodDesc typicalMethodDef, RuntimeDete public override bool IsAbstract => _typicalMethodDef.IsAbstract; public override bool IsFinal => _typicalMethodDef.IsFinal; public override bool IsDefaultConstructor => _typicalMethodDef.IsDefaultConstructor; - public override string Name => _typicalMethodDef.Name; - public override ReadOnlySpan U8Name => _typicalMethodDef.U8Name; + public override ReadOnlySpan Name => _typicalMethodDef.Name; public override MethodDesc GetTypicalMethodDefinition() => _typicalMethodDef; public override Instantiation Instantiation => _typicalMethodDef.Instantiation; diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs index f2803781574f67..116ec5d33022fd 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/TypeSystemContext.RuntimeDetermined.cs @@ -77,7 +77,7 @@ public MethodForRuntimeDeterminedTypeKey(MethodDesc typicalMethodDef, RuntimeDet { _typicalMethodDef = typicalMethodDef; _rdType = rdType; - _hashcode = rdType.CanonicalType.GetHashCode() ^ VersionResilientHashCode.NameHashCode(typicalMethodDef.U8Name); + _hashcode = rdType.CanonicalType.GetHashCode() ^ VersionResilientHashCode.NameHashCode(typicalMethodDef.Name); } public MethodDesc TypicalMethodDef diff --git a/src/coreclr/tools/ILVerify/Program.cs b/src/coreclr/tools/ILVerify/Program.cs index c5129006e4fa0e..3d5cab0ab42b01 100644 --- a/src/coreclr/tools/ILVerify/Program.cs +++ b/src/coreclr/tools/ILVerify/Program.cs @@ -194,7 +194,7 @@ private void PrintVerifyMethodsResult(VerificationResult result, EcmaModule modu private static void PrintMethod(EcmaMethod method) { - Write(method.Name); + Write(method.GetName()); Write("("); try { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs index 14975d1ee88f1d..0d4a575f362b6f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/BodySubstitutionParser.cs @@ -108,7 +108,7 @@ protected override void ProcessField(TypeDesc type, XPathNavigator fieldNav) if (string.IsNullOrEmpty(name)) return; - var field = type.GetFields().FirstOrDefault(f => f.U8Name.StringEquals(name)); + var field = type.GetFields().FirstOrDefault(f => f.Name.StringEquals(name)); if (field == null) { #if !READYTORUN diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs index 3e0d48df0f6eab..da6b1676e39f93 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs @@ -177,7 +177,7 @@ public MethodDesc ExpandIntrinsicForCallsite(MethodDesc intrinsicMethod, MethodD if (intrinsicOwningType.U8Name.SequenceEqual("Type"u8) && intrinsicOwningType.U8Namespace.SequenceEqual("System"u8)) { - if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.U8Name.SequenceEqual("GetType"u8)) + if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.Name.SequenceEqual("GetType"u8)) { ModuleDesc callsiteModule = (callsiteMethod.OwningType as MetadataType)?.Module; if (callsiteModule != null) @@ -189,7 +189,7 @@ public MethodDesc ExpandIntrinsicForCallsite(MethodDesc intrinsicMethod, MethodD } else if (intrinsicOwningType.U8Name.SequenceEqual("Assembly"u8) && intrinsicOwningType.U8Namespace.SequenceEqual("System.Reflection"u8)) { - if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.U8Name.SequenceEqual("GetExecutingAssembly"u8)) + if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.Name.SequenceEqual("GetExecutingAssembly"u8)) { ModuleDesc callsiteModule = (callsiteMethod.OwningType as MetadataType)?.Module; if (callsiteModule != null) @@ -201,7 +201,7 @@ public MethodDesc ExpandIntrinsicForCallsite(MethodDesc intrinsicMethod, MethodD } else if (intrinsicOwningType.U8Name.SequenceEqual("MethodBase"u8) && intrinsicOwningType.U8Namespace.SequenceEqual("System.Reflection"u8)) { - if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.U8Name.SequenceEqual("GetCurrentMethod"u8)) + if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.Name.SequenceEqual("GetCurrentMethod"u8)) { return _methodBaseGetCurrentMethodThunks.GetHelper(callsiteMethod).InstantiateAsOpen(); } @@ -455,7 +455,7 @@ public bool IsFatPointerCandidate(MethodDesc containingMethod, MethodSignature s return false; // Delegate invocation never needs fat calls - if (owningType.IsDelegate && containingMethod.U8Name.SequenceEqual("Invoke"u8)) + if (owningType.IsDelegate && containingMethod.Name.SequenceEqual("Invoke"u8)) return false; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs index 18af56877ee1d2..9a2e9eeebb883c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs @@ -404,19 +404,11 @@ public GenericUnboxingThunk(BoxedValueType owningType, MethodDesc targetMethod) public MethodDesc TargetMethod => _targetMethod; - public override string Name + public override ReadOnlySpan Name { get { - return _targetMethod.Name + "_Unbox"; - } - } - - public override ReadOnlySpan U8Name - { - get - { - return _targetMethod.U8Name.Append("_Unbox"u8); + return _targetMethod.Name.Append("_Unbox"u8); } } @@ -509,19 +501,11 @@ public UnboxingThunk(BoxedValueType owningType, MethodDesc targetMethod) public MethodDesc TargetMethod => _targetMethod; - public override string Name + public override ReadOnlySpan Name { get { - return _targetMethod.Name + "_Unbox"; - } - } - - public override ReadOnlySpan U8Name - { - get - { - return _targetMethod.U8Name.Append("_Unbox"u8); + return _targetMethod.Name.Append("_Unbox"u8); } } @@ -619,9 +603,7 @@ public ValueTypeInstanceMethodWithHiddenParameter(MethodDesc methodRepresented) public override TypeSystemContext Context => _methodRepresented.Context; public override TypeDesc OwningType => _methodRepresented.OwningType; - public override string Name => _methodRepresented.Name; - - public override ReadOnlySpan U8Name => _methodRepresented.U8Name; + public override ReadOnlySpan Name => _methodRepresented.Name; public override string DiagnosticName => _methodRepresented.DiagnosticName; public override MethodSignature Signature diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs index 3ba9caee3abcae..a4fab8a96fa96e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs @@ -57,9 +57,9 @@ public MethodDesc TryResolveConstrainedEnumMethod(TypeDesc enumType, MethodDesc EnumInfo info = _enumInfoHashtable.GetOrCreateValue(enumTypeDefinition); MethodDesc resolvedMethod; - if (virtualMethod.U8Name.SequenceEqual("Equals"u8)) + if (virtualMethod.Name.SequenceEqual("Equals"u8)) resolvedMethod = info.EqualsMethod; - else if (virtualMethod.U8Name.SequenceEqual("GetHashCode"u8)) + else if (virtualMethod.Name.SequenceEqual("GetHashCode"u8)) resolvedMethod = info.GetHashCodeMethod; else return null; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs index dfd392cc10f81c..005d5d40053149 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs @@ -195,7 +195,7 @@ public DefaultInterfaceMethodImplementationInstantiationThunk(TypeDesc owningTyp public MethodDesc TargetMethod => _targetMethod; - public override string Name + public override ReadOnlySpan Name { get { @@ -203,14 +203,6 @@ public override string Name } } - public override ReadOnlySpan U8Name - { - get - { - return _targetMethod.U8Name; - } - } - public override string DiagnosticName { get @@ -315,8 +307,7 @@ public DefaultInterfaceMethodImplementationWithHiddenParameter(MethodDesc method public override TypeSystemContext Context => _methodRepresented.Context; public override TypeDesc OwningType => _owningType; - public override string Name => _methodRepresented.Name; - public override ReadOnlySpan U8Name => _methodRepresented.U8Name; + public override ReadOnlySpan Name => _methodRepresented.Name; public override string DiagnosticName => _methodRepresented.DiagnosticName; public override MethodSignature Signature diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs index ac3c9770abb468..789935b52d5cc9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs @@ -657,7 +657,7 @@ private partial bool MethodIsTypeConstructor(MethodProxy method) private partial IEnumerable GetMethodsOnTypeHierarchy(TypeProxy type, string name, BindingFlags? bindingFlags) { - foreach (var method in type.Type.GetMethodsOnTypeHierarchy(m => m.U8Name.StringEquals(name), bindingFlags)) + foreach (var method in type.Type.GetMethodsOnTypeHierarchy(m => m.Name.StringEquals(name), bindingFlags)) yield return new SystemReflectionMethodBaseValue(new MethodProxy(method)); } @@ -712,7 +712,7 @@ private partial void MarkEventsOnTypeHierarchy(TypeProxy type, string name, Bind => _reflectionMarker.MarkEventsOnTypeHierarchy(_diagnosticContext.Origin, type.Type, e => e.Name == name, _reason, bindingFlags); private partial void MarkFieldsOnTypeHierarchy(TypeProxy type, string name, BindingFlags? bindingFlags) - => _reflectionMarker.MarkFieldsOnTypeHierarchy(_diagnosticContext.Origin, type.Type, f => f.U8Name.StringEquals(name), _reason, bindingFlags); + => _reflectionMarker.MarkFieldsOnTypeHierarchy(_diagnosticContext.Origin, type.Type, f => f.Name.StringEquals(name), _reason, bindingFlags); private partial void MarkPropertiesOnTypeHierarchy(TypeProxy type, string name, BindingFlags? bindingFlags) => _reflectionMarker.MarkPropertiesOnTypeHierarchy(_diagnosticContext.Origin, type.Type, p => p.Name == name, _reason, bindingFlags); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs index c74c80463278bc..4aa96d078df4d2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs @@ -974,7 +974,7 @@ private void OutputVirtualSlots(NodeFactory factory, ref ObjectDataBuilder objDa // Object.Finalize shouldn't get a virtual slot. Finalizer is stored in an optional field // instead: most MethodTable don't have a finalizer, but all EETypes contain Object's vtable. // This lets us save a pointer (+reloc) on most EETypes. - Debug.Assert(!declType.IsObject || !declMethod.U8Name.SequenceEqual("Finalize"u8)); + Debug.Assert(!declType.IsObject || !declMethod.Name.SequenceEqual("Finalize"u8)); // No generic virtual methods can appear in the vtable! Debug.Assert(!declMethod.HasInstantiation); @@ -999,8 +999,8 @@ private void OutputVirtualSlots(NodeFactory factory, ref ObjectDataBuilder objDa // We also null out Equals/GetHashCode - that's just a marginal size/startup optimization. if (isAsyncStateMachineValueType) { - if ((declType.IsObject && (declMethod.U8Name.SequenceEqual("Equals"u8) || declMethod.U8Name.SequenceEqual("GetHashCode"u8)) && implMethod.OwningType.IsWellKnownType(WellKnownType.ValueType)) - || (declType.IsWellKnownType(WellKnownType.ValueType) && declMethod.U8Name.SequenceEqual(ValueTypeGetFieldHelperMethodOverride.U8MetadataName))) + if ((declType.IsObject && (declMethod.Name.SequenceEqual("Equals"u8) || declMethod.Name.SequenceEqual("GetHashCode"u8)) && implMethod.OwningType.IsWellKnownType(WellKnownType.ValueType)) + || (declType.IsWellKnownType(WellKnownType.ValueType) && declMethod.Name.SequenceEqual(ValueTypeGetFieldHelperMethodOverride.U8MetadataName))) { shouldEmitImpl = false; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs index 508e8431781ffc..f498451f8afd3c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs @@ -63,7 +63,7 @@ public static bool IsInlineableStringsResource(EcmaModule module, string resourc public static void AddDependenciesDueToResourceStringUse(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { - if (method.U8Name.SequenceEqual(U8ResourceAccessorGetStringMethodName) && method.OwningType is MetadataType mdType + if (method.Name.SequenceEqual(U8ResourceAccessorGetStringMethodName) && method.OwningType is MetadataType mdType && mdType.U8Name.SequenceEqual(U8ResourceAccessorTypeName) && mdType.U8Namespace.SequenceEqual(U8ResourceAccessorTypeNamespace)) { dependencies ??= new DependencyList(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs index 81480df8b439ca..2ec4de0835ed59 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/VTableSliceNode.cs @@ -43,7 +43,7 @@ protected static MethodDesc[] ComputeSlots(TypeDesc type) continue; // Finalizers are called via a field on the MethodTable, not through the VTable - if (isObjectType && method.U8Name.SequenceEqual("Finalize"u8)) + if (isObjectType && method.Name.SequenceEqual("Finalize"u8)) continue; // Current type doesn't define this slot. @@ -204,7 +204,7 @@ public void AddEntry(MethodDesc virtualMethod) #endif // Finalizers are called via a field on the MethodTable, not through the VTable - if (_type.IsObject && virtualMethod.U8Name.SequenceEqual("Finalize"u8)) + if (_type.IsObject && virtualMethod.Name.SequenceEqual("Finalize"u8)) return; _usedMethods.Add(virtualMethod); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExternSymbolMappedField.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExternSymbolMappedField.cs index d48156499d1b98..4c83d4854232bd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExternSymbolMappedField.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ExternSymbolMappedField.cs @@ -20,9 +20,7 @@ public ExternSymbolMappedField(TypeDesc fieldType, string symbolName) _symbolName = symbolName; } - public override string Name => _symbolName; - - public override ReadOnlySpan U8Name => System.Text.Encoding.UTF8.GetBytes(Name); + public override ReadOnlySpan Name => System.Text.Encoding.UTF8.GetBytes(_symbolName); public string SymbolName => _symbolName; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/HardwareIntrinsicHelpers.Aot.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/HardwareIntrinsicHelpers.Aot.cs index 379b6293fd6ce9..e02ed8a0e597cd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/HardwareIntrinsicHelpers.Aot.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/HardwareIntrinsicHelpers.Aot.cs @@ -16,7 +16,7 @@ public static partial class HardwareIntrinsicHelpers { public static bool IsIsSupportedMethod(MethodDesc method) { - return method.U8Name.SequenceEqual("get_IsSupported"u8); + return method.Name.SequenceEqual("get_IsSupported"u8); } /// diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs index 984902588ed4ee..fe5b3f4b7c5d26 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs @@ -585,7 +585,7 @@ private static void GetMatchingMethods(string id, ref int index, TypeDesc type, foreach (var method in type.GetMethods()) { index = startIndex; - if (!method.U8Name.StringEquals(memberName)) + if (!method.Name.StringEquals(memberName)) continue; var methodArity = method.Instantiation.Length; @@ -682,7 +682,7 @@ private static void GetMatchingFields(TypeDesc type, string memberName, List _context; public override TypeDesc OwningType => _context.GeneratedAssembly.GetGlobalModuleType(); - public override string Name => "InitializeReachabilityInfo"; - public override ReadOnlySpan U8Name => "InitializeReachabilityInfo"u8; + public override ReadOnlySpan Name => "InitializeReachabilityInfo"u8; public override string DiagnosticName => "InitializeReachabilityInfo"; public override MethodIL EmitIL() diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs index 144f86d462c90d..fd28d1d8f13829 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs @@ -417,7 +417,7 @@ public MethodIL GetMethodILWithInlinedSubstitutions(MethodIL method) && calleeType.U8Name.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeName) && calleeType.U8Namespace.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeNamespace) && callee.Signature is { Length: 0, IsStatic: true } - && callee.U8Name.StartsWith("get_"u8)) + && callee.Name.StartsWith("get_"u8)) { flags[offset] |= OpcodeFlags.GetResourceStringCall; hasGetResourceStringCall = true; @@ -822,7 +822,7 @@ private bool TryGetConstantArgument(MethodIL methodIL, byte[] body, OpcodeFlags[ { return true; } - else if (method.IsIntrinsic && (method.U8Name.SequenceEqual("get_IsValueType"u8) || method.U8Name.SequenceEqual("get_IsEnum"u8)) + else if (method.IsIntrinsic && (method.Name.SequenceEqual("get_IsValueType"u8) || method.Name.SequenceEqual("get_IsEnum"u8)) && method.OwningType is MetadataType mdt && mdt.U8Name.SequenceEqual("Type"u8) && mdt.U8Namespace.SequenceEqual("System"u8) && mdt.Module == mdt.Context.SystemModule && TryExpandTypeIs(methodIL, body, flags, currentOffset, method.GetName(), out constant)) @@ -1133,7 +1133,7 @@ private static bool ReadGetTypeFromHandle(ref ILReader reader, MethodIL methodIL MethodDesc method = (MethodDesc)methodIL.GetObject(reader.ReadILToken()); - if (!method.IsIntrinsic || !method.U8Name.SequenceEqual("GetTypeFromHandle"u8)) + if (!method.IsIntrinsic || !method.Name.SequenceEqual("GetTypeFromHandle"u8)) return false; if ((flags[reader.Offset] & OpcodeFlags.BasicBlockStart) != 0) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs index d6ab77e0383a9e..01391039647f75 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs @@ -134,8 +134,8 @@ public bool HasSubstitutedValue(FieldDesc field) internal string GetResourceStringForAccessor(EcmaMethod method) { - Debug.Assert(method.U8Name.StartsWith("get_"u8)); - string resourceStringName = System.Text.Encoding.UTF8.GetString(method.U8Name.Slice(4)); + Debug.Assert(method.Name.StartsWith("get_"u8)); + string resourceStringName = System.Text.Encoding.UTF8.GetString(method.Name.Slice(4)); Dictionary dict = _hashtable.GetOrCreateValue(method.Module).InlineableResourceStrings; if (dict != null diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs index bd561a87e6685c..5eec852b659c90 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapMetadata.cs @@ -22,18 +22,18 @@ internal sealed class Map private sealed class ThrowingMethodStub : ILStubMethod { private readonly TypeDesc _typeMapGroup; + private readonly byte[] _name; public ThrowingMethodStub(TypeDesc owningType, TypeDesc typeMapGroup, bool externalTypeMap, TypeSystemException ex) { OwningType = owningType; _typeMapGroup = typeMapGroup; - Name = $"InvalidTypeMapStub_{_typeMapGroup}_{(externalTypeMap ? "External" : "Proxy")}"; + _name = System.Text.Encoding.UTF8.GetBytes($"InvalidTypeMapStub_{_typeMapGroup}_{(externalTypeMap ? "External" : "Proxy")}"); Exception = ex; } public TypeSystemException Exception { get; } - public override string Name { get; } - public override ReadOnlySpan U8Name => System.Text.Encoding.UTF8.GetBytes(Name); + public override ReadOnlySpan Name => _name; public override MethodIL EmitIL() { return TypeSystemThrowingILEmitter.EmitIL(this, Exception); @@ -41,7 +41,7 @@ public override MethodIL EmitIL() protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer) { - return U8Name.SequenceCompareTo(other.U8Name); + return Name.SequenceCompareTo(other.Name); } public override bool IsPInvoke => false; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index bb3425ade9d003..1c608b5a58481b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -2524,14 +2524,14 @@ bool IHasInstanceFields.TrySetField(FieldDesc field, Value value) if (field.OwningType != _parent._entryType) return false; - if (field.U8Name.SequenceEqual("IID"u8) + if (field.Name.SequenceEqual("IID"u8) && value is ValueTypeValue guidValue && guidValue.Size == _parent._guidBytes[_index].Length) { Array.Copy(guidValue.InstanceBytes, _parent._guidBytes[_index], _parent._guidBytes[_index].Length); return true; } - else if (field.U8Name.SequenceEqual("Vtable"u8) + else if (field.Name.SequenceEqual("Vtable"u8) && value is ByRefValueBase byrefValue && byrefValue.BackingField != null) { @@ -2970,7 +2970,7 @@ public bool TrySetField(FieldDesc field, Value value) if (elementType != _value._elementType) return false; - if (field.U8Name.SequenceEqual("_length"u8)) + if (field.Name.SequenceEqual("_length"u8)) { _value._length = value.AsInt32() * _value._elementType.InstanceFieldSize.AsInt; return true; @@ -2978,7 +2978,7 @@ public bool TrySetField(FieldDesc field, Value value) if (value is ByRefValue byref) { - Debug.Assert(field.U8Name.SequenceEqual("_reference"u8)); + Debug.Assert(field.Name.SequenceEqual("_reference"u8)); _value._bytes = byref.PointedToBytes; _value._index = byref.PointedToOffset; return true; @@ -2997,10 +2997,10 @@ public Value GetField(FieldDesc field) if (elementType != _value._elementType) ThrowHelper.ThrowInvalidProgramException(); - if (field.U8Name.SequenceEqual("_length"u8)) + if (field.Name.SequenceEqual("_length"u8)) return ValueTypeValue.FromInt32(_value._length / elementType.InstanceFieldSize.AsInt); - Debug.Assert(field.U8Name.SequenceEqual("_reference"u8)); + Debug.Assert(field.Name.SequenceEqual("_reference"u8)); return new ByRefValue(_value._bytes, _value._index); } @@ -3260,7 +3260,7 @@ public void WriteContent(ref ObjectDataBuilder builder, ISymbolNode thisNode, No if (_methodPointed.Signature.IsStatic) { - Debug.Assert(creationInfo.Constructor.Method.U8Name.SequenceEqual("InitializeOpenStaticThunk"u8)); + Debug.Assert(creationInfo.Constructor.Method.Name.SequenceEqual("InitializeOpenStaticThunk"u8)); // _firstParameter builder.EmitPointerReloc(thisNode); @@ -3277,7 +3277,7 @@ public void WriteContent(ref ObjectDataBuilder builder, ISymbolNode thisNode, No } else { - Debug.Assert(creationInfo.Constructor.Method.U8Name.SequenceEqual("InitializeClosedInstance"u8)); + Debug.Assert(creationInfo.Constructor.Method.Name.SequenceEqual("InitializeClosedInstance"u8)); // _firstParameter _firstParameter.WriteFieldData(ref builder, factory); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs index 01765e1465ba62..329a8ed31569ab 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs @@ -381,7 +381,7 @@ private void ImportCall(ILOpcode opcode, int token) } } - if (method.OwningType.IsDelegate && method.U8Name.SequenceEqual("Invoke"u8) && + if (method.OwningType.IsDelegate && method.Name.SequenceEqual("Invoke"u8) && opcode != ILOpcode.ldftn && opcode != ILOpcode.ldvirtftn) { // This call is expanded as an intrinsic; it's not an actual function call. @@ -997,7 +997,7 @@ private void ImportLdToken(int token) { if (type.IsCanonicalDefinitionType(CanonicalFormKind.Any)) { - Debug.Assert(_methodIL.OwningMethod.U8Name.SequenceEqual("GetCanonType"u8)); + Debug.Assert(_methodIL.OwningMethod.Name.SequenceEqual("GetCanonType"u8)); helperId = ReadyToRunHelperId.NecessaryTypeHandle; } @@ -1468,7 +1468,7 @@ private static void ReportInvalidInstruction(ILOpcode opcode) private static bool IsTypeGetTypeFromHandle(MethodDesc method) { - if (method.IsIntrinsic && method.U8Name.SequenceEqual("GetTypeFromHandle"u8)) + if (method.IsIntrinsic && method.Name.SequenceEqual("GetTypeFromHandle"u8)) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -1482,7 +1482,7 @@ private static bool IsTypeGetTypeFromHandle(MethodDesc method) private static bool IsActivatorDefaultConstructorOf(MethodDesc method) { - if (method.IsIntrinsic && method.U8Name.SequenceEqual("DefaultConstructorOf"u8) && method.Instantiation.Length == 1) + if (method.IsIntrinsic && method.Name.SequenceEqual("DefaultConstructorOf"u8) && method.Instantiation.Length == 1) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -1496,7 +1496,7 @@ private static bool IsActivatorDefaultConstructorOf(MethodDesc method) private static bool IsActivatorAllocatorOf(MethodDesc method) { - if (method.IsIntrinsic && method.U8Name.SequenceEqual("AllocatorOf"u8) && method.Instantiation.Length == 1) + if (method.IsIntrinsic && method.Name.SequenceEqual("AllocatorOf"u8) && method.Instantiation.Length == 1) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -1510,7 +1510,7 @@ private static bool IsActivatorAllocatorOf(MethodDesc method) private static bool IsEETypePtrOf(MethodDesc method) { - if (method.IsIntrinsic && method.U8Name.SequenceEqual("Of"u8) && method.Instantiation.Length == 1) + if (method.IsIntrinsic && method.Name.SequenceEqual("Of"u8) && method.Instantiation.Length == 1) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -1524,7 +1524,7 @@ private static bool IsEETypePtrOf(MethodDesc method) private static bool IsRuntimeHelpersIsReferenceOrContainsReferences(MethodDesc method) { - if (method.IsIntrinsic && method.U8Name.SequenceEqual("IsReferenceOrContainsReferences"u8) && method.Instantiation.Length == 1) + if (method.IsIntrinsic && method.Name.SequenceEqual("IsReferenceOrContainsReferences"u8) && method.Instantiation.Length == 1) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) @@ -1538,7 +1538,7 @@ private static bool IsRuntimeHelpersIsReferenceOrContainsReferences(MethodDesc m private static bool IsMemoryMarshalGetArrayDataReference(MethodDesc method) { - if (method.IsIntrinsic && method.U8Name.SequenceEqual("GetArrayDataReference"u8) && method.Instantiation.Length == 1) + if (method.IsIntrinsic && method.Name.SequenceEqual("GetArrayDataReference"u8) && method.Instantiation.Length == 1) { MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs index 1cc0c7da840d2d..949ce0597b8ec6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/NativeLibraryStartupMethod.cs @@ -40,15 +40,7 @@ public override TypeDesc OwningType } } - public override string Name - { - get - { - return "NativeLibraryStartup"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs index ff65ba4bf2c501..b74ec0b0814e5b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/Stubs/StartupCode/StartupCodeMainMethod.cs @@ -45,15 +45,7 @@ public override TypeDesc OwningType } } - public override string Name - { - get - { - return "StartupCodeMain"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -238,15 +230,7 @@ public override TypeDesc OwningType get; } - public override string Name - { - get - { - return "MainMethodWrapper"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs index a9066e2ba5084f..6cd75581ece3e8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs @@ -147,22 +147,22 @@ static bool IsSystemType(TypeDesc t) static bool IsTypeGetTypeFromHandle(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode == ILOpcode.call && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method - && method.IsIntrinsic && method.U8Name.SequenceEqual("GetTypeFromHandle"u8) + && method.IsIntrinsic && method.Name.SequenceEqual("GetTypeFromHandle"u8) && IsSystemType(method.OwningType); static bool IsTypeEquals(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode == ILOpcode.call && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method - && method.IsIntrinsic && method.U8Name.SequenceEqual("op_Equality"u8) + && method.IsIntrinsic && method.Name.SequenceEqual("op_Equality"u8) && IsSystemType(method.OwningType); static bool IsTypeInequals(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode == ILOpcode.call && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method - && method.IsIntrinsic && method.U8Name.SequenceEqual("op_Inequality"u8) + && method.IsIntrinsic && method.Name.SequenceEqual("op_Inequality"u8) && IsSystemType(method.OwningType); static bool IsObjectGetType(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode is ILOpcode.call or ILOpcode.callvirt && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method - && method.IsIntrinsic && method.U8Name.SequenceEqual("GetType"u8) && method.OwningType.IsObject; + && method.IsIntrinsic && method.Name.SequenceEqual("GetType"u8) && method.OwningType.IsObject; static bool IsArgumentOrLocalLoad(ILOpcode opcode) => opcode is (>= ILOpcode.ldloc_0 and <= ILOpcode.ldloc_3) or (>= ILOpcode.ldarg_0 and <= ILOpcode.ldarg_3); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs index d5ac3c3a01c03b..0f4cfe2b0a0c97 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs @@ -215,7 +215,7 @@ Task ValidateTypeWorkerHelper(TypeDesc typeToCheckForSkipValidation) { if (methodDef.Attributes.HasFlag(MethodAttributes.RTSpecialName)) { - if (!method.U8Name.SequenceEqual(".cctor"u8) && !method.U8Name.StartsWith("_VtblGap"u8)) + if (!method.Name.SequenceEqual(".cctor"u8) && !method.Name.StartsWith("_VtblGap"u8)) { AddTypeValidationError(type, $"Special name method {method} defined on interface"); return false; diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileDataManager.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileDataManager.cs index ffc9600597693d..492ef797360ded 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileDataManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ProfileDataManager.cs @@ -202,7 +202,7 @@ private PgoSchemaElem[] SynthesizeSchema(Compilation comp, MethodDesc method) if (targetMeth.Signature.IsStatic || !targetMeth.IsTypicalMethodDefinition) continue; - bool isDelegateInvoke = targetMeth.OwningType.IsDelegate && targetMeth.U8Name.SequenceEqual("Invoke"u8); + bool isDelegateInvoke = targetMeth.OwningType.IsDelegate && targetMeth.Name.SequenceEqual("Invoke"u8); if (opcode != ILOpcode.callvirt && !isDelegateInvoke) continue; diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/RuntimeDeterminedTypeHelper.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/RuntimeDeterminedTypeHelper.cs index b28b4b30937883..b13a190754d917 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/RuntimeDeterminedTypeHelper.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/RuntimeDeterminedTypeHelper.cs @@ -142,7 +142,7 @@ public static bool Equals(FieldDesc field1, FieldDesc field2) { return field1 == null && field2 == null; } - return field1.U8Name.SequenceEqual(field2.U8Name) && + return field1.Name.SequenceEqual(field2.Name) && RuntimeDeterminedTypeHelper.Equals(field1.OwningType, field2.OwningType) && RuntimeDeterminedTypeHelper.Equals(field1.FieldType, field2.FieldType); } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs index 555d832f15f448..521cb531e4ad1a 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs @@ -410,7 +410,7 @@ private uint LookupIbcMethodToken(MetadataType methodMetadataType, uint ibcToken foreach (MethodDesc method in ecmaType.GetMethods()) { - if (method.U8Name.SequenceEqual(methodName)) + if (method.Name.SequenceEqual(methodName)) { EcmaMethod ecmaCandidateMethod = method as EcmaMethod; if (ecmaCandidateMethod == null) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs index fdfa9c80f239fb..1047587d467c44 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs @@ -50,7 +50,7 @@ private MethodIL TryGetIntrinsicMethodILForActivator(MethodDesc method) { if (method.Instantiation.Length == 1 && method.Signature.Length == 0 - && method.U8Name.SequenceEqual("CreateInstance"u8)) + && method.Name.SequenceEqual("CreateInstance"u8)) { TypeDesc type = method.Instantiation[0]; if (type.IsValueType && type.GetParameterlessConstructor() == null) diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/InstanceCalliHelperIntrinsics.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/InstanceCalliHelperIntrinsics.cs index 91eefcdd4774b5..a5d42af06d398c 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/InstanceCalliHelperIntrinsics.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/Stubs/InstanceCalliHelperIntrinsics.cs @@ -14,7 +14,7 @@ public static MethodIL EmitIL(MethodDesc method) { MethodIL methodIL = EcmaMethodIL.Create((EcmaMethod)method); - if (method.U8Name.StartsWith("Invoke"u8)) + if (method.Name.StartsWith("Invoke"u8)) { methodIL = new ExplicitThisCall(methodIL); } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index eef401cc9bd678..92302c2181d398 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -529,9 +529,9 @@ public static bool ShouldSkipCompilation(InstructionSetSupport instructionSetSup } if (methodNeedingCode.OwningType.IsDelegate && ( methodNeedingCode.IsConstructor || - methodNeedingCode.U8Name.SequenceEqual("BeginInvoke"u8) || - methodNeedingCode.U8Name.SequenceEqual("Invoke"u8) || - methodNeedingCode.U8Name.SequenceEqual("EndInvoke"u8))) + methodNeedingCode.Name.SequenceEqual("BeginInvoke"u8) || + methodNeedingCode.Name.SequenceEqual("Invoke"u8) || + methodNeedingCode.Name.SequenceEqual("EndInvoke"u8))) { // Special methods on delegate types return true; @@ -1917,7 +1917,7 @@ private void ceeInfoGetCallInfo( // JIT compilation, and require a runtime lookup for the actual code pointer // to call. - if (constrainedType.IsEnum && originalMethod.U8Name.SequenceEqual("GetHashCode"u8)) + if (constrainedType.IsEnum && originalMethod.Name.SequenceEqual("GetHashCode"u8)) { MethodDesc methodOnUnderlyingType = constrainedType.UnderlyingType.FindVirtualFunctionTargetMethodOnObjectType(originalMethod); Debug.Assert(methodOnUnderlyingType != null); @@ -2070,8 +2070,8 @@ private void ceeInfoGetCallInfo( // 2) Delegate.Invoke() - since a Delegate is a sealed class as per ECMA spec // 3) JIT intrinsics - since they have pre-defined behavior devirt = targetMethod.OwningType.IsValueType || - (targetMethod.OwningType.IsDelegate && targetMethod.U8Name.SequenceEqual("Invoke"u8)) || - (targetMethod.OwningType.IsObject && targetMethod.U8Name.SequenceEqual("GetType"u8)); + (targetMethod.OwningType.IsDelegate && targetMethod.Name.SequenceEqual("Invoke"u8)) || + (targetMethod.OwningType.IsObject && targetMethod.Name.SequenceEqual("GetType"u8)); callVirtCrossingVersionBubble = true; } diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs index 14975628088fd5..22eaffa1c285cc 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs @@ -212,19 +212,11 @@ public override TypeSystemContext Context } } - public override string Name + public override ReadOnlySpan Name { get { - return _name; - } - } - - public override ReadOnlySpan U8Name - { - get - { - return System.Text.Encoding.UTF8.GetBytes(Name); + return System.Text.Encoding.UTF8.GetBytes(_name); } } diff --git a/src/coreclr/tools/aot/crossgen2/Program.cs b/src/coreclr/tools/aot/crossgen2/Program.cs index 1e2c70985ab856..90aabdbc349c31 100644 --- a/src/coreclr/tools/aot/crossgen2/Program.cs +++ b/src/coreclr/tools/aot/crossgen2/Program.cs @@ -764,7 +764,7 @@ internal static string CreateReproArgumentString(MethodDesc method) int curIndex = 0; foreach (var searchMethod in method.OwningType.GetMethods()) { - if (!searchMethod.U8Name.SequenceEqual(method.U8Name)) + if (!searchMethod.Name.SequenceEqual(method.Name)) continue; curIndex++; diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs index 72aada80d93ddf..7104bb3f727a48 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemField.cs @@ -25,8 +25,7 @@ public TypeRefTypeSystemField(TypeRefTypeSystemType type, ReadOnlySpan nam _embeddedSignatureData = embeddedSigData; } - public override string Name => System.Text.Encoding.UTF8.GetString(U8Name); - public override ReadOnlySpan U8Name => _name; + public override ReadOnlySpan Name => _name; public override DefType OwningType => _type; public override TypeDesc FieldType => _fieldType; diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemMethod.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemMethod.cs index cae606c67bc44a..7812746900155c 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemMethod.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemMethod.cs @@ -37,9 +37,7 @@ public TypeRefTypeSystemMethod(TypeRefTypeSystemType type, ReadOnlySpan na } } - public override string Name => System.Text.Encoding.UTF8.GetString(U8Name); - - public override ReadOnlySpan U8Name => _name; + public override ReadOnlySpan Name => _name; public override Instantiation Instantiation => _instantiation; From 1281547e0c43899c75aab5f2940b10fc19a37125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Sun, 7 Sep 2025 23:17:18 +0200 Subject: [PATCH 14/19] Delete DefType.Name --- .../Compiler/Dataflow/TypeExtensions.cs | 2 +- .../Common/Compiler/InstructionSetSupport.cs | 6 +-- .../Compiler/Int128FieldLayoutAlgorithm.cs | 4 +- .../Common/Compiler/ProcessLinkerXmlBase.cs | 2 +- .../Compiler/VectorFieldLayoutAlgorithm.cs | 18 +++---- .../Internal/Runtime/EETypeBuilderHelpers.cs | 8 ++-- .../tools/Common/JitInterface/CorInfoImpl.cs | 8 ++-- .../Common/TypeSystem/Canon/CanonTypes.cs | 44 +++-------------- .../Common/CastingHelper.TypeEquivalence.cs | 4 +- .../tools/Common/TypeSystem/Common/DefType.cs | 12 ++--- .../TypeSystem/Common/InstantiatedType.cs | 20 +------- .../Common/TypeSystem/Common/MetadataType.cs | 5 +- .../Common/MetadataTypeSystemContext.cs | 4 +- .../TypeSystem/Common/TypeSystemHelpers.cs | 15 ++++++ .../Common/TypeWithRepeatedFields.cs | 8 +--- .../Ecma/CustomAttributeTypeProvider.cs | 4 +- .../Ecma/EcmaType.TypeEquivalence.cs | 2 +- .../tools/Common/TypeSystem/Ecma/EcmaType.cs | 48 ++----------------- .../TypeSystem/IL/NativeAotILProvider.cs | 22 ++++----- .../Stubs/DelegateMarshallingMethodThunk.cs | 2 +- .../IL/Stubs/ForwardDelegateCreationThunk.cs | 2 +- .../IL/Stubs/InterlockedIntrinsics.cs | 2 +- .../IL/Stubs/RuntimeHelpersIntrinsics.cs | 6 +-- .../TypeSystem/IL/Stubs/StreamIntrinsics.cs | 2 +- .../IL/Stubs/StructMarshallingThunk.cs | 2 +- .../TypeSystem/IL/Stubs/UnsafeIntrinsics.cs | 2 +- .../TypeSystem/Interop/IL/InlineArrayType.cs | 26 ++-------- .../TypeSystem/Interop/IL/MarshalHelpers.cs | 4 +- .../TypeSystem/Interop/IL/NativeStructType.cs | 24 ++-------- .../Interop/IL/PInvokeDelegateWrapper.cs | 24 ++-------- .../Common/TypeSystem/Interop/InteropTypes.cs | 4 +- .../Interop/UnmanagedCallingConventions.cs | 2 +- .../TypeSystemMetadataEmitter.cs | 2 +- .../RuntimeDeterminedType.cs | 22 ++------- .../tools/ILVerification/ILImporter.Verify.cs | 2 +- .../SwiftLoweringTests.cs | 2 +- .../Compiler/Compilation.cs | 8 ++-- .../CompilerTypeSystemContext.BoxedTypes.cs | 9 ++-- ...ilerTypeSystemContext.GeneratedAssembly.cs | 22 ++------- ...pilerTypeSystemContext.ValueTypeMethods.cs | 2 +- .../Compiler/Dataflow/FlowAnnotations.cs | 6 +-- .../Compiler/Dataflow/HandleCallAction.cs | 2 +- .../CodeBasedDependencyAlgorithm.cs | 6 +-- .../InlineableStringsResourceNode.cs | 2 +- .../Compiler/DescriptorMarker.cs | 2 +- .../Logging/DocumentationSignatureParser.cs | 4 +- .../Compiler/SubstitutedILProvider.cs | 6 +-- .../Compiler/SubstitutionProvider.cs | 2 +- .../Compiler/TypeMapManager.cs | 8 ++-- .../Compiler/TypePreinit.cs | 18 +++---- .../Compiler/UsageBasedInteropStubManager.cs | 2 +- .../Compiler/VectorOfTFieldLayoutAlgorithm.cs | 2 +- .../IL/ILImporter.Scanner.cs | 12 ++--- .../IL/TypeEqualityPatternAnalyzer.cs | 2 +- .../Metadata/Transform.CustomAttribute.cs | 2 +- .../Compiler/ReadyToRunCompilerContext.cs | 2 +- .../Compiler/ReadyToRunXmlRootProvider.cs | 2 +- .../IBC/MIbcProfileParser.cs | 4 +- .../IL/ReadyToRunILProvider.cs | 12 ++--- .../TestCasesRunner/AssemblyChecker.cs | 2 +- .../MemberAssertionsCollector.cs | 2 +- .../SyntheticVirtualOverrideTests.cs | 8 ++-- .../TypeEquivalenceTests.cs | 2 +- src/coreclr/tools/aot/ILCompiler/Program.cs | 2 +- .../TraceRuntimeDescToTypeSystemDesc.cs | 2 +- .../TypeRefTypeSystemType.cs | 12 ++--- 66 files changed, 182 insertions(+), 351 deletions(-) diff --git a/src/coreclr/tools/Common/Compiler/Dataflow/TypeExtensions.cs b/src/coreclr/tools/Common/Compiler/Dataflow/TypeExtensions.cs index 1fc95c63517752..a4f66b891f7c4d 100644 --- a/src/coreclr/tools/Common/Compiler/Dataflow/TypeExtensions.cs +++ b/src/coreclr/tools/Common/Compiler/Dataflow/TypeExtensions.cs @@ -16,7 +16,7 @@ internal static class TypeExtensions { public static bool IsTypeOf(this TypeDesc type, string ns, string name) { - return type is MetadataType mdType && mdType.U8Name.StringEquals(name) && mdType.U8Namespace.StringEquals(ns); + return type is MetadataType mdType && mdType.Name.StringEquals(name) && mdType.Namespace.StringEquals(ns); } public static bool IsTypeOf(this TypeDesc type, string fullTypeName) diff --git a/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs b/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs index d844e83a021795..db31a5880f8a12 100644 --- a/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs +++ b/src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs @@ -61,7 +61,7 @@ public static string GetHardwareIntrinsicId(TargetArchitecture architecture, Typ return ""; // 64-bit ISA variants are not included in the mapping dictionary, so we use the containing type instead - if (potentialType.U8Name.SequenceEqual("X64"u8) || potentialType.U8Name.SequenceEqual("Arm64"u8)) + if (potentialType.Name.SequenceEqual("X64"u8) || potentialType.Name.SequenceEqual("Arm64"u8)) { if (architecture is TargetArchitecture.X64 or TargetArchitecture.ARM64) potentialType = (MetadataType)potentialType.ContainingType; @@ -79,12 +79,12 @@ public static string GetHardwareIntrinsicId(TargetArchitecture architecture, Typ if (architecture is TargetArchitecture.X64 or TargetArchitecture.X86) { - if (!potentialType.U8Namespace.SequenceEqual("System.Runtime.Intrinsics.X86"u8)) + if (!potentialType.Namespace.SequenceEqual("System.Runtime.Intrinsics.X86"u8)) return ""; } else if (architecture is TargetArchitecture.ARM64 or TargetArchitecture.ARM) { - if (!potentialType.U8Namespace.SequenceEqual("System.Runtime.Intrinsics.Arm"u8)) + if (!potentialType.Namespace.SequenceEqual("System.Runtime.Intrinsics.Arm"u8)) return ""; } else if (architecture is TargetArchitecture.LoongArch64) diff --git a/src/coreclr/tools/Common/Compiler/Int128FieldLayoutAlgorithm.cs b/src/coreclr/tools/Common/Compiler/Int128FieldLayoutAlgorithm.cs index 63fc8522d8cb7f..97153023558b76 100644 --- a/src/coreclr/tools/Common/Compiler/Int128FieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/Common/Compiler/Int128FieldLayoutAlgorithm.cs @@ -84,8 +84,8 @@ public override ValueTypeShapeCharacteristics ComputeValueTypeShapeCharacteristi public static bool IsIntegerType(DefType type) { return type.IsIntrinsic - && type.U8Namespace.SequenceEqual("System"u8) - && (type.U8Name.SequenceEqual("Int128"u8) || type.U8Name.SequenceEqual("UInt128"u8)); + && type.Namespace.SequenceEqual("System"u8) + && (type.Name.SequenceEqual("Int128"u8) || type.Name.SequenceEqual("UInt128"u8)); } } } diff --git a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs index c39db4b79a3c40..f28632acf8db4b 100644 --- a/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs +++ b/src/coreclr/tools/Common/Compiler/ProcessLinkerXmlBase.cs @@ -642,7 +642,7 @@ protected override void AppendNameForInstantiatedType(StringBuilder sb, DefType } protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type) { - if (!type.U8Namespace.IsEmpty) + if (!type.Namespace.IsEmpty) { sb.Append(type.GetNamespace()); sb.Append('.'); diff --git a/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs b/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs index 0ba5fa2cb29993..d375651f64cdc0 100644 --- a/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs @@ -29,11 +29,11 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp LayoutInt alignment; - if (defType.U8Name.SequenceEqual("Vector64`1"u8)) + if (defType.Name.SequenceEqual("Vector64`1"u8)) { alignment = new LayoutInt(8); } - else if (defType.U8Name.SequenceEqual("Vector128`1"u8)) + else if (defType.Name.SequenceEqual("Vector128`1"u8)) { if (defType.Context.Target.Architecture == TargetArchitecture.ARM) { @@ -45,7 +45,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp alignment = new LayoutInt(16); } } - else if (defType.U8Name.SequenceEqual("Vector256`1"u8)) + else if (defType.Name.SequenceEqual("Vector256`1"u8)) { if (defType.Context.Target.Architecture == TargetArchitecture.ARM) { @@ -78,7 +78,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp } else { - Debug.Assert(defType.U8Name.SequenceEqual("Vector512`1"u8)); + Debug.Assert(defType.Name.SequenceEqual("Vector512`1"u8)); if (defType.Context.Target.Architecture == TargetArchitecture.ARM) { @@ -166,11 +166,11 @@ public override ValueTypeShapeCharacteristics ComputeValueTypeShapeCharacteristi public static bool IsVectorType(DefType type) { return type.IsIntrinsic && - type.U8Namespace.SequenceEqual("System.Runtime.Intrinsics"u8) && - (type.U8Name.SequenceEqual("Vector64`1"u8) || - type.U8Name.SequenceEqual("Vector128`1"u8) || - type.U8Name.SequenceEqual("Vector256`1"u8) || - type.U8Name.SequenceEqual("Vector512`1"u8)); + type.Namespace.SequenceEqual("System.Runtime.Intrinsics"u8) && + (type.Name.SequenceEqual("Vector64`1"u8) || + type.Name.SequenceEqual("Vector128`1"u8) || + type.Name.SequenceEqual("Vector256`1"u8) || + type.Name.SequenceEqual("Vector512`1"u8)); } } } diff --git a/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs b/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs index 641526c3e28687..1454df291cc4ae 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/EETypeBuilderHelpers.cs @@ -187,8 +187,8 @@ public static ushort ComputeFlagsEx(TypeDesc type) if (type is MetadataType mdType && mdType.Module == mdType.Context.SystemModule && - (mdType.U8Name.SequenceEqual("WeakReference"u8) || mdType.U8Name.SequenceEqual("WeakReference`1"u8)) && - mdType.U8Namespace.SequenceEqual("System"u8)) + (mdType.Name.SequenceEqual("WeakReference"u8) || mdType.Name.SequenceEqual("WeakReference`1"u8)) && + mdType.Namespace.SequenceEqual("System"u8)) { flagsEx |= (ushort)EETypeFlagsEx.HasEagerFinalizerFlag; } @@ -273,8 +273,8 @@ private static bool HasCriticalFinalizer(TypeDesc type) if (type is MetadataType mdType && mdType.Module == mdType.Context.SystemModule && - mdType.U8Name.SequenceEqual("CriticalFinalizerObject"u8) && - mdType.U8Namespace.SequenceEqual("System.Runtime.ConstrainedExecution"u8)) + mdType.Name.SequenceEqual("CriticalFinalizerObject"u8) && + mdType.Namespace.SequenceEqual("System.Runtime.ConstrainedExecution"u8)) return true; type = type.BaseType; diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 758e60704cc17b..bc082216c91fe9 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -2021,8 +2021,8 @@ private CorInfoType asCorInfoType(CORINFO_CLASS_STRUCT_* cls) else if (type is MetadataType mdType) { if (namespaceName != null) - *namespaceName = (byte*)GetPin(SpanToPinnableBytes(mdType.U8Namespace)); - return (byte*)GetPin(SpanToPinnableBytes(mdType.U8Name)); + *namespaceName = (byte*)GetPin(SpanToPinnableBytes(mdType.Namespace)); + return (byte*)GetPin(SpanToPinnableBytes(mdType.Name)); } if (namespaceName != null) @@ -2503,7 +2503,7 @@ private GetTypeLayoutResult GetTypeLayoutHelper(MetadataType type, uint parentIn // not care about since they are considered primitives by the JIT. if (type.IsIntrinsic) { - ReadOnlySpan ns = type.U8Namespace; + ReadOnlySpan ns = type.Namespace; if (ns.SequenceEqual("System.Runtime.Intrinsics"u8) || ns.SequenceEqual("System.Numerics"u8)) { parNode->simdTypeHnd = ObjectToHandle(type); @@ -3174,7 +3174,7 @@ private static CORINFO_FIELD_ACCESSOR getFieldIntrinsic(FieldDesc field) { return CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INTRINSIC_EMPTY_STRING; } - else if (owningType.U8Name.SequenceEqual("BitConverter"u8) && owningType.U8Namespace.SequenceEqual("System"u8) && + else if (owningType.Name.SequenceEqual("BitConverter"u8) && owningType.Namespace.SequenceEqual("System"u8) && field.Name.SequenceEqual("IsLittleEndian"u8)) { return CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN; diff --git a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs index 01fc7abdc5de1d..722978648f68b0 100644 --- a/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs +++ b/src/coreclr/tools/Common/TypeSystem/Canon/CanonTypes.cs @@ -61,15 +61,7 @@ internal sealed partial class CanonType : CanonBaseType { private int _hashcode; - public override string Namespace - { - get - { - return "System"; - } - } - - public override ReadOnlySpan U8Namespace + public override ReadOnlySpan Namespace { get { @@ -77,15 +69,7 @@ public override ReadOnlySpan U8Namespace } } - public override string Name - { - get - { - return "__Canon"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -147,7 +131,7 @@ public override int GetHashCode() { if (_hashcode == 0) { - _hashcode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); + _hashcode = VersionResilientHashCode.NameHashCode(Namespace, Name); } return _hashcode; @@ -161,15 +145,7 @@ internal sealed partial class UniversalCanonType : CanonBaseType { private int _hashcode; - public override string Namespace - { - get - { - return "System"; - } - } - - public override ReadOnlySpan U8Namespace + public override ReadOnlySpan Namespace { get { @@ -177,15 +153,7 @@ public override ReadOnlySpan U8Namespace } } - public override string Name - { - get - { - return "__UniversalCanon"; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -245,7 +213,7 @@ public override int GetHashCode() { if (_hashcode == 0) { - _hashcode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); + _hashcode = VersionResilientHashCode.NameHashCode(Namespace, Name); } return _hashcode; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs b/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs index 62baa9d49b4865..bfc730f96f2b85 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.TypeEquivalence.cs @@ -128,10 +128,10 @@ static bool IsEquivalentTo_TypeDefinition(MetadataType type1, MetadataType type2 if (!data1.Equals(data2)) return false; - if (!type1.U8Name.SequenceEqual(type2.U8Name)) + if (!type1.Name.SequenceEqual(type2.Name)) return false; - if (!type1.U8Namespace.SequenceEqual(type2.U8Namespace)) + if (!type1.Namespace.SequenceEqual(type2.Namespace)) return false; var containingType1 = (MetadataType)type1.ContainingType; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs b/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs index bb27d3293b9f30..71032d5409cab8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/DefType.cs @@ -16,11 +16,9 @@ public abstract partial class DefType : TypeDesc /// /// Gets the namespace of the type. /// - public virtual string Namespace => null; + public virtual ReadOnlySpan Namespace => []; - public virtual ReadOnlySpan U8Namespace => []; - - public string GetNamespace() => System.Text.Encoding.UTF8.GetString(U8Namespace + public string GetNamespace() => System.Text.Encoding.UTF8.GetString(Namespace #if NETSTANDARD .ToArray() #endif @@ -29,11 +27,9 @@ public string GetNamespace() => System.Text.Encoding.UTF8.GetString(U8Namespace /// /// Gets the name of the type as represented in the metadata. /// - public virtual string Name => null; - - public virtual ReadOnlySpan U8Name => []; + public virtual ReadOnlySpan Name => []; - public string GetName() => System.Text.Encoding.UTF8.GetString(U8Name + public string GetName() => System.Text.Encoding.UTF8.GetString(Name #if NETSTANDARD .ToArray() #endif diff --git a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs index f8e163368d1a34..c5ad763b438f07 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/InstantiatedType.cs @@ -127,7 +127,7 @@ protected override TypeFlags ComputeTypeFlags(TypeFlags mask) return flags; } - public override string Name + public override ReadOnlySpan Name { get { @@ -135,15 +135,7 @@ public override string Name } } - public override ReadOnlySpan U8Name - { - get - { - return _typeDef.U8Name; - } - } - - public override string Namespace + public override ReadOnlySpan Namespace { get { @@ -151,14 +143,6 @@ public override string Namespace } } - public override ReadOnlySpan U8Namespace - { - get - { - return _typeDef.U8Namespace; - } - } - public override IEnumerable GetMethods() { foreach (var typicalMethodDef in _typeDef.GetMethods()) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.cs index 18d3ee8f754d59..d8ce9f38d0eba8 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataType.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using System.Diagnostics; @@ -12,9 +13,9 @@ namespace Internal.TypeSystem /// public abstract partial class MetadataType : DefType { - public abstract override string Name { get; } + public abstract override ReadOnlySpan Name { get; } - public abstract override string Namespace { get; } + public abstract override ReadOnlySpan Namespace { get; } /// /// Gets metadata that controls instance layout of this type. diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs b/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs index 72f2ab0aa5397f..bc6cff8b7a4f6c 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MetadataTypeSystemContext.cs @@ -106,8 +106,8 @@ protected internal sealed override bool IsIDynamicInterfaceCastableInterface(Def { MetadataType t = (MetadataType)type; return t.Module == SystemModule - && t.U8Name.SequenceEqual("IDynamicInterfaceCastable"u8) - && t.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8); + && t.Name.SequenceEqual("IDynamicInterfaceCastable"u8) + && t.Namespace.SequenceEqual("System.Runtime.InteropServices"u8); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs index 9e1818e5714bf8..c00fdd4d9c19d5 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeSystemHelpers.cs @@ -464,5 +464,20 @@ public static ReadOnlySpan Append(this ReadOnlySpan s1, ReadOnlySpan return buffer; } + + public static ReadOnlySpan Append(this ReadOnlySpan s1, ReadOnlySpan s2, ReadOnlySpan s3, uint i) + { + Span s4 = stackalloc byte[16]; + System.Buffers.Text.Utf8Formatter.TryFormat(i, s4, out int s4length); + + Span buffer = new byte[s1.Length + s2.Length + s3.Length + s4length]; + + s1.CopyTo(buffer); + s2.CopyTo(buffer.Slice(s1.Length)); + s3.CopyTo(buffer.Slice(s1.Length + s2.Length)); + s4.Slice(0, s4length).CopyTo(buffer.Slice(s1.Length + s2.Length + s3.Length)); + + return buffer; + } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs b/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs index 6377088d211394..a345eccae67c98 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TypeWithRepeatedFields.cs @@ -92,13 +92,9 @@ public override IEnumerable GetFields() protected override TypeFlags ComputeTypeFlags(TypeFlags mask) => MetadataType.GetTypeFlags(mask); - public override string Namespace => MetadataType.Namespace; + public override ReadOnlySpan Namespace => MetadataType.Namespace; - public override ReadOnlySpan U8Namespace => MetadataType.U8Namespace; - - public override string Name => MetadataType.Name; - - public override ReadOnlySpan U8Name => MetadataType.U8Name; + public override ReadOnlySpan Name => MetadataType.Name; public override DefType[] ExplicitlyImplementedInterfaces => Array.Empty(); diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs index d7f4d9ad6a6967..45a7a6944484be 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/CustomAttributeTypeProvider.cs @@ -88,9 +88,9 @@ public bool IsSystemType(TypeDesc type) { var metadataType = type as MetadataType; return metadataType != null - && metadataType.U8Name.SequenceEqual("Type"u8) + && metadataType.Name.SequenceEqual("Type"u8) && metadataType.Module == _module.Context.SystemModule - && metadataType.U8Namespace.SequenceEqual("System"u8); + && metadataType.Namespace.SequenceEqual("System"u8); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.TypeEquivalence.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.TypeEquivalence.cs index 30da82af59367f..9a222bd8180456 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.TypeEquivalence.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.TypeEquivalence.cs @@ -43,7 +43,7 @@ private TypeIdentifierData ComputeTypeIdentifierFromGuids() string scope = (string)guidAttribute.Value.FixedArguments[0].Value; string name = this.GetName(); - if (this.U8Namespace.Length > 0) + if (this.Namespace.Length > 0) name = this.GetNamespace() + "." + name; return new TypeIdentifierData(scope, name); diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs index ecac3c0c069467..026563ca7c69d6 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs @@ -24,8 +24,6 @@ public sealed partial class EcmaType : MetadataType, EcmaModule.IEntityHandleObj private TypeDefinition _typeDefinition; // Cached values - private string _typeName; - private string _typeNamespace; private TypeDesc[] _genericParameters; private MetadataType _baseType; private int _hashcode; @@ -38,12 +36,6 @@ internal EcmaType(EcmaModule module, TypeDefinitionHandle handle) _typeDefinition = module.MetadataReader.GetTypeDefinition(handle); _baseType = this; // Not yet initialized flag - -#if DEBUG - // Initialize name eagerly in debug builds for convenience - InitializeName(); - InitializeNamespace(); -#endif } public override int GetHashCode() @@ -55,7 +47,7 @@ public override int GetHashCode() private int InitializeHashCode() { - int hashCode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); + int hashCode = VersionResilientHashCode.NameHashCode(Namespace, Name); DefType containingType = ContainingType; if (containingType != null) @@ -267,24 +259,7 @@ protected override TypeFlags ComputeTypeFlags(TypeFlags mask) return flags; } - private string InitializeName() - { - var metadataReader = this.MetadataReader; - _typeName = metadataReader.GetString(_typeDefinition.Name); - return _typeName; - } - - public override string Name - { - get - { - if (_typeName == null) - return InitializeName(); - return _typeName; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -292,24 +267,7 @@ public override ReadOnlySpan U8Name } } - private string InitializeNamespace() - { - var metadataReader = this.MetadataReader; - _typeNamespace = metadataReader.GetString(_typeDefinition.Namespace); - return _typeNamespace; - } - - public override string Namespace - { - get - { - if (_typeNamespace == null) - return InitializeNamespace(); - return _typeNamespace; - } - } - - public override ReadOnlySpan U8Namespace + public override ReadOnlySpan Namespace { get { diff --git a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs index 5b0406e0ec6530..373b2abd826af7 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs @@ -48,25 +48,25 @@ private static MethodIL TryGetIntrinsicMethodIL(MethodDesc method) { case "Unsafe": { - if (owningType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) + if (owningType.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) return UnsafeIntrinsics.EmitIL(method); } break; case "Debug": { - if (owningType.U8Namespace.SequenceEqual("System.Diagnostics"u8) && method.Name.SequenceEqual("DebugBreak"u8)) + if (owningType.Namespace.SequenceEqual("System.Diagnostics"u8) && method.Name.SequenceEqual("DebugBreak"u8)) return new ILStubMethodIL(method, new byte[] { (byte)ILOpcode.break_, (byte)ILOpcode.ret }, Array.Empty(), null); } break; case "RuntimeAugments": { - if (owningType.U8Namespace.SequenceEqual("Internal.Runtime.Augments"u8) && method.Name.SequenceEqual("GetCanonType"u8)) + if (owningType.Namespace.SequenceEqual("Internal.Runtime.Augments"u8) && method.Name.SequenceEqual("GetCanonType"u8)) return GetCanonTypeIntrinsic.EmitIL(method); } break; case "MethodTable": { - if (owningType.U8Namespace.SequenceEqual("Internal.Runtime"u8) && method.Name.SequenceEqual("get_SupportsRelativePointers"u8)) + if (owningType.Namespace.SequenceEqual("Internal.Runtime"u8) && method.Name.SequenceEqual("get_SupportsRelativePointers"u8)) { ILOpcode value = method.Context.Target.SupportsRelativePointers ? ILOpcode.ldc_i4_1 : ILOpcode.ldc_i4_0; @@ -76,7 +76,7 @@ private static MethodIL TryGetIntrinsicMethodIL(MethodDesc method) break; case "Stream": { - if (owningType.U8Namespace.SequenceEqual("System.IO"u8)) + if (owningType.Namespace.SequenceEqual("System.IO"u8)) return StreamIntrinsics.EmitIL(method); } break; @@ -104,7 +104,7 @@ private static MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc metho { case "Interlocked": { - if (owningType.U8Namespace.SequenceEqual("System.Threading"u8)) + if (owningType.Namespace.SequenceEqual("System.Threading"u8)) return InterlockedIntrinsics.EmitIL(method); } break; @@ -132,25 +132,25 @@ private static MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc metho break; case "RuntimeHelpers": { - if (owningType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) + if (owningType.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) return RuntimeHelpersIntrinsics.EmitIL(method); } break; case "Comparer`1": { - if (methodName == "Create" && owningType.U8Namespace.SequenceEqual("System.Collections.Generic"u8)) + if (methodName == "Create" && owningType.Namespace.SequenceEqual("System.Collections.Generic"u8)) return ComparerIntrinsics.EmitComparerCreate(method); } break; case "EqualityComparer`1": { - if (methodName == "Create" && owningType.U8Namespace.SequenceEqual("System.Collections.Generic"u8)) + if (methodName == "Create" && owningType.Namespace.SequenceEqual("System.Collections.Generic"u8)) return ComparerIntrinsics.EmitEqualityComparerCreate(method); } break; case "ComparerHelpers": { - if (!owningType.U8Namespace.SequenceEqual("Internal.IntrinsicSupport"u8)) + if (!owningType.Namespace.SequenceEqual("Internal.IntrinsicSupport"u8)) return null; if (methodName == "EnumOnlyCompare") @@ -184,7 +184,7 @@ private static MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc metho break; case "EqualityComparerHelpers": { - if (!owningType.U8Namespace.SequenceEqual("Internal.IntrinsicSupport"u8)) + if (!owningType.Namespace.SequenceEqual("Internal.IntrinsicSupport"u8)) return null; if (methodName == "EnumOnlyEquals") diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs index edb10a8d94ee1b..7293a92143f14f 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs @@ -260,7 +260,7 @@ public override ReadOnlySpan Name { get { - return U8NamePrefix.Append("__"u8, DelegateType.U8Name); + return U8NamePrefix.Append("__"u8, DelegateType.Name); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs index cfc557988a5c57..9d4ef6cbb517bb 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ForwardDelegateCreationThunk.cs @@ -66,7 +66,7 @@ public override ReadOnlySpan Name { get { - return "ForwardDelegateCreationStub__"u8.Append(DelegateType.U8Name); + return "ForwardDelegateCreationStub__"u8.Append(DelegateType.Name); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs index 043a2989b1a55f..30f5fca3d9521c 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/InterlockedIntrinsics.cs @@ -20,7 +20,7 @@ public static MethodIL EmitIL( #endif // READYTORUN MethodDesc method) { - Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("Interlocked"u8)); + Debug.Assert(((MetadataType)method.OwningType).Name.SequenceEqual("Interlocked"u8)); Debug.Assert(!method.IsGenericMethodDefinition); if (method.HasInstantiation && method.Name.SequenceEqual("CompareExchange"u8)) diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index 3f8e77bc9575b4..ae97ccd4c597d8 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -16,7 +16,7 @@ public static class RuntimeHelpersIntrinsics { public static MethodIL EmitIL(MethodDesc method) { - Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("RuntimeHelpers"u8)); + Debug.Assert(((MetadataType)method.OwningType).Name.SequenceEqual("RuntimeHelpers"u8)); // All the methods handled below are per-instantiation generic methods if (method.Instantiation.Length != 1 || method.IsTypicalMethodDefinition) @@ -57,8 +57,8 @@ public static MethodIL EmitIL(MethodDesc method) if (elementType is MetadataType mdType) { if (mdType.Module == mdType.Context.SystemModule && - mdType.U8Namespace.SequenceEqual("System.Text"u8) && - mdType.U8Name.SequenceEqual("Rune"u8)) + mdType.Namespace.SequenceEqual("System.Text"u8) && + mdType.Name.SequenceEqual("Rune"u8)) { result = true; } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs index f0fe60ad728dc0..f678bfe9bd74e5 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StreamIntrinsics.cs @@ -16,7 +16,7 @@ public static class StreamIntrinsics { public static MethodIL EmitIL(MethodDesc method) { - Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("Stream"u8)); + Debug.Assert(((MetadataType)method.OwningType).Name.SequenceEqual("Stream"u8)); bool isRead = method.Name.SequenceEqual("HasOverriddenBeginEndRead"u8); if (!isRead && !method.Name.SequenceEqual("HasOverriddenBeginEndWrite"u8)) diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs index d5e34a303baff6..314bc803ed10ca 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs @@ -144,7 +144,7 @@ public override ReadOnlySpan Name { get { - return U8NamePrefix.Append("__"u8, ManagedType.U8Name); + return U8NamePrefix.Append("__"u8, ManagedType.Name); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs index 142ddc2e961043..65b26afcf46f57 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs @@ -16,7 +16,7 @@ public static class UnsafeIntrinsics { public static MethodIL EmitIL(MethodDesc method) { - Debug.Assert(((MetadataType)method.OwningType).U8Name.SequenceEqual("Unsafe"u8)); + Debug.Assert(((MetadataType)method.OwningType).Name.SequenceEqual("Unsafe"u8)); switch (method.GetName()) { diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs index e37f5a886b6087..dfe4f1a029e22d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/InlineArrayType.cs @@ -27,19 +27,11 @@ public override ModuleDesc Module get; } - public override string Name + public override ReadOnlySpan Name { get { - return "_InlineArray__" + ElementType.Name + "__"+ Length; - } - } - - public override ReadOnlySpan U8Name - { - get - { - return System.Text.Encoding.UTF8.GetBytes(Name); + return "_InlineArray__"u8.Append(ElementType.Name, "__"u8, Length); } } @@ -51,15 +43,7 @@ public override string DiagnosticName } } - public override string Namespace - { - get - { - return "Internal.CompilerGenerated"; - } - } - - public override ReadOnlySpan U8Namespace + public override ReadOnlySpan Namespace { get { @@ -71,7 +55,7 @@ public override string DiagnosticNamespace { get { - return Namespace; + return "Internal.CompilerGenerated"; } } @@ -224,7 +208,7 @@ public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlyS private int InitializeHashCode() { - return _hashCode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); + return _hashCode = VersionResilientHashCode.NameHashCode(Namespace, Name); } public override int GetHashCode() diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs index 4759e0e2a8a12f..3dbd4aaadc9ed4 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs @@ -202,8 +202,8 @@ private static bool HasCopyConstructorCustomModifier(int? parameterIndex, if (customModifierType == null) continue; - if ((customModifierType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) && customModifierType.U8Name.SequenceEqual("IsCopyConstructed"u8)) || - (customModifierType.U8Namespace.SequenceEqual("Microsoft.VisualC"u8) && customModifierType.U8Name.SequenceEqual("NeedsCopyConstructorModifier"u8))) + if ((customModifierType.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) && customModifierType.Name.SequenceEqual("IsCopyConstructed"u8)) || + (customModifierType.Namespace.SequenceEqual("Microsoft.VisualC"u8) && customModifierType.Name.SequenceEqual("NeedsCopyConstructorModifier"u8))) { return true; } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs index 9e0ac3c0b9e52f..a8d80d4b6c81ce 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/NativeStructType.cs @@ -21,19 +21,11 @@ public override ModuleDesc Module get; } - public override string Name + public override ReadOnlySpan Name { get { - return "__NativeType__" + ManagedStructType.Name; - } - } - - public override ReadOnlySpan U8Name - { - get - { - return "__NativeType__"u8.Append(ManagedStructType.U8Name); + return "__NativeType__"u8.Append(ManagedStructType.Name); } } @@ -45,15 +37,7 @@ public override string DiagnosticName } } - public override string Namespace - { - get - { - return "Internal.CompilerGenerated"; - } - } - - public override ReadOnlySpan U8Namespace + public override ReadOnlySpan Namespace { get { @@ -297,7 +281,7 @@ public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlyS private int InitializeHashCode() { - return _hashCode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); + return _hashCode = VersionResilientHashCode.NameHashCode(Namespace, Name); } public override int GetHashCode() diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs index 9533591d4384ac..67c1d0df27035d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.cs @@ -26,19 +26,11 @@ public override ModuleDesc Module get; } - public override string Name + public override ReadOnlySpan Name { get { - return "PInvokeDelegateWrapper__" + DelegateType.Name; - } - } - - public override ReadOnlySpan U8Name - { - get - { - return "PInvokeDelegateWrapper__"u8.Append(DelegateType.U8Name); + return "PInvokeDelegateWrapper__"u8.Append(DelegateType.Name); } } @@ -50,15 +42,7 @@ public override string DiagnosticName } } - public override string Namespace - { - get - { - return "Internal.CompilerGenerated"; - } - } - - public override ReadOnlySpan U8Namespace + public override ReadOnlySpan Namespace { get { @@ -207,7 +191,7 @@ public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlyS private int InitializeHashCode() { - return _hashCode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); + return _hashCode = VersionResilientHashCode.NameHashCode(Namespace, Name); } public override int GetHashCode() diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs b/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs index e86da4893531e3..09822e13f8b4de 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs @@ -82,8 +82,8 @@ public static bool IsCriticalHandle(TypeSystemContext context, TypeDesc type) private static bool IsCoreNamedType(TypeSystemContext context, TypeDesc type, ReadOnlySpan @namespace, ReadOnlySpan name) { return type is MetadataType mdType && - mdType.U8Name.SequenceEqual(name) && - mdType.U8Namespace.SequenceEqual(@namespace) && + mdType.Name.SequenceEqual(name) && + mdType.Namespace.SequenceEqual(@namespace) && mdType.Module == context.SystemModule; } diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs b/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs index 59183d02b98803..36cdc01805540b 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/UnmanagedCallingConventions.cs @@ -189,7 +189,7 @@ private static UnmanagedCallingConventions GetUnmanagedCallingConventionFromAttr private static UnmanagedCallingConventions AccumulateCallingConventions(UnmanagedCallingConventions existing, MetadataType newConvention) { - if (!newConvention.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) + if (!newConvention.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) return existing; UnmanagedCallingConventions? addedCallConv = newConvention.GetName() switch diff --git a/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs b/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs index 037525f3c3bc52..23ad91a45d9d0a 100644 --- a/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs +++ b/src/coreclr/tools/Common/TypeSystem/MetadataEmitter/TypeSystemMetadataEmitter.cs @@ -214,7 +214,7 @@ public EntityHandle GetTypeRef(TypeDesc type) { // Make a typeref StringHandle typeName = _metadataBuilder.GetOrAddString(metadataType.GetName()); - StringHandle typeNamespace = metadataType.U8Namespace.Length > 0 ? _metadataBuilder.GetOrAddString(metadataType.GetNamespace()) : default(StringHandle); + StringHandle typeNamespace = metadataType.Namespace.Length > 0 ? _metadataBuilder.GetOrAddString(metadataType.GetNamespace()) : default(StringHandle); EntityHandle resolutionScope; if (metadataType.ContainingType == null) diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs index 436eddebbda37c..c80a99c0ca9780 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs @@ -90,7 +90,7 @@ public override Instantiation Instantiation } } - public override string Name + public override ReadOnlySpan Name { get { @@ -98,27 +98,11 @@ public override string Name } } - public override ReadOnlySpan U8Name + public override ReadOnlySpan Namespace { get { - return _rawCanonType.U8Name; - } - } - - public override string Namespace - { - get - { - return string.Concat(_runtimeDeterminedDetailsType.Name, "_", _rawCanonType.Namespace); - } - } - - public override ReadOnlySpan U8Namespace - { - get - { - return _runtimeDeterminedDetailsType.U8Name.Append("_"u8, _rawCanonType.U8Namespace); + return _runtimeDeterminedDetailsType.U8Name.Append("_"u8, _rawCanonType.Namespace); } } diff --git a/src/coreclr/tools/ILVerification/ILImporter.Verify.cs b/src/coreclr/tools/ILVerification/ILImporter.Verify.cs index b0f59a1d46e83b..430c7e083b8ece 100644 --- a/src/coreclr/tools/ILVerification/ILImporter.Verify.cs +++ b/src/coreclr/tools/ILVerification/ILImporter.Verify.cs @@ -2730,7 +2730,7 @@ static bool HasIsExternalInit(MethodSignature signature) { foreach (var data in signature.GetEmbeddedSignatureData()) { - if (data.type is MetadataType mdType && mdType.Namespace == "System.Runtime.CompilerServices" && mdType.Name == "IsExternalInit" && + if (data.type is MetadataType mdType && mdType.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) && mdType.Name.SequenceEqual("IsExternalInit"u8) && data.index == MethodSignature.IndexOfCustomModifiersOnReturnType) return true; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/SwiftLoweringTests.cs b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/SwiftLoweringTests.cs index bcd93162c92c1b..4b1c830eaee392 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/SwiftLoweringTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler.Tests/SwiftLoweringTests.cs @@ -46,7 +46,7 @@ public static IEnumerable DiscoverSwiftTypes() foreach (var type in testModule.GetAllTypes()) { if (type is EcmaType { IsValueType: true } ecmaType - && ecmaType.U8Namespace.SequenceEqual("ILCompiler.Compiler.Tests.Assets.SwiftTypes"u8) + && ecmaType.Namespace.SequenceEqual("ILCompiler.Compiler.Tests.Assets.SwiftTypes"u8) && ecmaType.GetDecodedCustomAttribute("ILCompiler.Compiler.Tests.Assets.SwiftTypes", "ExpectedLoweringAttribute") is { } expectedLoweringAttribute) { // By default, we assume that our lowered representation is meant to be naturally aligned. diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs index da6b1676e39f93..b9896e38facc76 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs @@ -175,7 +175,7 @@ public MethodDesc ExpandIntrinsicForCallsite(MethodDesc intrinsicMethod, MethodD if (intrinsicOwningType.Module != TypeSystemContext.SystemModule) return intrinsicMethod; - if (intrinsicOwningType.U8Name.SequenceEqual("Type"u8) && intrinsicOwningType.U8Namespace.SequenceEqual("System"u8)) + if (intrinsicOwningType.Name.SequenceEqual("Type"u8) && intrinsicOwningType.Namespace.SequenceEqual("System"u8)) { if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.Name.SequenceEqual("GetType"u8)) { @@ -187,7 +187,7 @@ public MethodDesc ExpandIntrinsicForCallsite(MethodDesc intrinsicMethod, MethodD } } } - else if (intrinsicOwningType.U8Name.SequenceEqual("Assembly"u8) && intrinsicOwningType.U8Namespace.SequenceEqual("System.Reflection"u8)) + else if (intrinsicOwningType.Name.SequenceEqual("Assembly"u8) && intrinsicOwningType.Namespace.SequenceEqual("System.Reflection"u8)) { if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.Name.SequenceEqual("GetExecutingAssembly"u8)) { @@ -199,7 +199,7 @@ public MethodDesc ExpandIntrinsicForCallsite(MethodDesc intrinsicMethod, MethodD } } } - else if (intrinsicOwningType.U8Name.SequenceEqual("MethodBase"u8) && intrinsicOwningType.U8Namespace.SequenceEqual("System.Reflection"u8)) + else if (intrinsicOwningType.Name.SequenceEqual("MethodBase"u8) && intrinsicOwningType.Namespace.SequenceEqual("System.Reflection"u8)) { if (intrinsicMethod.Signature.IsStatic && intrinsicMethod.Name.SequenceEqual("GetCurrentMethod"u8)) { @@ -451,7 +451,7 @@ public bool IsFatPointerCandidate(MethodDesc containingMethod, MethodSignature s if (containingMethod.OwningType is MetadataType owningType) { // RawCalliHelper is a way for the class library to opt out of fat calls - if (owningType.U8Name.SequenceEqual("RawCalliHelper"u8)) + if (owningType.Name.SequenceEqual("RawCalliHelper"u8)) return false; // Delegate invocation never needs fat calls diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs index 9a2e9eeebb883c..9396411f96ca34 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs @@ -256,11 +256,8 @@ private sealed partial class BoxedValueType : MetadataType, INonEmittableType public override ModuleDesc Module { get; } - public override string Name => "Boxed_" + ValueTypeRepresented.Name; - public override ReadOnlySpan U8Name => "Boxed_"u8.Append(ValueTypeRepresented.U8Name); - - public override string Namespace => ValueTypeRepresented.Namespace; - public override ReadOnlySpan U8Namespace => ValueTypeRepresented.U8Namespace; + public override ReadOnlySpan Name => "Boxed_"u8.Append(ValueTypeRepresented.Name); + public override ReadOnlySpan Namespace => ValueTypeRepresented.Namespace; public override string DiagnosticName => "Boxed_" + ValueTypeRepresented.DiagnosticName; public override string DiagnosticNamespace => ValueTypeRepresented.DiagnosticNamespace; public override Instantiation Instantiation => ValueTypeRepresented.Instantiation; @@ -310,7 +307,7 @@ public BoxedValueType(ModuleDesc owningModule, MetadataType valuetype) protected override MethodImplRecord[] ComputeVirtualMethodImplsForType() => Array.Empty(); public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlySpan name) => Array.Empty(); - public override int GetHashCode() => VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); + public override int GetHashCode() => VersionResilientHashCode.NameHashCode(Namespace, Name); protected override TypeFlags ComputeTypeFlags(TypeFlags mask) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs index 588e9013e48b3e..fd5c1412eec621 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.GeneratedAssembly.cs @@ -88,15 +88,7 @@ public override TypeSystemContext Context } } - public override string Name - { - get - { - return ""; - } - } - - public override ReadOnlySpan U8Name + public override ReadOnlySpan Name { get { @@ -112,15 +104,7 @@ public override string DiagnosticName } } - public override string Namespace - { - get - { - return "Internal.CompilerGenerated"; - } - } - - public override ReadOnlySpan U8Namespace + public override ReadOnlySpan Namespace { get { @@ -145,7 +129,7 @@ public override int GetHashCode() private int InitializeHashCode() { - return _hashcode = VersionResilientHashCode.NameHashCode(U8Namespace, U8Name); + return _hashcode = VersionResilientHashCode.NameHashCode(Namespace, Name); } public override bool IsCanonicalSubtype(CanonicalFormKind policy) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs index ecf9c151b5b21b..280a85081829d2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.ValueTypeMethods.cs @@ -103,7 +103,7 @@ private bool RequiresValueTypeGetFieldHelperMethod(MetadataType valueType) return false; // ValueTuples override Equals/GetHashCode and don't have a `base.GetHashCode` call. So avoid the infrastructure. - if (valueType.Module == SystemModule && valueType.U8Name.StartsWith("ValueTuple`"u8) && valueType.U8Namespace.SequenceEqual("System"u8)) + if (valueType.Module == SystemModule && valueType.Name.StartsWith("ValueTuple`"u8) && valueType.Namespace.SequenceEqual("System"u8)) return false; return !_typeStateHashtable.GetOrCreateValue(valueType).CanCompareValueTypeBits; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs index 5bce7f7558dbd3..585b5a15f212eb 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs @@ -270,16 +270,16 @@ public static bool IsTypeInterestingForDataflow(TypeDesc type) foreach (var intf in type.RuntimeInterfaces) { - if (intf.U8Name.SequenceEqual("IReflect"u8) && intf.U8Namespace.SequenceEqual("System.Reflection"u8)) + if (intf.Name.SequenceEqual("IReflect"u8) && intf.Namespace.SequenceEqual("System.Reflection"u8)) return true; } - if (metadataType.U8Name.SequenceEqual("IReflect"u8) && metadataType.U8Namespace.SequenceEqual("System.Reflection"u8)) + if (metadataType.Name.SequenceEqual("IReflect"u8) && metadataType.Namespace.SequenceEqual("System.Reflection"u8)) return true; do { - if (metadataType.U8Name.SequenceEqual("Type"u8) && metadataType.U8Namespace.SequenceEqual("System"u8)) + if (metadataType.Name.SequenceEqual("Type"u8) && metadataType.Namespace.SequenceEqual("System"u8)) return true; } while ((metadataType = metadataType.MetadataBaseType) != null); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs index 789935b52d5cc9..e2a128d6d33d72 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs @@ -663,7 +663,7 @@ private partial IEnumerable GetMethodsOnTypeHie private partial IEnumerable GetNestedTypesOnType(TypeProxy type, string name, BindingFlags? bindingFlags) { - foreach (var nestedType in type.Type.GetNestedTypesOnType(t => t.U8Name.StringEquals(name), bindingFlags)) + foreach (var nestedType in type.Type.GetNestedTypesOnType(t => t.Name.StringEquals(name), bindingFlags)) yield return new SystemTypeValue(new TypeProxy(nestedType)); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs index 394a76804fffcd..d09c6646c7c96a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/CodeBasedDependencyAlgorithm.cs @@ -36,16 +36,16 @@ public static void AddDependenciesDueToMethodCodePresence(ref DependencyList dep case "Create": if (method.IsSharedByGenericInstantiations && owningType.Module == factory.TypeSystemContext.SystemModule - && owningType.U8Namespace.SequenceEqual("System.Collections.Generic"u8)) + && owningType.Namespace.SequenceEqual("System.Collections.Generic"u8)) { TypeDesc[] templateDependencies = null; - if (owningType.U8Name.SequenceEqual("Comparer`1"u8)) + if (owningType.Name.SequenceEqual("Comparer`1"u8)) { templateDependencies = Internal.IL.Stubs.ComparerIntrinsics.GetPotentialComparersForType( owningType.Instantiation[0]); } - else if (owningType.U8Name.SequenceEqual("EqualityComparer`1"u8)) + else if (owningType.Name.SequenceEqual("EqualityComparer`1"u8)) { templateDependencies = Internal.IL.Stubs.ComparerIntrinsics.GetPotentialEqualityComparersForType( owningType.Instantiation[0]); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs index f498451f8afd3c..832724e7d5f08a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs @@ -64,7 +64,7 @@ public static bool IsInlineableStringsResource(EcmaModule module, string resourc public static void AddDependenciesDueToResourceStringUse(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { if (method.Name.SequenceEqual(U8ResourceAccessorGetStringMethodName) && method.OwningType is MetadataType mdType - && mdType.U8Name.SequenceEqual(U8ResourceAccessorTypeName) && mdType.U8Namespace.SequenceEqual(U8ResourceAccessorTypeNamespace)) + && mdType.Name.SequenceEqual(U8ResourceAccessorTypeName) && mdType.Namespace.SequenceEqual(U8ResourceAccessorTypeNamespace)) { dependencies ??= new DependencyList(); dependencies.Add(factory.InlineableStringResource((EcmaModule)mdType.Module), "Using the System.SR class"); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs index 498e40ad3cc29a..5a95e3d6927c72 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DescriptorMarker.cs @@ -77,7 +77,7 @@ private void ProcessNamespaces(ModuleDesc assembly, XPathNavigator nav) bool foundMatch = false; foreach (DefType type in assembly.GetAllTypes()) { - if (!type.U8Namespace.StringEquals(fullname)) + if (!type.Namespace.StringEquals(fullname)) continue; foundMatch = true; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs index fe5b3f4b7c5d26..56eb9ccb70f418 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/DocumentationSignatureParser.cs @@ -557,8 +557,8 @@ private static void GetMatchingTypes(ModuleDesc module, TypeDesc declaringType, foreach (var nestedType in mdDeclaringType.GetNestedTypes()) { - Debug.Assert(nestedType.U8Namespace.IsEmpty); - if (!nestedType.U8Name.StringEquals(name)) + Debug.Assert(nestedType.Namespace.IsEmpty); + if (!nestedType.Name.StringEquals(name)) continue; // Compute arity counting only the newly-introduced generic parameters diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs index fd28d1d8f13829..7e3d93233cac18 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs @@ -414,8 +414,8 @@ public MethodIL GetMethodILWithInlinedSubstitutions(MethodIL method) { var callee = method.GetObject(reader.ReadILToken(), NotFoundBehavior.ReturnNull) as EcmaMethod; if (callee != null && callee.IsSpecialName && callee.OwningType is EcmaType calleeType - && calleeType.U8Name.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeName) - && calleeType.U8Namespace.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeNamespace) + && calleeType.Name.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeName) + && calleeType.Namespace.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeNamespace) && callee.Signature is { Length: 0, IsStatic: true } && callee.Name.StartsWith("get_"u8)) { @@ -824,7 +824,7 @@ private bool TryGetConstantArgument(MethodIL methodIL, byte[] body, OpcodeFlags[ } else if (method.IsIntrinsic && (method.Name.SequenceEqual("get_IsValueType"u8) || method.Name.SequenceEqual("get_IsEnum"u8)) && method.OwningType is MetadataType mdt - && mdt.U8Name.SequenceEqual("Type"u8) && mdt.U8Namespace.SequenceEqual("System"u8) && mdt.Module == mdt.Context.SystemModule + && mdt.Name.SequenceEqual("Type"u8) && mdt.Namespace.SequenceEqual("System"u8) && mdt.Module == mdt.Context.SystemModule && TryExpandTypeIs(methodIL, body, flags, currentOffset, method.GetName(), out constant)) { return true; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs index 01391039647f75..4b686bcb2528dc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutionProvider.cs @@ -73,7 +73,7 @@ private bool TryGetFeatureCheckValue(EcmaMethod method, out bool value) if (featureGuardAttribute.FixedArguments is not [CustomAttributeTypedArgument { Value: EcmaType featureType }]) continue; - if (featureType.U8Namespace.SequenceEqual("System.Diagnostics.CodeAnalysis"u8)) + if (featureType.Namespace.SequenceEqual("System.Diagnostics.CodeAnalysis"u8)) { switch (featureType.GetName()) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapManager.cs index fa5be49b78713e..c59b9e854b3e94 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypeMapManager.cs @@ -33,13 +33,13 @@ public enum TypeMapAttributeKind public static TypeMapAttributeKind LookupTypeMapType(TypeDesc attrType) { var typeDef = attrType.GetTypeDefinition() as MetadataType; - if (typeDef != null && typeDef.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8)) + if (typeDef != null && typeDef.Namespace.SequenceEqual("System.Runtime.InteropServices"u8)) { - if (typeDef.U8Name.SequenceEqual("TypeMapAssemblyTargetAttribute`1"u8)) + if (typeDef.Name.SequenceEqual("TypeMapAssemblyTargetAttribute`1"u8)) return TypeMapAttributeKind.TypeMapAssemblyTarget; - else if (typeDef.U8Name.SequenceEqual("TypeMapAttribute`1"u8)) + else if (typeDef.Name.SequenceEqual("TypeMapAttribute`1"u8)) return TypeMapAttributeKind.TypeMap; - else if (typeDef.U8Name.SequenceEqual("TypeMapAssociationAttribute`1"u8)) + else if (typeDef.Name.SequenceEqual("TypeMapAssociationAttribute`1"u8)) return TypeMapAttributeKind.TypeMapAssociation; } return TypeMapAttributeKind.None; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs index 1c608b5a58481b..cfc9a9f25e7d19 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs @@ -1825,8 +1825,8 @@ private static bool TryGetSpanElementType(TypeDesc type, bool isReadOnlySpan, ou if (type.IsByRefLike && type is MetadataType maybeSpan && maybeSpan.Module == type.Context.SystemModule - && ((isReadOnlySpan && maybeSpan.U8Name.SequenceEqual("ReadOnlySpan`1"u8)) || (!isReadOnlySpan && maybeSpan.U8Name.SequenceEqual("Span`1"u8))) - && maybeSpan.U8Namespace.SequenceEqual("System"u8) + && ((isReadOnlySpan && maybeSpan.Name.SequenceEqual("ReadOnlySpan`1"u8)) || (!isReadOnlySpan && maybeSpan.Name.SequenceEqual("Span`1"u8))) + && maybeSpan.Namespace.SequenceEqual("System"u8) && maybeSpan.Instantiation[0] is MetadataType readOnlySpanElementType) { elementType = readOnlySpanElementType; @@ -1873,7 +1873,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V { case "InitializeArray": if (method.OwningType is MetadataType mdType - && mdType.U8Name.SequenceEqual("RuntimeHelpers"u8) && mdType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) + && mdType.Name.SequenceEqual("RuntimeHelpers"u8) && mdType.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) && mdType.Module == mdType.Context.SystemModule && parameters[0] is ArrayInstance array && parameters[1] is RuntimeFieldHandleValue fieldHandle @@ -1886,7 +1886,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V return false; case "CreateSpan": if (method.OwningType is MetadataType createSpanType - && createSpanType.U8Name.SequenceEqual("RuntimeHelpers"u8) && createSpanType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) + && createSpanType.Name.SequenceEqual("RuntimeHelpers"u8) && createSpanType.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) && createSpanType.Module == createSpanType.Context.SystemModule && parameters[0] is RuntimeFieldHandleValue createSpanFieldHandle && createSpanFieldHandle.Field.IsStatic && createSpanFieldHandle.Field.HasRva @@ -1926,7 +1926,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V } case "IsReferenceOrContainsReferences" when method.Instantiation.Length == 1 && method.OwningType is MetadataType isReferenceOrContainsReferencesType - && isReferenceOrContainsReferencesType.U8Name.SequenceEqual("RuntimeHelpers"u8) && isReferenceOrContainsReferencesType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) + && isReferenceOrContainsReferencesType.Name.SequenceEqual("RuntimeHelpers"u8) && isReferenceOrContainsReferencesType.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8) && isReferenceOrContainsReferencesType.Module == method.Context.SystemModule: { bool result = method.Instantiation[0].IsGCPointer || (method.Instantiation[0] is DefType defType && defType.ContainsGCPointers); @@ -1935,7 +1935,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V } case "GetArrayDataReference" when method.Instantiation.Length == 1 && method.OwningType is MetadataType getArrayDataReferenceType - && getArrayDataReferenceType.U8Name.SequenceEqual("MemoryMarshal"u8) && getArrayDataReferenceType.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8) + && getArrayDataReferenceType.Name.SequenceEqual("MemoryMarshal"u8) && getArrayDataReferenceType.Namespace.SequenceEqual("System.Runtime.InteropServices"u8) && getArrayDataReferenceType.Module == method.Context.SystemModule && parameters[0] is ArrayInstance arrayData && ((ArrayType)arrayData.Type).ElementType == method.Instantiation[0]: @@ -1947,7 +1947,7 @@ private bool TryHandleIntrinsicCall(MethodDesc method, Value[] parameters, out V static bool IsSystemType(TypeDesc type) => type is MetadataType typeType - && typeType.U8Name.SequenceEqual("Type"u8) && typeType.U8Namespace.SequenceEqual("System"u8) + && typeType.Name.SequenceEqual("Type"u8) && typeType.Namespace.SequenceEqual("System"u8) && typeType.Module == typeType.Context.SystemModule; return false; @@ -2422,9 +2422,9 @@ public ComInterfaceEntryArrayValue(TypeDesc type, TypeDesc entryType) private static bool IsComInterfaceEntryType(TypeDesc type) => type is MetadataType mdType - && mdType.U8Name.SequenceEqual("ComInterfaceEntry"u8) + && mdType.Name.SequenceEqual("ComInterfaceEntry"u8) && mdType.ContainingType is MetadataType comWrappersType - && comWrappersType.U8Name.SequenceEqual("ComWrappers"u8) && comWrappersType.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8) + && comWrappersType.Name.SequenceEqual("ComWrappers"u8) && comWrappersType.Namespace.SequenceEqual("System.Runtime.InteropServices"u8) && comWrappersType.Module == comWrappersType.Context.SystemModule; public static bool IsCompatible(TypeDesc type, out TypeDesc entryType) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs index 07da091594e157..01834179b1f9d3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedInteropStubManager.cs @@ -60,7 +60,7 @@ public override void AddMarshalAPIsGenericDependencies(ref DependencyList depend MetadataType metadataType = owningType as MetadataType; if (metadataType != null && metadataType.Module == factory.TypeSystemContext.SystemModule) { - if (metadataType.U8Name.SequenceEqual("Marshal"u8) && metadataType.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8)) + if (metadataType.Name.SequenceEqual("Marshal"u8) && metadataType.Namespace.SequenceEqual("System.Runtime.InteropServices"u8)) { string methodName = method.GetName(); if (methodName == "GetFunctionPointerForDelegate" || diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs index 8a077285755c68..e4694484a7bf35 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VectorOfTFieldLayoutAlgorithm.cs @@ -98,7 +98,7 @@ public override bool ComputeIsUnsafeValueType(DefType type) public static bool IsVectorOfTType(DefType type) { - return type.IsIntrinsic && type.U8Namespace.SequenceEqual("System.Numerics"u8) && type.U8Name.SequenceEqual("Vector`1"u8); + return type.IsIntrinsic && type.Namespace.SequenceEqual("System.Numerics"u8) && type.Name.SequenceEqual("Vector`1"u8); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs index 329a8ed31569ab..8bb7c1f6eedd6c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs @@ -1473,7 +1473,7 @@ private static bool IsTypeGetTypeFromHandle(MethodDesc method) MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.U8Name.SequenceEqual("Type"u8) && owningType.U8Namespace.SequenceEqual("System"u8); + return owningType.Name.SequenceEqual("Type"u8) && owningType.Namespace.SequenceEqual("System"u8); } } @@ -1487,7 +1487,7 @@ private static bool IsActivatorDefaultConstructorOf(MethodDesc method) MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.U8Name.SequenceEqual("Activator"u8) && owningType.U8Namespace.SequenceEqual("System"u8); + return owningType.Name.SequenceEqual("Activator"u8) && owningType.Namespace.SequenceEqual("System"u8); } } @@ -1501,7 +1501,7 @@ private static bool IsActivatorAllocatorOf(MethodDesc method) MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.U8Name.SequenceEqual("Activator"u8) && owningType.U8Namespace.SequenceEqual("System"u8); + return owningType.Name.SequenceEqual("Activator"u8) && owningType.Namespace.SequenceEqual("System"u8); } } @@ -1515,7 +1515,7 @@ private static bool IsEETypePtrOf(MethodDesc method) MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.U8Name.SequenceEqual("MethodTable"u8) && owningType.U8Namespace.SequenceEqual("Internal.Runtime"u8); + return owningType.Name.SequenceEqual("MethodTable"u8) && owningType.Namespace.SequenceEqual("Internal.Runtime"u8); } } @@ -1529,7 +1529,7 @@ private static bool IsRuntimeHelpersIsReferenceOrContainsReferences(MethodDesc m MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.U8Name.SequenceEqual("RuntimeHelpers"u8) && owningType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8); + return owningType.Name.SequenceEqual("RuntimeHelpers"u8) && owningType.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8); } } @@ -1543,7 +1543,7 @@ private static bool IsMemoryMarshalGetArrayDataReference(MethodDesc method) MetadataType owningType = method.OwningType as MetadataType; if (owningType != null) { - return owningType.U8Name.SequenceEqual("MemoryMarshal"u8) && owningType.U8Namespace.SequenceEqual("System.Runtime.InteropServices"u8); + return owningType.Name.SequenceEqual("MemoryMarshal"u8) && owningType.Namespace.SequenceEqual("System.Runtime.InteropServices"u8); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs index 6cd75581ece3e8..20f35667ab50c3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/IL/TypeEqualityPatternAnalyzer.cs @@ -143,7 +143,7 @@ public void Advance(ILOpcode opcode, in ILReader reader, MethodIL methodIL) } static bool IsSystemType(TypeDesc t) - => t is MetadataType mdType && mdType.U8Name.SequenceEqual("Type"u8) && mdType.U8Namespace.SequenceEqual("System"u8); + => t is MetadataType mdType && mdType.Name.SequenceEqual("Type"u8) && mdType.Namespace.SequenceEqual("System"u8); static bool IsTypeGetTypeFromHandle(ILOpcode opcode, in ILReader reader, MethodIL methodIL) => opcode == ILOpcode.call && methodIL.GetObject(reader.PeekILToken()) is MethodDesc method diff --git a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs index 6ec6ed18c78412..1469a42950de64 100644 --- a/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs +++ b/src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs @@ -99,7 +99,7 @@ private static Ecma.SerializationTypeCode TypeDescToSerializationTypeCode(Cts.Ty return Ecma.SerializationTypeCode.String; if (type is not Cts.MetadataType mdType - || !mdType.U8Name.SequenceEqual("Type"u8) || !mdType.U8Namespace.SequenceEqual("System"u8)) + || !mdType.Name.SequenceEqual("Type"u8) || !mdType.Namespace.SequenceEqual("System"u8)) throw new UnreachableException(); return Ecma.SerializationTypeCode.Type; diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs index fcc5d35b1cd7bf..be77f7112f084b 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs @@ -314,7 +314,7 @@ public override ValueTypeShapeCharacteristics ComputeValueTypeShapeCharacteristi public static bool IsVectorOfTType(DefType type) { - return type.IsIntrinsic && type.U8Namespace.SequenceEqual("System.Numerics"u8) && type.U8Name.SequenceEqual("Vector`1"u8); + return type.IsIntrinsic && type.Namespace.SequenceEqual("System.Numerics"u8) && type.Name.SequenceEqual("Vector`1"u8); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunXmlRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunXmlRootProvider.cs index cee3ce9ab89056..aba6be552c672f 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunXmlRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunXmlRootProvider.cs @@ -168,7 +168,7 @@ private void ProcessNamespaces(ModuleDesc assembly, XPathNavigator nav) string fullname = GetFullName(namespaceNav); foreach (DefType type in assembly.GetAllTypes()) { - if (!type.U8Namespace.StringEquals(fullname)) + if (!type.Namespace.StringEquals(fullname)) continue; ProcessType(type, nav); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs index 1ad6d4bd1d9564..d8472631847de4 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/MIbcProfileParser.cs @@ -641,9 +641,9 @@ public override object GetType(ReadOnlySpan nameSpace, ReadOnlySpan { TypeSystemContext context = Context; - if (context.SupportsCanon && nameSpace.SequenceEqual(context.CanonType.U8Namespace) && name.SequenceEqual(context.CanonType.U8Name)) + if (context.SupportsCanon && nameSpace.SequenceEqual(context.CanonType.Namespace) && name.SequenceEqual(context.CanonType.Name)) return Context.CanonType; - if (context.SupportsUniversalCanon && nameSpace.SequenceEqual(context.UniversalCanonType.U8Namespace) && name.SequenceEqual(context.UniversalCanonType.U8Name)) + if (context.SupportsUniversalCanon && nameSpace.SequenceEqual(context.UniversalCanonType.Namespace) && name.SequenceEqual(context.UniversalCanonType.Name)) return Context.UniversalCanonType; else { diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs index 1047587d467c44..4f1020d92b7772 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs @@ -75,17 +75,17 @@ private MethodIL TryGetIntrinsicMethodIL(MethodDesc method) if (mdType == null) return null; - if (mdType.U8Name.SequenceEqual("RuntimeHelpers"u8) && mdType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) + if (mdType.Name.SequenceEqual("RuntimeHelpers"u8) && mdType.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) { return RuntimeHelpersIntrinsics.EmitIL(method); } - if (mdType.U8Name.SequenceEqual("Unsafe"u8) && mdType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) + if (mdType.Name.SequenceEqual("Unsafe"u8) && mdType.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) { return UnsafeIntrinsics.EmitIL(method); } - if (mdType.U8Name.SequenceEqual("InstanceCalliHelper"u8) && mdType.U8Namespace.SequenceEqual("System.Reflection"u8)) + if (mdType.Name.SequenceEqual("InstanceCalliHelper"u8) && mdType.Namespace.SequenceEqual("System.Reflection"u8)) { return InstanceCalliHelperIntrinsics.EmitIL(method); } @@ -104,17 +104,17 @@ private MethodIL TryGetPerInstantiationIntrinsicMethodIL(MethodDesc method) if (mdType == null) return null; - if (mdType.U8Name.SequenceEqual("RuntimeHelpers"u8) && mdType.U8Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) + if (mdType.Name.SequenceEqual("RuntimeHelpers"u8) && mdType.Namespace.SequenceEqual("System.Runtime.CompilerServices"u8)) { return RuntimeHelpersIntrinsics.EmitIL(method); } - if (mdType.U8Name.SequenceEqual("Activator"u8) && mdType.U8Namespace.SequenceEqual("System"u8)) + if (mdType.Name.SequenceEqual("Activator"u8) && mdType.Namespace.SequenceEqual("System"u8)) { return TryGetIntrinsicMethodILForActivator(method); } - if (mdType.U8Name.SequenceEqual("Interlocked"u8) && mdType.U8Namespace.SequenceEqual("System.Threading"u8)) + if (mdType.Name.SequenceEqual("Interlocked"u8) && mdType.Namespace.SequenceEqual("System.Threading"u8)) { return InterlockedIntrinsics.EmitIL(_compilationModuleGroup, method); } diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs index 8e349351d5813e..c2a72782b08448 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/AssemblyChecker.cs @@ -294,7 +294,7 @@ static bool ShouldIncludeType(TypeDesc type) return false; } - if (metadataType.U8Namespace.StartsWith("Internal"u8)) + if (metadataType.Namespace.StartsWith("Internal"u8)) return false; if (metadataType.Module.Assembly is EcmaAssembly asm && asm.Assembly.GetName().Name == "System.Private.CoreLib") diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs index 2da5b5025d0eb1..6fb3ef8be2a3b7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/MemberAssertionsCollector.cs @@ -80,7 +80,7 @@ private static bool IsMemberAssertion(MetadataType attributeType) if (attributeType == null) return false; - if (!attributeType.U8Namespace.SequenceEqual("Mono.Linker.Tests.Cases.Expectations.Assertions"u8)) + if (!attributeType.Namespace.SequenceEqual("Mono.Linker.Tests.Cases.Expectations.Assertions"u8)) return false; MetadataType t = attributeType; diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs index 22eaffa1c285cc..1880bbcd6606d3 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SyntheticVirtualOverrideTests.cs @@ -143,8 +143,8 @@ protected override IEnumerable GetAllMethods(TypeDesc type) { MetadataType mdType = type as MetadataType; - if (mdType.U8Name.SequenceEqual("StructWithNoEqualsAndGetHashCode"u8) - || mdType.U8Name.SequenceEqual("ClassWithInjectedEqualsAndGetHashCode"u8)) + if (mdType.Name.SequenceEqual("StructWithNoEqualsAndGetHashCode"u8) + || mdType.Name.SequenceEqual("ClassWithInjectedEqualsAndGetHashCode"u8)) { yield return GetEqualsMethod(type); yield return GetGetHashCodeMethod(type); @@ -158,8 +158,8 @@ protected override IEnumerable GetAllVirtualMethods(TypeDesc type) { MetadataType mdType = type as MetadataType; - if (mdType.U8Name.SequenceEqual("StructWithNoEqualsAndGetHashCode"u8) - || mdType.U8Name.SequenceEqual("ClassWithInjectedEqualsAndGetHashCode"u8)) + if (mdType.Name.SequenceEqual("StructWithNoEqualsAndGetHashCode"u8) + || mdType.Name.SequenceEqual("ClassWithInjectedEqualsAndGetHashCode"u8)) { yield return GetEqualsMethod(type); yield return GetGetHashCodeMethod(type); diff --git a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs index 932a3513d20758..298982f37e00b8 100644 --- a/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs +++ b/src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/TypeEquivalenceTests.cs @@ -231,7 +231,7 @@ public void TestTypesWhichShouldNotBeLoadable() { foreach (var typePair in GetTypesWhichClaimMatchingTypeIdentifiersInNamespace("TypesWhichDoNotLoad")) { - if (((MetadataType)typePair.Item1).U8Name.EndsWith("IGNORE"u8)) + if (((MetadataType)typePair.Item1).Name.EndsWith("IGNORE"u8)) continue; _logger.WriteLine($"Checking load behavior of {typePair.Item1}"); diff --git a/src/coreclr/tools/aot/ILCompiler/Program.cs b/src/coreclr/tools/aot/ILCompiler/Program.cs index 9e9403d8a097c2..90f9d2e42b7279 100644 --- a/src/coreclr/tools/aot/ILCompiler/Program.cs +++ b/src/coreclr/tools/aot/ILCompiler/Program.cs @@ -683,7 +683,7 @@ static bool IsRelatedToInvalidInput(MethodDesc method) // but not scanned, it's usually fine. If it wasn't fine, we would probably crash before getting here. return method.OwningType is MetadataType mdType && mdType.Module == method.Context.SystemModule - && (mdType.U8Name.EndsWith("Exception"u8) || mdType.U8Namespace.StartsWith("Internal.Runtime"u8)); + && (mdType.Name.EndsWith("Exception"u8) || mdType.Namespace.StartsWith("Internal.Runtime"u8)); } // If optimizations are enabled, the results will for sure not match in the other direction due to inlining, etc. diff --git a/src/coreclr/tools/dotnet-pgo/TraceRuntimeDescToTypeSystemDesc.cs b/src/coreclr/tools/dotnet-pgo/TraceRuntimeDescToTypeSystemDesc.cs index 6713489af3980f..c7513ad80c1478 100644 --- a/src/coreclr/tools/dotnet-pgo/TraceRuntimeDescToTypeSystemDesc.cs +++ b/src/coreclr/tools/dotnet-pgo/TraceRuntimeDescToTypeSystemDesc.cs @@ -426,7 +426,7 @@ public TypeDesc ResolveTypeHandle(long handle, ref bool dependsOnKnownNonLoadabl } else { - if ((uninstantiatedType.U8Name.SequenceEqual("__Canon"u8)) && uninstantiatedType.U8Namespace.SequenceEqual("System"u8) && (uninstantiatedType.Module == uninstantiatedType.Context.SystemModule)) + if ((uninstantiatedType.Name.SequenceEqual("__Canon"u8)) && uninstantiatedType.Namespace.SequenceEqual("System"u8) && (uninstantiatedType.Module == uninstantiatedType.Context.SystemModule)) { tinfo.Type = uninstantiatedType.Context.CanonType; } diff --git a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs index 6977f31a924b99..4856afaca8a06f 100644 --- a/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs +++ b/src/coreclr/tools/dotnet-pgo/TypeRefTypeSystem/TypeRefTypeSystemType.cs @@ -140,13 +140,9 @@ public FieldDesc GetOrAddField(ReadOnlySpan name, TypeDesc fieldType, Embe public override PInvokeStringFormat PInvokeStringFormat => throw new NotImplementedException(); - public override string Name => Encoding.UTF8.GetString(_name); + public override ReadOnlySpan Name => _name; - public override ReadOnlySpan U8Name => _name; - - public override string Namespace => Encoding.UTF8.GetString(_namespace); - - public override ReadOnlySpan U8Namespace => _namespace; + public override ReadOnlySpan Namespace => _namespace; public override bool IsExplicitLayout => throw new NotImplementedException(); @@ -191,8 +187,8 @@ public override MetadataType MetadataBaseType public override int GetHashCode() { var hash = new HashCode(); - hash.AddBytes(U8Namespace); - hash.AddBytes(U8Name); + hash.AddBytes(Namespace); + hash.AddBytes(Name); hash.Add(Module); return hash.ToHashCode(); } From 52a96844c5e8e07c3c22051f96629d3aafd28bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Mon, 8 Sep 2025 00:14:22 +0200 Subject: [PATCH 15/19] Cleanups --- .../TypeSystem/Common/GenericParameterDesc.cs | 8 ------ .../TypeSystem/Ecma/EcmaGenericParameter.cs | 9 ------- ...DelegateMarshallingMethodThunk.Mangling.cs | 2 +- .../Stubs/DelegateMarshallingMethodThunk.cs | 25 +++---------------- .../Stubs/StructMarshallingThunk.Mangling.cs | 2 +- .../IL/Stubs/StructMarshallingThunk.cs | 25 +++---------------- .../ValueTypeGetFieldHelperMethodOverride.cs | 4 +-- .../RuntimeDeterminedType.cs | 3 ++- .../Compiler/DependencyAnalysis/EETypeNode.cs | 2 +- .../InlineableStringsResourceNode.cs | 17 ++++++------- .../Compiler/NoMetadataBlockingPolicy.cs | 2 +- .../Compiler/SubstitutedILProvider.cs | 4 +-- 12 files changed, 23 insertions(+), 80 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs index 8d62f1843d149a..c361733737d4ff 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/GenericParameterDesc.cs @@ -77,14 +77,6 @@ public virtual string Name } } - public virtual ReadOnlySpan U8Name - { - get - { - return System.Text.Encoding.UTF8.GetBytes(Name); - } - } - /// /// Gets a value indicating whether this is a type or method generic parameter. /// diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs index 904777ec988c66..bd8473913443ec 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaGenericParameter.cs @@ -62,15 +62,6 @@ public override string Name } } - public override ReadOnlySpan U8Name - { - get - { - MetadataReader reader = _module.MetadataReader; - return reader.GetStringBytes(reader.GetGenericParameter(_handle).Name); - } - } - public override GenericParameterKind Kind { get diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Mangling.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Mangling.cs index 27dbb90c06c859..98efc7c0cc707d 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Mangling.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.Mangling.cs @@ -19,7 +19,7 @@ string IPrefixMangledType.Prefix { get { - return NamePrefix; + return System.Text.Encoding.UTF8.GetString(NamePrefix); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs index 7293a92143f14f..834eb90e0eeae9 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/DelegateMarshallingMethodThunk.cs @@ -218,26 +218,7 @@ public MethodSignature DelegateSignature } } - private string NamePrefix - { - get - { - switch (Kind) - { - case DelegateMarshallingMethodThunkKind.ReverseOpenStatic: - return "ReverseOpenStaticDelegateStub"; - case DelegateMarshallingMethodThunkKind.ReverseClosed: - return "ReverseDelegateStub"; - case DelegateMarshallingMethodThunkKind.ForwardNativeFunctionWrapper: - return "ForwardNativeFunctionWrapper"; - default: - Debug.Fail("Unexpected DelegateMarshallingMethodThunkKind."); - return string.Empty; - } - } - } - - private ReadOnlySpan U8NamePrefix + private ReadOnlySpan NamePrefix { get { @@ -260,7 +241,7 @@ public override ReadOnlySpan Name { get { - return U8NamePrefix.Append("__"u8, DelegateType.Name); + return NamePrefix.Append("__"u8, DelegateType.Name); } } @@ -268,7 +249,7 @@ public override string DiagnosticName { get { - return NamePrefix + "__" + DelegateType.DiagnosticName; + return GetName(); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Mangling.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Mangling.cs index 68506e92117f40..0ddfcaa7789623 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Mangling.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.Mangling.cs @@ -19,7 +19,7 @@ string IPrefixMangledType.Prefix { get { - return NamePrefix; + return System.Text.Encoding.UTF8.GetString(NamePrefix); } } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs index 314bc803ed10ca..1d0263ef3cc52e 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/StructMarshallingThunk.cs @@ -102,26 +102,7 @@ public override MethodSignature Signature } } - private string NamePrefix - { - get - { - switch (ThunkType) - { - case StructMarshallingThunkType.ManagedToNative: - return "ManagedToNative"; - case StructMarshallingThunkType.NativeToManaged: - return "NativeToManaged"; - case StructMarshallingThunkType.Cleanup: - return "Cleanup"; - default: - Debug.Fail("Unexpected Struct marshalling thunk type"); - return string.Empty; - } - } - } - - private ReadOnlySpan U8NamePrefix + private ReadOnlySpan NamePrefix { get { @@ -144,7 +125,7 @@ public override ReadOnlySpan Name { get { - return U8NamePrefix.Append("__"u8, ManagedType.Name); + return NamePrefix.Append("__"u8, ManagedType.Name); } } @@ -152,7 +133,7 @@ public override string DiagnosticName { get { - return NamePrefix + "__" + ManagedType.DiagnosticName; + return GetName(); } } diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs index 60cb0e0c53ceb6..73b362d8154ada 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/ValueTypeGetFieldHelperMethodOverride.cs @@ -215,13 +215,13 @@ public override bool IsVirtual } } - internal static ReadOnlySpan U8MetadataName => "__GetFieldHelper"u8; + internal static ReadOnlySpan MetadataName => "__GetFieldHelper"u8; public override ReadOnlySpan Name { get { - return U8MetadataName; + return MetadataName; } } diff --git a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs index c80a99c0ca9780..1834c19f5339e8 100644 --- a/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs +++ b/src/coreclr/tools/Common/TypeSystem/RuntimeDetermined/RuntimeDeterminedType.cs @@ -102,7 +102,8 @@ public override ReadOnlySpan Namespace { get { - return _runtimeDeterminedDetailsType.U8Name.Append("_"u8, _rawCanonType.Namespace); + return System.Text.Encoding.UTF8.GetBytes(_runtimeDeterminedDetailsType.Name) + .Append("_"u8, _rawCanonType.Namespace); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs index 4aa96d078df4d2..0f6fc1d3e3aeee 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs @@ -1000,7 +1000,7 @@ private void OutputVirtualSlots(NodeFactory factory, ref ObjectDataBuilder objDa if (isAsyncStateMachineValueType) { if ((declType.IsObject && (declMethod.Name.SequenceEqual("Equals"u8) || declMethod.Name.SequenceEqual("GetHashCode"u8)) && implMethod.OwningType.IsWellKnownType(WellKnownType.ValueType)) - || (declType.IsWellKnownType(WellKnownType.ValueType) && declMethod.Name.SequenceEqual(ValueTypeGetFieldHelperMethodOverride.U8MetadataName))) + || (declType.IsWellKnownType(WellKnownType.ValueType) && declMethod.Name.SequenceEqual(ValueTypeGetFieldHelperMethodOverride.MetadataName))) { shouldEmitImpl = false; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs index 832724e7d5f08a..fcda5e674b8f4f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InlineableStringsResourceNode.cs @@ -19,12 +19,9 @@ internal sealed class InlineableStringsResourceNode : DependencyNodeCore U8ResourceAccessorTypeName => "SR"u8; - public const string ResourceAccessorTypeNamespace = "System"; - public static ReadOnlySpan U8ResourceAccessorTypeNamespace => "System"u8; - public const string ResourceAccessorGetStringMethodName = "GetResourceString"; - public static ReadOnlySpan U8ResourceAccessorGetStringMethodName => "GetResourceString"u8; + public static ReadOnlySpan ResourceAccessorTypeName => "SR"u8; + public static ReadOnlySpan ResourceAccessorTypeNamespace => "System"u8; + public static ReadOnlySpan ResourceAccessorGetStringMethodName => "GetResourceString"u8; public InlineableStringsResourceNode(EcmaModule module) { @@ -54,17 +51,17 @@ public static bool IsInlineableStringsResource(EcmaModule module, string resourc if (resourceName != resourceName1 && resourceName != resourceName2) return false; - MetadataType srType = module.GetType(U8ResourceAccessorTypeNamespace, U8ResourceAccessorTypeName, throwIfNotFound: false); + MetadataType srType = module.GetType(ResourceAccessorTypeNamespace, ResourceAccessorTypeName, throwIfNotFound: false); if (srType == null) return false; - return srType.GetMethod(U8ResourceAccessorGetStringMethodName, null) != null; + return srType.GetMethod(ResourceAccessorGetStringMethodName, null) != null; } public static void AddDependenciesDueToResourceStringUse(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { - if (method.Name.SequenceEqual(U8ResourceAccessorGetStringMethodName) && method.OwningType is MetadataType mdType - && mdType.Name.SequenceEqual(U8ResourceAccessorTypeName) && mdType.Namespace.SequenceEqual(U8ResourceAccessorTypeNamespace)) + if (method.Name.SequenceEqual(ResourceAccessorGetStringMethodName) && method.OwningType is MetadataType mdType + && mdType.Name.SequenceEqual(ResourceAccessorTypeName) && mdType.Namespace.SequenceEqual(ResourceAccessorTypeNamespace)) { dependencies ??= new DependencyList(); dependencies.Add(factory.InlineableStringResource((EcmaModule)mdType.Module), "Using the System.SR class"); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs index ba238a6a186224..2b50dfc2c65a92 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/NoMetadataBlockingPolicy.cs @@ -54,7 +54,7 @@ public override bool IsBlocked(MethodDesc method) return true; // Also don't expose the ValueType.__GetFieldOverride method. - if (ecmaMethod.Name.SequenceEqual(Internal.IL.Stubs.ValueTypeGetFieldHelperMethodOverride.U8MetadataName) + if (ecmaMethod.Name.SequenceEqual(Internal.IL.Stubs.ValueTypeGetFieldHelperMethodOverride.MetadataName) && ecmaMethod.OwningType.IsWellKnownType(WellKnownType.ValueType)) return true; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs index 7e3d93233cac18..dc4e1c91a49cf9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/SubstitutedILProvider.cs @@ -414,8 +414,8 @@ public MethodIL GetMethodILWithInlinedSubstitutions(MethodIL method) { var callee = method.GetObject(reader.ReadILToken(), NotFoundBehavior.ReturnNull) as EcmaMethod; if (callee != null && callee.IsSpecialName && callee.OwningType is EcmaType calleeType - && calleeType.Name.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeName) - && calleeType.Namespace.SequenceEqual(InlineableStringsResourceNode.U8ResourceAccessorTypeNamespace) + && calleeType.Name.SequenceEqual(InlineableStringsResourceNode.ResourceAccessorTypeName) + && calleeType.Namespace.SequenceEqual(InlineableStringsResourceNode.ResourceAccessorTypeNamespace) && callee.Signature is { Length: 0, IsStatic: true } && callee.Name.StartsWith("get_"u8)) { From f617346c9959f78ff56c0e0de893da1d0a79fb02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Tue, 9 Sep 2025 15:21:01 +0200 Subject: [PATCH 16/19] Perf improvements --- .../tools/Common/TypeSystem/Ecma/EcmaField.cs | 21 +++- .../Common/TypeSystem/Ecma/EcmaMethod.cs | 24 +++- .../Common/TypeSystem/Ecma/EcmaModule.cs | 119 ++++++++++++++---- .../TypeSystem/Ecma/EcmaType.MethodImpls.cs | 3 +- .../tools/Common/TypeSystem/Ecma/EcmaType.cs | 36 +++++- .../TypeSystem/Ecma/MetadataExtensions.cs | 23 +++- 6 files changed, 186 insertions(+), 40 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs index f47742434dad0e..8af05729f76140 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs @@ -5,7 +5,9 @@ using System.Diagnostics; using System.Reflection; using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; using System.Runtime.CompilerServices; +using System.Threading; namespace Internal.TypeSystem.Ecma { @@ -31,6 +33,8 @@ private static class FieldFlags private FieldDefinitionHandle _handle; // Cached values + private nint _namePointer; + private int _nameLength; private ThreadSafeFlags _fieldFlags; private TypeDesc _fieldType; @@ -255,12 +259,23 @@ public FieldAttributes Attributes } } - public override ReadOnlySpan Name + public unsafe ReadOnlySpan InitializeName() + { + StringHandle handle = MetadataReader.GetFieldDefinition(_handle).Name; + _nameLength = MetadataReader.GetStringBytes(handle).Length; + Volatile.Write(ref _namePointer, (nint)(MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle))); + return new ReadOnlySpan((byte*)_namePointer, _nameLength); + } + + public override unsafe ReadOnlySpan Name { get { - MetadataReader reader = MetadataReader; - return reader.GetStringBytes(reader.GetFieldDefinition(_handle).Name); + if (_namePointer != 0) + { + return new ReadOnlySpan((byte*)_namePointer, _nameLength); + } + return InitializeName(); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index f7e710645efeda..a9647043520ebf 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -1,12 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Diagnostics; -using System.Runtime.CompilerServices; using System.Reflection; using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; +using System.Runtime.CompilerServices; using System.Threading; -using System; namespace Internal.TypeSystem.Ecma { @@ -37,6 +38,8 @@ private static class MethodFlags private MethodDefinitionHandle _handle; // Cached values + private nint _namePointer; + private int _nameLength; private ThreadSafeFlags _methodFlags; private MethodSignature _signature; private TypeDesc[] _genericParameters; // TODO: Optional field? @@ -380,12 +383,23 @@ public MethodImplAttributes ImplAttributes } } - public override ReadOnlySpan Name + public unsafe ReadOnlySpan InitializeName() + { + StringHandle handle = MetadataReader.GetMethodDefinition(_handle).Name; + _nameLength = MetadataReader.GetStringBytes(handle).Length; + Volatile.Write(ref _namePointer, (nint)(MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle))); + return new ReadOnlySpan((byte*)_namePointer, _nameLength); + } + + public override unsafe ReadOnlySpan Name { get { - var metadataReader = MetadataReader; - return metadataReader.GetStringBytes(metadataReader.GetMethodDefinition(_handle).Name); + if (_namePointer != 0) + { + return new ReadOnlySpan((byte*)_namePointer, _nameLength); + } + return InitializeName(); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs index b8e393ae6bb34a..e8b1d352542ffc 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs @@ -285,51 +285,124 @@ public bool IsPlatformNeutral } } - private Dictionary<(string Name, string Namespace), EntityHandle> _nameLookupCache; + private TypeDefinitionHandle[] _typeDefinitionBuckets; + private volatile TypeDefinitionHandle[] _typeDefinitionBucketHeads; - private Dictionary<(string Name, string Namespace), EntityHandle> CreateNameLookupCache() + private TypeDefinitionHandle[] InitializeTypeDefinitionBucketHeads() { - // TODO: it's not particularly efficient to materialize strings just to hash them and hold - // onto them forever. We could instead hash the UTF-8 bytes and hold the TypeDefinitionHandle - // so we can obtain the bytes again when needed. - // E.g. see the scheme explored in the first commit of https://github.com/dotnet/runtime/pull/84285. + TypeDefinitionHandle[] buckets = new TypeDefinitionHandle[_metadataReader.TypeDefinitions.Count + 1]; + TypeDefinitionHandle[] bucketHeads = new TypeDefinitionHandle[(buckets.Length / 8) + 1]; - var result = new Dictionary<(string Name, string Namespace), EntityHandle>(); - - MetadataReader metadataReader = _metadataReader; - foreach (TypeDefinitionHandle typeDefHandle in metadataReader.TypeDefinitions) + MetadataReader reader = _metadataReader; + foreach (TypeDefinitionHandle typeHandle in reader.TypeDefinitions) { - TypeDefinition typeDefinition = metadataReader.GetTypeDefinition(typeDefHandle); - if (typeDefinition.Attributes.IsNested()) + TypeDefinition typeDef = reader.GetTypeDefinition(typeHandle); + if (typeDef.Attributes.IsNested()) continue; - result.Add((metadataReader.GetString(typeDefinition.Name), metadataReader.GetString(typeDefinition.Namespace)), typeDefHandle); + int hashCode = VersionResilientHashCode.NameHashCode(reader.GetStringBytes(typeDef.Namespace), reader.GetStringBytes(typeDef.Name)); + + ref TypeDefinitionHandle head = ref bucketHeads[(uint)hashCode % bucketHeads.Length]; + ref TypeDefinitionHandle entry = ref buckets[MetadataTokens.GetRowNumber(typeHandle)]; + + entry = head; + head = typeHandle; } - foreach (ExportedTypeHandle exportedTypeHandle in metadataReader.ExportedTypes) + _typeDefinitionBuckets = buckets; + _typeDefinitionBucketHeads = bucketHeads; + + return bucketHeads; + } + + private TypeDefinitionHandle FindDefinedType(int hashCode, ReadOnlySpan nameSpace, ReadOnlySpan name) + { + MetadataReader reader = _metadataReader; + + TypeDefinitionHandle[] bucketHeads = _typeDefinitionBucketHeads ?? InitializeTypeDefinitionBucketHeads(); + TypeDefinitionHandle entry = bucketHeads[(uint)hashCode % bucketHeads.Length]; + while (!entry.IsNil) { - ExportedType exportedType = metadataReader.GetExportedType(exportedTypeHandle); - if (exportedType.Implementation.Kind == HandleKind.ExportedType) + var typeDefinition = reader.GetTypeDefinition(entry); + if (reader.StringEquals(typeDefinition.Name, name) && + reader.StringEquals(typeDefinition.Namespace, nameSpace)) + { + return entry; + } + + entry = _typeDefinitionBuckets[MetadataTokens.GetRowNumber(entry)]; + } + + return default; + } + + private ExportedTypeHandle[] _exportedTypeBuckets; + private volatile ExportedTypeHandle[] _exportedTypeBucketHeads; + + private ExportedTypeHandle[] InitializeExportedTypeBucketHeads() + { + ExportedTypeHandle[] buckets = new ExportedTypeHandle[_metadataReader.ExportedTypes.Count + 1]; + ExportedTypeHandle[] bucketHeads = new ExportedTypeHandle[(buckets.Length / 8) + 1]; + + MetadataReader reader = _metadataReader; + foreach (ExportedTypeHandle typeHandle in reader.ExportedTypes) + { + ExportedType exportDef = reader.GetExportedType(typeHandle); + if (exportDef.Implementation.Kind == HandleKind.ExportedType) continue; - result.Add((metadataReader.GetString(exportedType.Name), metadataReader.GetString(exportedType.Namespace)), exportedTypeHandle); + int hashCode = VersionResilientHashCode.NameHashCode(reader.GetStringBytes(exportDef.Namespace), reader.GetStringBytes(exportDef.Name)); + + ref ExportedTypeHandle head = ref bucketHeads[(uint)hashCode % bucketHeads.Length]; + ref ExportedTypeHandle entry = ref buckets[MetadataTokens.GetRowNumber(typeHandle)]; + + entry = head; + head = typeHandle; } - return _nameLookupCache = result; + _exportedTypeBuckets = buckets; + _exportedTypeBucketHeads = bucketHeads; + + return bucketHeads; + } + + private ExportedTypeHandle FindExportedType(int hashCode, ReadOnlySpan nameSpace, ReadOnlySpan name) + { + MetadataReader reader = _metadataReader; + + ExportedTypeHandle[] bucketHeads = _exportedTypeBucketHeads ?? InitializeExportedTypeBucketHeads(); + ExportedTypeHandle entry = bucketHeads[(uint)hashCode % bucketHeads.Length]; + while (!entry.IsNil) + { + var exportedType = reader.GetExportedType(entry); + if (reader.StringEquals(exportedType.Name, name) && + reader.StringEquals(exportedType.Namespace, nameSpace)) + { + return entry; + } + + entry = _exportedTypeBuckets[MetadataTokens.GetRowNumber(entry)]; + } + + return default; } public sealed override object GetType(ReadOnlySpan nameSpace, ReadOnlySpan name, NotFoundBehavior notFoundBehavior) { + int hashCode = VersionResilientHashCode.NameHashCode(nameSpace, name); + var currentModule = this; // src/coreclr/vm/clsload.cpp use the same restriction to detect a loop in the type forwarding. for (int typeForwardingChainSize = 0; typeForwardingChainSize <= 1024; typeForwardingChainSize++) { - if ((currentModule._nameLookupCache ?? currentModule.CreateNameLookupCache()).TryGetValue((System.Text.Encoding.UTF8.GetString(name.ToArray()), System.Text.Encoding.UTF8.GetString(nameSpace.ToArray())), out EntityHandle foundHandle)) - { - if (foundHandle.Kind == HandleKind.TypeDefinition) - return currentModule.GetType((TypeDefinitionHandle)foundHandle); + TypeDefinitionHandle typeDefHandle = currentModule.FindDefinedType(hashCode, nameSpace, name); + if (!typeDefHandle.IsNil) + return currentModule.GetType(typeDefHandle); - ExportedType exportedType = currentModule._metadataReader.GetExportedType((ExportedTypeHandle)foundHandle); + ExportedTypeHandle exportedTypeHandle = currentModule.FindExportedType(hashCode, nameSpace, name); + if (!exportedTypeHandle.IsNil) + { + ExportedType exportedType = currentModule._metadataReader.GetExportedType(exportedTypeHandle); if (exportedType.IsForwarder) { object implementation = currentModule.GetObject(exportedType.Implementation, notFoundBehavior); diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs index 1fc391456736f6..9d29e54464846d 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.MethodImpls.cs @@ -40,8 +40,7 @@ public override MethodImplRecord[] FindMethodsImplWithMatchingDeclName(ReadOnlyS _ => default }; - ReadOnlySpan foundDeclName = metadataReader.GetStringBytes(foundDeclNameHandle); - if (declName.SequenceEqual(foundDeclName)) + if (metadataReader.StringEquals(foundDeclNameHandle, declName)) { MethodImplRecord newRecord = new MethodImplRecord( (MethodDesc)_module.GetObject(methodImpl.MethodDeclaration), diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs index 026563ca7c69d6..1fc38f2d40d88e 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs @@ -24,6 +24,10 @@ public sealed partial class EcmaType : MetadataType, EcmaModule.IEntityHandleObj private TypeDefinition _typeDefinition; // Cached values + private nint _namePointer; + private int _nameLength; + private nint _namespacePointer; + private int _namespaceLength; private TypeDesc[] _genericParameters; private MetadataType _baseType; private int _hashcode; @@ -259,19 +263,43 @@ protected override TypeFlags ComputeTypeFlags(TypeFlags mask) return flags; } - public override ReadOnlySpan Name + private unsafe ReadOnlySpan InitializeName() + { + StringHandle handle = _typeDefinition.Name; + _nameLength = MetadataReader.GetStringBytes(handle).Length; + Volatile.Write(ref _namePointer, (nint)(MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle))); + return new ReadOnlySpan((byte*)_namePointer, _nameLength); + } + + public override unsafe ReadOnlySpan Name { get { - return MetadataReader.GetStringBytes(_typeDefinition.Name); + if (_namePointer != 0) + { + return new ReadOnlySpan((byte*)_namePointer, _nameLength); + } + return InitializeName(); } } - public override ReadOnlySpan Namespace + private unsafe ReadOnlySpan InitializeNamespace() + { + StringHandle handle = _typeDefinition.Namespace; + _namespaceLength = MetadataReader.GetStringBytes(handle).Length; + Volatile.Write(ref _namespacePointer, (nint)(MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle))); + return new ReadOnlySpan((byte*)_namespacePointer, _namespaceLength); + } + + public override unsafe ReadOnlySpan Namespace { get { - return MetadataReader.GetStringBytes(_typeDefinition.Namespace); + if (_namespacePointer != 0) + { + return new ReadOnlySpan((byte*)_namespacePointer, _namespaceLength); + } + return InitializeNamespace(); } } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs index a7de9a8374b04a..1a0dc816c7b34b 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/MetadataExtensions.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Reflection; using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; using System.Runtime.InteropServices; namespace Internal.TypeSystem.Ecma @@ -320,9 +321,25 @@ public static unsafe ReadOnlySpan GetStringBytes(this MetadataReader reade public static unsafe bool StringEquals(this MetadataReader reader, StringHandle handle, ReadOnlySpan otherString) { - BlobReader blobReader = reader.GetBlobReader(handle); - ReadOnlySpan thisString = new ReadOnlySpan(blobReader.CurrentPointer, blobReader.Length); - return thisString.SequenceEqual(otherString); + int stringOffset = reader.GetHeapOffset(handle); + + // Could the heap hold a string this big? + if (stringOffset + otherString.Length >= reader.GetHeapSize(HeapIndex.String)) + return false; + + // Check for null terminator at the expected location + byte* currentChar = reader.MetadataPointer + reader.GetHeapMetadataOffset(HeapIndex.String) + stringOffset; + if (*(currentChar + otherString.Length) != 0) + return false; + + // Compare characters + for (int i = 0; i < otherString.Length; i++) + { + if (otherString[i] != *(currentChar++)) + return false; + } + + return true; } } } From d0fa65de2d943a7f625cc37b6fda1a453f238e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Wed, 10 Sep 2025 00:21:43 +0200 Subject: [PATCH 17/19] Use volatile --- .../tools/Common/TypeSystem/Ecma/EcmaField.cs | 10 +++++----- .../Common/TypeSystem/Ecma/EcmaMethod.cs | 10 +++++----- .../tools/Common/TypeSystem/Ecma/EcmaType.cs | 20 +++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs index 8af05729f76140..8ca033acdbb086 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs @@ -33,7 +33,7 @@ private static class FieldFlags private FieldDefinitionHandle _handle; // Cached values - private nint _namePointer; + private unsafe volatile byte* _namePointer; private int _nameLength; private ThreadSafeFlags _fieldFlags; private TypeDesc _fieldType; @@ -263,17 +263,17 @@ public unsafe ReadOnlySpan InitializeName() { StringHandle handle = MetadataReader.GetFieldDefinition(_handle).Name; _nameLength = MetadataReader.GetStringBytes(handle).Length; - Volatile.Write(ref _namePointer, (nint)(MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle))); - return new ReadOnlySpan((byte*)_namePointer, _nameLength); + _namePointer = MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle); + return new ReadOnlySpan(_namePointer, _nameLength); } public override unsafe ReadOnlySpan Name { get { - if (_namePointer != 0) + if (_namePointer != null) { - return new ReadOnlySpan((byte*)_namePointer, _nameLength); + return new ReadOnlySpan(_namePointer, _nameLength); } return InitializeName(); } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index a9647043520ebf..7cc080d27399cf 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -38,7 +38,7 @@ private static class MethodFlags private MethodDefinitionHandle _handle; // Cached values - private nint _namePointer; + private unsafe volatile byte* _namePointer; private int _nameLength; private ThreadSafeFlags _methodFlags; private MethodSignature _signature; @@ -387,17 +387,17 @@ public unsafe ReadOnlySpan InitializeName() { StringHandle handle = MetadataReader.GetMethodDefinition(_handle).Name; _nameLength = MetadataReader.GetStringBytes(handle).Length; - Volatile.Write(ref _namePointer, (nint)(MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle))); - return new ReadOnlySpan((byte*)_namePointer, _nameLength); + _namePointer = MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle); + return new ReadOnlySpan(_namePointer, _nameLength); } public override unsafe ReadOnlySpan Name { get { - if (_namePointer != 0) + if (_namePointer != null) { - return new ReadOnlySpan((byte*)_namePointer, _nameLength); + return new ReadOnlySpan(_namePointer, _nameLength); } return InitializeName(); } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs index 8173b991ccc05b..2a3be550a32e1a 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs @@ -25,9 +25,9 @@ public sealed partial class EcmaType : MetadataType, EcmaModule.IEntityHandleObj private TypeDefinition _typeDefinition; // Cached values - private nint _namePointer; + private unsafe volatile byte* _namePointer; private int _nameLength; - private nint _namespacePointer; + private unsafe volatile byte* _namespacePointer; private int _namespaceLength; private TypeDesc[] _genericParameters; private MetadataType _baseType; @@ -268,17 +268,17 @@ private unsafe ReadOnlySpan InitializeName() { StringHandle handle = _typeDefinition.Name; _nameLength = MetadataReader.GetStringBytes(handle).Length; - Volatile.Write(ref _namePointer, (nint)(MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle))); - return new ReadOnlySpan((byte*)_namePointer, _nameLength); + _namePointer = MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle); + return new ReadOnlySpan(_namePointer, _nameLength); } public override unsafe ReadOnlySpan Name { get { - if (_namePointer != 0) + if (_namePointer != null) { - return new ReadOnlySpan((byte*)_namePointer, _nameLength); + return new ReadOnlySpan(_namePointer, _nameLength); } return InitializeName(); } @@ -288,17 +288,17 @@ private unsafe ReadOnlySpan InitializeNamespace() { StringHandle handle = _typeDefinition.Namespace; _namespaceLength = MetadataReader.GetStringBytes(handle).Length; - Volatile.Write(ref _namespacePointer, (nint)(MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle))); - return new ReadOnlySpan((byte*)_namespacePointer, _namespaceLength); + _namespacePointer = MetadataReader.MetadataPointer + MetadataReader.GetHeapMetadataOffset(HeapIndex.String) + MetadataReader.GetHeapOffset(handle); + return new ReadOnlySpan(_namespacePointer, _namespaceLength); } public override unsafe ReadOnlySpan Namespace { get { - if (_namespacePointer != 0) + if (_namespacePointer != null) { - return new ReadOnlySpan((byte*)_namespacePointer, _namespaceLength); + return new ReadOnlySpan(_namespacePointer, _namespaceLength); } return InitializeNamespace(); } From a4cce2336ffdfa3c67f41a2ee2cc742ff2eefd58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Wed, 10 Sep 2025 17:29:03 +0200 Subject: [PATCH 18/19] Only load field once --- src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs | 5 +++-- src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs | 5 +++-- src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs | 10 ++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs index 8ca033acdbb086..79a35f033d2011 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaField.cs @@ -271,9 +271,10 @@ public override unsafe ReadOnlySpan Name { get { - if (_namePointer != null) + byte* namePointer = _namePointer; + if (namePointer != null) { - return new ReadOnlySpan(_namePointer, _nameLength); + return new ReadOnlySpan(namePointer, _nameLength); } return InitializeName(); } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index 7cc080d27399cf..0decf370cfe759 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -395,9 +395,10 @@ public override unsafe ReadOnlySpan Name { get { - if (_namePointer != null) + byte* namePointer = _namePointer; + if (namePointer != null) { - return new ReadOnlySpan(_namePointer, _nameLength); + return new ReadOnlySpan(namePointer, _nameLength); } return InitializeName(); } diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs index 2a3be550a32e1a..87a39108774b30 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.cs @@ -276,9 +276,10 @@ public override unsafe ReadOnlySpan Name { get { - if (_namePointer != null) + byte* namePointer = _namePointer; + if (namePointer != null) { - return new ReadOnlySpan(_namePointer, _nameLength); + return new ReadOnlySpan(namePointer, _nameLength); } return InitializeName(); } @@ -296,9 +297,10 @@ public override unsafe ReadOnlySpan Namespace { get { - if (_namespacePointer != null) + byte* namespacePointer = _namespacePointer; + if (namespacePointer != null) { - return new ReadOnlySpan(_namespacePointer, _namespaceLength); + return new ReadOnlySpan(namespacePointer, _namespaceLength); } return InitializeNamespace(); } From def8af1fdf1a1c050268376a8e9d47bcf6db5566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 11 Sep 2025 13:59:59 +0200 Subject: [PATCH 19/19] ilverify tests --- src/tests/ilverify/TestDataLoader.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/ilverify/TestDataLoader.cs b/src/tests/ilverify/TestDataLoader.cs index be91d80cde6a7e..92769dc2a028a9 100644 --- a/src/tests/ilverify/TestDataLoader.cs +++ b/src/tests/ilverify/TestDataLoader.cs @@ -174,7 +174,7 @@ private static List GetTestMethodsFromDll(Func