Skip to content

Enable R2R for unresolved static virtual interface calls - #131282

Merged
jkoritzinsky merged 2 commits into
dotnet:mainfrom
jkoritzinsky:fix/r2r-unresolved-static-virtual-lookup
Jul 29, 2026
Merged

jkoritzinsky merged 2 commits into
dotnet:mainfrom
jkoritzinsky:fix/r2r-unresolved-static-virtual-lookup

Conversation

@jkoritzinsky

Copy link
Copy Markdown
Member

Summary

Enable Crossgen2 to compile unresolved constrained static virtual interface calls that require a runtime lookup.

The lookup now:

  • uses CORINFO_CALL_CODE_POINTER so the computed runtime lookup is preserved
  • encodes a ConstrainedMethodEntrySlot with the runtime-determined constraint
  • suppresses the hidden instantiation argument expected by a normal shared-generic callsite

This allows System.RuntimeType+IGenericCacheEntry<TCache>.CreateAndCache to be emitted as R2R code instead of falling back to runtime JIT compilation.

Fixes #120405

Testing

  • dotnet.cmd build src/coreclr/tools/aot/crossgen2/crossgen2.csproj -c Debug --no-restore
  • Compiled IGenericCacheEntry<ActivatorCache>.CreateAndCache in Crossgen2 single-method mode
  • Verified with R2RDump that Create and GetStorageRef use constrained lookups against var #0, not System.__Canon, followed by indirect calls
  • Ran the CoreCLR StaticVirtualMethods loader suite successfully

Note

This pull request description was generated by GitHub Copilot.

Copilot AI review requested due to automatic review settings July 23, 2026 18:21
@github-actions github-actions Bot added the area-crossgen2-coreclr only use for closed issues label Jul 23, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Enable Crossgen2 (ReadyToRun JIT interface) to R2R-compile unresolved constrained static virtual interface calls that require an exact-context runtime lookup, instead of bailing out to runtime JIT.

Changes:

  • Replace the RequiresRuntimeJitException for exactContextNeedsRuntimeLookup unresolved constrained SVM calls with a CORINFO_CALL_CODE_POINTER + runtime lookup path.
  • Use DictionaryEntryKind.ConstrainedMethodEntrySlot for the runtime lookup and request an instantiating stub (suppress hidden instantiation argument at the callsite).

@jkoritzinsky

Copy link
Copy Markdown
Member Author

/azp run runtime-coreclr crossgen2 outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI review requested due to automatic review settings July 27, 2026 22:28
@jkoritzinsky

Copy link
Copy Markdown
Member Author

/azp run runtime-coreclr crossgen2-composite gcstress

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

@davidwrighton

Copy link
Copy Markdown
Member

@jkoritzinsky Have you validated what happens when a case where the structure doesn't implement the interface method, but it is implemented by a default implementation on the interface?

@jtschuster jtschuster added area-ReadyToRun and removed area-crossgen2-coreclr only use for closed issues labels Jul 28, 2026
@jkoritzinsky

Copy link
Copy Markdown
Member Author

In https://dev.azure.com/dnceng-public/public/_build/results?buildId=1524294&view=logs&jobId=c7387c70-b93d-5740-226d-f0ff8a1214f4 (from f16965a, the first commit in this PR), I ran all the src/tests tree under ReadyToRun, so that should be covered by the StructWithDIM case in the StaticVirtualDIMOnReferenceType test suite.

@jkoritzinsky

Copy link
Copy Markdown
Member Author

/ba-g failure is only in NAOT and this code is only in R2R

@jkoritzinsky
jkoritzinsky enabled auto-merge (squash) July 29, 2026 23:28
@jkoritzinsky
jkoritzinsky merged commit 85dad87 into dotnet:main Jul 29, 2026
117 of 120 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Jul 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

R2R code missing for static interface methods

4 participants