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

Optimize GetType with known type #87579

Closed
wants to merge 30 commits into from
Closed
Changes from 7 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b753523
Optimize GetType with known type
MichalPetryka Jun 14, 2023
5862a59
Keep side effects
MichalPetryka Jun 14, 2023
41f70ed
Update importercalls.cpp
MichalPetryka Jun 14, 2023
7448b59
Update importercalls.cpp
MichalPetryka Jun 15, 2023
929d18f
Update importercalls.cpp
MichalPetryka Jun 15, 2023
779a799
Update importercalls.cpp
MichalPetryka Jun 15, 2023
4de198e
Update importercalls.cpp
MichalPetryka Jun 15, 2023
7f44e8f
Check if box is at fault here
MichalPetryka Jun 16, 2023
127bd47
Update importer.cpp
MichalPetryka Jun 16, 2023
0e62429
Sprinkle some asserts
MichalPetryka Jun 21, 2023
cde9a24
Fix building
MichalPetryka Jun 21, 2023
dcf25a8
Update importercalls.cpp
MichalPetryka Jun 23, 2023
6abbd7b
Update importercalls.cpp
MichalPetryka Jun 23, 2023
4b35aa9
Format code
MichalPetryka Jun 23, 2023
eb56645
Merge
MichalPetryka Jun 23, 2023
6a60fc0
Try fixing the r2r test
MichalPetryka Jun 23, 2023
cbe32bf
Update test.cs
MichalPetryka Jun 24, 2023
a128856
Update main.cs
MichalPetryka Jun 24, 2023
f573051
Update newarray.cs
MichalPetryka Jun 24, 2023
f2dad1d
Update generics.cs
MichalPetryka Jun 24, 2023
a1b6fd7
Update gentree.cpp
MichalPetryka Jun 27, 2023
b61f1e1
Update gentree.cpp
MichalPetryka Jun 27, 2023
be56999
Update lclvars.cpp
MichalPetryka Jun 27, 2023
c95231a
Update lclvars.cpp
MichalPetryka Jun 27, 2023
0885714
Merge branch 'dotnet:main' into gettype-exacttype
MichalPetryka Jun 28, 2023
e1514e4
Merge
MichalPetryka Jul 10, 2023
ff1adcd
Revert separated changes
MichalPetryka Jul 10, 2023
cf9e771
Cleanup
MichalPetryka Jul 10, 2023
32c2b3a
Fix the helper
MichalPetryka Jul 11, 2023
75163fd
Update src/coreclr/jit/importer.cpp
MichalPetryka Jul 11, 2023
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
24 changes: 24 additions & 0 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3635,6 +3635,30 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
}
}

// Load handle directly for known types
if (retNode == nullptr)
{
bool isExact = false;
bool notNull = false;
CORINFO_CLASS_HANDLE typeHnd = gtGetClassHandle(op1, &isExact, &notNull);
if ((typeHnd != NO_CLASS_HANDLE) && isExact &&
((info.compCompHnd->getClassAttribs(typeHnd) & (CORINFO_FLG_SHAREDINST | CORINFO_FLG_GENERIC_TYPE_VARIABLE)) != 0))
MichalPetryka marked this conversation as resolved.
Show resolved Hide resolved
{
JITDUMP("Optimizing object.GetType() with known type to typeof\n");
op1 = impPopStack().val;
if (!notNull && fgAddrCouldBeNull(op1))
{
impAppendTree(gtNewNullCheck(op1, compCurBB), CHECK_SPILL_ALL, impCurStmtDI);
}
else if ((op1->gtFlags & GTF_SIDE_EFFECT) != 0)
{
impAppendTree(gtUnusedValNode(op1), CHECK_SPILL_ALL, impCurStmtDI);
}
GenTree* handle = gtNewIconEmbClsHndNode(typeHnd);
retNode = gtNewHelperCallNode(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE, TYP_REF, handle);
}
}

#ifdef DEBUG
if (retNode != nullptr)
{
Expand Down