Skip to content

Commit a6f6f13

Browse files
committed
Remove IsClass and IsPrimitive
1 parent 75d5c84 commit a6f6f13

12 files changed

Lines changed: 16 additions & 304 deletions

File tree

src/coreclr/src/ToolBox/superpmi/superpmi-shim-collector/icorjitcompiler.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ CorJitResult __stdcall interceptor_ICJC::compileMethod(ICorJitInfo*
4747
our_ICorJitInfo.getBuiltinClass(CLASSID_STRING);
4848
our_ICorJitInfo.getBuiltinClass(CLASSID_ARGUMENT_HANDLE);
4949
our_ICorJitInfo.getBuiltinClass(CLASSID_RUNTIME_TYPE);
50-
our_ICorJitInfo.getBuiltinClass(CLASSID_ENUM);
51-
our_ICorJitInfo.getBuiltinClass(CLASSID___CANON);
5250

5351
#ifdef fatMC
5452
// to build up a fat mc

src/coreclr/src/inc/corinfo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,8 +1012,6 @@ enum CorInfoClassId
10121012
CLASSID_STRING,
10131013
CLASSID_ARGUMENT_HANDLE,
10141014
CLASSID_RUNTIME_TYPE,
1015-
CLASSID_ENUM,
1016-
CLASSID___CANON,
10171015
};
10181016

10191017
enum CorInfoInline

src/coreclr/src/jit/importer.cpp

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4015,15 +4015,12 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
40154015
break;
40164016
}
40174017

4018-
case NI_System_Type_get_IsClass:
4019-
case NI_System_Type_get_IsPrimitive:
40204018
case NI_System_Type_get_IsValueType:
40214019
{
4022-
// Optimize things like
4020+
// Optimize
40234021
//
4024-
// ldtoken [Type]
40254022
// call Type.GetTypeFromHandle (which is replaced with CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE)
4026-
// call Type.IsValueType (also IsClass and IsPrimitive)
4023+
// call Type.IsValueType
40274024
//
40284025
// to `true` or `false`
40294026
// e.g. `typeof(int).IsValueType` => `true`
@@ -4033,51 +4030,13 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
40334030
if (call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE))
40344031
{
40354032
CORINFO_CLASS_HANDLE hClass = gtGetHelperArgClassHandle(call->gtCallArgs->GetNode());
4036-
if (hClass == NO_CLASS_HANDLE || hClass == info.compCompHnd->getBuiltinClass(CLASSID___CANON))
4033+
if (hClass != NO_CLASS_HANDLE)
40374034
{
4038-
// Ignore System.__Canon
4039-
break;
4040-
}
4041-
4042-
BOOL isValueType = eeIsValueClass(hClass);
4043-
CorInfoType cit = info.compCompHnd->getTypeForPrimitiveValueClass(hClass);
4044-
if (ni == NI_System_Type_get_IsPrimitive)
4045-
{
4046-
if (isValueType && (cit >= CORINFO_TYPE_BOOL) && (cit <= CORINFO_TYPE_DOUBLE))
4047-
{
4048-
// Enums are not primitive types
4049-
BOOL isEnum = info.compCompHnd->getBuiltinClass(CLASSID_ENUM) ==
4050-
info.compCompHnd->getParentType(hClass);
4051-
retNode = gtNewIconNode(!isEnum ? 1 : 0);
4052-
}
4053-
else
4054-
{
4055-
retNode = gtNewIconNode(0);
4056-
}
4057-
}
4058-
else if (ni == NI_System_Type_get_IsClass)
4059-
{
4060-
// Pointers are also classes (e.g. typeof(int*).IsClass is true)
4061-
if (isValueType && (cit != CORINFO_TYPE_PTR))
4062-
{
4063-
retNode = gtNewIconNode(0);
4064-
}
4065-
else
4066-
{
4067-
BOOL isInterface = info.compCompHnd->getClassAttribs(hClass) & CORINFO_FLG_INTERFACE;
4068-
retNode = gtNewIconNode(isInterface ? 0 : 1);
4069-
}
4035+
retNode = gtNewIconNode((eeIsValueClass(hClass) &&
4036+
// pointers are not value types (e.g. typeof(int*).IsValueType is false)
4037+
info.compCompHnd->getTypeForPrimitiveValueClass(hClass) != CORINFO_TYPE_PTR) ? 1 : 0);
4038+
impPopStack(); // drop CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE call
40704039
}
4071-
else if (ni == NI_System_Type_get_IsValueType)
4072-
{
4073-
retNode = gtNewIconNode((isValueType && (cit != CORINFO_TYPE_PTR)) ? 1 : 0);
4074-
}
4075-
else
4076-
{
4077-
assert(false);
4078-
}
4079-
// drop CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE call
4080-
impPopStack();
40814040
}
40824041
}
40834042
break;
@@ -4380,14 +4339,6 @@ NamedIntrinsic Compiler::lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method)
43804339
{
43814340
result = NI_System_Type_get_IsValueType;
43824341
}
4383-
else if (strcmp(methodName, "get_IsClass") == 0)
4384-
{
4385-
result = NI_System_Type_get_IsClass;
4386-
}
4387-
else if (strcmp(methodName, "get_IsPrimitive") == 0)
4388-
{
4389-
result = NI_System_Type_get_IsPrimitive;
4390-
}
43914342
}
43924343
}
43934344
#if defined(_TARGET_XARCH_) // We currently only support BSWAP on x86

src/coreclr/src/jit/namedintrinsiclist.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ enum NamedIntrinsic : unsigned short
2020
NI_System_Buffers_Binary_BinaryPrimitives_ReverseEndianness,
2121
NI_System_GC_KeepAlive,
2222
NI_System_Type_get_IsValueType,
23-
NI_System_Type_get_IsClass,
24-
NI_System_Type_get_IsPrimitive,
2523

2624
#ifdef FEATURE_HW_INTRINSICS
2725
NI_IsSupported_True,

src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,12 +1689,6 @@ private CorInfoInitClassResult initClass(CORINFO_FIELD_STRUCT_* field, CORINFO_M
16891689
TypeDesc typeOfRuntimeType = _compilation.GetTypeOfRuntimeType();
16901690
return typeOfRuntimeType != null ? ObjectToHandle(typeOfRuntimeType) : null;
16911691

1692-
case CorInfoClassId.CLASSID_ENUM:
1693-
return ObjectToHandle(_compilation.TypeSystemContext.GetWellKnownType(WellKnownType.Enum));
1694-
1695-
case CorInfoClassId.CLASSID___CANON:
1696-
return ObjectToHandle(_compilation.TypeSystemContext.GetWellKnownType(WellKnownType.__Canon));
1697-
16981692
default:
16991693
throw new NotImplementedException();
17001694
}

src/coreclr/src/tools/Common/JitInterface/CorInfoTypes.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,6 @@ public enum CorInfoClassId
492492
CLASSID_STRING,
493493
CLASSID_ARGUMENT_HANDLE,
494494
CLASSID_RUNTIME_TYPE,
495-
CLASSID_ENUM,
496-
CLASSID___CANON,
497495
}
498496
public enum CorInfoInline
499497
{

src/coreclr/src/tools/Common/TypeSystem/Common/TypeDesc.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ internal void SetWellKnownType(WellKnownType wellKnownType)
120120
flags = TypeFlags.ValueType;
121121
break;
122122

123-
// Should WellKnownType.__Canon be handled here?
124-
125123
default:
126124
throw new ArgumentException();
127125
}

src/coreclr/src/tools/Common/TypeSystem/Common/WellKnownType.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,5 @@ public enum WellKnownType
4848

4949
TypedReference,
5050
ByReferenceOfT,
51-
__Canon,
5251
}
5352
}

src/coreclr/src/vm/jitinterface.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4310,12 +4310,6 @@ CORINFO_CLASS_HANDLE CEEInfo::getBuiltinClass(CorInfoClassId classId)
43104310
case CLASSID_RUNTIME_TYPE:
43114311
result = CORINFO_CLASS_HANDLE(g_pRuntimeTypeClass);
43124312
break;
4313-
case CLASSID_ENUM:
4314-
result = CORINFO_CLASS_HANDLE(g_pEnumClass);
4315-
break;
4316-
case CLASSID___CANON:
4317-
result = CORINFO_CLASS_HANDLE(g_pCanonMethodTableClass);
4318-
break;
43194313
default:
43204314
_ASSERTE(!"NYI: unknown classId");
43214315
break;

0 commit comments

Comments
 (0)