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

JIT: Don't allocate string literals inside potential BBJ_THROW candidates #50112

Merged
merged 3 commits into from
Mar 26, 2021
Merged
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
12 changes: 12 additions & 0 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9588,7 +9588,19 @@ GenTree* Compiler::fgMorphConst(GenTree* tree)
// guarantee slow performance for that block. Instead cache the return value
// of CORINFO_HELP_STRCNS and go to cache first giving reasonable perf.

bool useLazyStrCns = false;
if (compCurBB->bbJumpKind == BBJ_THROW)
{
useLazyStrCns = true;
}
else if (fgGlobalMorph && compCurStmt->GetRootNode()->IsCall())
{
// Quick check: if the root node of the current statement happens to be a noreturn call.
GenTreeCall* call = compCurStmt->GetRootNode()->AsCall();
useLazyStrCns = call->IsNoReturn() || fgIsThrow(call);
}

if (useLazyStrCns)
{
CorInfoHelpFunc helper = info.compCompHnd->getLazyStringLiteralHelper(tree->AsStrCon()->gtScpHnd);
if (helper != CORINFO_HELP_UNDEF)
Expand Down