Skip to content
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

Make it possible to construct StackFrame without MethodBase #80681

Merged
merged 3 commits into from
Jan 17, 2023

Conversation

MichalStrehovsky
Copy link
Member

@MichalStrehovsky MichalStrehovsky commented Jan 16, 2023

Contributes to #80165.

Resolving a MethodBase is a pretty expensive operation and currently even a hello world needs it because of Exception.ToString(). This pull request is trying to get MethodBase out of the picture when constructing the exception string.

We currently only need _method for two things - the public GetMethod API, and StackFrame.ToString. The StackFrame.ToString can already deal with _method being null (and that codepath exists solely for NativeAOT). This is the minimal change. We could potentially explore other approaches - leave MethodBase always at null, or unshare the StackFrame class.

Cc @dotnet/ilc-contrib

Contributes to dotnet#80165.

Resolving a `MethodBase` is a pretty expensive operation and currently even a hello world needs it because of `Exception.ToString()`. This pull request is trying to get `MethodBase` out of the picture when constructing the exception string.

We currently only need `_method` for two things - the public `GetMethod` API, and `StackFrame.ToString`. The `StackFrame.ToString` can already deal with `_method` being null (and that codepath exists solely for NativeAOT). This is the minimal change. We could potentially explore other approaches - leave `MethodBase` always at null, or unshare the `StackFrame` class.
@ghost
Copy link

ghost commented Jan 16, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Contributes to #80165.

Resolving a MethodBase is a pretty expensive operation and currently even a hello world needs it because of Exception.ToString(). This pull request is trying to get MethodBase out of the picture when constructing the exception string.

We currently only need _method for two things - the public GetMethod API, and StackFrame.ToString. The StackFrame.ToString can already deal with _method being null (and that codepath exists solely for NativeAOT). This is the minimal change. We could potentially explore other approaches - leave MethodBase always at null, or unshare the StackFrame class.

Author: MichalStrehovsky
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -


private bool TryInitializeMethodBase()
{
if (_noMethodBaseAvailable || _ipAddress == IntPtr.Zero)
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to handle Exception.EdiSeparator?

if (_method != null)
return true;

IntPtr methodStartAddress = RuntimeImports.RhFindMethodStartAddress(_ipAddress);
Copy link
Member

Choose a reason for hiding this comment

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

This can be just _ipAddress - _nativeOffset. (We can assert that it is same value as what RhFindMethodStartAddress returns.)

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks

@MichalStrehovsky MichalStrehovsky merged commit 7237cb5 into dotnet:main Jan 17, 2023
@MichalStrehovsky MichalStrehovsky deleted the stackframemethod branch January 17, 2023 05:55
@ghost ghost locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants