Skip to content
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

Updating the JIT to support marshaling blittable generics. #103

Merged
merged 5 commits into from
Nov 22, 2019
Merged

Updating the JIT to support marshaling blittable generics. #103

merged 5 commits into from
Nov 22, 2019

Conversation

tannergooding
Copy link
Member

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 18, 2019
@tannergooding
Copy link
Member Author

I think the only open question I had was on how to properly test crossgen2 against the appropriate tests: dotnet/coreclr#23899 (comment)

@ViktorHofer
Copy link
Member

cc @trylek for the crossgen2 question.

@trylek
Copy link
Member

trylek commented Nov 18, 2019

@tannergooding - right now the only CI testing available for Crossgen2 is a single pipeline I created recently, "runtime crossgen2" which runs checked Pri0 tests on the three OS'es / x64. Sadly the results aren't yet completely clean, there are typically something like 60~70 remaining failures. For local testing, it's easiest to use the tool ReadyToRun.SuperIlc - ping me or Jan Vorlicek on IM if you're interested in guidance how to do that.

@tannergooding
Copy link
Member Author

I was able to locally validate that the Crossgen2 changes work as expected.

I believe this should be ready for review/merging (provided CI is stable enough for it to pass now).

@jkotas
Copy link
Member

jkotas commented Nov 19, 2019

Is there test coverage for the unmanaged -> managed direction (delegates)? I am not able to find it, but it may be just a github search not working.

@tannergooding
Copy link
Member Author

No, I hadn't written any tests for the reverse case. I'll try to get a few written tomorrow.

@tannergooding
Copy link
Member Author

@jkotas, the changes for the reverse case are a bit more complex and require updating the Marshal APIs. This is currently tracked by https://github.com/dotnet/coreclr/issues/25973 and https://github.com/dotnet/coreclr/issues/27754.

I've started updating the relevant checks, but was wondering if you wanted it as part of this PR or if it would be preferred to have a separate PR handling them?

@jkotas
Copy link
Member

jkotas commented Nov 20, 2019

Yes, it would be better to have those as separate change.

What does the current version of the change does in these cases? Does it fail predictably?

@tannergooding
Copy link
Member Author

What does the current version of the change does in these cases? Does it fail predictably?

Yes. These paths all throw an ArgumentException which states the type must be non-generic today:

@jkotas
Copy link
Member

jkotas commented Nov 20, 2019

What about cases like delegate void MyDelegate(Vector256<double> x); + GetFunctionPointerForDelegate ?

@tannergooding
Copy link
Member Author

What about cases like delegate void MyDelegate(Vector256 x); + GetFunctionPointerForDelegate ?

That looks to work today, even without these changes (as does the reverse).

@jkotas
Copy link
Member

jkotas commented Nov 20, 2019

It does not work in master today. You will get an exception like:

Unhandled exception. System.Runtime.InteropServices.MarshalDirectiveException: Cannot marshal 'parameter #1': Generic types cannot be marshaled.

Note that you need to actually call the delegate. The marshaling stub compilation is done lazily.

It should continue to throw exception, same as the forward direction.

@tannergooding
Copy link
Member Author

The marshaling stub compilation is done lazily.

Ah, I see. I had only validated that the calls succeeded. I can reproduce the above failure without these changes.

With these changes, the marshaling stub works for blittable generics and fails with the following for blocked types (such as Vector128<float>):

Unhandled exception. System.Runtime.InteropServices.MarshalDirectiveException: Cannot marshal 'parameter #1': Non-blittable generic types cannot be marshaled.

@jkotas jkotas merged commit e296ee8 into dotnet:master Nov 22, 2019
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
MichalStrehovsky added a commit to MichalStrehovsky/runtime that referenced this pull request Oct 12, 2020
Move the logic to find slot defining method of generic virtual methods to a common location and use it from the scanner.

The fact that I touched compilation dependencies in the JitInterface but didn't update the scanner should have been a red flag. Fixes a Release-only issue discovered in dotnet#103. Can't wait to have the CI fully up and running.
MichalStrehovsky added a commit to MichalStrehovsky/runtime that referenced this pull request Oct 12, 2020
Remaining tests are the multimodule ones and static/shared library support.
@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2020
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.

6 participants