You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[release/7.0] JIT: Simplify JitDisasm matching behavior and support namespaces/generics in release (#75260)
* JIT: Simplify JitDisasm matching behavior (#74430)
This changes how the JIT matches method names and signatures for method
sets (e.g. JitDisasm). It also starts printing method instantiations for full method names
and makes references to types consistent in generic instantiations and the signature.
In addition it starts supporting generic instantiations in release too.
To do this, most of the type printing is moved to the JIT, which also aligns the output
between crossgen2 and the VM (there were subtle differences here, like spaces between generic type arguments).
More importantly, we (for the most part) stop relying on JIT-EE methods that are documented to only be for debug purposes.
The new behavior of the matching is the following:
* The matching behavior is always string based.
* The JitDisasm string is a space-separated list of patterns. Patterns can arbitrarily
contain both '*' (match any characters) and '?' (match any 1 character).
* The string matched against depends on characters in the pattern:
+ If the pattern contains a ':' character, the string matched against is prefixed by the class name and a colon
+ If the pattern contains a '(' character, the string matched against is suffixed by the signature
+ If the class name (part before colon) contains a '[', the class contains its generic instantiation
+ If the method name (part between colon and '(') contains a '[', the method contains its generic instantiation
For example, consider
```
namespace MyNamespace
{
public class C<T1, T2>
{
[MethodImpl(MethodImplOptions.NoInlining)]
public void M<T3, T4>(T1 arg1, T2 arg2, T3 arg3, T4 arg4)
{
}
}
}
new C<sbyte, string>().M<int, object>(default, default, default, default); // compilation 1
new C<int, int>().M<int, int>(default, default, default, default); // compilation 2
```
The full strings are:
Before the change:
```
MyNamespace.C`2[SByte,__Canon][System.SByte,System.__Canon]:M(byte,System.__Canon,int,System.__Canon)
MyNamespace.C`2[Int32,Int32][System.Int32,System.Int32]:M(int,int,int,int)
```
Notice no method instantiation and the double class instantiation, which seems like an EE bug. Also two different names are used for sbyte: System.SByte and byte.
After the change the strings are:
```
MyNamespace.C`2[byte,System.__Canon]:M[int,System.__Canon](byte,System.__Canon,int,System.__Canon)
MyNamespace.C`2[int,int]:M[int,int](int,int,int,int)
```
The following strings will match both compilations:
```
M
*C`2:M
*C`2[*]:M[*](*)
MyNamespace.C`2:M
```
The following will match only the first one:
```
M[int,*Canon]
MyNamespace.C`2[byte,*]:M
M(*Canon)
```
There is one significant change in behavior here, which is that I have removed the special case that allows matching class names without namespaces. In particular, today Console:WriteLine would match all overloads of System.Console.WriteLine, while after this change it will not match. However, with generalized wild cards the replacement is simple in *Console:WriteLine.
* Update JIT-EE GUID
Avoid using the same JIT-EE GUID as the main branch.
Copy file name to clipboardExpand all lines: docs/design/coreclr/jit/viewing-jit-dumps.md
+42-12Lines changed: 42 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -120,29 +120,59 @@ These can be set in one of three ways:
120
120
121
121
## Specifying method names
122
122
123
-
The complete syntax for specifying a single method name (for a flag that takes a method name, such as `COMPlus_JitDump`) is:
124
-
123
+
Some environment variables such as `COMPlus_JitDump` take a set of patterns specifying method names. The matching works in the following way:
124
+
* A method set string is a space-separated list of patterns. Patterns can arbitrarily contain both '*' (match any characters) and '?' (match any 1 character).
125
+
* The string matched against depends on characters in the pattern:
126
+
+ If the pattern contains a ':' character, the string matched against is prefixed by the class name and a colon
127
+
+ If the pattern contains a '(' character, the string matched against is suffixed by the signature
128
+
+ If the class name (part before colon) contains a '[', the class contains its generic instantiation
129
+
+ If the method name (part between colon and '(') contains a '[', the method contains its generic instantiation
130
+
131
+
In particular, the matching is done against strings of the following format which coincides with how the JIT displays method signatures (so these can be copy pasted into the environment variable).
Note that ``C`2`` here is the name put into metadata by Roslyn; the suffix is not added by RyuJIT.
160
+
For Powershell users keep in mind that backtick is the escape character and itself has to be escaped via double backtick.
140
161
141
-
will match all methods named Main from any class and any number of arguments.
142
-
143
-
`<types>` is a comma separated list of type names. Note that presently only the number of arguments and not the types themselves are used to distinguish methods. Thus, `Main(Foo, Bar)` and `Main(int, int)` will both match any main method with two arguments.
162
+
The following strings will match both compilations:
163
+
```
164
+
M
165
+
*C`2:M
166
+
*C`2[*]:M[*](*)
167
+
MyNamespace.C`2:M
168
+
```
144
169
145
-
The wildcard character `*` can be used for `<ClassName>` and `<MethodName>`. In particular `*` by itself indicates every method.
0 commit comments