Skip to content

Avoid CORINFO_..._HANDLEs in JIT helper signatures #116675

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 1 commit into from
Jun 16, 2025

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Jun 14, 2025

CORINFO_..._HANDLEs are meant to be JIT/EE interface abstraction. Using them in JIT helper signatures causes confusion.

@Copilot Copilot AI review requested due to automatic review settings June 14, 2025 18:57
@jkotas jkotas requested review from BrzVlad, janvorli and kg as code owners June 14, 2025 18:57
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.

Pull Request Overview

This pull request updates several JIT helper signatures and related functions to avoid using CORINFO_..._HANDLE types in favor of more explicit type‐safe parameters. Key changes include:

  • Removing and replacing the use of CORINFO_MODULE_HANDLE and CORINFO_CLASS_HANDLE with Module*, EnregisteredTypeHandle, or equivalent types.
  • Updating return types and parameter types of functions such as GenericHandleWorkerCore, JIT_GetClassFromMethodParam, and GenericHandleCommon.
  • Adjusting helper functions in both core JIT interface and interpreter implementations to ensure consistency with the new type usage.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/coreclr/vm/jitinterface.h Removal of ConstructStringLiteral declaration to avoid exposing CORINFO_ handles.
src/coreclr/vm/jitinterface.cpp Local variable rename and direct use of Module::ResolveStringRef for clarity.
src/coreclr/vm/jithelpers.cpp Function signatures updated to replace CORINFO_ handles with EnregisteredTypeHandle and MethodDesc*.
src/coreclr/vm/interpexec.cpp Updated type conversions and function signatures to reflect new handle types.
src/coreclr/vm/appdomainnative.hpp/.cpp Adjusted the String_StrCns API to use Module* consistently.
Comments suppressed due to low confidence (6)

src/coreclr/vm/jitinterface.h:1029

  • The removal of ConstructStringLiteral from the public header is consistent with avoiding CORINFO_ handles; ensure that all internal references now use the updated approach.
STRINGREF* ConstructStringLiteral(CORINFO_MODULE_HANDLE scopeHnd, mdToken metaTok, void** ppPinnedString = nullptr);

src/coreclr/vm/jitinterface.cpp:12082

  • The change to use Module::ResolveStringRef directly (with the renamed pPinnedString) aligns with the PR's goal; please verify that all internal usages are consistent.
STRINGREF* ptr = ((Module*)scopeHnd)->ResolveStringRef(metaTok, &pPinnedString);

src/coreclr/vm/jithelpers.cpp:540

  • Changing the return type from CORINFO_GENERIC_HANDLE to DictionaryEntry should be verified against all call sites to ensure that the new type is handled correctly.
DictionaryEntry GenericHandleWorkerCore(MethodDesc * pMD, MethodTable * pMT, LPVOID signature, DWORD dictionaryIndexAndSlot, Module* pModule)

src/coreclr/vm/jithelpers.cpp:767

  • Updating JIT_GetClassFromMethodParam to accept a MethodDesc* parameter instead of a CORINFO_METHOD_HANDLE is in line with eliminating CORINFO_ handles; please ensure this change is compatible with all callers.
HCIMPL1(EnregisteredTypeHandle, JIT_GetClassFromMethodParam, MethodDesc* pMD)

src/coreclr/vm/interpexec.cpp:136

  • Changing GenericHandleCommon's return type from CORINFO_GENERIC_HANDLE to void* requires verification that all usages correctly handle the new return type.
void* GenericHandleCommon(MethodDesc * pMD, MethodTable * pMT, LPVOID signature)

src/coreclr/vm/appdomainnative.hpp:19

  • Updating the parameter of String_StrCns to accept a Module* instead of a CORINFO_MODULE_HANDLE fulfills the PR goal; confirm that all invocations pass a valid Module pointer.
extern "C" STRINGREF* QCALLTYPE String_StrCns(UINT32 rid, Module* pModule);

Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@jkotas jkotas force-pushed the CORINFO_HANDLEs branch from 9699610 to 8eae19c Compare June 14, 2025 18:59
// ppPinnedString: If the string is pinned (e.g. allocated in frozen heap),
// the pointer to the pinned string is returned in *ppPinnedPointer. ppPinnedPointer == nullptr
// means that the caller does not care whether the string is pinned or not.
STRINGREF* ConstructStringLiteral(CORINFO_MODULE_HANDLE scopeHnd, mdToken metaTok, void** ppPinnedString = nullptr);
Copy link
Member Author

Choose a reason for hiding this comment

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

Unnecessary wrapper

@@ -12078,12 +12078,12 @@ InfoAccessType CEECodeGenInfo::constructStringLiteral(CORINFO_MODULE_HANDLE scop
else
{
// If ConstructStringLiteral returns a pinned reference we can return it by value (IAT_VALUE)
Copy link
Member

Choose a reason for hiding this comment

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

comment outdated now

CORINFO_..._HANDLEs are meant to be JIT/EE interface abstraction. Using them in JIT helper signatures causes confusion.
@jkotas jkotas force-pushed the CORINFO_HANDLEs branch from 4079b9b to 9777651 Compare June 15, 2025 14:44
Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@janvorli janvorli merged commit a7bd51e into dotnet:main Jun 16, 2025
96 checks passed
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.

3 participants