JP2011002976A - Program execution controller - Google Patents
Program execution controller Download PDFInfo
- Publication number
- JP2011002976A JP2011002976A JP2009144894A JP2009144894A JP2011002976A JP 2011002976 A JP2011002976 A JP 2011002976A JP 2009144894 A JP2009144894 A JP 2009144894A JP 2009144894 A JP2009144894 A JP 2009144894A JP 2011002976 A JP2011002976 A JP 2011002976A
- Authority
- JP
- Japan
- Prior art keywords
- jit
- intermediate code
- jit compilation
- method information
- interpreter
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Abstract
Description
本発明は、中間コード列からなるプログラムを実行するプログラム実行制御装置に関し、特に、JITコンパイラを用いたプログラム実行制御装置に関するものである。 The present invention relates to a program execution control apparatus that executes a program including an intermediate code string, and more particularly to a program execution control apparatus using a JIT compiler.
特定のプラットフォームに依存することなくプログラムを実行する、仮想計算機の代表的なものの一つとして、Java(登録商標)言語を用いる技術がある。例えば、Java(登録商標)バイトコードを解釈して実行する、JVM(Java(登録商標) Virtual Machine)が挙げられる。 One of the typical virtual machines that execute programs without depending on a specific platform is a technology using Java (registered trademark) language. For example, there is a JVM (Java (registered trademark) Virtual Machine) that interprets and executes a Java (registered trademark) bytecode.
Java(登録商標)バイトコードは、Java(登録商標)言語で記述されたソースコードをコンパイルすることにより生成される一種の中間コードである。また、JVMは、このバイトコードを逐次解釈してプロセッサに処理を実行させるいわゆるインタプリタとして機能する。 Java (registered trademark) bytecode is a kind of intermediate code generated by compiling source code written in Java (registered trademark) language. The JVM functions as a so-called interpreter that sequentially interprets the bytecode and causes the processor to execute processing.
JVMの介在により、プラットフォームに依存しないプログラム実行環境を実現できるが、その実行速度は、プロセッサが直接理解できるネイティブコードに変換されたプログラムの実行速度に比べ、一般的に遅くなる。そのため、プログラム実行時に、バイトコードをネイティブコードへコンパイルするためのJIT(Just In Time)コンパイラを備えたJVMが考案され、一般に用いられている。 Through the intervention of the JVM, a platform-independent program execution environment can be realized, but the execution speed is generally slower than the execution speed of a program converted into native code that can be directly understood by the processor. Therefore, a JVM having a JIT (Just In Time) compiler for compiling bytecode into native code at the time of program execution has been devised and used in general.
また、Java(登録商標)Scriptなどのスクリプト言語により記述されたプログラムは、スクリプトエンジンにより実行される。このスクリプトエンジンは、プラットフォームに依存しないプログラム実行環境を実現する手段として有用である。このため、スクリプトエンジンは、インタラクティブなネットワーク上のアプリケーションを実現する手段として、ブラウザなどに実装されている。 A program written in a script language such as Java (registered trademark) Script is executed by a script engine. This script engine is useful as a means for realizing a platform-independent program execution environment. For this reason, the script engine is implemented in a browser or the like as a means for realizing an application on an interactive network.
このようなスクリプト言語で記述されたプログラムは、スクリプトエンジンによって一旦中間コードに変換された後、インタプリタ処理で逐次実行されることになる。このようなスクリプトエンジンにおいても、上述のJVM同様、JITコンパイラを備えたものが知られている。 A program written in such a script language is once converted into an intermediate code by a script engine and then sequentially executed by an interpreter process. Also in such a script engine, the thing provided with the JIT compiler is known like the above-mentioned JVM.
上述のようなインタプリタとJITコンパイラを共に備えた従来のプログラム実行制御装置は、プログラム自体の構造解析や、インタプリタ処理時の、メソッドの起動回数の計数などで、当該メソッドをJITコンパイルするか否かを決定する。これは、今後も頻繁に呼び出される可能性が高く、JITコンパイルする価値のある箇所を優先的にJITコンパイルするためである。しかしながら、このように優先順位付けをしてJITコンパイルを行うとしても、プログラム実行開始当初などの一定期間にJITコンパイルが集中してしまうため、プログラムの応答性能の低下が顕著にあらわれるという課題があった。 The conventional program execution control apparatus equipped with both the interpreter and the JIT compiler as described above determines whether or not to JIT compile the method by analyzing the structure of the program itself or counting the number of times the method is activated during the interpreter process. To decide. This is because there is a high possibility that it will be frequently called in the future, and JIT compilation is preferentially performed at a place worth JIT compilation. However, even if JIT compilation is performed with priorities assigned in this way, JIT compilation is concentrated in a certain period of time such as the beginning of program execution, so that there is a problem that the response performance of the program is significantly reduced. It was.
この課題を解決するため、従来の技術では、JITコンパイルは、インタプリタ処理やネイティブコードの実行といったプログラムの実行タスクとは別の低優先度のタスクとして、並行して行うものがあった(例えば、特許分権1参照)。 In order to solve this problem, in the conventional technology, JIT compilation is performed in parallel as a low-priority task different from a program execution task such as interpreter processing or native code execution (for example, See Patent Decentralization 1).
特許文献1に開示された従来の技術では、JITコンパイル済みでないメソッドが呼び出された際は、常にインタプリタ処理で実行していた。また、JITコンパイル中であるメソッドが呼び出された場合、JITコンパイルの終了を待ってからネイティブコードを実行していた。 In the conventional technique disclosed in Patent Document 1, when a method that has not been JIT compiled is called, the method is always executed by an interpreter process. Also, when a method that is undergoing JIT compilation is called, the native code is executed after the end of JIT compilation.
しかしながら、前記従来の技術では、JITコンパイル中であるメソッドが呼び出された際に、当該メソッドのJITコンパイルの状況に基づいて、適切に処理を切り替えることがでないという課題を有していた。 However, the conventional technique has a problem that when a method being JIT compiled is called, the process cannot be switched appropriately based on the JIT compilation status of the method.
つまり、JITコンパイルの終了を待ってからネイティブコードを実行するため、メソッドが呼び出されたとき、当該メソッドがまだJITコンパイル開始の直後であることも考えられる。この場合、JITコンパイルの終了を待つ時間が、オーバーヘッドとなる。一方、常にインタプリタ処理を行う実装の場合、メソッドが呼び出されたとき、当該メソッドのJITコンパイルが既に、終了直前にまで達していると、中間コードのインタプリタ処理での実行に要する時間が、そのままオーバーヘッドとなる。 In other words, since native code is executed after the end of JIT compilation, when a method is called, the method may still be immediately after the start of JIT compilation. In this case, the time waiting for the end of JIT compilation is an overhead. On the other hand, in the case of an implementation that always performs interpreter processing, when a method is called, if the JIT compilation of the method has already reached just before termination, the time required for execution of the intermediate code interpreter processing remains overhead. It becomes.
本発明は、前記従来の課題を解決するもので、メソッドが呼び出された際に、当該メソッドのJITコンパイルの状況に基づいて、ネイティブコード実行またはインタプリタ処理を選択するプログラム実行制御装置を提供することを目的とする。 The present invention solves the above-described conventional problems, and provides a program execution control device that selects native code execution or interpreter processing when a method is called based on the JIT compilation status of the method. With the goal.
前記従来の課題を解決するために、本発明のプログラム実行制御装置は、コンパイラと、インタプリタと、別タスクで行うJITコンパイラとを備え、ソースコードから生成した中間コードを順次読み込んで、解釈実行するプログラム実行制御装置であって、前記JITコンパイラによる前記中間コードのJITコンパイル状況をメソッド情報としてメソッド毎に保持するメソッド情報管理手段と、前記メソッド情報管理手段に保持されているメソッド情報へのアクセスを制御するメソッド情報更新手段と、前記メソッド情報管理手段に保持されているメソッド情報に基づいて、前記JITコンパイル状況が転換点に達しているか否かを判定するJITコンパイル状況判定手段と、前記インタプリタによる前記中間コードの実行がメソッドの呼び出しに達した際に、前記メソッド情報管理手段に保持されているメソッド情報を参照し、呼び出された前記メソッドがコンパイル中であって、前記JITコンパイル状況が転換点に達していない場合には、前記インタプリタにより前記中間コードを逐次解釈し実行することを選択し、転換点に達している場合には、前記JITコンパイラによるネイティブコードへの変換の終了を待ってから前記ネイティブコードを実行することを選択するプログラム制御手段を備えたことを特徴とする。 In order to solve the above-described conventional problems, a program execution control apparatus according to the present invention includes a compiler, an interpreter, and a JIT compiler that performs a separate task, and sequentially reads and interprets intermediate code generated from source code. A program execution control device, comprising: a method information management unit that holds the JIT compilation status of the intermediate code by the JIT compiler as method information for each method; and access to the method information held in the method information management unit. A method information updating means for controlling, a JIT compilation status judging means for judging whether or not the JIT compilation status has reached a turning point based on the method information held in the method information management means, and the interpreter The execution of the intermediate code is the method If the method called in the method information management means is referred to and the called method is being compiled and the JIT compilation status has not reached the turning point The intermediate code is selected to be sequentially interpreted and executed by the interpreter, and when the turning point has been reached, the native code is executed after waiting for the JIT compiler to complete the conversion to the native code. And a program control means for selecting.
本構成によって、メソッドが呼び出された際に、当該メソッドのJITコンパイルの進捗状況に基づいて、ネイティブコードを実行するか、インタプリタ処理を行うかを、選択し、適切に処理を切り替えることができる。 With this configuration, when a method is called, it is possible to select whether to execute native code or to perform interpreter processing based on the progress of JIT compilation of the method, and to appropriately switch processing.
本発明のプログラム実行制御装置によれば、呼び出されたメソッドがJITコンパイル途中である場合、当該メソッドのJITコンパイルの状況に基づいて、適切に処理を切り替えることにより、計算機システムのオーバーヘッドを削減することができる。 According to the program execution control apparatus of the present invention, when the called method is in the middle of JIT compilation, the processing system overhead is reduced by appropriately switching the processing based on the JIT compilation status of the method. Can do.
以下、本発明の実施の形態について、図面を参照しながら説明する。 Hereinafter, embodiments of the present invention will be described with reference to the drawings.
図1は、本発明の実施の形態におけるプログラム実行制御装置の構成の概要図である。 FIG. 1 is a schematic diagram of a configuration of a program execution control device according to an embodiment of the present invention.
図中101は、本発明のプログラム実行制御装置を示している。プログラム実行制御装置101は、それが動くCPUに固有のネイティブコードへコンパイルされたプログラムであり、メモリシステム上に常駐してソースコードを実行する。即ち、プログラム実行制御装置101は、ソースコードから中間コードへのコンパイル、中間コードの順次読み出しとインタプリタによる逐次実行、中間コードからネイティブコードへのJITコンパイル、ネイティブコードの実行、を行う。
In the figure,
図中102は、プログラムコードの集まりであるソースコード列を表している。ソースコード列102は、それ自体がアプリケーションプログラムのプログラムコードであり、プログラム実行制御装置101が介在することにより、任意のCPUで実行される。
In the figure,
図中103は、中間コードの集まりである中間コード列を表している。プログラム実行制御装置101が、ソースコード列102から、中間コード列103を生成する。中間コード列103は、ソースコード列102と同様、プログラム実行制御装置101の介在により動く。
In the figure,
図中104は、CPU固有のネイティブコードの集まりであるネイティブコード列を表している。プログラム実行制御装置101が、中間コード列103から、メソッド毎にコンパイルして、ネイティブコードを生成する。
In the figure,
これら、ソースコード列102、中間コード列103、ネイティブコード列104は、また、計算機システムのメモリシステム上にある。
These
図中105は、ソースコード列102を中間コード列103へ変換するためのコンパイラである。コンパイラ105は、ソースコード列102から中間コード列103への変換を、中間コードの逐次実行に先行して、一般に一括して行う。
In the figure,
コンパイラ105は、ソースコード列102から中間コード列103へコンパイルする時に、メソッド毎の中間コードサイズを、中間コード内に付与する。中間コードサイズは、メソッド呼び出し時に、後述のメソッド情報管理表201に登録され、その後のJITコンパイル状況の判定に用いられる。
When compiling from the
なお、コンパイラ105は、プログラム実行制御装置101の他の部分と切り離されていてもよい。例えば、サーバサイドが、ソースコード列102から中間コード列103へのコンパイルを行う。クライアントサイドが、ネットワーク経由で、サーバサイドから中間コード列103を取得し、クライアントサイドに実装されたプログラム実行制御装置101を実行するというような構成も可能である。
The
図中106は、プログラム実行手段であり、プログラム実行制御装置101を制御するプログラムを表している。プログラム実行手段106は、メソッドが呼び出された際に、当該メソッドのJITコンパイルの状況に基づいて、ネイティブコード実行またはインタプリタ処理を選択し、切り替える機能を有している。
In the figure,
図中107は、プログラム実行制御装置101のインタプリタであり、プログラム実行手段106が読み込んだ中間コードを逐次解釈して実行する。
In the figure,
図中108は、プログラム実行制御装置101のJITコンパイラであり、中間コードからネイティブコードへの変換をメソッド毎に行う。
In the figure,
以下、プログラム実行手段106、インタプリタ107、JITコンパイラ108について説明する。
The program execution means 106,
プログラム実行手段106は、コンパイラ105に指示を出し、ソースコード列102から中間コード列103への変換を行う。なお、前述のように、この部分はプログラム実行制御装置101から切り離されていてもよく、プログラム実行手段106の指示で中間コード列102へのコンパイルが行われることに限定されない。
The program execution means 106 instructs the
次に、プログラム実行手段106は、中間コード列103を順次読み込み、インタプリタ107により処理していく。メソッドの呼び出しに達すると、プログラム実行手段106は、当該メソッドの中間コードを中間コード列103から読み込んでインタプリタ処理するか、ネイティブコード列104中の当該メソッドのネイティブコードを実行するか選択する。
Next, the program execution means 106 sequentially reads the
当該メソッドの中間コードをインタプリタ処理する場合には、インタプリタ107により逐次実行する。
When the intermediate code of the method is interpreted, it is sequentially executed by the
なお、ここにおいて、中間コードをインタプリタ処理するとは、少量の処理単位で読み込んだ中間コードに対応するネイティブコードを、CPUに実行させること指している。即ち、インタプリタ107が、中間コードの種類毎に、それが読み込まれたときにどのようなネイティブコードをCPUに実行させるのかを管理している。そして、インタプリタ107が、順次読み込まれた中間コードに対応するネイティブコードを、逐次、CPUに実行させることになる。
Here, interpreting the intermediate code refers to causing the CPU to execute native code corresponding to the intermediate code read in a small amount of processing units. That is, the
他方、当該メソッドのネイティブコードを実行するとは、当該メソッドのネイティブコードがあるメモリシステムのアドレスがプログラム実行手段106で管理されている。そして、プログラム実行手段106が、そのアドレスをCPUのプログラムカウンタに設定することに相当する。 On the other hand, to execute the native code of the method, the program execution means 106 manages the address of the memory system where the native code of the method is located. This corresponds to the program execution means 106 setting the address in the program counter of the CPU.
また、プログラム実行手段106は、メソッドの呼び出し時に当該メソッドの中間コードを新規にJITコンパイルするか否かを判断する。JITコンパイルする場合には、JITコンパイラ108に当該メソッドのJITコンパイルを指示する。
Further, the program execution means 106 determines whether or not to JIT-compile the intermediate code of the method at the time of calling the method. In the case of JIT compilation, the
インタプリタ107は、プログラム実行手段106からの指示に従い、順次読み込まれる中間コード列103を解釈、実行する。また、インタプリタ107は、メソッド毎のインタプリタ処理時間を計測し、プログラム実行手段106に通知する。
The
JITコンパイラ108は、プログラム実行手段106からのJITコンパイル指示を受け、中間コードからCPU固有のネイティブコードへのJITコンパイルを行う。なお、プログラム実行制御装置101においては、中間コードからネイティブコードへのJITコンパイルは、インタプリタ処理や、ネイティブコードの実行といったプログラムの実行タスクとは別のタスクにおいて並行して行われる。
The
また、JITコンパイラ108が、中間コードのコンパイル済みサイズをプログラム実行手段106に通知し、プログラム実効手段106においてメソッド毎に更新、保持される。なお、JITコンパイラ108からの中間コードコンパイル済みサイズの通知は、一定時間が経過したタイミングや、一定サイズのJITコンパイルが終了したタイミングで行われる。
Further, the
また、JITコンパイラ108はJITコンパイル速度(中間コードの単位サイズあたりのJITコンパイル時間)を計測し、プログラム実行手段106に通知する。これは、後述するJITコンパイル状況判定手段203が、JITコンパイルの終了までに必要な残り時間を見積もるのに用いられる。なお、JITコンパイル速度は、直近のものに限らず、ある一定期間で平均値をとるなどして平滑化したものであってもよい。また、JITコンパイラ108は、JITコンパイルの終了をプログラム実行手段106に通知する。
The
以下、プログラム実行手段106の構成を図2に示し、動作の詳細を説明する。 In the following, the configuration of the program execution means 106 is shown in FIG.
図中201は、メソッド情報管理表であり、中間コードの実行時に呼び出されたメソッドの情報が初回に登録され、以後、更新される。
In the figure,
図中202は、メソッド情報管理表更新手段であり、メソッド情報管理表へのアクセス(読み書き)の制御を行う。
In the figure,
図中203は、JITコンパイル状況判定手段であり、メソッド情報管理表に登録されているメソッドのJITコンパイルの状況を判定する。
In the figure,
図中204は、プログラム制御手段であり、プログラム実行手段106全般の制御と、プログラム実行手段106のデータの入出力を行う。
In the figure,
なお、プログラム実行手段106は、それ自体がプログラムである。また、前述のメソッド情報管理表201、メソッド情報管理表更新手段202、JITコンパイル状況判定手段203、プログラム制御手段204は、プログラム実行手段106の概要を説明するために機能毎に分類して明示した構成要素である。
The program execution means 106 is a program itself. Further, the method information management table 201, the method information management
以下、メソッド情報管理表201、メソッド情報管理表更新手段202、JITコンパイル状況判定手段203、プログラム制御手段204の動作を説明する。
Hereinafter, operations of the method information management table 201, the method information management
メソッド情報管理表201の登録の欄は、そのラインのメソッド情報が有効であるかが登録される。ここでは、1’b0が無効を、1’b1が有効を表すものとする。全ライン、初期値は1’b0であり、メソッド情報が新規に登録されると1’b1に更新される。また、そのラインのメソッド情報が破棄されると、1’b0に更新される。 The registration column of the method information management table 201 registers whether the method information of the line is valid. Here, 1'b0 represents invalidity and 1'b1 represents valid. All lines have an initial value of 1'b0 and are updated to 1'b1 when method information is newly registered. When the method information of the line is discarded, it is updated to 1'b0.
なお、メソッド情報の破棄の方法に関して、ここでは述べないが、別途メソッドの呼び出し傾向などを管理し、呼び出されなくなったメソッドから情報を破棄するなどすればよい。 Although the method information discarding method is not described here, it is only necessary to separately manage the method invocation tendency and discard information from the method that is no longer invoked.
メソッド情報管理表201のメソッドIDの欄には、メソッドを一意に識別するためのメソッドIDが、プログラム制御手段204の指示で、メソッド情報管理表更新手段202により登録される。
In the method ID column of the method information management table 201, a method ID for uniquely identifying a method is registered by the method information management
以降、メソッド情報管理表の参照、更新は、直接にはメソッド情報管理表更新手段202が行うものとして説明する。
In the following description, it is assumed that the method information management
メソッド情報管理表201のインタプリタ処理回数の欄にはメソッド情報の新規登録時に初期値1が登録され、以後当該メソッドがインタプリタ処理されるたびにインクリメントされる。なお、インタプリタ処理の回数に閾値を設け、コンパイル開始条件に用いている場合などは、その閾値でインクリメントを停止してもよい。 In the interpreter processing count column of the method information management table 201, an initial value 1 is registered when new method information is registered, and is incremented each time the method is interpreted. In addition, when the threshold value is provided in the frequency | count of an interpreter process and it uses for a compile start condition, you may stop an increment with the threshold value.
メソッド情報管理表201のインタプリタ処理時間の欄には、インタプリタ107からプログラム制御手段204に通知されるメソッド毎のインタプリタ処理時間が登録、更新される。
In the interpreter processing time column of the method information management table 201, the interpreter processing time for each method notified from the
なお、インタプリタ107でのインタプリタ処理時間の計測、インタプリタ107からの処理時間の通知、インタプリタ処理時間の欄への登録、更新は、当該メソッドのJITコンパイル状況の欄が2’b01の期間のみであってもよい。これは、インタプリタ処理時間が、JITコンパイル状況判定手段203において、JITコンパイル状況を2’b01から2’b10へ遷移させるときの判定にのみ用いられるからである。また、インタプリタ処理時間は、直近の値に限らず、数回の平均値をとるなどしてある程度の平滑化がなされていてもよい。また、インタプリタ処理の数回おきに計測、更新するなどでもよく、毎回行う必要はない。
Note that the
メソッド情報管理表201の中間コードサイズの欄には、中間コード列103中に付与された値が、メソッドの呼び出し時にプログラム制御手段204によって読み取られ、メソッド情報の新規登録時に登録される。
In the intermediate code size column of the method information management table 201, a value assigned in the
メソッド情報管理表201の中間コードコンパイル済みサイズの欄には、メソッドの新規登録時に初期値0が登録され、以後、JITコンパイラ108からプログラム制御手段204へ通知されるコンパイル済みサイズで更新される。
In the intermediate code compiled size column of the method information management table 201, an initial value of 0 is registered when a method is newly registered, and thereafter updated with the compiled size notified from the
なお、JITコンパイラ108におけるコンパイル済みサイズの累積、コンパイル済みサイズの通知、中間コードコンパイル済みサイズの欄の更新は、当該メソッドのJITコンパイル状況の欄が2’b01の期間のみであってもよい。これは、中間コードコンパイル済みサイズは、JITコンパイル状況判定手段203において、JITコンパイル状況を2’b01から2’b10へ遷移させるときの判定にのみ用いられるからである。
The
メソッド情報管理表201のJITコンパイル状況の欄には、メソッドの新規登録時に初期値で2’b00が登録され、以後、コンパイルが進むにつれて更新される。 In the JIT compilation status column of the method information management table 201, 2'b00 is registered as an initial value when a method is newly registered, and is updated as compilation proceeds thereafter.
なお、ここでは、JITコンパイル状況の欄の2’b00が未コンパイル状態、2’b01がコンパイル中で転換点には達していない状態、2’b10がコンパイル中で転換点に達している状態、2’b11はコンパイルが終了している状態を表している。 In this example, 2'b00 in the JIT compilation status column is in an uncompiled state, 2'b01 is being compiled and has not reached a turning point, and 2'b10 is being compiled and has reached a turning point. 2′b11 represents a state in which compilation is finished.
プログラム制御手段204が、当該メソッドのJITコンパイルの開始を決定すると、当該メソッドに対応する、メソッド情報管理表201のJITコンパイル状況欄の値が2’b00から2’b01に更新される。その後、JITコンパイルが進み、JITコンパイル状況判定手段203が転換点に達したと判定すると、JITコンパイル状況欄の値が2’b01から2’b10に更新される。その後、JITコンパイル終了時に、JITコンパイル状況欄の値が2’b10から2’b11に更新される。
When the
メソッド情報管理表201のネイティブコードのアドレスの欄には、JITコンパイル後のネイティブコードが格納されるメモリシステムのアドレスが、当該メソッドのJITコンパイルの開始時にプログラム制御手段204から通知され、登録される。 In the address field of the native code of the method information management table 201, the address of the memory system where the native code after JIT compilation is stored is notified from the program control means 204 at the start of JIT compilation of the method and registered. .
メソッド情報管理表更新手段202は、プログラム制御手段204からのメソッド情報管理表201へのアクセスを制御する。メソッド情報の新規登録の際は、プログラム制御手段204から、メソッドID、中間コードサイズを受け、メソッド情報管理表201の登録の欄の値が1’b0であるラインに登録する。
The method information management
また、メソッド情報管理表更新手段202は、メソッド情報の新規登録の際、インタプリタ処理回数の欄の値を1に、中間コードコンパイル済みサイズの値を0に、JITコンパイル状況の値を2’b00に初期化する。
Also, the method information management
また、メソッド情報管理表更新手段202は、プログラム制御手段204からインタプリタ処理時間を適宜受け、更新する。
Further, the method information management
また、メソッド情報管理表更新手段202は、JITコンパイル開始時にはネイティブコードのアドレスを受け、登録する。
Also, the method information management
なお、メソッド情報管理表201のインタプリタ処理時間の欄を更新する際に、平滑化などが行われる場合は、メソッド情報管理表更新手段202においてなされればよい。
If smoothing or the like is performed when updating the interpreter processing time column of the method information management table 201, it may be performed by the method information management
また、メソッド情報管理表更新手段202は、プログラム制御手段204に対してインタプリタ処理回数を通知する。プログラム制御手段204は、インタプリタ処理回数をもとにして、当該メソッドのJITコンパイル開始を判断する。なお、インタプリタ処理回数の通知のタイミングは、プログラム制御手段204からのアクセスのタイミングで行われればよい。
The method information management
また、メソッド情報管理表更新手段202は、JITコンパイル状況判定手段203を用いて、JITコンパイル状況を判定する。判定は、JITコンパイル状況の欄の値が2’b01のメソッドに対してのみ行われ、JITコンパイルが転換点に達したか否かを判定する。この際、メソッド情報管理表更新手段202は、JITコンパイル状況判定手段203に、判定対象のメソッドのインタプリタ処理時間と、中間コードサイズと、中間コードコンパイル済みサイズを渡す。判定後、メソッド情報管理表更新手段202は、JITコンパイル状況判定手段203から、転換点に達していることを通知された場合、メソッド情報管理表のJITコンパイル状況を2’b01から2’b10に変更する。
Further, the method information management
JITコンパイル状況判定手段203は、メソッド情報管理表201の中間コードコンパイル済みサイズの更新が行われる際に、JITコンパイル状況の欄の値を2’b01から2’b10へ遷移させるか否かの判定を行う。
The JIT compilation
なお、JITコンパイル状況の判定は、インタプリタ処理時間の更新に同期して行うとしてもよいし、中間コードコンパイル済みサイズの更新とインタプリタ処理時間の更新の両方に同期するとしてもよい。 The determination of the JIT compilation status may be performed in synchronization with the update of the interpreter processing time, or may be synchronized with both the update of the intermediate code compiled size and the update of the interpreter processing time.
また、JITコンパイル状況判定手段203は、JITコンパイラ108からプログラム制御手段204を介して通知されるJITコンパイル速度を保持し、JITコンパイルの終了までに必要な残り時間の見積もりに用いる。
The JIT compilation
以下、JITコンパイル状況判定手段203が、JITコンパイルの終了までに必要な残り時間とネイティブコードの実行時間とを見積もり、JITコンパイルが転換点に達しているか否かを判定するまでの流れを例示する。
The following is an example of a flow from when the JIT compilation
図2に示すように、メソッド情報管理表201に登録されているメソッドIDがmethod1のメソッドでは、インタプリタ処理時間が1100[ms]である。また、中間コードサイズが10200[byte]、中間コードコンパイル済みサイズが2500[byte]である。 As shown in FIG. 2, in the method whose method ID is method1 registered in the method information management table 201, the interpreter processing time is 1100 [ms]. The intermediate code size is 10200 [bytes], and the intermediate code compiled size is 2500 [bytes].
いま、JITコンパイル状況判定手段203が保持しているコンパイル速度が0.2[ms/byte]であるとし、ネイティブコードの実行時間はインタプリタ処理時間に0.05を掛けて見積もられるものとする。
Assume that the compilation speed held by the JIT compilation
JITコンパイル状況判定手段203は、メソッド情報管理表更新手段202から、インタプリタ処理時間、中間コードサイズ、中間コードコンパイル済みサイズを受け取り、JITコンパイル終了までに必要な残り時間を見積もる。
The JIT compilation
このとき、JITコンパイルの残量は10200[byte]−2500[byte]=7700[byte]である。このため、JITコンパイル終了までに必要な残り時間は7700[byte]×0.2[ms/byte]=1540[ms]となる。 At this time, the remaining amount of JIT compilation is 10200 [bytes] -2500 [bytes] = 7700 [bytes]. For this reason, the remaining time required until the end of JIT compilation is 7700 [bytes] × 0.2 [ms / byte] = 1540 [ms].
また、JITコンパイル状況判定手段203は、ネイティブコードの実行時間を1100[ms]×0.05=55[ms]と見積もる。
Further, the JIT compilation
ここで、必要な残り時間は、(コンパイル終了までに必要な残り時間)+(ネイティブコード実行時間)=1540[ms]+55[ms]=1595[ms]となる。この場合、必要な残り時間は、インタプリタ処理時間1100[ms]よりも長い。 Here, the necessary remaining time is (remaining time necessary until the end of compilation) + (native code execution time) = 1540 [ms] +55 [ms] = 1595 [ms]. In this case, the necessary remaining time is longer than the interpreter processing time 1100 [ms].
ゆえに、JITコンパイル判定手段203は、コンパイル中で転換点には達していないと判定し、結果をメソッド情報管理表更新手段202に通知する。この状況で、メソッドIDがmethod1のメソッドが呼び出された場合は、プログラム制御手段204はインタプリタ107でのインタプリタ処理による実行を選択することになる。
Therefore, the JIT
他方、メソッド情報管理表201に登録されているメソッドIDがmethod3のメソッドでは、インタプリタ処理時間が2300[ms]であり、中間コードサイズが33240[byte]、中間コードコンパイル済みサイズが24000[byte]である。 On the other hand, in the method whose method ID is method3 registered in the method information management table 201, the interpreter processing time is 2300 [ms], the intermediate code size is 33240 [bytes], and the intermediate code compiled size is 24000 [bytes]. It is.
同様に、JITコンパイル終了までに必要な残り時間は(33240[ms]−24000[ms])×0.2=1848[ms]である。また、ネイティブコード実行時間は2300[ms]×0.05=115[ms]である。つまり、必要な残り時間は、(JITコンパイル終了までに必要な残り時間)+(ネイティブコード実行時間)=1848[ms]+115[ms]=1963[ms]となる。この場合、必要な残り時間は、インタプリタ処理時間2300[ms]よりも短い。 Similarly, the remaining time required until the end of JIT compilation is (33240 [ms] −24000 [ms]) × 0.2 = 1848 [ms]. The native code execution time is 2300 [ms] × 0.05 = 115 [ms]. That is, the necessary remaining time is (remaining time required until the end of JIT compilation) + (native code execution time) = 1848 [ms] +115 [ms] = 1963 [ms]. In this case, the necessary remaining time is shorter than the interpreter processing time 2300 [ms].
ゆえに、JITコンパイル状況判定手段203は、コンパイル中で転換点に達している状態であると判定する。結果、method3のJITコンパイル状況の欄が2’b10に更新されることになる。
Therefore, the JIT compilation
JITコンパイル状況の欄を更新後、メソッドIDがmethod3のメソッドが呼びだされた場合、プログラム制御手段204は、当該メソッドのネイティブコードの実行を選択することになる。
After updating the JIT compilation status column, when a method whose method ID is method3 is called, the
なお、JITコンパイル状況判定手段203がネイティブコードの実行時間を見積もる方法は、上記方法に限らず、例えば中間コードサイズに一定値を掛けるなどの他の方法で見積もるとしてもよい。あるいは、ネイティブコードの実行時間は相対的に微小な値であるため、無視するとしてもよい。
Note that the method by which the JIT compilation
また、JITコンパイルの終了を待ってからネイティブコードを実行する場合においては、JITコンパイルタスクへのCPU資源やメモリ資源の割り当てをJITコンパイル終了まで一時的に増やすような制御が考えられる。これは、実行タスクがアイドルに遷移するためである。このような場合、実際のJITコンパイル速度は、JITコンパイル状況判定手段203に保持したJITコンパイル速度よりも早くなる。そのため、JITコンパイル状況判定手段203は、保持したJITコンパイル速度に補正を施してから、コンパイル終了までに必要な残時間を見積もるなどとしてもよい。
In the case where the native code is executed after the end of JIT compilation, it is possible to control such that the allocation of CPU resources and memory resources to the JIT compilation task is temporarily increased until the end of JIT compilation. This is because the execution task transitions to idle. In such a case, the actual JIT compilation speed is faster than the JIT compilation speed held in the JIT compilation
なお、中間コードサイズが比較的小さいメソッドに関しては、インタプリタ処理時間もJITコンパイル時間も短時間であると考えられる。それゆえ、プログラム制御手段204は、中間コードサイズに閾値を設けて処理を行ってもよい。例えば、プログラム制御手段204は、閾値を超えたメソッドのみに対して前述のようにインタプリタ処理時間や中間コードコンパイル済みサイズを更新し、JITコンパイル状況判定手段203において転換点に達しているか否かを判定する。この場合、閾値以下のサイズの小さいメソッドに関しては、JITコンパイル中に呼び出された場合、インタプリタ処理で実行するか、JITコンパイルの終了を待ってネイティブコードを実行するかを固定的に決めておくなどすればよい。
For methods with a relatively small intermediate code size, the interpreter processing time and JIT compilation time are considered to be short. Therefore, the
プログラム制御手段204は、コンパイラ105へのソースコードのコンパイル指示、中間コードの順次読み込みとインタプリタ107を用いての逐次処理、JITコンパイラ108へのJITコンパイル指示、メソッドのネイティブコードの実行といった一連のプログラム実行を制御する。
The program control means 204 is a series of programs including instructions for compiling source code to the
また、前述のように、プログラム制御手段204は、インタプリタ107とJITコンパイラ108から、インタプリタ処理時間やJITコンパイル速度、中間コードコンパイル済みサイズを受け取る。また、プログラム制御手段204は、受け取った情報を、メソッド情報管理表更新手段202やJITコンパイル状況判定手段203に渡す。
As described above, the
また、プログラム制御手段204は、メソッドの呼び出しに達した際に、当該メソッドをインタプリタ処理するか、当該メソッドのネイティブコードを実行するかの判断を行う。
Further, when reaching the method call, the
ここで、プログラム制御手段204の、メソッド呼び出しからの動作の流れを図3に示し、先行例に記載の従来技術のプログラム実行制御装置との差異を明らかにする。 Here, the flow of the operation of the program control means 204 from the method call is shown in FIG. 3, and the difference from the prior art program execution control device described in the preceding example is clarified.
ここでは、メソッド呼び出しは2回目以降であり、メソッド情報管理表201に当該メソッドの情報が既に登録されているものとして示す。因みに、初回のメソッド呼び出しである場合には、先ず当該メソッドの初期値の新規登録を行い、プログラム制御手段204はインタプリタ処理でのメソッド実行を選択する。なお、初回のメソッド呼び出し時は、メソッド情報管理表201に当該メソッドの情報が登録されていない状態である。 Here, the method call is the second and subsequent times, and the method information management table 201 shows that the method information has already been registered. Incidentally, in the case of the first method call, first the initial value of the method is newly registered, and the program control means 204 selects execution of the method in the interpreter process. When the method is called for the first time, the method information management table 201 is not registered with the method information.
メソッド呼び出し時、プログラム制御手段204は、メソッド情報管理表更新手段202を介して、メソッド情報管理表201を参照する(ステップS300)。
When the method is called, the
メソッド情報管理表201のJITコンパイル状況の欄が2’b11で、当該メソッドがコンパイル済みであることが示されている場合には(ステップ301でYES)、当該メソッドのネイティブコードを実行する(ステップ302)。 If the JIT compilation status column of the method information management table 201 is 2'b11 and indicates that the method has been compiled (YES in step 301), the native code of the method is executed (step 302).
メソッド情報管理表201のJITコンパイル状況の欄が2’b10で、コンパイル中で転換点に達していることが示されている場合には(ステップ301でNO→ステップ303でYES→ステップ304でYES)、JITコンパイルの終了まで待機し(ステップ305)、当該メソッドのネイティブコードを実行する(ステップ302)。
If the JIT compilation status column of the method information management table 201 is 2′b10 and indicates that the turning point has been reached during compilation (NO in
メソッド情報管理表201のJITコンパイル状況の欄が2’b01で、コンパイル中で転換点に達していないことが示されている場合には(ステップ301でNO→ステップ303でYES→ステップ304でNO)、インタプリタ107で当該メソッドの中間コードを逐次処理することを選択する(ステップ308)。
If the JIT compilation status column of the method information management table 201 is 2′b01, indicating that the turning point has not been reached during compilation (NO in
メソッド情報管理表201のJITコンパイル状況の欄が2’b00で、未コンパイルであることが示されている場合には(ステップ301でNO→ステップ303でNO)、管理情報表201のインタプリタ処理回数の欄の値等から、当該メソッドを新規にJITコンパイルするべきか否かを判断する(ステップS306)。新規にJITコンパイルすると判断した場合には(ステップ306でYES)、JITコンパイラ108に対して当該メソッドのJITコンパイルを指示し、インタプリタ107で当該メソッドの中間コードを逐次処理することを選択する(ステップ308)。JITコンパイルしないと判断した場合には(ステップ306でNO)、インタプリタ107で当該メソッドの中間コードを逐次処理することを選択する(ステップ308)。
If the JIT compilation status column of the method information management table 201 is 2′b00, indicating that it has not been compiled (NO in
以上により、本発明のプログラム実行制御装置は、JITコンパイル途中のメソッドを呼び出した場合、当該メソッドのJITコンパイルの状況に基づいて、ネイティブコードを実行するか、インタプリタ処理を行うかを、適切に選択できる。この選択で、JITコンパイルの終了を待ってからネイティブコードを実行するのと、即座に中間コードのインタプリタ処理に移るのとの選択において、より実行時間の短い方を選ぶことが可能になる。これにより、どちらか一方を固定的に選択するときに発生していたオーバーヘッドを除くことが可能になる。また、中間コードのJITコンパイルを低優先度のタスクとして、実行タスクと併走させる構成が採り易く、プログラムの応答性能を保つことができる。 As described above, the program execution control apparatus according to the present invention appropriately selects whether to execute native code or perform interpreter processing based on the JIT compilation status of the method when a method during JIT compilation is called. it can. With this selection, it is possible to select a shorter execution time in selecting whether to execute the native code after waiting for the end of JIT compilation or to immediately move to the interpreter process of the intermediate code. As a result, it is possible to eliminate the overhead that has occurred when either one is fixedly selected. In addition, it is easy to adopt a configuration in which JIT compilation of intermediate code is run as a low priority task in parallel with the execution task, and the response performance of the program can be maintained.
本発明のプログラム実行制御装置は、インタプリタとJITコンパイラを備えた仮想計算機として有用である。また、この仮想計算機を組み込んだ各種の家電機器、携帯電話など通信機器、産業機器、乗用機器などの用途にも応用できる。 The program execution control device of the present invention is useful as a virtual computer including an interpreter and a JIT compiler. The present invention can also be applied to various home appliances incorporating this virtual machine, communication equipment such as mobile phones, industrial equipment, and passenger equipment.
101 プログラム実行制御装置
102 ソースコード列
103 中間コード列
104 ネイティブコード列
105 コンパイラ(ソースコード→中間コード)
106 プログラム実行手段
107 インタプリタ
108 JITコンパイラ(中間コード→ネイティブコード)
201 メソッド情報管理表
202 メソッド情報管理表更新手段
203 JITコンパイル状況判定手段
204 プログラム制御手段
101 program
106
201 Method Information Management Table 202 Method Information Management
Claims (5)
前記JITコンパイラによる前記中間コードのJITコンパイル状況をメソッド情報としてメソッド毎に保持するメソッド情報管理手段と、
前記メソッド情報管理手段に保持されているメソッド情報へのアクセスを制御するメソッド情報更新手段と、
前記メソッド情報管理手段に保持されているメソッド情報に基づいて、前記JITコンパイル状況が転換点に達しているか否かを判定するJITコンパイル状況判定手段と、
前記インタプリタによる前記中間コードの実行がメソッドの呼び出しに達した際に、前記メソッド情報管理手段に保持されているメソッド情報を参照し、呼び出された前記メソッドがコンパイル中であって、前記JITコンパイル状況が転換点に達していない場合には、前記インタプリタにより前記中間コードを逐次解釈し実行することを選択し、転換点に達している場合には、前記JITコンパイラによるネイティブコードへの変換の終了を待ってから前記ネイティブコードを実行することを選択するプログラム制御手段を備えた
ことを特徴とするプログラム実行制御装置。 A program execution control device that includes a compiler, an interpreter, and a JIT compiler that performs separate tasks, sequentially reads intermediate code generated from source code, interprets and executes the program,
Method information management means for holding the JIT compilation status of the intermediate code by the JIT compiler as method information for each method;
Method information update means for controlling access to method information held in the method information management means;
JIT compilation status determination means for determining whether or not the JIT compilation status has reached a turning point based on the method information held in the method information management means;
When the execution of the intermediate code by the interpreter reaches a method call, the method information held in the method information management means is referred to, the called method is being compiled, and the JIT compilation status Is not reached the turning point, it is selected to sequentially interpret and execute the intermediate code by the interpreter. When the turning point has been reached, the conversion to the native code by the JIT compiler is terminated. A program execution control apparatus comprising program control means for selecting to execute the native code after waiting.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009144894A JP2011002976A (en) | 2009-06-18 | 2009-06-18 | Program execution controller |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009144894A JP2011002976A (en) | 2009-06-18 | 2009-06-18 | Program execution controller |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2011002976A true JP2011002976A (en) | 2011-01-06 |
Family
ID=43560888
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2009144894A Pending JP2011002976A (en) | 2009-06-18 | 2009-06-18 | Program execution controller |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2011002976A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2014504764A (en) * | 2011-01-18 | 2014-02-24 | アップル インコーポレイテッド | System and method for supporting JIT in a secure system with randomly allocated memory ranges |
US9170830B2 (en) | 2013-03-26 | 2015-10-27 | Fujitsu Limited | Method for controlling program execution |
US9389889B2 (en) | 2011-11-16 | 2016-07-12 | Fujitsu Limited | Application server for optimizing timing of performing dynamic compilation |
-
2009
- 2009-06-18 JP JP2009144894A patent/JP2011002976A/en active Pending
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2014504764A (en) * | 2011-01-18 | 2014-02-24 | アップル インコーポレイテッド | System and method for supporting JIT in a secure system with randomly allocated memory ranges |
US9389889B2 (en) | 2011-11-16 | 2016-07-12 | Fujitsu Limited | Application server for optimizing timing of performing dynamic compilation |
US9170830B2 (en) | 2013-03-26 | 2015-10-27 | Fujitsu Limited | Method for controlling program execution |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP3894698B2 (en) | A hybrid just-in-time compiler that minimizes resource consumption | |
KR100589798B1 (en) | Bytecode Optimization Devices and Methods During Interruption | |
US8527969B2 (en) | Systems, methods, and computer programs for dynamic binary translation in an interpreter | |
WO2004107170A1 (en) | Program execution control device | |
JP2010286898A (en) | Multithread execution device, and multithread execution method | |
KR20120083803A (en) | Extra code generating apparatus and method for virtual machine | |
JP2011002976A (en) | Program execution controller | |
US8276128B2 (en) | Systems, methods, and computer programs for dynamic binary translation in a master control program interpreter | |
JP5324050B2 (en) | Mechanism to reduce detectable pauses in dynamic output generated by dynamic compilation | |
JP2012181578A (en) | Update control device and program | |
US20130117757A1 (en) | Method and apparatus for scheduling application programs | |
CN108536514B (en) | Hot spot method identification method and device | |
EP1653355A2 (en) | Information processor, information processing method, and programs therefor | |
JP2009009253A (en) | Program execution method, program, and program execution system | |
KR20120064446A (en) | Appratus and method for processing branch of bytecode on computing system | |
US10303523B2 (en) | Method and apparatus to migrate stacks for thread execution | |
CN106325963B (en) | Self-adaptive dynamic compiling and scheduling method and device | |
JP2017045144A (en) | Information processor and control method thereof | |
JPH08263299A (en) | Method for converting program | |
CN110362314B (en) | Information processing method and device, computer readable medium and electronic equipment | |
EP2605134B1 (en) | Systems, methods, and computer programs for dynamic binary translation in an interpreter | |
JP5021584B2 (en) | Microcomputer simulator, simulation method thereof, program, and computer-readable medium | |
US9015720B2 (en) | Efficient state transition among multiple programs on multi-threaded processors by executing cache priming program | |
WO2001013223A1 (en) | Method and apparatus for operating virtual computer | |
WO2021056277A1 (en) | Program execution method |