JIT热重编译

时间:2013-09-01 15:05:58

标签: .net performance compiler-construction clr jit

我的问题与this one类似,但有所不同,因为我不会询问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)

所以我们得到了一个优化,因为最先检查条件的可能性最小。那么热重新编译如何被命名?它是如何以及在哪里工作的?

1 个答案:

答案 0 :(得分:0)

可以调用Branch Reordering

GCC似乎也支持类似的branch profiling option,这可能会帮助您追踪真实姓名。

-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.