Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 96d7b6f

Browse files
Implement initThisClass for generic types in ReadyToRun (#7842)
Only implementing the RyuJIT portion for CoreRT purposes (CoreRT side at dotnet/corert#2085). I can file an issue to add support for this in CoreCLR if there's interest. On CoreCLR this is currently a disqualification from ReadyToRun and causes fallback to JITting.
1 parent 0061932 commit 96d7b6f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/jit/morph.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16209,6 +16209,23 @@ GenTreePtr Compiler::fgInitThisClass()
1620916209
}
1621016210
else
1621116211
{
16212+
#ifdef FEATURE_READYTORUN_COMPILER
16213+
// Only CoreRT understands CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE. Don't do this on CoreCLR.
16214+
if (opts.IsReadyToRun() && eeGetEEInfo()->targetAbi == CORINFO_CORERT_ABI)
16215+
{
16216+
CORINFO_RESOLVED_TOKEN resolvedToken;
16217+
ZeroMemory(&resolvedToken, sizeof(resolvedToken));
16218+
16219+
GenTreePtr ctxTree = getRuntimeContextTree(kind.runtimeLookupKind);
16220+
16221+
// CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE with a zeroed out resolvedToken means "get the static
16222+
// base of the class that owns the method being compiled". If we're in this method, it means we're not
16223+
// inlining and there's no ambiguity.
16224+
return impReadyToRunHelperToTree(&resolvedToken, CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE, TYP_BYREF,
16225+
gtNewArgList(ctxTree), &kind);
16226+
}
16227+
#endif
16228+
1621216229
// Collectible types requires that for shared generic code, if we use the generic context paramter
1621316230
// that we report it. (This is a conservative approach, we could detect some cases particularly when the
1621416231
// context parameter is this that we don't need the eager reporting logic.)

0 commit comments

Comments
 (0)