Skip to content
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
54 changes: 5 additions & 49 deletions src/coreclr/src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3447,8 +3447,8 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,

if ((methodFlags & CORINFO_FLG_JIT_INTRINSIC) != 0)
{
// The recursive non-virtual calls to Jit intrinsics are must-expand by convention.
mustExpand = mustExpand || (gtIsRecursiveCall(method) && !(methodFlags & CORINFO_FLG_VIRTUAL));
// The recursive calls to Jit intrinsics are must-expand by convention.
mustExpand = mustExpand || gtIsRecursiveCall(method);

if (intrinsicID == CORINFO_INTRINSIC_Illegal)
{
Expand Down Expand Up @@ -4014,49 +4014,6 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
break;
}

case NI_System_Type_IsAssignableFrom:
{
// Optimize patterns like:
//
// typeof(TTo).IsAssignableFrom(typeof(TTFrom))
// valueTypeVar.GetType().IsAssignableFrom(typeof(TTFrom))
//
// to true/false
GenTree* typeTo = impStackTop(1).val;
GenTree* typeFrom = impStackTop(0).val;

if (typeTo->IsCall() && typeFrom->IsCall())
{
// make sure both arguments are `typeof()`
CORINFO_METHOD_HANDLE hTypeof = eeFindHelper(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE);
if ((typeTo->AsCall()->gtCallMethHnd == hTypeof) && (typeFrom->AsCall()->gtCallMethHnd == hTypeof))
{
CORINFO_CLASS_HANDLE hClassTo =
gtGetHelperArgClassHandle(typeTo->AsCall()->gtCallArgs->GetNode());
CORINFO_CLASS_HANDLE hClassFrom =
gtGetHelperArgClassHandle(typeFrom->AsCall()->gtCallArgs->GetNode());

if (hClassTo == NO_CLASS_HANDLE || hClassFrom == NO_CLASS_HANDLE)
{
break;
}

TypeCompareState castResult = info.compCompHnd->compareTypesForCast(hClassFrom, hClassTo);
if (castResult == TypeCompareState::May)
{
// requires runtime check
// e.g. __Canon, COMObjects, Nullable
break;
}

retNode = gtNewIconNode((castResult == TypeCompareState::Must) ? 1 : 0);
impPopStack(); // drop both CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE calls
impPopStack();
}
}
break;
}

case NI_System_Type_get_IsValueType:
{
// Optimize
Expand Down Expand Up @@ -4384,10 +4341,6 @@ NamedIntrinsic Compiler::lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method)
{
result = NI_System_Type_get_IsValueType;
}
else if (strcmp(methodName, "IsAssignableFrom") == 0)
{
result = NI_System_Type_IsAssignableFrom;
}
}
}
#if defined(TARGET_XARCH) // We currently only support BSWAP on x86
Expand Down Expand Up @@ -7650,6 +7603,9 @@ var_types Compiler::impImportCall(OPCODE opcode,

if (call != nullptr)
{
assert(!(mflags & CORINFO_FLG_VIRTUAL) || (mflags & CORINFO_FLG_FINAL) ||
(clsFlags & CORINFO_FLG_FINAL));

#ifdef FEATURE_READYTORUN_COMPILER
if (call->OperGet() == GT_INTRINSIC)
{
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/src/jit/namedintrinsiclist.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ enum NamedIntrinsic : unsigned short
NI_System_Buffers_Binary_BinaryPrimitives_ReverseEndianness,
NI_System_GC_KeepAlive,
NI_System_Type_get_IsValueType,
NI_System_Type_IsAssignableFrom,

#ifdef FEATURE_HW_INTRINSICS
NI_IsSupported_True,
Expand Down

This file was deleted.

16 changes: 7 additions & 9 deletions src/coreclr/tests/src/JIT/Intrinsics/TypeIntrinsics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;

public partial class Program
public class Program
{
private static int _errors = 0;

Expand Down Expand Up @@ -98,8 +98,6 @@ public static int Main(string[] args)
ThrowsNRE(() => { IsValueTypeRef(ref _varNullableIntNull); });
ThrowsNRE(() => { IsValueTypeRef(ref _varStringNull); });

TestIsAssignableFrom();

return 100 + _errors;
}

Expand Down Expand Up @@ -137,25 +135,25 @@ public static int Main(string[] args)
private static dynamic CreateDynamic2() => new { Name = "Test" };


static void IsTrue(bool expression, [CallerLineNumber] int line = 0, [CallerFilePath] string file = "")
static void IsTrue(bool expression, [CallerLineNumber] int line = 0)
{
if (!expression)
{
Console.WriteLine($"{file}:L{line} test failed (expected: true).");
Console.WriteLine($"Line {line}: test failed (expected: true).");
_errors++;
}
}

static void IsFalse(bool expression, [CallerLineNumber] int line = 0, [CallerFilePath] string file = "")
static void IsFalse(bool expression, [CallerLineNumber] int line = 0)
{
if (expression)
{
Console.WriteLine($"{file}:L{line} test failed (expected: false).");
Console.WriteLine($"Line {line}: test failed (expected: false).");
_errors++;
}
}

static void ThrowsNRE(Action action, [CallerLineNumber] int line = 0, [CallerFilePath] string file = "")
static void ThrowsNRE(Action action, [CallerLineNumber] int line = 0)
{
try
{
Expand All @@ -167,7 +165,7 @@ static void ThrowsNRE(Action action, [CallerLineNumber] int line = 0, [CallerFil
}
catch (Exception exc)
{
Console.WriteLine($"{file}:L{line} {exc}");
Console.WriteLine($"Line {line}: {exc}");
}
Console.WriteLine($"Line {line}: test failed (expected: NullReferenceException)");
}
Expand Down
Loading