[clr-interp] Add support for catching exceptions which are dependent on the context param#119336
Merged
davidwrighton merged 1 commit intodotnet:mainfrom Sep 4, 2025
Merged
Conversation
…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.
69 tasks
Contributor
There was a problem hiding this comment.
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 |
This was referenced Sep 4, 2025
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.
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.