Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make getTypeForPrimitiveValueClass treat different signs as different types #71633

Merged
merged 4 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 6 additions & 50 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -13938,7 +13894,7 @@ BOOL LoadDynamicInfoEntry(Module *currentModule,
{
DWORD dwBlobSize = CorSigUncompressData(pBlob);
const uint8_t *const pBlobStart = pBlob;
pBlob += dwBlobSize;
pBlob += dwBlobSize;
StackSArray<TypeHandle> types;
DWORD cTypes = CorSigUncompressData(pBlob);
bool fail = false;
Expand All @@ -13965,7 +13921,7 @@ BOOL LoadDynamicInfoEntry(Module *currentModule,
}

MethodDesc *pMDCompare = NULL;

if (!fail)
{
if (kind == ENCODE_CHECK_IL_BODY)
Expand Down Expand Up @@ -13995,7 +13951,7 @@ BOOL LoadDynamicInfoEntry(Module *currentModule,

fail = fail || (pMethodMetadata->cByteData != dwBlobSize);
}

if (!fail)
{
fail = 0 != memcmp(pBlobStart, pMethodMetadata->pByteData, dwBlobSize);
Expand Down
45 changes: 45 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_71632/Runtime_71632.cs
Original file line number Diff line number Diff line change
@@ -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<T>(ref T arg) { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>