diff --git a/src/coreclr/tools/Common/Compiler/EventPseudoDesc.cs b/src/coreclr/tools/Common/Compiler/EventPseudoDesc.cs index 287d86cdee7687..02d0cbe811ca7e 100644 --- a/src/coreclr/tools/Common/Compiler/EventPseudoDesc.cs +++ b/src/coreclr/tools/Common/Compiler/EventPseudoDesc.cs @@ -93,7 +93,16 @@ public EventPseudoDesc(EcmaType type, EventDefinitionHandle handle) public override string ToString() => $"{_type}.{Name}"; - public static bool operator ==(EventPseudoDesc a, EventPseudoDesc b) => a._type == b._type && a._handle == b._handle; + public static bool operator ==(EventPseudoDesc a, EventPseudoDesc b) + { + if (a is null) + return b is null; + + if (b is null) + return false; + + return a._type == b._type && a._handle == b._handle; + } public static bool operator !=(EventPseudoDesc a, EventPseudoDesc b) => !(a == b); } diff --git a/src/coreclr/tools/Common/Compiler/PropertyPseudoDesc.cs b/src/coreclr/tools/Common/Compiler/PropertyPseudoDesc.cs index 2ceb2d9eda75de..af03919dc4c48b 100644 --- a/src/coreclr/tools/Common/Compiler/PropertyPseudoDesc.cs +++ b/src/coreclr/tools/Common/Compiler/PropertyPseudoDesc.cs @@ -88,7 +88,16 @@ public PropertyPseudoDesc(EcmaType type, PropertyDefinitionHandle handle) public override string ToString() => $"{_type}.{Name}"; - public static bool operator ==(PropertyPseudoDesc a, PropertyPseudoDesc b) => a._type == b._type && a._handle == b._handle; + public static bool operator ==(PropertyPseudoDesc a, PropertyPseudoDesc b) + { + if (a is null) + return b is null; + + if (b is null) + return false; + + return a._type == b._type && a._handle == b._handle; + } public static bool operator !=(PropertyPseudoDesc a, PropertyPseudoDesc b) => !(a == b); } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs index accf88bec29fce..5a5a45b5240c38 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs @@ -208,7 +208,7 @@ public ModuleAndIntValueKey(int integer, EcmaModule module) Module = module; } - public bool Equals(ModuleAndIntValueKey other) => IntValue == other.IntValue && ((Module == null && other.Module == null) || Module.Equals(other.Module)); + public bool Equals(ModuleAndIntValueKey other) => IntValue == other.IntValue && Module == other.Module; public override bool Equals(object obj) => obj is ModuleAndIntValueKey && Equals((ModuleAndIntValueKey)obj); public override int GetHashCode() { diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs index d0ca5431be42d0..41a70f79c87f65 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs @@ -633,20 +633,6 @@ public Import GenericLookupHelper( (MethodWithToken)helperArgument, methodContext); - case ReadyToRunHelperId.MethodDictionary: - return GenericLookupMethodHelper( - runtimeLookupKind, - ReadyToRunFixupKind.MethodHandle, - (MethodWithToken)helperArgument, - methodContext); - - case ReadyToRunHelperId.TypeDictionary: - return GenericLookupTypeHelper( - runtimeLookupKind, - ReadyToRunFixupKind.TypeDictionary, - (TypeDesc)helperArgument, - methodContext); - case ReadyToRunHelperId.VirtualDispatchCell: return GenericLookupMethodHelper( runtimeLookupKind, diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs index 547458296fd024..90215c273ff83e 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs @@ -655,13 +655,14 @@ public bool IsInheritanceChainLayoutFixedInCurrentVersionBubble(TypeDesc type) if (CompilationModuleGroup.TypeLayoutCompilationUnits(type).HasMultipleInexactCompilationUnits) return false; - while (!type.IsObject && type != null) + while (!type.IsObject) { if (!IsLayoutFixedInCurrentVersionBubble(type)) { return false; } type = type.BaseType; + Debug.Assert(type != null); } } diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/TypeSystem/Mutable/MutableModule.Sorting.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/TypeSystem/Mutable/MutableModule.Sorting.cs index e6676ff7d0a2d3..28c1823b5d4ec7 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/TypeSystem/Mutable/MutableModule.Sorting.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/TypeSystem/Mutable/MutableModule.Sorting.cs @@ -1,22 +1,17 @@ // 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.Threading; - using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem.Ecma { partial class MutableModule { - // This isn't deterministic, but it is functional. At this time, since only 1 MutableModule is contained in a build, it will be deterministic as it will always return 0. - static int s_globalIndex = 0; - - int _index = Interlocked.Increment(ref s_globalIndex); + // There is only ever a single MutableModule in a build, so any comparison is against itself. public int CompareTo(MutableModule other) { - return _index.CompareTo(_index); + Debug.Assert(this == other); + return 0; } } }