-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Removing conversion from typehandle to methodtable #119625
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
Conversation
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 removes the explicit conversion from TypeHandle to MethodTable by directly using the TypeHandle's internal target address field instead of calling GetMethodTable().
Key Changes
- Eliminates intermediate MethodTable pointer variable
- Replaces TypeHandle::GetMethodTable() call with direct access to the internal m_asTAddr field
- Simplifies null checking by using the address field directly
Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag |
@jkotas I realized that removing the conversion without any changes to SOS may not be the best approach. If I look at it in windbg, we then print out an address in the "MT" column that is actually not a method table. Then there is the command shortcut, which of course leads to "is not a MethodTable". ![]() I don't know if there is a more meaningful approach, maybe we just set these to be displayed as zero on the SOS side. It also turns out that the "more detailed names" only appear for ValueType and Class at least now. I could look into expanding that as an enhancement. |
I think Jan's original suggestion to pass through MethodTable pointers as-is and convert all other TypeDescs into NULL is just fine. We aren't losing much. The other alternative is change the implementation of DumpMT to accept any TypeHandle and pretty print it, not just MethodTable pointers. I'm guessing doing that nicely may require some new DAC APIs in which case its probably better to file it as a feature suggestion for another time rather than continue to expand the scope of this PR. |
if (th.AsTAddr()) | ||
{ | ||
FieldDescData->MTOfType = HOST_CDADDR(th.GetMethodTable()); | ||
FieldDescData->MTOfType = HOST_CDADDR(PTR_MethodTable(th.AsTAddr())); |
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.
FieldDescData->MTOfType = HOST_CDADDR(PTR_MethodTable(th.AsTAddr())); | |
FieldDescData->MTOfType = TO_CDADDR(th.AsTAddr()); |
Any reason to convert the TADDR to a pointer to convert it back to a TADDR?
This wouldn't require any new APIs. The cDAC already supports this behavior today. All of the APIs that take a MethodTable implicitly allow You are correct that the DAC implementation doesn't support this right now. If we set the field to 0 for TypeDescs, I think we should leave an issue/comment to convert it to pass in the TypeDesc when the DAC is deprecated. |
I think we can pass on zero for TypeDescs in both DAC and cDAC if we use our existing method table validation. In the DAC we can use DacValidateMethodTable, and in the cDAC we can expose MT validation as an API in addition to having it wrapped up in GetTypeHandle. |
There is another cDAC API, GetMethodTableData, whose expected behavior is to fail on non-valid method tables, but it looks like it just returns an empty data structure. If we have a way to validate method tables, we could implement the correct behavior for these. Alternatively we could throw on the methods that expect a valid method tables, such as GetBase, but I believe having a way to validate method tables is cleaner. |
L
We can differentiate using Jan’s suggestion. |
That sounds good. I think we just keep the original DAC behavior for now or pass null, and if we wanted to change it do it in conjunction with possible changes to SOS. |
We already have IsFunctionPointer and IsGenericVariable |
No description provided.