1

rabbitmqのrabbit.erlを読むと、ヒップコンパイル関連のコードが含まれています。

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のリファレンスドキュメントにはヒップについての説明はありません。の意味は'o3'何ですか?

(emacs@chen-yumatoMacBook-Pro.local)51> hipe:c(xx_reader,[o3]).
{ok,xx_reader}

上記のようにhipe:cを使用した後、pwd()ディレクトリに新しいコンパイル済みファイルが見つかりませんか?どこですか?

4

2 に答える 2

3

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_option(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は、Javaで使用されているものと同じように、JITコンパイルだと思います。ネイティブパーツは実行時にのみ使用できるため、ファイルシステムに明示的な表現があってはなりません。

また、ファイルが存在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}
于 2012-11-29T09:08:41.687 に答える
1

erlangのドキュメントにいくつかあります。ここを参照してください。しかし、ドキュメントは実際にはそれほど多くありません。HiPEのインデックスページは最近更新されたばかりです。

また、erlangシェルでいくつかのヘルプを確認することができます。

> hipe:help().
> hipe:help_options().
> hipe:help_option(Option).
于 2012-11-29T08:17:52.980 に答える