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

Consider remove aggressive inlining for small method #44

Open
YohDeadfall opened this issue Apr 10, 2023 · 1 comment
Open

Consider remove aggressive inlining for small method #44

YohDeadfall opened this issue Apr 10, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@YohDeadfall
Copy link

The code can be simplified by avoiding MethodImpl with AggressiveInlining at least for simple methods since the JIT compiler is smart enough to do that automatically at least for .NET/.NET Core (has no idea about .NET Framework and cannot check it). There's a rule for small methods which IL size is lower or equal to 32 bytes, and attributed methods I checked just reroute execution. There are additional rules on flow graphs, but again, these methods are very simple and should be automatically inlined.

@kekyo
Copy link
Owner

kekyo commented Apr 11, 2023

Thanks for the suggestions! 😄 I tend to write this attribute and it has affected FlashCap as well. As you pointed out, I knew that JIT automatically optimizes for small method bodies. And likewise, I don't know exactly how it works in the .NET Framework CLR.

On the other hand, I am not comfortable with the application of a lot of attributes whose effects are not concrete. I would be willing to consider removing attributes in a positive way.


The following is really based on my personal imagination and thoughts and may have nothing to do with this issue.

The reason why I persistently apply this attribute is because (which has nothing to do with FlashCap) in one of my projects, IL2C, I had the intention of using this attribute as a apply to give the output C code inline as well (not yet realized, but not difficult to do so).

This means, of course, that it is hard to guess how this attribute will be evaluated by the .NET runtime. .NET runtime nowadays may refer to CoreCLR, but not so long ago (really not so long ago ! :) , mono was still in use and there were various attempts to re-implement CLR. Since I am one of those people, I would unintentionally implement the CoreCLR in such a way that it is neutral and not adapted to the convenience of CoreCLR.

@kekyo kekyo added the enhancement New feature or request label Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants