1

我的问题与类似,但有所不同,因为我不询问 EditAndContinue。

我读过存在热重新编译。我的意思是,例如我们有这样的代码

if (a > 0 && b >0 && c > 0 && d > 0)

我们假设我们有一个监控可执行文件和启动 JIT 的环境(例如 CLR)。所以这个环境看到这种情况很少见(我们不知道或编译时d > 0的实际值,我们只能在运行时收集一些统计信息)。所以它可以像这样重新编译它a b cd

if (d > 0 && a > 0 && b >0 && c > 0)

因此,由于首先检查了最不可能的条件,我们得到了优化。那么这个热重编译实际上是如何命名的呢?它如何以及在哪里工作?

4

1 回答 1

0

可以称为分支重新排序

GCC 似乎也支持类似的分支分析选项,这可能会帮助您追踪真实姓名。

-fbranch-probabilities
   After running a program compiled with -fprofile-arcs
   (see Options for Debugging Your Program or gcc), you can compile it a second
   time using -fbranch-probabilities, to improve optimizations based on the number
   of times each branch was taken. When a program compiled with -fprofile-arcs
   exits, it saves arc execution counts to a file called sourcename.gcda for each
   source file. The information in this data file is very dependent on the
   structure of the generated code, so you must use the same source code and the
   same optimization options for both compilations. 

   With -fbranch-probabilities, GCC puts a ‘REG_BR_PROB’ note on each ‘JUMP_INSN’
   and ‘CALL_INSN’. These can be used to improve optimization. Currently, they are
   only used in one place: in reorg.c, instead of guessing which path a branch is
   most likely to take, the ‘REG_BR_PROB’ values are used to exactly determine
   which path is taken more often. 
于 2013-12-17T04:54:33.583 回答