Erlang hipe编译选项的含义以及本机文件的位置

Erlang hipe编译选项的含义以及本机文件的位置,erlang,hipe,Erlang,Hipe,读取rabbitmq的rabbit.erl时,它包含与hipe编译相关的代码 hipe_compile() -> Count = length(?HIPE_WORTHY), io:format("HiPE compiling: |~s|~n |", [string:copies("-", Count)]), T1 = erlang:now(), PidMRefs = [spawn_monitor(

读取rabbitmq的rabbit.erl时,它包含与hipe编译相关的代码

hipe_compile() ->
    Count = length(?HIPE_WORTHY),
    io:format("HiPE compiling:  |~s|~n                 |",
              [string:copies("-", Count)]),
    T1 = erlang:now(),
    PidMRefs = [spawn_monitor(fun () -> [begin
                                             {ok, M} = hipe:c(M, [o3]),
                                             io:format("#")
                                         end || M <- Ms]
                              end) ||
                   Ms <- split(?HIPE_WORTHY, ?HIPE_PROCESSES)],
    [receive
         {'DOWN', MRef, process, _, normal} -> ok;
         {'DOWN', MRef, process, _, Reason} -> exit(Reason)
     end || {_Pid, MRef} <- PidMRefs],
    T2 = erlang:now(),
    io:format("|~n~nCompiled ~B modules in ~Bs~n",
              [Count, timer:now_diff(T2, T1) div 1000000]).
在我如上所述使用hipe:c之后,在pwd()目录中找不到新的编译文件?
它在哪里?

在erlang的文档中有一些。看见但医生确实不多。HiPE的定义最近才更新

此外,您还可以在erlang shell中查看一些帮助

> hipe:help().
> hipe:help_options().
> hipe:help_option(Option).

在erlang的文档中有一些。看见但医生确实不多。HiPE的定义最近才更新

此外,您还可以在erlang shell中查看一些帮助

> hipe:help().
> hipe:help_options().
> hipe:help_option(Option).

o3
表示编译器使用的优化级别。还有级别
o0
o1
o2
。详情如下:

   o1 = [inline_fp,pmatch,peephole],
   o2 = [icode_range,icode_ssa_const_prop,icode_ssa_copy_prop,icode_type,
         icode_inline_bifs,rtl_lcm,rtl_ssa,rtl_ssa_const_prop,spillmin_color,
         use_indexing,remove_comments,concurrent_comp,binary_opt] ++ o1,
   o3 = [{regalloc,coalescing},icode_range] ++ o2.
您可以使用
hipe:help\u选项(option)
进一步调查不同选项的含义。比如说,

3> hipe:help_option(regalloc).
regalloc - Select register allocation algorithm. Used as {regalloc, METHOD}.
  Currently available methods:
    naive - spills everything (for debugging and testing)
    linear_scan - fast; not so good if few registers available
    graph_color - slow, but gives OK performance
    coalescing - slower, tries hard to use registers
    optimistic - another variant of a coalescing allocator
ok
4> hipe:help_option(icode_range).
icode_range - Performs integer range analysis on the Icode level
ok

我认为HiPE是JIT编译,就像Java中使用的一样。本机部件仅在运行时可用,因此在文件系统中不应有显式表示

另外,
hipe:c
确实需要一个
。beam
文件存在。例如,如果您使用一些东西创建一个
test.erl
,而没有将其编译为
.beam
文件,直接调用
hipe:c
将导致错误:

1> hipe:c(test, [o3]).
<HiPE (v 3.9.3)> EXITED with reason {cant_find_beam_file,test} @hipe:419

=ERROR REPORT==== 29-Nov-2012::17:03:02 ===
<HiPE (v 3.9.3)> Error: [hipe:418]: Cannot find test.beam file.** exception error: {hipe,419,{cant_find_beam_file,test}}
     in function  hipe:beam_file/1 (hipe.erl, line 419)
     in call from hipe:c/2 (hipe.erl, line 313)
2> c(test).
{ok,test}
3> hipe:c(test, [o3]).
{ok,test}
1>hipe:c(测试[o3])。
退出原因为{cant_find_beam_file,test}@hipe:419
=错误报告===2012年11月29日::17:03:02===
错误:[hipe:418]:找不到test.beam文件。**异常错误:{hipe,419,{cant\u find\u beam\u file,test}
函数hipe:beam_文件/1(hipe.erl,第419行)
hipe呼叫:c/2(hipe.erl,第313行)
2> c(测试)。
{好的,测试}
3> hipe:c(测试[o3])。
{好的,测试}

o3
表示编译器使用的优化级别。还有级别
o0
o1
o2
。详情如下:

   o1 = [inline_fp,pmatch,peephole],
   o2 = [icode_range,icode_ssa_const_prop,icode_ssa_copy_prop,icode_type,
         icode_inline_bifs,rtl_lcm,rtl_ssa,rtl_ssa_const_prop,spillmin_color,
         use_indexing,remove_comments,concurrent_comp,binary_opt] ++ o1,
   o3 = [{regalloc,coalescing},icode_range] ++ o2.
您可以使用
hipe:help\u选项(option)
进一步调查不同选项的含义。比如说,

3> hipe:help_option(regalloc).
regalloc - Select register allocation algorithm. Used as {regalloc, METHOD}.
  Currently available methods:
    naive - spills everything (for debugging and testing)
    linear_scan - fast; not so good if few registers available
    graph_color - slow, but gives OK performance
    coalescing - slower, tries hard to use registers
    optimistic - another variant of a coalescing allocator
ok
4> hipe:help_option(icode_range).
icode_range - Performs integer range analysis on the Icode level
ok

我认为HiPE是JIT编译,就像Java中使用的一样。本机部件仅在运行时可用,因此在文件系统中不应有显式表示

另外,
hipe:c
确实需要一个
。beam
文件存在。例如,如果您使用一些东西创建一个
test.erl
,而没有将其编译为
.beam
文件,直接调用
hipe:c
将导致错误:

1> hipe:c(test, [o3]).
<HiPE (v 3.9.3)> EXITED with reason {cant_find_beam_file,test} @hipe:419

=ERROR REPORT==== 29-Nov-2012::17:03:02 ===
<HiPE (v 3.9.3)> Error: [hipe:418]: Cannot find test.beam file.** exception error: {hipe,419,{cant_find_beam_file,test}}
     in function  hipe:beam_file/1 (hipe.erl, line 419)
     in call from hipe:c/2 (hipe.erl, line 313)
2> c(test).
{ok,test}
3> hipe:c(test, [o3]).
{ok,test}
1>hipe:c(测试[o3])。
退出原因为{cant_find_beam_file,test}@hipe:419
=错误报告===2012年11月29日::17:03:02===
错误:[hipe:418]:找不到test.beam文件。**异常错误:{hipe,419,{cant\u find\u beam\u file,test}
函数hipe:beam_文件/1(hipe.erl,第419行)
hipe呼叫:c/2(hipe.erl,第313行)
2> c(测试)。
{好的,测试}
3> hipe:c(测试[o3])。
{好的,测试}

HiPE不是JIT编译器。本机代码保存为.beam文件的一部分,因此,如果您曾经将模块编译为本机代码,则下次可以立即加载本机代码。(如果将.beam文件移动到其他体系结构,则除非在新平台上重新编译,否则无法使用本机代码。)@RichardC谢谢!你有详细的参考资料吗?为什么
hipe:c
要求存在
.beam
文件?hipe:c()不要求存在.beam文件。但是普通用户不应该使用hipe模块来编译模块——只需将+native标志赋予erlc即可。另请参见HiPE不是JIT编译器。本机代码保存为.beam文件的一部分,因此,如果您曾经将模块编译为本机代码,则下次可以立即加载本机代码。(如果将.beam文件移动到其他体系结构,则除非在新平台上重新编译,否则无法使用本机代码。)@RichardC谢谢!你有详细的参考资料吗?为什么
hipe:c
要求存在
.beam
文件?hipe:c()不要求存在.beam文件。但是普通用户不应该使用hipe模块来编译模块——只需将+native标志赋予erlc即可。也看到