Skip to content

[RyuJIT] Make casthelpers cold for sealed classes #49295

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

Merged
merged 3 commits into from
Mar 10, 2021
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
4 changes: 2 additions & 2 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2354,12 +2354,12 @@ bool Compiler::fgOptimizeEmptyBlock(BasicBlock* block)
{
case BBJ_COND:
case BBJ_SWITCH:
case BBJ_THROW:

/* can never happen */
noway_assert(!"Conditional, switch, or throw block with empty body!");
noway_assert(!"Conditional or switch block with empty body!");
break;

case BBJ_THROW:
case BBJ_CALLFINALLY:
case BBJ_RETURN:
case BBJ_EHCATCHRET:
Expand Down
10 changes: 6 additions & 4 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11075,9 +11075,6 @@ GenTree* Compiler::impCastClassOrIsInstToTree(GenTree* op1,
condTrue = gtNewIconNode(0, TYP_REF);
}

#define USE_QMARK_TREES

#ifdef USE_QMARK_TREES
GenTree* qmarkMT;
//
// Generate first QMARK - COLON tree
Expand All @@ -11091,6 +11088,12 @@ GenTree* Compiler::impCastClassOrIsInstToTree(GenTree* op1,
temp = new (this, GT_COLON) GenTreeColon(TYP_REF, condTrue, condFalse);
qmarkMT = gtNewQmarkNode(TYP_REF, condMT, temp);

if (isCastClass && impIsClassExact(pResolvedToken->hClass) && condTrue->OperIs(GT_CALL))
{
// condTrue is used only for throwing InvalidCastException in case of casting to an exact class.
condTrue->AsCall()->gtCallMoreFlags |= GTF_CALL_M_DOES_NOT_RETURN;
}

GenTree* qmarkNull;
//
// Generate second QMARK - COLON tree
Expand Down Expand Up @@ -11119,7 +11122,6 @@ GenTree* Compiler::impCastClassOrIsInstToTree(GenTree* op1,
JITDUMP("Marked V%02u as a single def temp\n", tmp);
lvaSetClass(tmp, pResolvedToken->hClass);
return gtNewLclvNode(tmp, TYP_REF);
#endif
}

#ifndef DEBUG
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17698,6 +17698,11 @@ void Compiler::fgExpandQmarkForCastInstOf(BasicBlock* block, Statement* stmt)
// Finally remove the nested qmark stmt.
fgRemoveStmt(block, stmt);

if (true2Expr->OperIs(GT_CALL) && (true2Expr->AsCall()->gtCallMoreFlags & GTF_CALL_M_DOES_NOT_RETURN))
{
fgConvertBBToThrowBB(helperBlock);
}

#ifdef DEBUG
if (verbose)
{
Expand Down