トレーシング実行時コンパイル
[Wikipedia|▼Menu]
.mw-parser-output .sidebar{width:auto;float:right;clear:right;margin:0.5em 0 1em 1em;background:#f8f9fa;border:1px solid #aaa;padding:0.2em;text-align:center;line-height:1.4em;font-size:88%;border-collapse:collapse;display:table}body.skin-minerva .mw-parser-output .sidebar{display:table!important;float:right!important;margin:0.5em 0 1em 1em!important}.mw-parser-output .sidebar-subgroup{width:100%;margin:0;border-spacing:0}.mw-parser-output .sidebar-left{float:left;clear:left;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-none{float:none;clear:both;margin:0.5em 1em 1em 0}.mw-parser-output .sidebar-outer-title{padding:0 0.4em 0.2em;font-size:125%;line-height:1.2em;font-weight:bold}.mw-parser-output .sidebar-top-image{padding:0.4em}.mw-parser-output .sidebar-top-caption,.mw-parser-output .sidebar-pretitle-with-top-image,.mw-parser-output .sidebar-caption{padding:0.2em 0.4em 0;line-height:1.2em}.mw-parser-output .sidebar-pretitle{padding:0.4em 0.4em 0;line-height:1.2em}.mw-parser-output .sidebar-title,.mw-parser-output .sidebar-title-with-pretitle{padding:0.2em 0.8em;font-size:145%;line-height:1.2em}.mw-parser-output .sidebar-title-with-pretitle{padding:0 0.4em}.mw-parser-output .sidebar-image{padding:0.2em 0.4em 0.4em}.mw-parser-output .sidebar-heading{padding:0.1em 0.4em}.mw-parser-output .sidebar-content{padding:0 0.5em 0.4em}.mw-parser-output .sidebar-content-with-subgroup{padding:0.1em 0.4em 0.2em}.mw-parser-output .sidebar-above,.mw-parser-output .sidebar-below{padding:0.3em 0.8em;font-weight:bold}.mw-parser-output .sidebar-collapse .sidebar-above,.mw-parser-output .sidebar-collapse .sidebar-below{border-top:1px solid #aaa;border-bottom:1px solid #aaa}.mw-parser-output .sidebar-navbar{text-align:right;font-size:75%;padding:0 0.4em 0.4em}.mw-parser-output .sidebar-list-title{padding:0 0.4em;text-align:left;font-weight:bold;line-height:1.6em;font-size:105%}.mw-parser-output .sidebar-list-title-c{padding:0 0.4em;text-align:center;margin:0 3.3em}@media(max-width:720px){body.mediawiki .mw-parser-output .sidebar{width:100%!important;clear:both;float:none!important;margin-left:0!important;margin-right:0!important}}

プログラムの実行
一般的な概念


コード(英語版)

トランスレーション

コンパイル

コンパイル時


コンパイラの最適化(英語版)


中間表現 (IR)

実行

ランタイムシステム

ランタイム


実行ファイル

インタプリタ

バーチャルマシン


コードの種類


ソースコード

オブジェクトコード

バイトコード

機械語(マシン語)

マイクロコード

コンパイル戦略


実行時コンパイル (JIT)

トレーシング実行時コンパイル


事前コンパイル (AOT)

トランスコンパイル

再コンパイル(英語版)

有名なランタイム


Android Runtime (ART)

Common Language Runtime (CLR) & Mono

crt0(英語版)

HHVM

Java仮想マシン (JVM)

Objective-C & Swift

Chrome V8 & Node.js

PyPy

Zend Engine

有名なコンパイラとツールチェーン


GNUコンパイラコレクション (GCC)

LLVM & Clang

.mw-parser-output .hlist ul,.mw-parser-output .hlist ol{padding-left:0}.mw-parser-output .hlist li,.mw-parser-output .hlist dd,.mw-parser-output .hlist dt{margin-right:0;display:inline-block;white-space:nowrap}.mw-parser-output .hlist dt:after,.mw-parser-output .hlist dd:after,.mw-parser-output .hlist li:after{white-space:normal}.mw-parser-output .hlist li:after,.mw-parser-output .hlist dd:after{content:" ・\a0 ";font-weight:bold}.mw-parser-output .hlist dt:after{content:": "}.mw-parser-output .hlist-pipe dd:after,.mw-parser-output .hlist-pipe li:after{content:" |\a0 ";font-weight:normal}.mw-parser-output .hlist-hyphen dd:after,.mw-parser-output .hlist-hyphen li:after{content:" -\a0 ";font-weight:normal}.mw-parser-output .hlist-comma dd:after,.mw-parser-output .hlist-comma li:after{content:"、";font-weight:normal}.mw-parser-output .hlist-slash dd:after,.mw-parser-output .hlist-slash li:after{content:" /\a0 ";font-weight:normal}.mw-parser-output .hlist dd:last-child:after,.mw-parser-output .hlist dt:last-child:after,.mw-parser-output .hlist li:last-child:after{content:none}.mw-parser-output .hlist dd dd:first-child:before,.mw-parser-output .hlist dd dt:first-child:before,.mw-parser-output .hlist dd li:first-child:before,.mw-parser-output .hlist dt dd:first-child:before,.mw-parser-output .hlist dt dt:first-child:before,.mw-parser-output .hlist dt li:first-child:before,.mw-parser-output .hlist li dd:first-child:before,.mw-parser-output .hlist li dt:first-child:before,.mw-parser-output .hlist li li:first-child:before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child:after,.mw-parser-output .hlist dd dt:last-child:after,.mw-parser-output .hlist dd li:last-child:after,.mw-parser-output .hlist dt dd:last-child:after,.mw-parser-output .hlist dt dt:last-child:after,.mw-parser-output .hlist dt li:last-child:after,.mw-parser-output .hlist li dd:last-child:after,.mw-parser-output .hlist li dt:last-child:after,.mw-parser-output .hlist li li:last-child:after{content:")\a0 ";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li:before{content:" "counter(listitem)" ";white-space:nowrap}.mw-parser-output .hlist dd ol>li:first-child:before,.mw-parser-output .hlist dt ol>li:first-child:before,.mw-parser-output .hlist li ol>li:first-child:before{content:" ("counter(listitem)" "}.mw-parser-output .navbar{display:inline;font-size:75%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}.mw-parser-output .infobox .navbar{font-size:88%}.mw-parser-output .navbox .navbar{display:block;font-size:88%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}









トレーシング実行時コンパイル(トレーシングじっこうじコンパイル、トレーシングJIT、: Tracing just-in-time compilation)は、プログラムの実行を最適化するために、実行時(runtime)に仮想マシンが用いる技術の一つ。頻繁に実行される演算の並びを記録し、それをネイティブコードコンパイルしてから実行する。通常の実行時コンパイラ(just-in-time compiler、JIT)はメソッド毎にこれを行っており、この点が異なる。
概要

JITコンパイルは実行時にプログラムの一部を機械語にコンパイルすることでプログラムを高速に実行させる技術である。コンパイル対象の範囲によってJITコンパイラを分類すると、メソッド単位を基本とするJITコンパイラは一度に一つのメソッドを機械語に変換するが、トレーシングJITは頻繁に実行されるループをコンパイル対象の単位としている。トレーシングJITは、プログラムの実行時間の大半はプログラムの一部のループ(ホットループ)の実行に費やされており、かつそのループが再び実行される場合はたいてい前回と同様の実行パスを経る、という仮定に基づいている。通常、トレーシングJIT機能を有する仮想マシンは代替となる実行環境モードであるインタプリタやメソッドコンパイラも具備する。
技術詳細

トレーシング実行時コンパイラは実行時に以下のステップを経る:第一に、ループに関するプロファイリング情報を収集する。次にホットループを特定した後、トレーシング実行モードに移行し、そのループを実行するのに用いられたすべての演算を記録する。記録された演算列はトレース(trace)と呼ばれる。その後トレースは最適化され機械語にコンパイルされる。再びそのループが実行される際はオリジナルのコードではなくコンパイル済みのトレースを実行する。

以下で各ステップを詳細に説明する。
プロファイリングフェーズ

プロファイリングの目的はホットループを特定することである。よく使われる方法は、すべてのループについて繰り返し回数を数えることである。この数がある特定のしきい値を超えた場合、そのループはホットループとみなされ、トレーシングモードが有効化される。
トレーシングフェーズ

トレーシングフェーズ下ではループの実行は通常通りだが、加えてすべての実行された演算がトレースに記録される。記録される演算はたいていは中間言語として保存される。ループ内からの関数コールも追跡され、場合によってはトレース内にインライン展開される。トレーシングはループが終了するかスタート点にジャンプするまで継続される。

トレースが記録できるのは、ある1つの実行パス条件のみであり、その後の実行がこの記録された実行パスとは異なる条件で実行される場合も考えられる。条件が同じかどうかを判定するためにガード命令がトレースに挿入される場合がある。if 文は挿入される場所の一例である。ガードは仮定していた条件が成り立っているかどうかを判定する。条件が成り立っていなければトレースは中止させられる。

トレーシングは実行時において行われるため実行時情報を含むことができる(例、実行時型情報)。この情報は最適化においてコードの品質を上げるのに使うことができる。
最適化とコード生成フェーズ

トレースは制御フローのない一列の実行パスでしかないため最適化は容易である。以下は典型的な最適化例である:

共通部分式除去


次ページ
記事の検索
おまかせリスト
▼オプションを表示
ブックマーク登録
mixiチェック!
Twitterに投稿
オプション/リンク一覧
話題のニュース
列車運行情報
暇つぶしWikipedia

Size:23 KB
出典: フリー百科事典『ウィキペディア(Wikipedia)
担当:undef