Skip to content

Conversation

@davidwrighton
Copy link
Member

  • 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
Copilot AI review requested due to automatic review settings September 25, 2025 23:23
Copy link
Contributor

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 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

@dotnet-policy-service
Copy link
Contributor

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

@kg
Copy link
Member

kg commented Sep 25, 2025

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?)

@davidwrighton
Copy link
Member Author

@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.

@davidwrighton davidwrighton merged commit 2964308 into dotnet:main Sep 26, 2025
96 of 98 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants