Skip to content

Widen return values in CallTailCallTarget stubs - #55740

Closed
jakobbotsch wants to merge 3 commits into
dotnet:mainfrom
jakobbotsch:fix-55253
Closed

jakobbotsch wants to merge 3 commits into
dotnet:mainfrom
jakobbotsch:fix-55253

Conversation

@jakobbotsch

Copy link
Copy Markdown
Member

In the managed calling convention the callee is responsible for widening
the return value up to 4 bytes. We need to mimic this in portable
tailcall helpers as the JIT cannot know which call eventually produced
the value that was stored in the return value buffer passed to the
dispatcher.

Fix #55253

In the managed calling convention the callee is responsible for widening
the return value up to 4 bytes. We need to mimic this in portable
tailcall helpers as the JIT cannot know which call eventually produced
the value that was stored in the return value buffer passed to the
dispatcher.

Fix dotnet#55253
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 15, 2021
@jakobbotsch

Copy link
Copy Markdown
Member Author

/azp run runtime-coreclr tailcallstress

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@jakobbotsch

Copy link
Copy Markdown
Member Author

/azp run runtime-coreclr jitstress

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jakobbotsch

Copy link
Copy Markdown
Member Author

@jakobbotsch

Copy link
Copy Markdown
Member Author

/azp run runtime-coreclr jitstress

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jakobbotsch

Copy link
Copy Markdown
Member Author

/azp run runtime

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jakobbotsch

Copy link
Copy Markdown
Member Author

For a little context, we only just recently started making use of the widening done in callees in #54864 which exposed this bug in portable tailcall helpers.

The test failures seem to be unrelated test infra failures. @jkotas PTAL.

if (isSigned)
pCode->EmitCONV_I4();
else
pCode->EmitCONV_U4();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this even needed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not be. EmitLDLOC should do the appropriate widening implicitly.

@jkotas

jkotas commented Jul 19, 2021

Copy link
Copy Markdown
Member

Why does the slow tail call path need to know about this?

If the JIT wants to play calling convention tricks for fast tail calls, it is fine with me. But I think it would be preferable to keep the slow tail call path simple.

@jakobbotsch

Copy link
Copy Markdown
Member Author

The alternative is to reject explicit tail calls when there is implicit widening. That's what the logic has been previously.

I took a look and ECMA-335 does seem to imply that tail. is permissible whenever the callee's return type is assignable-to the caller's return type, which covers these newly allowed scenarios if I'm not wrong.

I don't have a strong opinion. It should not be difficult to reject explicit tailcalls when types are mismatching on the JIT side. Do you think that's better?

@jkotas

jkotas commented Jul 19, 2021

Copy link
Copy Markdown
Member

Yes, I think it would be better to reject explicit tailcalls when the return types do not match exactly, like it was done before.

The platform-specific (or CoreCLR/RyuJIT specific) calling convention details should not be leaking into when tailcalls work or do not work.

@jakobbotsch

Copy link
Copy Markdown
Member Author

Superseded by #55989.

@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test Failure:Microsoft.Extensions.Logging.Generators.Tests.LoggerMessageGeneratorEmitterTests.TestBaseline_TestWithTwoParams_Success

2 participants