diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index ea91727f15023..29ba345bada96 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3969,54 +3969,10 @@ CorInfoType CEEInfo::getTypeForPrimitiveValueClass( } else { - switch (th.GetInternalCorElementType()) + CorElementType elementType = th.GetInternalCorElementType(); + if (CorIsPrimitiveType(elementType)) { - case ELEMENT_TYPE_I1: - case ELEMENT_TYPE_U1: - case ELEMENT_TYPE_BOOLEAN: - result = asCorInfoType(ELEMENT_TYPE_I1); - break; - - case ELEMENT_TYPE_I2: - case ELEMENT_TYPE_U2: - case ELEMENT_TYPE_CHAR: - result = asCorInfoType(ELEMENT_TYPE_I2); - break; - - case ELEMENT_TYPE_I4: - case ELEMENT_TYPE_U4: - result = asCorInfoType(ELEMENT_TYPE_I4); - break; - - case ELEMENT_TYPE_I8: - case ELEMENT_TYPE_U8: - result = asCorInfoType(ELEMENT_TYPE_I8); - break; - - case ELEMENT_TYPE_I: - case ELEMENT_TYPE_U: - result = asCorInfoType(ELEMENT_TYPE_I); - break; - - case ELEMENT_TYPE_R4: - result = asCorInfoType(ELEMENT_TYPE_R4); - break; - - case ELEMENT_TYPE_R8: - result = asCorInfoType(ELEMENT_TYPE_R8); - break; - - case ELEMENT_TYPE_VOID: - result = asCorInfoType(ELEMENT_TYPE_VOID); - break; - - case ELEMENT_TYPE_PTR: - case ELEMENT_TYPE_FNPTR: - result = asCorInfoType(ELEMENT_TYPE_PTR); - break; - - default: - break; + result = asCorInfoType(elementType); } } @@ -13938,7 +13894,7 @@ BOOL LoadDynamicInfoEntry(Module *currentModule, { DWORD dwBlobSize = CorSigUncompressData(pBlob); const uint8_t *const pBlobStart = pBlob; - pBlob += dwBlobSize; + pBlob += dwBlobSize; StackSArray types; DWORD cTypes = CorSigUncompressData(pBlob); bool fail = false; @@ -13965,7 +13921,7 @@ BOOL LoadDynamicInfoEntry(Module *currentModule, } MethodDesc *pMDCompare = NULL; - + if (!fail) { if (kind == ENCODE_CHECK_IL_BODY) @@ -13995,7 +13951,7 @@ BOOL LoadDynamicInfoEntry(Module *currentModule, fail = fail || (pMethodMetadata->cByteData != dwBlobSize); } - + if (!fail) { fail = 0 != memcmp(pBlobStart, pMethodMetadata->pByteData, dwBlobSize); diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_71632/Runtime_71632.cs b/src/tests/JIT/Regression/JitBlue/Runtime_71632/Runtime_71632.cs new file mode 100644 index 0000000000000..73d38c3bc5f49 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_71632/Runtime_71632.cs @@ -0,0 +1,45 @@ +// 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.Numerics; +using System.Runtime.CompilerServices; + +public class Runtime_71632 +{ + public static int Main() + { + try + { + Problem(1); + return 101; + } + catch (InvalidCastException) {} + + try + { + Problem2(1); + return 102; + } + catch (InvalidCastException) {} + + return 100; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static sbyte Problem(byte a) + { + object box = a; + Use(ref box); + return (sbyte)box; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static sbyte Problem2(byte a) + { + object box = a; + return (sbyte)box; + } + + static void Use(ref T arg) { } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_71632/Runtime_71632.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_71632/Runtime_71632.csproj new file mode 100644 index 0000000000000..f492aeac9d056 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_71632/Runtime_71632.csproj @@ -0,0 +1,9 @@ + + + Exe + True + + + + + \ No newline at end of file