Lullar    


ビデオジャパンは、最大でランク。

ジャストインタイムコンパイル方式 Jasutointaimukonpairu method

出典: フリー百科事典『ウィキペディア(Wikipedia)』 Source: material may be challenged Wikipedia encyclopedia (Wikipedia) 』

ジャストインタイムコンパイルJust In Time CompilationJITコンパイル 、その都度のコンパイル)方式とは、 ソフトウェアの実行時にコードのコンパイルを行い実行速度の向上を図る方式である。 Jasutointaimukonpairu (Just In Time Compilation, JIT compilation, compile each time) and the method is a method to improve the speed of execution and the compiled code when running the software. 通常のコンパイラソースコード (あるいは中間コード )から対象CPUの機械語への変換を実行前に(コンパイル時に)行う。 Compiler of the code typically source (code intermediate or) from the CPU to be executed before the conversion to machine language (when compiled) do. これをJITと対比して事前コンパイル (Ahead Of Time, AOT ) コンパイルと呼ぶ。 JIT compilation it in contrast with prior (Ahead Of Time, AOT) compilation called.

JITコンパイルという用語は、ソフトウェアを構成するモジュールやクラス、関数などの、ある単位のコードがまさに実行されるその時に、コンパイルされることから「Just In Time」の名前が付けられた。 The term JIT compilation, configure the software modules and classes, such as the function to be executed when the code is just a unit, to be compiled from the "Just In Time" was named for. 一方、 動的コンパイルという用語は、実行時に機械語を生成するというより広い意味で使われることがあり、その意味ではJITコンパイルは動的コンパイルの一種と考えることができる。 The terms of dynamic compilation is to be used in a broad sense rather than to generate a machine language runtime JIT compilation in that sense can be thought of as a kind of dynamic compilation.

事前コンパイル方式と比べ、JIT方式ではコンパイル時間の分がプログラム実行時間に関するオーバーヘッドとなる。 Compared with pre-compilation method, JIT is a method and program execution time overhead of compiling the minutes of the time. また、事前コンパイルで可能な、高度で時間のかかる最適化を行うことは許されない。 Also available in pre-compiled, optimized to perform sophisticated and time-consuming is not allowed. これは、実行速度を向上させるためにコンパイルするのだから、あまり時間がかかっては意味がないためである。 This is because you want to compile in order to run faster, less time consuming because there is no meaning.

事前のコンパイルと比べてこのような不利な点を持ちながらも、JIT方式が有用なのは、実行時にコンパイルを行うことでオペレーティングシステムやCPUに依存しないソースコードや中間コードの状態でソフトウェアを配布することができるからである。 But has the disadvantage compared to such pre-compilation, JIT is a useful method, the operating system and compile it to run when the CPU state to distribute the software in source code or intermediate code independent can be from.

JITを装備した処理系は、表面上はインタプリタとして動作するが、内部でコンパイルを行い、メモリ上に生成した機械語のコードが実行されるため、インタプリタと比べると実行速度を向上することができる。 Processing system is equipped with a JIT, on the surface to act as interpreter, and an internally compiled to machine code to run when you create a memory and can run faster than the interpreter . この意味で、JITはCPUOSに依存しない実行形式を配布できる、というインタプリタの利点を保ったまま、実行速度が遅い、という欠点を克服しようとするものといえる。 In this sense, JIT is a CPU and OS can distribute the forms to perform independent, while maintaining the benefits of the interpreter that runs slowly, and say that attempts to overcome the shortcomings.

目次 Contents

[ 編集 ] インタプリタ方式との比較 Comparison with interpreter

インタプリタ方式との違いは、インタプリタ方式がその都度コードを解釈しながら実行するのに対して、JIT方式は機械語に変換したものを実行することである。 Difference between the interpretive method for interpreting the code to execute while the system each time the interpreter, JIT is to run the scheme is converted into machine language. また、インタプリタ方式と同様に実行時にJava仮想マシン共通言語ランタイムのようなランタイム環境を必要とする。 In addition, the interpretive method as well as run-time Java that require a runtime environment such as the common language runtime and virtual machine.

インタプリタ方式と比較すると性能面では以下のような差が出てくる In terms of performance compared with the difference coming out interpretive method is as follows:

  • 機械語に変換されるため、コンパイル後の実行速度はインタプリタ方式の数倍の性能となる To be converted into machine language, after compilation and execution speed several times the performance of interpretive method
  • モジュールやクラス、関数のロード時にコンパイルが行われるため、プログラムの起動には時間がかかる Modules and classes to be compiled when the load on the function of the program is slow to start
  • 一度コンパイルしたコードを保持するために、より多くのメモリ容量を必要とする In order to maintain the code once compiled, you need more memory capacity

[ 編集 ] 適応的コンパイル (Adaptive Compilation) Compiling Adaptive (Adaptive Compilation)

上のようなJITコンパイラの短所を補うためのJITコンパイルの一方式として適応的コンパイルという方式がある。 Such as the JIT compiler to compensate for the disadvantages of JIT, another method for adaptive compilation as one of the compiled expression. これは、起動当初はインタプリタとして実行し、よく呼び出されるメソッドや繰り返し実行されるコードの検出( プロファイリング )を行い、そのようなコードのみをコンパイルする、というものである。 It will run initially started as an interpreter, detection methods and code that is executed repeatedly invoked frequently (filing pro) and the only such code to compile, what it is. このとき、コードが使われた時にすぐにコンパイルするのではなく、何回か呼ばれた後に遅らせてコンパイル を行うが、このことを遅延コンパイル (Lazy Compilation)と呼ぶ。 This time, instead of just at the time was used to compile the code to compile is called delayed several times after the compilation of this delay that (Lazy Compilation) call. 一般にプログラムの実行においてその実行時間の大半はプログラム中のごく一部において費やされる、という経験則がある(実際の比率については状況に依存するが、典型的にはコードの実行時間の80%は20%のコードにおいて費やされるといわれ、 80-20の法則と呼ばれる)が、適応的コンパイルにおいては実行時間の大半が費やされるような、ボトルネックとなるコードのみをコンパイルすることで、起動時のオーバーヘッドや利用メモリ増大を抑えたうえで、効率よく実行速度を向上することができる。 In the majority of its running time is spent running the program in general a small fraction of the program, there is a rule of thumb (for the actual ratio is dependent on the situation, typically 80% of the code execution time 20% is said to be spent in the code, known as 80-20 and law), but adaptive You Hana compiled in most of the time spent running, the code can be compiled only bottleneck at startup Ue an increase in memory and use less overhead and can run faster and efficiently. この適応的コンパイルによる適応的最適化 (Adaptive Optimization) は、静的コンパイルでは得られない情報を元に最適化が行えるため、静的コンパイルより、むしろパフォーマンスが上がる場合もある。 Adaptive optimization of the compilation of this adaptive (Adaptive Optimization) is a statically compiled so can not be optimized based on information obtained from the static compilation performance increases rather sometimes.

[ 編集 ] JITコンパイル方式の利点 JIT compilation scheme benefits

JITコンパイル方式と事前コンパイルの生成コードの質を比べると、前述のようにコンパイル時間に対する制約のためJIT方式の方が不利であるが、有利な点もある。 Compare the quality of generated code and JIT compilation system and pre-compiled for the previous constraints on the JIT compilation time as better methods have a disadvantage, some advantages. それは、実行環境を知った上でそれに応じた生成コードの選択や最適化を行うことができるということである。 It is that you can do to select and optimize accordingly with the knowledge generated code execution environment.

インテルx86 CPUを例にとって見ると、IA32アーキテクチャの範囲内でもそれぞれの世代でさまざまに命令が拡張されてきているが、アプリケーションコードの後方互換性を保持する場合、実行バイナリ中では386と互換の命令しか使うことができない。 Intel x86 CPU, and show an example, IA32 has been has been extended to various orders in each generation within the range of architecture, if you keep the backward compatibility of the application code running in the 386 binary compatible with not be used for instruction only. つまり、 MMX PentiumMMX命令を含んだコードは80386Pentiumでは実行できない。 In other words, MMX Pentium's MMX instruction that contains the code 80386 and the Pentium does not run. しかし、JIT方式では、CPUがMMXをサポートしているならMMX命令を使ったコードを生成し、そうでなければ多少効率の悪いPentiumの命令の範囲内での実行を行う、ということができる。 However, JIT is a method, CPU that supports MMX If you generate code using MMX instructions, otherwise somewhat inefficient to run in the range Pentium instruction can be called.

また、実行環境におけるキャッシュメモリのサイズ、速度特性なども実行時にならないと最終的にはわからない。 The size of the memory and cache in the execution environment, and ultimately also have to run at speed characteristics are unknown. JITコンパイル方式では実際に走行しているCPUやメモリの情報を知ることができるため、それに応じたコードを生成することができ、事前コンパイルよりも優れたコードを生成できる可能性がある。 JIT compilation method that can be run in order to know the actual CPU and memory information, you can generate code accordingly, have the potential to generate better code than the pre-compiled.

さらに、 オブジェクト指向言語の実行においては仮想メソッドの呼び出しは仮想関数表を経由した間接呼び出しになるが、動的コンパイルにおいては、そのメソッドをオーバーライド定義したサブクラスが存在しない限り、 間接呼び出しを静的束縛として呼び出したり、あるいはインライン展開することができる(そのメソッドをオーバーライドするサブクラスが動的にロードされる可能性があるが、その場合はこのコンパイルされたメソッドは最適化戻し (deoptimize) される必要がある)。 Moreover, in the run-oriented language object is calling a virtual method call will be indirect through the virtual function table, in a dynamic compilation, unless there is a defined subclass overrides the method, called static binding indirectly call or as may be, or inline (which could be loaded dynamically subclasses to override the method, in which case this method returns the compiled optimized (deoptimize) must be there).

[ 編集 ] 応用 Applications

JIT処理はJava技術の普及に伴い広範囲に使われるようになったが、JavaのHotspot技術はSunにおけるSelf言語での動的コンパイル技術研究に基づいており、それに先立つ商用Smalltalk処理系でもJITコンパイル技術は確立されていた。 Java JIT process is now widely used due to the spread of technology, Java is Sun's Hotspot technology in Self and based on research in the language of dynamic compilation technology, which prior to commercial Smalltalk systems in JIT compilation technology process had been established.

JIT技術はトランスメタ社によるCrusoeでx86コードからCrusoeのVLIW命令への変換に用いられている。 JIT technology company with meta transformer Crusoe in Crusoe x86 code in the VLIW has been used to convert the instruction. 適応的コンパイル技術はDEC社によるFX!32技術でも用いられていた。 Adaptive compilation technology is DEC's by FX! 32 technology was also used.

Microsoft社による.NETプラットフォームも当初からJITによる実行を前提に設計されている。 Microsoft by the company. NET from the beginning the platform has been designed for JIT to run with.

[ 編集 ] JavaのJITコンパイラ Java's JIT compiler

Symantec社によるsymjitおよびBorland社によるJITコンパイラは初期の主要なJITコンパイラであった。 Symantec's by symjit and Borland's JIT compiler of the initial major JIT compiler was.

Sun Microsystems自身によるHotSpotコンパイラは本格的に適応的コンパイル方式を採用したJIT処理系である。 Sun Microsystems by itself HotSpot compiler has adopted the JIT compilation is a full-scale adaptive processing system. Hotspot以降はJITコンパイラ部分のインタフェースが規定されており、JITコンパイルエンジン部分を差し替えることができるようになった。 Since the Hotspot JIT provisions are part of an interface compiler, JIT was able to replace a portion of the compilation engine.

IBMによるIBM JDK、 BEAによるJRockitはいずれも適応的コンパイルを行う独自のJIT処理系を持っている。 IBM using IBM JDK, BEA JRockit is unique due to JIT compilation has both adaptive processing system. 後者は特にx86に特化して実行効率を高めている。 The latter in particular has increased the efficiency of x86-specific run.

学術的なものとしては、首藤氏によるShuJITや、 富士通研東京工業大学によるリフレクション機能を扱うOpenJITなどがある。 As an academic, by Mr. Shuto and ShuJIT, handling capabilities and reflection by the Tokyo Institute of Technology and Fujitsu Labs OpenJIT there.

[ 編集 ] JavaScriptのJITコンパイラ JavaScript and JIT compiler

Internet Explorer以外の主要なウェブブラウザJavaScriptのエンジンにJITコンパイラを搭載し、高速に処理できるようになっている。 Internet Explorer Web browser other than major is JavaScript engine equipped with a JIT compiler has to be processed faster. Internet Explorer 9、 Mozilla Firefox 3.5、 Google Chrome 1、 Safari 4、 Opera 10.50、 NetFront Browser 4以降のウェブブラウザに搭載している(予定を含む)。 Internet Explorer 9, Mozilla Firefox 3.5, Google Chrome 1, Safari 4, Opera 10.50, NetFront Browser is equipped with 4 or later web browser (including the plan). 変数の型は統計的には安定しているという事実を使い、実行時の変数に代入された値の統計データから、変数に型を割り振ることにより、JITコンパイラが実現し、高速にJavaScriptを処理できるようになった[1] Type of a variable is statistically consistent use of the fact that, from statistical data value assigned to the variable at run time by assigning a type variable, JIT compiler to achieve the fast processing JavaScript Now we can [1]. Google ChromeのV8など、 インタプリタを使わずに最初からJITコンパイルし、変数などの型は実行時に随時割り振っていくタイプと、Firefox 3.5のように、事前に一度インタプリタで実行して、その情報を元に型を割り振りながらJITコンパイルするタイプなどがある。 Google Chrome's V8, such as from the beginning without the interpreter and JIT compilation, such as type of variable types and will allocate at run time to time, Firefox 3.5, as running time interpreter in advance, based on information that While there is allocated a type such as JIT compile type. どちらのタイプであっても、型が安定しているケースは、高速に実行できるようになっている。 Or even type, case type that is stable, that is to run fast. JavaScriptにおいて、型が安定しているというのは、オブジェクトについては、プロパティが追加されていないという意味も含む。 In JavaScript, the type that is stable, the objects, including additional means are not property. プロパティアクセスの時に、まず、型が期待通りの型であるかチェックし、もし、そうならば、プロパティからそれが指し示す番地へはC言語構造体のように定数を足し算するだけで求まる。 When the property access, first checks whether the type is the type of expectations, if, if so, to address that point from the property is C求Maru just a constant addition to the structure of language.

[ 編集 ] 参照 See also

  1. ^ an overview of TraceMonkey ✩ hacks.mozilla.org ^ AN overview of TraceMonkey ✩ Hacks.mozilla.org

[ 編集 ] 外部リンク External links


ビデオジャパンは、最大でランク。




© Lullar