Repository navigation
[wasm][coreclr] Cache calli cookies - #127016
Merged
Merged
Conversation
Avoid repeated expensive calls to get calli cookie by caching it
Contributor
|
Tagging subscribers to this area: @agocke |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces overhead in the WASM interpreter call path by caching the computed calli cookie on the MethodDesc, avoiding repeated (and potentially expensive) cookie computation for repeated invocations of the same managed method.
Changes:
- Cache and reuse a per-
MethodDesccalli cookie inInvokeManagedMethodon WASM. - Extend
MethodDescCodeData(portable entrypoints + interpreter builds) to store aCalliCookie. - Add
MethodDesc::{GetCalliCookie, SetCalliCookie}APIs to manage the cached value thread-safely.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/vm/wasm/helpers.cpp | Uses MethodDesc-cached cookie to avoid repeated GetCookieForCalliSig calls. |
| src/coreclr/vm/method.hpp | Adds CalliCookie storage in MethodDescCodeData and declares accessor APIs under the relevant feature flags. |
| src/coreclr/vm/method.cpp | Implements thread-safe cookie get/set using EnsureCodeDataExists + interlocked/volatile operations. |
jkotas
reviewed
Apr 17, 2026
jkotas
reviewed
Apr 17, 2026
…Cookie typedef - Define InterpreterCalliCookie typedef: function pointer on WASM, CallStubHeader* on non-WASM (Jan's feedback) - Unify SetCalliCookie/GetCalliCookie API, removing the separate SetCallStub/GetCallStub and FEATURE_PORTABLE_ENTRYPOINTS branching in MethodDesc - Cache calli cookie on targetMethod in the WASM calli path in interpexec.cpp (Jan's feedback) - Re-read cookie after SetCalliCookie in wasm/helpers.cpp to use the race-winning value (Aaron's feedback) Co-authored-by: Copilot <[email protected]>
This was referenced Apr 27, 2026
jkotas
approved these changes
Apr 27, 2026
added 2 commits
April 27, 2026 12:58
jkotas
reviewed
May 3, 2026
jkotas
reviewed
May 3, 2026
jkotas
reviewed
May 3, 2026
Co-authored-by: Jan Kotas <[email protected]>
This was referenced May 4, 2026
commented
May 5, 2026
Member
Author
|
/ba-g infra issues |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Avoid repeated expensive calls to get calli cookie by caching it
Checked in HelloWorld