Add support for statics access from shared generic code, as well as precise-init static class construction#117110
Merged
davidwrighton merged 4 commits intodotnet:mainfrom Jun 30, 2025
Conversation
Member
davidwrighton
commented
Jun 27, 2025
- There is another renaming of the helpers call opcodes to allow distinguishing between whether or not the arg is supplied via svar or dataindex.
- More tests to cover these scenarios
- This should finish up the support for shared generics
…recise-init static class construction - There is another renaming of the helpers call opcodes to allow distinguishing between whether or not the arg is supplied via svar or dataindex. - More tests to cover these scenarios - This should finish up the support for shared generics
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR extends the interpreter to distinguish helper call opcodes based on how arguments are supplied (via static var vs. data index) and adds support for precise static constructor initialization in shared generic code.
- Introduces new opcodes (
INTOP_CALL_HELPER_P_S,_PS,_SP,_GS,_APS,_AGS) in both the opcode definitions and interpreter execution. - Updates the compiler to emit the new opcodes and to insert precise-init calls for
initClassat method start and on static field access. - Adds
TestPreciseInitCctorsin the interpreter tests to verify that static constructors run exactly when expected.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/tests/JIT/interpreter/Interpreter.cs | Added TestPreciseInitCctors; hooked it into RunInterpreterTests |
| src/coreclr/vm/interpexec.cpp | Expanded switch to handle new helper‐call opcodes |
| src/coreclr/interpreter/intops.h | Declared InterpOpHelperFtnNoArgs for no-argument helpers |
| src/coreclr/interpreter/intops.def | Defined new opcodes (_S, _PS, _SP, _GS, _APS, _AGS) |
| src/coreclr/interpreter/compiler.cpp | Emit new opcodes in EmitPushHelperCall_*, insert precise-init logic, update PrintInsData |
Comments suppressed due to low confidence (5)
src/coreclr/interpreter/compiler.cpp:3318
- New code paths for method‐start
initClassand the subsequent runtime‐lookup branches (CORINFO_LOOKUP_THISOBJ,METHODPARAM, etc.) aren't covered by existing interpreter tests. Add tests inInterpreter.csto exercise these branches and validate that the correct helper opcodes are emitted and executed.
CorInfoInitClassResult initOnFunctionStart = m_compHnd->initClass(NULL, NULL, METHOD_BEING_COMPILED_CONTEXT());
src/tests/JIT/interpreter/Interpreter.cs:1996
- The error message references
TriggerCctorClasseven though this branch testsTriggerCctorMethod. Also it doesn't show the actualpreciseInitCctorsRunvalue. Consider usingConsole.WriteLine("preciseInitCctorsRun should be 2, but is {0}", preciseInitCctorsRun);for clarity.
Console.WriteLine("TriggerCctorClass should return 2, but did not");
src/tests/JIT/interpreter/Interpreter.cs:2003
- Same issue as above: this branch follows
new MyPreciseInitClass<double>()but prints the wrong helper name and omits the actual counter value. Update to referencepreciseInitCctorsRunwith the expected versus actual value.
Console.WriteLine("TriggerCctorClass should return 3, but did not");
src/tests/JIT/interpreter/Interpreter.cs:2016
- This message is in the branch testing
TriggerCctorMethod<object>()but again calls out the wrong helper name and hides the counter. Use a consistent message likepreciseInitCctorsRun should be 5, but is {0}.
Console.WriteLine("TriggerCctorClass should return 5, but did not");
src/tests/JIT/interpreter/Interpreter.cs:2023
- Similarly, this branch tests the constructor on
MyPreciseInitClass<Type>()but the message refers toTriggerCctorClassand omits the run count. Consider using the actualpreciseInitCctorsRunin the output for easy debugging.
Console.WriteLine("TriggerCctorClass should return 6, but did not");
Contributor
|
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg |
kg
reviewed
Jun 28, 2025
BrzVlad
approved these changes
Jun 30, 2025
Co-authored-by: Copilot <[email protected]>
This was referenced Jun 30, 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.