[NativeAOT] Fast interface dispatch helper for riscv64 - #134057
Merged
MichalStrehovsky merged 4 commits intoSep 24, 2026
Merged
Conversation
Interface dispatch moved to a helper with a global dispatch cache in dotnet#123252. amd64 and arm64 got optimized helpers that check the monomorphic cell inline and probe the cache in assembly; riscv64 was left with the slow path, so every interface call goes through RhpUniversalTransition and the managed resolver. Port the arm64 INTERFACE_DISPATCH macro: monomorphic cell check, then a GenericCache<Key, nint> probe using the same hash, the same quadratic reprobe and the same seqlock version check, falling back to RhpCidResolve and RhpCidResolve_Worker. Only temporaries are used, so nothing has to be spilled around the probe. Three things differ from arm64, all forced by the ISA: - arm64 gets its acquire loads from ldar and orders the value read against the version re-read with dmb ishld. RVWMO does not order a plain ld against later loads, so each of those becomes a fence r, r after the load. - at the key compare only one temporary is still free, so the probe count travels in the upper bits of the index register instead of having a register of its own. - the tail call to RhpUniversalTransitionTailCall is written out by hand: the tail pseudo-instruction expands through t1, which is carrying the thunk parameter. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
|
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. |
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The hand-written concurrent assembly requires RISC-V hardware validation of ABI and memory-ordering behavior.
Pull request overview
Adds optimized NativeAOT interface dispatch for RISC-V 64, matching existing ARM64 cache behavior.
Changes:
- Adds monomorphic dispatch-cell checks.
- Probes the global dispatch cache with RISC-V memory ordering.
- Preserves slow-path resolution for cache misses.
File summaries
| File | Description |
|---|---|
src/coreclr/nativeaot/Runtime/riscv64/DispatchResolve.S |
Implements cached RISC-V 64 interface dispatch. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Balanced
|
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. |
MichalStrehovsky
approved these changes
Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Interface dispatch moved to a helper with a global dispatch cache in #123252. amd64 and arm64 got optimized helpers that check the monomorphic cell inline and probe the cache in assembly; riscv64 was left with the slow path, so every interface call goes through RhpUniversalTransition and the managed resolver.
Port the arm64 INTERFACE_DISPATCH macro: monomorphic cell check, then a GenericCache<Key, nint> probe using the same hash, the same quadratic reprobe and the same seqlock version check, falling back to RhpCidResolve and RhpCidResolve_Worker. Only temporaries are used, so nothing has to be spilled around the probe.
Three things differ from arm64, all forced by the ISA: