Skip to content

JIT: Add support for struct returns from Swift reverse pinvokes - #100091

Merged
jakobbotsch merged 37 commits into
dotnet:mainfrom
jakobbotsch:swift-callback-struct-returns
Mar 23, 2024
Merged

JIT: Add support for struct returns from Swift reverse pinvokes#100091
jakobbotsch merged 37 commits into
dotnet:mainfrom
jakobbotsch:swift-callback-struct-returns

Conversation

@jakobbotsch

Copy link
Copy Markdown
Member

Update the 10 tests to have some struct returns as well.

We also have to change the prestub to save rax since it's used as a register for the ret buffer in Swift calls.

@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Mar 21, 2024
@jakobbotsch

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-coreclr jitstress, runtime-coreclr jitstressregs, runtime-coreclr jitstress2-jitstressregs

@azure-pipelines

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

@jakobbotsch
jakobbotsch marked this pull request as ready for review March 22, 2024 12:37
@jakobbotsch

Copy link
Copy Markdown
MemberAuthor

cc @dotnet/jit-contrib PTAL @amanasifkhalid

Failures look like #99810 and other known failures

FYI @jkurdek@kotlarmilos@matouskozak

@amanasifkhalidamanasifkhalid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

{
printf("Swift compilation returns %s as %d primitive(s) in registers\n",
typGetObjLayout(retTypeHnd)->GetClassName(), lowering->numLoweredElements);
for (size_t i = 0; i < lowering->numLoweredElements; i++)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we dump these lowered element types in a few places now, right? You may want to consider moving this logic to a helper method (though feel free to do that in a future PR).

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Yeah. Makes sense to factor this, let me do that in a follow-up.

@jakobbotsch

Copy link
Copy Markdown
MemberAuthor

Also FYI @jkoritzinsky and cc @jkotas for the stub change.

Comment threadsrc/coreclr/vm/amd64/theprestubamd64.S Outdated
Comment threadsrc/coreclr/vm/amd64/theprestubamd64.S Outdated
jakobbotschand others added 2 commits March 22, 2024 20:59
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@jkotas

Copy link
Copy Markdown
Member

The stub change LGTM

@jakobbotsch

Copy link
Copy Markdown
MemberAuthor

/azp run runtime

@azure-pipelines

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

@jakobbotsch
jakobbotsch merged commit d981ed9 into dotnet:mainMar 23, 2024
@jakobbotsch
jakobbotsch deleted the swift-callback-struct-returns branch March 23, 2024 19:15
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Apr 23, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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.

3 participants

@jakobbotsch@jkotas@amanasifkhalid