Skip to content

Commit

Permalink
JIT: add more inlining bail out checks (#72795)
Browse files Browse the repository at this point in the history
When inlining, new temp allocation may fail, and callers of methods
that allocate new temps must do suitable checks.

Add a few that were missing.

Fixes #64787.
  • Loading branch information
AndyAyersMS committed Jul 25, 2022
1 parent bbdd837 commit 193fd53
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9682,16 +9682,30 @@ var_types Compiler::impImportCall(OPCODE opcode,
}

GenTree* stubAddr = impRuntimeLookupToTree(pResolvedToken, &callInfo->stubLookup, methHnd);
assert(!compDonotInline());

// stubAddr tree may require a new temp.
// If we're inlining, this may trigger the too many locals inline failure.
//
// If so, we need to bail out.
//
if (compDonotInline())
{
return TYP_UNDEF;
}

// This is the rough code to set up an indirect stub call
assert(stubAddr != nullptr);

// The stubAddr may be a
// complex expression. As it is evaluated after the args,
// it may cause registered args to be spilled. Simply spill it.
//
unsigned const lclNum = lvaGrabTemp(true DEBUGARG("VirtualCall with runtime lookup"));
if (compDonotInline())
{
return TYP_UNDEF;
}

unsigned lclNum = lvaGrabTemp(true DEBUGARG("VirtualCall with runtime lookup"));
impAssignTempGen(lclNum, stubAddr, (unsigned)CHECK_SPILL_NONE);
stubAddr = gtNewLclvNode(lclNum, TYP_I_IMPL);

Expand Down

0 comments on commit 193fd53

Please sign in to comment.