Skip to content

Improve the interpreter internal diagnostic capabilities #116162

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

Merged

Conversation

davidwrighton
Copy link
Member

@davidwrighton davidwrighton commented May 30, 2025

  • Duplicate the concept of MethodSet's from the JIT
    • Methods can be specified with granularity of by method name, class, instantiation, etc.
    • This works for DOTNET_Interpreter, DOTNET_InterpDump and DOTNET_InterpHalt
  • Improve printing of method names. The names now match the JIT. One detail here is that the names are now derived directly from CorInfoType instead of the jittype. To avoid differences between interpreter and JIT behavior here, the naming in the jit was adjusted slightly. The most significant change is that bool, byte are now distinguishable, byte and sbyte names that instead of ubyte and byte, and we have nint/nuint instead of those cases being indistinguishable from the integral types.
  • Add a new config switch DOTNET_InterpList, when enabled this will list all methods that go through the Interpreter compiler
    • Since this is an integer, add support for arbitrary integer config knobs in the interpreter compiler

- Duplicate the concept of MethodSet's from the JIT
  -  Methods can be specified with granularity of by method name, class, instantiation, etc.
  - This works for DOTNET_Interpreter, DOTNET_InterpDump and DOTNET_InterpHalt
- Improve printing of method names to be very nearly equivalent to that of the JIT. This will include signatures/instantiations in all method printing
  - The only differences are where the JIT has a concept of var_type, and the interpreter just uses CorInfoType. I believe the ouput is very nearly identical, but I'm not 100% confident.
- Add a new config switch DOTNET_InterpList, when enabled this will list all methods that go through the Interpreter compiler
  - Since this is an integer, add support for arbitrary integer config knobs in the interpreter compiler
@Copilot Copilot AI review requested due to automatic review settings May 30, 2025 22:02
Copy link
Contributor

@Copilot 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

Enhance the interpreter’s diagnostics by refining method name printing (mirroring JIT functionality), duplicating MethodSet support for configurable method matching, and adding integer configuration for method listing.

  • Refactored method name printing in naming.cpp and compiler.cpp for detailed signature output.
  • Introduced MethodSet (in methodset.cpp and interpretershared.h) to support fine‐grained method specification and matching.
  • Added new configuration switches and integer config support in interpconfig* files for diagnostic capabilities.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/coreclr/interpreter/naming.cpp Updated functions to build method names for diagnostics.
src/coreclr/interpreter/methodset.cpp Implements MethodSet parsing and pattern matching.
src/coreclr/interpreter/interpretershared.h Declares new types and MethodSet for interpreter diagnostics.
src/coreclr/interpreter/interpconfigvalues.h Introduces configuration macros for MethodSet and integer config.
src/coreclr/interpreter/interpconfig.h Updates configuration getters and setters for interpreter configs.
src/coreclr/interpreter/interpconfig.cpp Initializes and destroys new configuration values.
src/coreclr/interpreter/eeinterp.cpp Updates interpretation conditions to use MethodSet matching.
src/coreclr/interpreter/datastructs.h Adds array-grow utilities supporting dynamic array operations.
src/coreclr/interpreter/compiler.h Declares enhanced method name printing functions and member updates.
src/coreclr/interpreter/compiler.cpp Uses improved method printing for verbose debug output.
src/coreclr/interpreter/CMakeLists.txt Includes new source files for the interpreter diagnostic enhancements.

Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @janvorli, @kg
See info in area-owners.md if you want to be subscribed.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
// and this class takes ownership of the string.
// host - Pointer to host interface
//
void MethodSet::initialize(const char* listFromConfig)
Copy link
Member

Choose a reason for hiding this comment

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

This is near verbatim copy of the code from the JIT.

(I am just pointing it out. Like on previous instances of code duplication - it does not need to be addressed in this PR.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. Most of this PR is approximately verbatim. Notably, the method name printing is ALSO nearly verbatim, but it has the advantage that it is not dependent on any significant JIT headers. The only thing it depends on is a growable array type. I think it is likely we would be able to share most of the logic of both of these between the JIT/Interpreter, but we haven't set up any real sharing between the two yet.

Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to put a marker comment at the top of the file to say where it was copied from? There's a risk of the information becoming stale but if there's an expectation that it will eventually get deduplicated it would likely help with the future effort.

Copy link
Member

@jakobbotsch jakobbotsch left a comment

Choose a reason for hiding this comment

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

The only differences are where the JIT has a concept of var_type, and the interpreter just uses CorInfoType. I believe the ouput is very nearly identical, but I'm not 100% confident.

Left some feedback that should make this match more, but we might consider changing the JIT's printing to print the CorInfoType names instead. Not sure how breaking we would consider a change like that.

@davidwrighton
Copy link
Member Author

@jakobbotsch honestly, I'd prefer to have the JIT match these, but yes, you've identified what I think are all the issues I could find.

@jakobbotsch
Copy link
Member

I am fine with changing the JIT names to match the names here, if we are ok with that small break. But I do think we should make sure they match each other exactly, regardless of which names we end up with.

@davidwrighton
Copy link
Member Author

@jakobbotsch I've updated the JIT to match the interpreter now. I've also spoken to @jkotas and he isn't concerned about this being a breaking change. (It's not considered a breaking change for customers... it might be slightly surprising to jit devs, but I expect you to all adjust very quickly.)

@jakobbotsch
Copy link
Member

jakobbotsch commented Jun 4, 2025

cc @dotnet/jit-contrib -- types printed in signatures (and matched when specifying method set names) are changing to use the more familiar names instead of the JIT type names. E.g. System.Byte is now printed as byte instead of ubyte, and signed bytes are now printed as sbyte instead of byte.

@davidwrighton davidwrighton merged commit 75de83c into dotnet:main Jun 5, 2025
110 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants