Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

[Enhancement] Use throwhelper in argument validation scenarios to be more inline friendly and reduce code size and improve generation #1415

Open
Mrnikbobjeff opened this issue Oct 5, 2020 · 3 comments
Labels
feature-request A request for a new feature.

Comments

@Mrnikbobjeff
Copy link
Contributor

Summary

Throw expressions are relatively expensive size wise, and may be the reason the method is not inlined. For such cases we might consider adding a throwhelper as we currently use for the netstandard notsupported messages.

API Changes

None, everything is internal. We would simply add a level of indirection to the throwhelper which will never be inlined and thus reduce the overall binary size

Intended Use Case

See the SR class in the dotnet/runtime repository, containing messages used to pass to a throwhelper. For a sample application see Barometer.shared.cs where both of the exceptions could be contained in a throwhelper

@Mrnikbobjeff Mrnikbobjeff added the feature-request A request for a new feature. label Oct 5, 2020
@mattleibow
Copy link
Contributor

I like this.

@Mrnikbobjeff Mrnikbobjeff changed the title [Enhancement] Use throwhelper in argument validation scenarios to be more inline friendly and reduce binary size [Enhancement] Use throwhelper in argument validation scenarios to be more inline friendly and reduce code size and improve generation Oct 5, 2020
@Mrnikbobjeff
Copy link
Contributor Author

https://gist.github.com/Mrnikbobjeff/3c7e65c8d80cea5ba110fbf4439b40cf shows the improved generation for where we simply want to add the indirection. Simply not having to build an exception frame should also be an improvement

@Mrnikbobjeff
Copy link
Contributor Author

The inlining would actually not happen regardless in barometer because of the exception handling mechanism. Other cases such as sms would profit. The question is how far we would want to take this, as they actuall dont pass string parameters to the throwhelper to reduct code size in the methods even more and have the loading il in the throwhelper.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request A request for a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants