我如何知道是否要内联Delphi函数? [英] How do I know if a Delphi function is going to be inlined?

查看:63
本文介绍了我如何知道是否要内联Delphi函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您将函数标记为 inline 时,会提示编译器该函数是内联的候选对象。编译器仍然可以认为这不是一个好主意,可以忽略它。

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. 是否有办法查看该函数获得内联与否,无需使用反汇编程序?
    是否有一些我可能不知道的编译器警告?

  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?

编译器使用的内联规则是什么?例如,是否存在使函数永不内联的构造?

What are the rules for inlining that the compiler uses? 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.

我记得您最近对我对另一个问题的回答进行了评论,该问题是内联后某个特定功能的运行速度提高了10倍。显然,您对内联感兴趣,但是在这种特殊情况下,我不敢相信具有这么多浮点运算的函数会​​获得如此巨大的收益。我怀疑内联实际上并没有给您带来您认为可以改善的性能。

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.

这篇关于我如何知道是否要内联Delphi函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆