Add MethodDef instance parameter to MethodDef_Instance::InitializeFromIndex()#3308
Conversation
📝 WalkthroughWalkthroughThe changes enhance the generic method initialization path in the CLR runtime by adding caller context support. The Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/CLR/Core/Interpreter.cpp`:
- Around line 2420-2423: The call to calleeInst.InitializeFromIndex(calleeReal,
*calleeInst.genericType, &stack->m_call) is fallible but its HRESULT is ignored;
update the dispatch code to capture and check the return value using
NANOCLR_CHECK_HRESULT (or NANOCLR_SET_AND_LEAVE on failure) so the function
bails out on error instead of continuing with an invalid calleeInst state;
locate the call site referencing InitializeFromIndex, calleeInst, calleeReal and
stack->m_call and wrap the call with the appropriate NANOCLR error-check macro
to propagate/handle failures.
In `@src/CLR/Core/TypeSystem.cpp`:
- Around line 1832-1870: The resolved generic argument handling in the MVAR
branch must detect and normalize constructed generic instances: after calls to
msInst.GetGenericArgument (and callerTs.GetGenericParam) check if the returned
CLR_RT_SignatureParser::Element has DataType == DATATYPE_GENERICINST and, if so,
replace it with its underlying generic definition token (or otherwise fail-fast)
before assigning ownerTypeIdx; ensure this logic is applied both where
argElement.Class and paramElement.Class are used (including the other block
around lines 1885–1889) so ownerTypeIdx is never set from an invalid Class field
of a GENERICINST element.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: ea4b26a0-2eb0-4f51-8ad6-6ea11b1227a7
📒 Files selected for processing (3)
src/CLR/Core/Interpreter.cppsrc/CLR/Core/TypeSystem.cppsrc/CLR/Include/nanoCLR_Runtime.h
…mIndex() - Now it has enough context to be able to resolve MVARs. - Adjust callers accordingly.
Automated fixes for code style.
Automated fixes for code style.
61163a0 to
4753d8b
Compare
Description
Motivation and Context
How Has This Been Tested?
Screenshots
Types of changes
Checklist