Skip to content

Commit

Permalink
JIT: allow CORINFO_HELP_READYTORUN_GENERIC_HANDLE to be optimized
Browse files Browse the repository at this point in the history
This helper is idempotent and exception free, so enable it for value numbering.
Also, no need to spill the entire eval stack for a virtual stub calls.

Addresses part of dotnet#7723.
  • Loading branch information
AndyAyersMS committed Mar 27, 2020
1 parent 25fdaa8 commit 0d6d4be
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7636,7 +7636,7 @@ var_types Compiler::impImportCall(OPCODE opcode,
// it may cause registered args to be spilled. Simply spill it.

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

// Create the actual call node
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/src/jit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,7 @@ void HelperCallProperties::init()
case CORINFO_HELP_RUNTIMEHANDLE_CLASS:
case CORINFO_HELP_RUNTIMEHANDLE_METHOD_LOG:
case CORINFO_HELP_RUNTIMEHANDLE_CLASS_LOG:
case CORINFO_HELP_READYTORUN_GENERIC_HANDLE:
// logging helpers are not technically pure but can be optimized away
isPure = true;
noThrow = true;
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/src/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8825,6 +8825,7 @@ void Compiler::fgValueNumberHelperCallFunc(GenTreeCall* call, VNFunc vnf, ValueN
case VNF_ReadyToRunGenericStaticBase:
case VNF_ReadyToRunIsInstanceOf:
case VNF_ReadyToRunCastClass:
case VNF_ReadyToRunGenericHandle:
{
useEntryPointAddrAsArg0 = true;
}
Expand Down Expand Up @@ -9220,6 +9221,10 @@ VNFunc Compiler::fgValueNumberJitHelperMethodVNFunc(CorInfoHelpFunc helpFunc)
vnf = VNF_RuntimeHandleMethod;
break;

case CORINFO_HELP_READYTORUN_GENERIC_HANDLE:
vnf = VNF_ReadyToRunGenericHandle;
break;

case CORINFO_HELP_RUNTIMEHANDLE_CLASS:
case CORINFO_HELP_RUNTIMEHANDLE_CLASS_LOG:
vnf = VNF_RuntimeHandleClass;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/src/jit/valuenumfuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ ValueNumFuncDef(GetsharedNongcthreadstaticBaseDynamicclass, 2, false, true, true
ValueNumFuncDef(ClassinitSharedDynamicclass, 2, false, false, false)
ValueNumFuncDef(RuntimeHandleMethod, 2, false, true, false)
ValueNumFuncDef(RuntimeHandleClass, 2, false, true, false)
ValueNumFuncDef(ReadyToRunGenericHandle, 2, false, true, false)

ValueNumFuncDef(GetStaticAddrContext, 1, false, true, false)
ValueNumFuncDef(GetStaticAddrTLS, 1, false, true, false)
Expand Down

0 comments on commit 0d6d4be

Please sign in to comment.