Skip to content

Conversation

@davidwrighton
Copy link
Member

  • Add support to the InterpreterCodeManager for the ability to understand the generic context of a given frame
  • This is done by adding implementation for InterpreterCodeManager::GetInstance, InterpreterCodeManager::GetParamTypeArg and InterpreterCodeManager::GetParamContextType
  • In addition, provide an implementation of InterpreterJitManager::ResolveEHClause. The enhancement with this is that it will support doing shared generic catch of a generically dependent exception type. (The JIT implements this by translating these sorts of catches into filters, but that doesn't seem like a good approach for the interpreter. The existing function is noted as being sensitive to stack overflow issues, so I didn't update this for all scenarios)

As a bonus, this work also enables !clrstack -i -a to understand the actual accurate generic types of all of the locals, and should probably enable collectible generics to have its generics lifetime tracking kick in like it should for interpreted methods.

…on the context param

- Add support to the InterpreterCodeManager for the ability to understand the generic context of a given frame
- This is done by adding implementation for InterpreterCodeManager::GetInstance, InterpreterCodeManager::GetParamTypeArg and InterpreterCodeManager::GetParamContextType
- In addition, provide an  implementation of InterpreterJitManager::ResolveEHClause. The enhancement with this is that it will support doing shared generic catch of a generically dependent exception type. (The JIT implements this by translating these sorts of catches into filters, but that doesn't seem like a good approach for the interpreter. The existing function is noted as being sensitive to stack overflow issues, so I didn't update this for all scenarios)

As a bonus, this work also enables !clrstack -i -a to understand the actual accurate generic types of all of the locals.
@Copilot Copilot AI review requested due to automatic review settings September 3, 2025 21:34
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 3, 2025
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 adds support for catching exceptions with generic type dependencies in the interpreter by implementing generic context parameter handling. The changes enable the interpreter to understand and resolve generic types at runtime, particularly for exception handling scenarios where catch clauses depend on generic context.

Key changes include:

  • Implementation of generic context parameter retrieval methods in InterpreterCodeManager
  • Addition of exception handling clause resolution for shared generic types in InterpreterJitManager
  • Integration of generic context information during GC info generation in the interpreter compiler

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/coreclr/vm/gcenv.ee.common.cpp Removes inline modifier from SafeToReportGenericParamContext to allow external access
src/coreclr/vm/eetwain.cpp Implements GetInstance, GetParamTypeArg, and GetParamContextType methods for interpreter generic context support
src/coreclr/vm/codeman.h Adds ResolveEHClause virtual method declaration and SafeToReportGenericParamContext function declaration
src/coreclr/vm/codeman.cpp Implements ResolveEHClause method for interpreter to handle generic exception type resolution
src/coreclr/interpreter/compiler.cpp Adds generic context parameter tracking during GC info generation for shared generic methods

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

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

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants