-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: fix invocation of unboxed entry when method returns struct #52998
Conversation
If a value class method returns a struct, and its unboxed entry point requires a type context argument, make sure to pass the context argument properly. Also, fetch the type context (method table) from the box, rather than creating it from the class handle we have on hand; this tends to produce smaller code as we're often fetching the method table for other reasons anyways. Closes dotnet#52975.
cc @dotnet/jit-contrib There are likely diffs in asp.net too, but I need to update the collection first. asm.libraries.pmi.windows.x64.checked
Detail diffs
asm.tests_libraries.pmi.windows.x64.checked
Detail diffs
|
ASP.NET diffs
|
Kicked off the experimental CI group to do some PGO testing. That has a few known failures in OSR, so will have to look at the results closely. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a few questions
src/coreclr/jit/importer.cpp
Outdated
@@ -21115,7 +21115,17 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call, | |||
// | |||
if ((Target::g_tgtArgOrder == Target::ARG_ORDER_R2L) || (call->gtCallArgs == nullptr)) | |||
{ | |||
call->gtCallArgs = gtPrependNewCallArg(methodTableArg, call->gtCallArgs); | |||
// If there's a ret buf, the context is the second arg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
// If there's a ret buf, the context is the second arg. | |
// If there's a ret buf, the method table is the second arg. |
src/coreclr/jit/importer.cpp
Outdated
if (call->HasRetBufArg()) | ||
{ | ||
GenTreeCall::Use* const beforeArg = call->gtCallArgs; | ||
beforeArg->SetNext(gtNewCallArgs(methodTableArg)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would gtInsertNewCallArgAfter(methodTableArg, call->gtCallArgs)
work here? If I understand correctly 'gtCallArgspoints to
retBufArgand we need to insert
methodTableArg` after it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would work. You prefer it that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it would be similar to 'else' then I think.
src/coreclr/jit/importer.cpp
Outdated
@@ -21194,26 +21204,26 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call, | |||
// locally, or was boxed locally but we were unable to remove the box for | |||
// various reasons. | |||
// | |||
// We may still be able to update the call to invoke the unboxed entry. | |||
// We can still to update the call to invoke the unboxed entry, if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
// We can still to update the call to invoke the unboxed entry, if the | |
// We can still update the call to invoke the unboxed entry, if the |
src/coreclr/jit/importer.cpp
Outdated
// | ||
// Prepend for R2L arg passing or empty L2R passing | ||
// Append for non-empty L2R | ||
// | ||
if ((Target::g_tgtArgOrder == Target::ARG_ORDER_R2L) || (call->gtCallArgs == nullptr)) | ||
{ | ||
call->gtCallArgs = gtPrependNewCallArg(methodTableArg, call->gtCallArgs); | ||
// If there's a ret buf, the context is the second arg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
src/coreclr/jit/importer.cpp
Outdated
if (call->HasRetBufArg()) | ||
{ | ||
GenTreeCall::Use* const beforeArg = call->gtCallArgs; | ||
beforeArg->SetNext(gtNewCallArgs(methodTableArg)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
Linux arm release libraries: tests succeeded by failed to properly upload status:
OSX failure is another instance of #52710. |
If a value class method returns a struct, and its unboxed entry point
requires a type context argument, make sure to pass the context argument
properly.
Also, fetch the type context (method table) from the box, rather than
creating it from the class handle we have on hand; this tends to produce
smaller code as we're often fetching the method table for other reasons
anyways.
Closes #52975.