-
Couldn't load subscription status.
- Fork 5.2k
[clr-interp] Fix dynamic methods #120124
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
[clr-interp] Fix dynamic methods #120124
Conversation
davidwrighton
commented
Sep 25, 2025
- We needed to clear the interpreter code pointer
- We needed to re-use any InterpreterPrecode that are associated with a dynamic method
- We needed to clear the interpreter code pointer - We needed to re-use any InterpreterPrecode that are associated with a dynamic method
There was a problem hiding this 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 PR fixes dynamic methods in the CLR interpreter by addressing two key issues: clearing interpreter code pointers during method reset and reusing InterpreterPrecode instances for dynamic methods.
- Adds a
ClearInterpreterCodePointer()method to properly reset interpreter state - Introduces logic to cache and reuse InterpreterPrecode instances for dynamic methods
- Integrates interpreter code clearing into the method reset process
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/vm/method.hpp | Adds ClearInterpreterCodePointer method and m_interpreterPrecode field to DynamicMethodDesc |
| src/coreclr/vm/method.cpp | Integrates interpreter code clearing into MethodDesc::Reset() |
| src/coreclr/vm/jitinterface.cpp | Implements InterpreterPrecode reuse logic for dynamic methods |
|
Tagging subscribers to this area: @mangod9 |
Co-authored-by: Copilot <[email protected]>
|
Are we properly resetting the precode associated with the dynamic method? Are transitions between 'interpreted dynamic method' and 'jitted dynamic method' possible at runtime, and do we care about them? If I understand the state of this PR correctly once a DM has interpreter precode it will always have interpreter precode, and if it has JIT precode it will always have JIT precode. I don't totally understand what's going on with the Reset stuff here - it looks like from grepping around we maintain a freelist of dynamic methods for reuse (after a dynamic method is GCd?) |
Co-authored-by: Jan Kotas <[email protected]>
|
@kg Not quite, this change makes it so that if we allocate an InterpreterPrecode for a MethodDesc, that is the one we'll always use, but it doesn't guarantee that we'll stay using an InterpreterPrecode. MethodDesc::Reset puts us back to having a normal entrypoint which can in theory go either way. |