-
Notifications
You must be signed in to change notification settings - Fork 206
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
Implement handling PreserveSig = false for interfaces #1206
Merged
jkotas
merged 9 commits into
dotnet:feature/NativeAOT
from
kant2002:kant/preservesig-false
Jun 8, 2021
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ba68a4b
Implement handling PerserveSig = false for interfaces
kant2002 f614212
Ignore delegating marshalling thunks
kant2002 15a5c68
I add special case for handling blittable types which are return type…
kant2002 48de7aa
Remove artificial constraing on PreserveSig=false
kant2002 0b5bb1c
Address PR feedback
kant2002 dbdb239
Fix
kant2002 5903921
Add simple tests for PreservSig=false functionality
kant2002 df9bdb1
Update src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs
kant2002 5e098f6
Reformat code based on PR feedback
kant2002 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -512,7 +512,7 @@ protected virtual void EmitMarshalReturnValueManagedToNative() | |
|
||
public virtual void LoadReturnValue(ILCodeStream codeStream) | ||
{ | ||
Debug.Assert(Return); | ||
Debug.Assert(Return || Index == 0); | ||
|
||
switch (MarshalDirection) | ||
{ | ||
|
@@ -653,9 +653,18 @@ protected void PropagateFromByRefArg(ILCodeStream stream, Home home) | |
/// </summary> | ||
protected void PropagateToByRefArg(ILCodeStream stream, Home home) | ||
{ | ||
stream.EmitLdArg(Index - 1); | ||
home.LoadValue(stream); | ||
stream.EmitStInd(ManagedType); | ||
// If by-ref arg has index == 0 then that argument is used for HR swapping and we just return that value. | ||
if (Index == 0) | ||
{ | ||
// Returning result would be handled by LoadReturnValue | ||
return; | ||
} | ||
else | ||
{ | ||
stream.EmitLdArg(Index - 1); | ||
home.LoadValue(stream); | ||
stream.EmitStInd(ManagedType); | ||
} | ||
kant2002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
protected virtual void EmitMarshalArgumentManagedToNative() | ||
|
@@ -903,7 +912,7 @@ class BlittableValueMarshaller : Marshaller | |
{ | ||
protected override void EmitMarshalArgumentManagedToNative() | ||
{ | ||
if (IsNativeByRef && MarshalDirection == MarshalDirection.Forward) | ||
if (IsNativeByRef && MarshalDirection == MarshalDirection.Forward && Index > 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would move the special case first and then leave the rest of the method intact.
|
||
{ | ||
ILCodeStream marshallingCodeStream = _ilCodeStreams.MarshallingCodeStream; | ||
ILEmitter emitter = _ilCodeStreams.Emitter; | ||
|
@@ -917,10 +926,14 @@ protected override void EmitMarshalArgumentManagedToNative() | |
marshallingCodeStream.EmitStLoc(native); | ||
_ilCodeStreams.CallsiteSetupCodeStream.EmitLdLoc(native); | ||
} | ||
else | ||
else if (Index > 0) | ||
{ | ||
_ilCodeStreams.CallsiteSetupCodeStream.EmitLdArg(Index - 1); | ||
} | ||
else | ||
{ | ||
base.EmitMarshalArgumentManagedToNative(); | ||
} | ||
} | ||
|
||
protected override void EmitMarshalArgumentNativeToManaged() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It would be nice to replace all
Index == 0
checks with a property. It would make the code much easier to understand.