Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add internal intrinsics for instance-based calli #114495

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

Merged
merged 10 commits into from
Apr 16, 2025

Conversation

steveharter
Copy link
Member

@steveharter steveharter commented Apr 10, 2025

Contributes to #112994. The next step in this process will use these intrinsics.

Adds support for both CoreClr JIT and R2R to modify the function pointer signature to add HasThis | ExplicitThis so specific function pointer signatures can be called on an instance method.

Local testing verified both:

  • R2R\crossgen2 created the native code with the HasThis | ExplicitThis signature and thus prevented JIT.
  • The non-R2R runtime cases replaced the IL of the method and added HasThis | ExplicitThis to the signature.

The tests added here currently don't verify the intrinsics, but an earlier version did (see the first commit). Once the next step of hooking into reflection is done, these tests will cover the new intrinsics added here. In particular, the new tests address missing test cases of calling an instance-based method with non-primitive return types such as Guid, DateTime and TimeSpan that would fail if reflection called these methods with function pointers \ Calli without HasThis | ExplicitThis.

@steveharter steveharter added this to the 10.0.0 milestone Apr 10, 2025
@steveharter steveharter self-assigned this Apr 10, 2025
@Copilot Copilot AI review requested due to automatic review settings April 10, 2025 16:28
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-reflection-emit
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 12 out of 14 changed files in this pull request and generated 3 comments.

Files not reviewed (2)
  • src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj: Language not supported
  • src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj: Language not supported

@MichalPetryka
Copy link
Contributor

MichalPetryka commented Apr 10, 2025

Wouldn't it be simpler to just write those stubs in IL instead of having to implement them in every VM?
Like this.

@jkotas
Copy link
Member

jkotas commented Apr 11, 2025

Wouldn't it be simpler to just write those stubs in IL instead of having to implement them in every VM?

We would need to invent build infrastructure to merge this IL into CoreLib....

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGMT otherwise. Thank you!

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

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

Thanks!

@steveharter
Copy link
Member Author

/ba-g infra timeout on building Libraries Test Run release coreclr linux_musl x64 Debug

@steveharter steveharter merged commit 24d8707 into dotnet:main Apr 16, 2025
120 of 130 checks passed
@steveharter steveharter deleted the ReflectionCalli branch April 16, 2025 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants