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

Implement support for copy constructors when marshalling in IJW #22805

Merged
merged 7 commits into from
Mar 19, 2019

Conversation

jkoritzinsky
Copy link
Member

Fixes #22219.

I decided to try simplifying the code when bringing this feature over from .NET Framework. The .NETFX x86 implementation of this marshaler adds a lot of extra code-paths, and intercepts the calling stub to enable it to exactly replicate the behavior of what would be the native code by copy-constructing an object in-place where it goes on the stack for the native call.

Instead of adding all of that extra goo, I decided to keep the implementation much more similar to the non-x86 implementation from .NETFX. Instead of intercepting the call and adding bookkeeping helper stubs, the marshaler just copies to a local in the IL stub, just like non-x86. When calling the native function, it just loads the local onto the IL stack and calls the native function as a normal function. There is a difference there, but I cannot think of a way that the difference is observable to the user.

The non-x86 implementation is identical to the .NETFX implementation.

@jkoritzinsky
Copy link
Member Author

@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test
@dotnet-bot test Windows_NT x64 Checked CoreFX Tests
@dotnet-bot test Windows_NT x86 Checked Innerloop Build and Test

@jkoritzinsky
Copy link
Member Author

@dotnet-bot test this please

1 similar comment
@jkoritzinsky
Copy link
Member Author

@dotnet-bot test this please

@jkoritzinsky
Copy link
Member Author

@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test

@jkoritzinsky jkoritzinsky merged commit 4bca728 into dotnet:master Mar 19, 2019
@jkoritzinsky jkoritzinsky deleted the copy-constructor-marshaler branch March 19, 2019 23:22
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…et/coreclr#22805)

Fixes dotnet/coreclr#22219.

I decided to try simplifying the code when bringing this feature over from .NET Framework. The .NETFX x86 implementation of this marshaler adds a lot of extra code-paths, and intercepts the calling stub to enable it to exactly replicate the behavior of what would be the native code by copy-constructing an object in-place where it goes on the stack for the native call.

Instead of adding all of that extra goo, I decided to keep the implementation much more similar to the non-x86 implementation from .NETFX. Instead of intercepting the call and adding bookkeeping helper stubs, the marshaler just copies to a local in the IL stub, just like non-x86. When calling the native function, it just loads the local onto the IL stack and calls the native function as a normal function. There is a difference there, but I cannot think of a way that the difference is observable to the user.

The non-x86 implementation is identical to the .NETFX implementation.



Commit migrated from dotnet/coreclr@4bca728
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants