From 5c26bb3071d983a7e6fc4a3cc17d4c2aab88db24 Mon Sep 17 00:00:00 2001 From: Nicolas Portmann Date: Wed, 1 Jul 2020 22:59:26 +0200 Subject: [PATCH 1/2] Align SpecializeComparer with ComparerHelpers --- src/coreclr/src/vm/compile.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/coreclr/src/vm/compile.cpp b/src/coreclr/src/vm/compile.cpp index bc3f4cae984f59..b42994f69d268a 100644 --- a/src/coreclr/src/vm/compile.cpp +++ b/src/coreclr/src/vm/compile.cpp @@ -4803,7 +4803,7 @@ static BOOL CanSatisfyConstraints(Instantiation typicalInst, Instantiation candi // -// This method has duplicated logic from bcl\system\collections\generic\comparer.cs +// This method has duplicated logic from coreclr\src\System.Private.CoreLib\src\System\Collections\Generic\ComparerHelpers.cs // static void SpecializeComparer(SString& ss, Instantiation& inst) { @@ -4843,26 +4843,14 @@ static void SpecializeComparer(SString& ss, Instantiation& inst) CorElementType et = elemTypeHnd.GetVerifierCorElementType(); if (et == ELEMENT_TYPE_I1 || et == ELEMENT_TYPE_I2 || - et == ELEMENT_TYPE_I4) - { - ss.Set(W("System.Collections.Generic.Int32EnumComparer`1")); - return; - } - if (et == ELEMENT_TYPE_U1 || + et == ELEMENT_TYPE_I4 || + et == ELEMENT_TYPE_I8 || + et == ELEMENT_TYPE_U1 || et == ELEMENT_TYPE_U2 || - et == ELEMENT_TYPE_U4) - { - ss.Set(W("System.Collections.Generic.UInt32EnumComparer`1")); - return; - } - if (et == ELEMENT_TYPE_I8) - { - ss.Set(W("System.Collections.Generic.Int64EnumComparer`1")); - return; - } - if (et == ELEMENT_TYPE_U8) + et == ELEMENT_TYPE_U4 || + et == ELEMENT_TYPE_U8) { - ss.Set(W("System.Collections.Generic.UInt64EnumComparer`1")); + ss.Set(W("System.Collections.Generic.EnumComparer`1")); return; } } From 4b6d0151878c089f32c6b77c09b25612ade8aaf1 Mon Sep 17 00:00:00 2001 From: Nicolas Portmann Date: Wed, 1 Jul 2020 23:27:16 +0200 Subject: [PATCH 2/2] Align SpecializeEqualityComparer with ComparerHelpers --- src/coreclr/src/vm/compile.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/coreclr/src/vm/compile.cpp b/src/coreclr/src/vm/compile.cpp index b42994f69d268a..90673d7e2a7a12 100644 --- a/src/coreclr/src/vm/compile.cpp +++ b/src/coreclr/src/vm/compile.cpp @@ -4857,7 +4857,7 @@ static void SpecializeComparer(SString& ss, Instantiation& inst) } // -// This method has duplicated logic from bcl\system\collections\generic\equalitycomparer.cs +// This method has duplicated logic from coreclr\src\System.Private.CoreLib\src\System\Collections\Generic\ComparerHelpers.cs // and matching logic in jitinterface.cpp // static void SpecializeEqualityComparer(SString& ss, Instantiation& inst) @@ -4895,25 +4895,19 @@ static void SpecializeEqualityComparer(SString& ss, Instantiation& inst) if (elemTypeHnd.IsEnum()) { - // Note: We have different comparers for Short and SByte because for those types we need to make sure we call GetHashCode on the actual underlying type as the - // implementation of GetHashCode is more complex than for the other types. CorElementType et = elemTypeHnd.GetVerifierCorElementType(); - if (et == ELEMENT_TYPE_I4 || - et == ELEMENT_TYPE_U4 || - et == ELEMENT_TYPE_U2 || + if (et == ELEMENT_TYPE_I1 || et == ELEMENT_TYPE_I2 || + et == ELEMENT_TYPE_I4 || + et == ELEMENT_TYPE_I8 || et == ELEMENT_TYPE_U1 || - et == ELEMENT_TYPE_I1) + et == ELEMENT_TYPE_U2 || + et == ELEMENT_TYPE_U4 || + et == ELEMENT_TYPE_U8) { ss.Set(W("System.Collections.Generic.EnumEqualityComparer`1")); return; } - else if (et == ELEMENT_TYPE_I8 || - et == ELEMENT_TYPE_U8) - { - ss.Set(W("System.Collections.Generic.LongEnumEqualityComparer`1")); - return; - } } }