开发者

How do I know if a Delphi function is going to be inlined?

开发者 https://www.devze.com 2023-02-11 22:25 出处:网络
When you mark a function as inline, you hint the compiler that this function is a candidate for inlining. The compiler can still decide that it\'s not a good idea, and ignore it.

When you mark a function as inline, you hint the compiler that this function is a candidate for inlining. The compiler can still decide that it's not a good idea, and ignore it.

  1. Is there a way to see if the function gets inlined or not, without using the disassembler? Is there some compiler warning that I don't know about maybe?

  2. What are the rules for inlining that the compiler uses开发者_JAVA技巧? Are there constructs that cause a function to never get inlined for example?


The compiler emits a hint if it can't inline your function. The documentation explains the rules for what can and cannot be inlined.

As for the discretionary decisions that the compiler takes as to whether or not to inline (as opposed to whether or not inlining is possible), they are not documented and can be considered an implementation detail.

I recall that you recently commented on one of my answers to a different question that a particular function was 10 times faster once inlined. Clearly you are interested in inlining but in that particular case I cannot believe such an enormous gain for a function with so many floating point operations. I suspect that inlining is not actually giving you the performance improvements that you think it does.


You can look at the blue dots in the gutter after building the project. If there are blue dots next to a function it hasn't been inlined at least once.

I don't think you can rely on hints emitted by the compiler. It tells you when it's not inlined because the file the function lives in isn't in the interface uses clause. If it's because of other reasons it typically doesn't tell you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号