首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >hipe compile选项的含义和本机文件的位置

hipe compile选项的含义和本机文件的位置
EN

Stack Overflow用户
提问于 2012-11-29 16:04:58
回答 2查看 2K关注 0票数 1

读取rabbitmq的rabbit.erl,it包含hipe编译相关代码。

代码语言:javascript
复制
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]).

但是在erlang的参考文档中没有关于hipe的解释。'o3'是什么意思?

代码语言:javascript
复制
(emacs@chen-yumatoMacBook-Pro.local)51> hipe:c(xx_reader,[o3]).
{ok,xx_reader}

在我如上使用hipe:c之后,在pwd()目录中找不到新的编译文件?它在哪里?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-11-29 17:08:42

o3表示编译器使用的优化级别。还有o0o1o2级别。有关级别的详细资料如下:

代码语言:javascript
复制
   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_option(Option)进一步研究不同选项的含义。例如,

代码语言:javascript
复制
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将导致错误:

代码语言:javascript
复制
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}
票数 3
EN

Stack Overflow用户

发布于 2012-11-29 16:17:53

在erlang的文档中有一些。参见here。但医生确实不是很多。HiPE的index page最近才更新。

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

代码语言:javascript
复制
> hipe:help().
> hipe:help_options().
> hipe:help_option(Option).
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13621285

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档