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

Fix generic context passed to resolved constrained method calls - #13577

Merged
MichalStrehovsky merged 2 commits into
dotnet:masterfrom
MichalStrehovsky:constrainedContext
Aug 25, 2017
Merged

MichalStrehovsky merged 2 commits into
dotnet:masterfrom
MichalStrehovsky:constrainedContext

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

If the EE was able to resolve a constrained call, the instantiating
parameter to use is the type by which the call was constrained with. We
embed pConstrainedResolvedToken as the extra argument because
pResolvedToken is an interface method and interface types make a poor
generic context.

The CLR doesn't hit this path because these types of constrained method
calls go through an instantiating stub. We don't do instantiating stubs
in CoreRT.

Contributes to fixing dotnet/corert#3608 (we'll need to clean up a couple workarounds).

If the EE was able to resolve a constrained call, the instantiating
parameter to use is the type by which the call was constrained with. We
embed pConstrainedResolvedToken as the extra argument because
pResolvedToken is an interface method and interface types make a poor
generic context.

The CLR doesn't hit this path because these types of constrained method
calls go through an instantiating stub. We don't do instantiating stubs
in CoreRT.
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

@dotnet/jit-contrib PTAL

@sandreenko

Copy link
Copy Markdown

@dotnet-bot test Tizen armel Cross Debug Build

@sandreenko

Copy link
Copy Markdown

@dotnet-bot test Windows_NT Release pri1r2r

@sandreenko

Copy link
Copy Markdown

Looks good to me.

@MichalStrehovsky
MichalStrehovsky merged commit c539df9 into dotnet:master Aug 25, 2017
@MichalStrehovsky
MichalStrehovsky deleted the constrainedContext branch August 25, 2017 23:09
@karelz karelz modified the milestone: 2.1.0 Aug 28, 2017
MichalStrehovsky added a commit to MichalStrehovsky/corert that referenced this pull request Aug 28, 2017
MichalStrehovsky added a commit to dotnet/corert that referenced this pull request Aug 28, 2017
MichalStrehovsky added a commit to MichalStrehovsky/runtimelab that referenced this pull request Aug 17, 2021
* We weren't able to get a usable generic context to the method being invoked.
* Undoes dotnet/coreclr#13577 that was papering over the issue, fixing this for non-generic methods, but leaving generic methods unfixed.
* The fix is similar to how CoreCLR handles this - on CoreCLR, we call a helper, get an instantiation thunk back, and invoke that.
* Since we don't have instantiation thunks in NativeAOT, we ask for a fat function pointer and perform a fat call.
* This is a bit less efficient than what we had in NativeAOT before this change (generic lookup for the context, and a direct call). We wouldn't be able to express the correct generic lookup sequence without a JitInterface change. What we get with this pull request is probably good enough.

Fixes dotnet#1357.
Fixes dotnet/corert#3608 (which is the same issue, but in CoreRT repo)
MichalStrehovsky added a commit to dotnet/runtimelab that referenced this pull request Aug 18, 2021
* We weren't able to get a usable generic context to the method being invoked.
* Undoes dotnet/coreclr#13577 that was papering over the issue, fixing this for non-generic methods, but leaving generic methods unfixed.
* The fix is similar to how CoreCLR handles this - on CoreCLR, we call a helper, get an instantiation thunk back, and invoke that.
* Since we don't have instantiation thunks in NativeAOT, we ask for a fat function pointer and perform a fat call.
* This is a bit less efficient than what we had in NativeAOT before this change (generic lookup for the context, and a direct call). We wouldn't be able to express the correct generic lookup sequence without a JitInterface change. What we get with this pull request is probably good enough.

Fixes #1357.
Fixes dotnet/corert#3608 (which is the same issue, but in CoreRT repo)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants