-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[clr-interp] allow modification of the this pointer in functions which use it as the generics context #119554
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] allow modification of the this pointer in functions which use it as the generics context #119554
Conversation
…h use it as the generics context - When the this pointer is used as the generics context, if some code modifies the this pointer, do not allow that modification to affect the generics behavior of the function - Implement this by making a shadow copy of the this pointer in this situation - To avoid doing this ALL of the time, I've added a scheme where we can restart the entire method compilation by setting a flag which describes the current set of retry rules.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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 implements a fix for CLR interpreter's handling of generic methods that use the "this" pointer as the generics context. The change addresses a scenario where modifications to the "this" pointer during method execution could incorrectly affect the generics behavior.
Key Changes:
- Creates a shadow copy of the "this" pointer when it's used as the generics context in generic methods
- Implements lazy evaluation - reserves space for the shadow copy but only uses it if the "this" pointer is actually modified
- Adds null reference checking for the generics context when derived from "this"
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/coreclr/vm/codeman.cpp | Adds null reference checking for "this"-derived generics context |
| src/coreclr/interpreter/compiler.h | Adds tracking variables for shadow copy state |
| src/coreclr/interpreter/compiler.cpp | Implements shadow copy logic, variable management, and GC reporting |
|
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg |
Co-authored-by: Copilot <[email protected]>
Address feedback from @kg
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.
LGTM, thank you!
Co-authored-by: Jan Vorlicek <[email protected]>
This is a new PR replacing #119338, since I fouled up a merge in that PR.