JP2006120043A - Virtual machine having compiler - Google Patents

Virtual machine having compiler Download PDF

Info

Publication number
JP2006120043A
JP2006120043A JP2004309225A JP2004309225A JP2006120043A JP 2006120043 A JP2006120043 A JP 2006120043A JP 2004309225 A JP2004309225 A JP 2004309225A JP 2004309225 A JP2004309225 A JP 2004309225A JP 2006120043 A JP2006120043 A JP 2006120043A
Authority
JP
Japan
Prior art keywords
instruction
code
buffer
fifo buffer
translated
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.)
Withdrawn
Application number
JP2004309225A
Other languages
Japanese (ja)
Inventor
Kazumi Iikura
二美 飯倉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2004309225A priority Critical patent/JP2006120043A/en
Publication of JP2006120043A publication Critical patent/JP2006120043A/en
Withdrawn legal-status Critical Current

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a Java virtual machine generating an instruction scheduled code even in a template JIT (just in time) compiler. <P>SOLUTION: This JIT compiler is provided with a translator 3 to translate a byte code into a native code using a template, a code buffer 6, an FIFO buffer 5, and an evaluator 4. The evaluator 4 outputs a translated latest instruction to the FIFO buffer 5 when there is interference between the latest instruction and the last number instruction of the code buffer 6 or when there is dependency between the translated latest instruction and an instruction stored in the FIFO buffer 5. In addition, the evaluator 4 outputs the translated latest instruction or an instruction of the FIFO buffer 5 to the code buffer 6 when there is no interference between the translated latest instruction or the instruction obtained from the FIFO buffer 5 and the last number instruction of the code buffer 6. <P>COPYRIGHT: (C)2006,JPO&NCIPI

Description

本発明はJITコンパイラを有する仮想マシンに関し、JITコンパイラがテンプレートJITコンパイラであっても、命令スケジュリングされたコードを生成することができるJITコンパイラを有する仮想マシンに関するものである。   The present invention relates to a virtual machine having a JIT compiler, and to a virtual machine having a JIT compiler capable of generating instruction-scheduled code even if the JIT compiler is a template JIT compiler.

近年、家電機器、車載機器などの組み込みシステムにおいてJAVA(登録商標)システム(以下JAVA(登録商標)を“ジャバ”という)が用いられる事例が増えている。ジャバプログラムはジャバのバイトコードをジャバ仮想マシンで実行するインタプリタ型のため、そのままでは実行効率が悪い。
そこでジャバプログラムのスピードアップの方法の一つとして、バイトコードをJITedコード(本発明ではネイティブコードという)にコンパイルして実行する、Just in Time(JIT)コンパイルという方法がある。
JITされたコードは(1)コードそのものの実行効率の改善、(2)メソッド呼び出しの効率化、によってバイトコードの実行より高速になっている。
上記のようにJITコンパイラはジャバのバイトコードをネイティブコードに変換して実行効率を上げる手段であり、例えば特許文献1には、バイトコードを高速にマシンコードに変換するコンパイラについて記載され、また、非特許文献1にも、ジャバ仮想マシンにおけるコンパイラについて記載されている。
In recent years, there have been an increasing number of cases in which JAVA (registered trademark) systems (hereinafter JAVA (registered trademark) is referred to as “Java”) are used in embedded systems such as home appliances and in-vehicle devices. Since the Java program is an interpreter type that executes Java bytecode in a Java virtual machine, the execution efficiency is poor as it is.
Therefore, as a method for speeding up the Java program, there is a method called Just in Time (JIT) compilation in which byte code is compiled into a JITed code (referred to as native code in the present invention) and executed.
JITed code is faster than bytecode execution by (1) improving the execution efficiency of the code itself and (2) increasing the efficiency of method calls.
As described above, the JIT compiler is a means for improving execution efficiency by converting Java bytecode into native code. For example, Patent Document 1 describes a compiler that converts bytecode into machine code at a high speed. Non-Patent Document 1 also describes a compiler in a Java virtual machine.

テンプレートJITコンパイラとは、バイトコードに対して一対一のネイティブコードのテンプレートを持ち、中間コード生成なしでJITコンパイルを行うもので、コンパイル時間が短く、中間コードのためのメモリ消費もないので、組み込みJAVA(登録商標)システムに適している。
一方、RISCアーキテクチャのプロセッサは、レジスタ干渉やメモリ干渉を避けて命令を配置することで性能を引き出すことができる。これを命令スケジュリングという。通常のコンパイラ(例:Cコンパイラ)ではソースを中間コードに変換し、中間コードをDAG(Directed Acyclic Graph)に変換し、最後にコード生成を行うことで命令スケジュリングを行っている。
特開平11−175349号公報 Proceedings of Java(登録商標)Virtual Machine Research and Technology Symposium,Monterey,California,USA,April23-24,2001,Michael Paleczny,Christpher Vick,Cliff Click「The Java(登録商標) HotSpotServer Compiler 」Sun Microsystems[平成16年10月14日検索]、インターネット<URL:http://www.usenix.org/publication/library/prceedings/jvm01/paleczny.html>
The template JIT compiler has a one-to-one native code template for bytecode, performs JIT compilation without intermediate code generation, has a short compile time, and does not consume memory for the intermediate code. Suitable for JAVA (registered trademark) system.
On the other hand, a RISC architecture processor can bring out performance by arranging instructions while avoiding register interference and memory interference. This is called instruction scheduling. In an ordinary compiler (for example, C compiler), instruction scheduling is performed by converting a source into intermediate code, converting the intermediate code into DAG (Directed Acyclic Graph), and finally generating code.
JP-A-11-175349 Proceedings of Java (registered trademark) Virtual Machine Research and Technology Symposium, Monterey, California, USA, April 23-24, 2001, Michael Paleczny, Christpher Vick, Cliff Click "The Java (registered trademark) HotSpotServer Compiler" Sun Microsystems [2004 Search October 14], Internet <URL: http: //www.usenix.org/publication/library/prceedings/jvm01/paleczny.html>

テンプレートでないJITコンパイラでは、命令スケジュリングを行うために中間コードを生成するなど、コンパイル時間、メモリ消費が必要である。
一方、テンプレートJITコンパイラでは中間コードを生成せず、バイトコードに対するネイティブコードが連続して生成されるため、命令スケジュリングが難しかった。
本発明は上記事情に鑑みなされたものであって、テンプレートJITコンパイラにおいても、命令スケジュリングされたコードを生成することができるジャバ仮想マシンを提供することを目的とする。
A JIT compiler that is not a template requires compile time and memory consumption, such as generating intermediate code for instruction scheduling.
On the other hand, the template JIT compiler does not generate intermediate code, and native code for byte code is generated continuously, so instruction scheduling is difficult.
The present invention has been made in view of the above circumstances, and an object of the present invention is to provide a Java virtual machine capable of generating instruction-scheduled code even in a template JIT compiler.

上記課題を解決するため、本発明においては、JITコンパイラに、テンプレートを用いてバイトコードをネイティブコードに翻訳する翻訳手段と、命令スケジュリング済みの命令を格納するコードバッファと、FIFOバッファと、評価手段を設ける。
上記評価手段は、上記翻訳された最新の命令と上記コードバッファに出力された最後の数命令に干渉があるかを調べ、干渉がなければ上記最新の命令をコードバッファに出力し、干渉があるとき、該最新の命令をFIFOバッファに出力する。
また、FIFOバッファに命令があるとき、FIFOバッファから命令を取り出し、該命令とコードバッファの最後の数命令との間に干渉があるかを調べ、干渉がなければFIFOバッファから取り出した命令をコードバッファに出力する。また、干渉があるとき、上記翻訳手段により翻訳された最新の命令とFIFOバッファの命令とに依存関係があるかを調べ、依存関係があれば、FIFOバッファに上記最新の命令を出力し、依存関係がなければ、上記のように最新の命令と上記コードバッファの最後の数命令に干渉があるかを調べ、干渉がなければ上記最新の命令をコードバッファに出力し、干渉があるとき、該最新の命令をFIFOバッファに出力する。
In order to solve the above-described problems, in the present invention, a JIT compiler includes a translation unit that translates bytecode into native code using a template, a code buffer that stores an instruction-scheduled instruction, a FIFO buffer, and an evaluation Means are provided.
The evaluation means checks whether there is an interference between the latest translated instruction and the last few instructions output to the code buffer. If there is no interference, the latest instruction is output to the code buffer, and there is an interference. The latest instruction is output to the FIFO buffer.
When there is an instruction in the FIFO buffer, the instruction is taken out from the FIFO buffer, and it is checked whether there is interference between the instruction and the last few instructions in the code buffer. If there is no interference, the instruction taken out from the FIFO buffer is coded. Output to buffer. Also, when there is interference, it is checked whether there is a dependency between the latest instruction translated by the translation means and the FIFO buffer instruction. If there is a dependency, the latest instruction is output to the FIFO buffer, If there is no relationship, the latest instruction and the last few instructions in the code buffer are checked for interference as described above. If there is no interference, the latest instruction is output to the code buffer. The latest instruction is output to the FIFO buffer.

本発明においては、上記のようにJITコンパイラに、テンプレートを用いてバイトコードをネイティブコードに翻訳する翻訳手段と、コードバッファと、FIFOバッファと、評価手段を設け、評価手段により、翻訳された最新の命令を評価して、命令スケジュリングを行っているので、テンプレートJITコンパイラであっても、命令スケジュリングを行うことができ、プログラムの実行速度を向上させることができる。   In the present invention, as described above, the JIT compiler is provided with a translation means for translating bytecode into native code using a template, a code buffer, a FIFO buffer, and an evaluation means, and the latest translated by the evaluation means. Since the instruction scheduling is performed and instruction scheduling is performed, even the template JIT compiler can perform instruction scheduling and improve the execution speed of the program.

図1に本発明のジャバ仮想マシンの全体構成を示す。
コンピュータ100はハードウエア20とOS30を有し、OS30上にジャバ仮想マシン10を備える。
ジャバ仮想マシン10はインタプリタ11とJITコンパイラ12を持つ。JITコンパイラ12はバイトコードに対して、一対一に対応付けられたネイティブコードを保持するテンプレートを持ち、該テンプレートを用いてバイトコードをネイティブコードに変換する。その際、翻訳されたネイティブコードを評価し、ネイティブコード間の干渉、依存関係に基づき、命令スケジュリングを行う。
FIG. 1 shows the overall configuration of the Java virtual machine of the present invention.
The computer 100 has hardware 20 and an OS 30, and the Java virtual machine 10 is provided on the OS 30.
The Java virtual machine 10 has an interpreter 11 and a JIT compiler 12. The JIT compiler 12 has a template that holds a native code associated with a byte code in a one-to-one relationship, and converts the byte code into a native code using the template. At that time, the translated native code is evaluated, and instruction scheduling is performed based on interference and dependency between native codes.

図2は、本実施例のJITコンパイラ12の機能構成を示すブロック図である。
同図に示すように、JITコンパイラ12は、テンプレート2、翻訳器3、評価器4、FIFOバッファ5、コードバッファ6を備える。
翻訳器2は、テンプレート2を用いて、バイトコード1をネイティブコード(以下命令という)に翻訳する。評価器4は、上記翻訳器2により翻訳された命令を評価して、命令スケジュリングを行い、スケジュリング結果をコードバッファ6に出力する。
すなわち、上記評価器4はFIFOバッファを用いて、以下の処理を繰り返し命令スケジュリングを行う。
(1)FIFOバッファ5に命令が保持されていないとき。
(i) 上記翻訳器2により翻訳された最新の命令Aと上記コードバッファ6に出力された最後の数命令Bとの間にレジスタ干渉やメモリ干渉があるかを調べる。
(ii)干渉がなければ上記命令Aをコードバッファ6に出力する。
(iii) 干渉があると、上記命令AをFIFOバッファ5に出力する。
ここで、レジスタ干渉やメモリ干渉があると(同じレジスタや同じメモリへアクセスする命令が数命令の間に続けて発行されると)、実行速度が遅くなる。そこで、上記のように干渉がある場合、上記命令Aを直ちにコードバッファ6に出力せず、取り合えずFIFOバッファ5に保持させる。なお、上記「最後の数命令B」とは、コードバッファ6に出力された通常1乃至4命令前の命令をいい、この数は命令の種類毎に定められるようにしてもよい。
FIG. 2 is a block diagram showing a functional configuration of the JIT compiler 12 of this embodiment.
As shown in the figure, the JIT compiler 12 includes a template 2, a translator 3, an evaluator 4, a FIFO buffer 5, and a code buffer 6.
The translator 2 translates the byte code 1 into a native code (hereinafter referred to as an instruction) using the template 2. The evaluator 4 evaluates the instruction translated by the translator 2, performs instruction scheduling, and outputs the scheduling result to the code buffer 6.
In other words, the evaluator 4 repeats the following processing using the FIFO buffer and performs instruction scheduling.
(1) When no instruction is held in the FIFO buffer 5.
(i) It is checked whether there is register interference or memory interference between the latest instruction A translated by the translator 2 and the last few instructions B output to the code buffer 6.
(ii) If there is no interference, the instruction A is output to the code buffer 6.
(iii) When there is interference, the instruction A is output to the FIFO buffer 5.
Here, if there is register interference or memory interference (when an instruction to access the same register or the same memory is issued continuously for several instructions), the execution speed becomes slow. Therefore, when there is interference as described above, the instruction A is not immediately output to the code buffer 6 but is held in the FIFO buffer 5 without being exchanged. The “last number of instructions B” refers to instructions that are normally 1 to 4 instructions before output to the code buffer 6, and this number may be determined for each type of instruction.

(2)FIFOバッファに命令が保持されているとき。
(i) FIFOバッファ5に命令が保持されている場合、FIFOバッファ5から命令Cを一つ取り出す。なお、FIFOバッファ5からは、格納された順にデータが取り出されるので、FIFOバッファ5に複数個の命令が格納されている場合、最初に格納されたデータ(最先の命令)が取り出される。
(ii)FIFOバッファ5から取り出した命令Cと、コードバッファ6の最後の数命令Bとの間に干渉があるかを調べる。
(iii) 干渉がなければ、上記命令Cをコードバッファ6に出力する。
(iv)干渉があれば、翻訳器3からの命令があるかを調べる。
ここで、翻訳すべきバイトコードがなくなり、新たな命令が翻訳器3から出力されなくなれば、干渉の有無に関わらずFIFOバッファ5に保持されていた命令Cをコードバッファに出力する。
(2) When an instruction is held in the FIFO buffer.
(i) When an instruction is held in the FIFO buffer 5, one instruction C is taken out from the FIFO buffer 5. Since data is extracted from the FIFO buffer 5 in the order of storage, when a plurality of instructions are stored in the FIFO buffer 5, the first stored data (first instruction) is extracted.
(ii) It is checked whether there is an interference between the instruction C fetched from the FIFO buffer 5 and the last several instructions B in the code buffer 6.
(iii) If there is no interference, the instruction C is output to the code buffer 6.
(iv) If there is interference, it is checked whether there is a command from the translator 3.
Here, when there is no byte code to be translated and no new instruction is output from the translator 3, the instruction C held in the FIFO buffer 5 is output to the code buffer regardless of the presence or absence of interference.

(v) 命令Cと最後の数命令Bの間に干渉があり、かつ翻訳器3からの最新の命令がある場合、翻訳器3から命令Dを取り出す。
(vi)翻訳器3から取り出した命令Dと、FIFOバッファ5に格納された全ての命令との間に依存関係があるかを調べる。すなわち、上記翻訳器3から取り出した命令が、FIFOバッファ5に格納されているいずれかの命令の実行結果を使用する命令であるかを調べる。
(vii) 上記命令Dと、FIFOバッファ5に保持された命令との間に依存関係がある場合、FIFOバッファ5に保持された命令が実行された後に上記命令Dが実行される必要があるので、上記命令DをFIFOバッファ5に格納する。FIFOバッファ5からは前記したように格納順に命令が取り出されるため、命令DをFIFOバッファ5に格納することで命令の実行順序は保証される。
(viii)上記命令Dと、FIFOバッファ5に保持された命令との間に依存関係がない場合には、前記(1)と同様に、上記命令Dとコードバッファ6に出力された最後の数命令Bとの間に干渉があるかを調べ、干渉がなければ上記翻訳された最新の命令Dをコードバッファ6に出力し、干渉があれば、該最新の命令DをFIFOバッファ5に出力する。
(v) If there is an interference between the instruction C and the last few instructions B and there is the latest instruction from the translator 3, the instruction D is taken out from the translator 3.
(vi) Check whether there is a dependency relationship between the instruction D fetched from the translator 3 and all the instructions stored in the FIFO buffer 5. That is, it is checked whether the instruction fetched from the translator 3 is an instruction that uses the execution result of any instruction stored in the FIFO buffer 5.
(vii) If there is a dependency between the instruction D and the instruction held in the FIFO buffer 5, the instruction D needs to be executed after the instruction held in the FIFO buffer 5 is executed. The instruction D is stored in the FIFO buffer 5. Since the instructions are taken out from the FIFO buffer 5 in the order of storage as described above, the instruction execution order is guaranteed by storing the instruction D in the FIFO buffer 5.
(viii) If there is no dependency between the instruction D and the instruction held in the FIFO buffer 5, the last number output to the instruction D and the code buffer 6 is the same as (1). If there is an interference with the instruction B, the latest translated instruction D is output to the code buffer 6 if there is no interference, and if there is an interference, the latest instruction D is output to the FIFO buffer 5. .

本実施例においては、上記のように、評価器4とFIFOバッファを設け、命令間の干渉、依存関係に基づきネイティブコードの命令スケジュリングを行っているので、テンプレートJITコンパイラであっても、比較的簡単な構成を付加するだけで、命令スケジュリングを行うことができる。
なお、本発明の命令スケジュリングでは、従来技術のように中間コードを生成して命令スケジューリングするほど完璧な命令スケジュリングはできないが、テンプレートJITコンパイラとしては、満足できる程度の命令スケジューリングが可能であり、スケジュリングしない場合と比べ、実行速度を向上させることができる。
In the present embodiment, as described above, the evaluator 4 and the FIFO buffer are provided, and the instruction scheduling of the native code is performed based on the interference and dependency between instructions. Instruction scheduling can be performed simply by adding a simple configuration.
In the instruction scheduling of the present invention, instruction scheduling as complete as intermediate code generation and instruction scheduling as in the prior art cannot be performed. However, as a template JIT compiler, satisfactory instruction scheduling is possible. The execution speed can be improved as compared with the case where scheduling is not performed.

図3、図4は本実施例の命令スケジュリング処理を示すフローチャートである。
まず、図3において、FIFOバッファに命令があるかを調べる(ステップS1)。FIFOバッファに命令がなければ、翻訳器からの新たな命令があるかを調べ、なければ処理を終了する(ステップS2)。
翻訳器からの命令があれば、翻訳器から命令を一つ取り出し(ステップS3)、この命令とコードバッファの中の最後の数命令との間に干渉があるかを調べ(ステップS4)、干渉がなければ上記翻訳器から取り出した命令をコードバッファに出力し、(A)に戻る(ステップ5)。また、干渉があれば、上記翻訳器から取り出した命令をFIFOバッファに入れ、(A)に戻る(ステップS6)。
3 and 4 are flowcharts showing the instruction scheduling process of this embodiment.
First, in FIG. 3, it is checked whether there is an instruction in the FIFO buffer (step S1). If there is no instruction in the FIFO buffer, it is checked whether there is a new instruction from the translator, and if not, the process is terminated (step S2).
If there is an instruction from the translator, one instruction is taken out from the translator (step S3), and it is checked whether there is interference between this instruction and the last few instructions in the code buffer (step S4). If not, the instruction fetched from the translator is output to the code buffer, and the process returns to (A) (step 5). If there is interference, the instruction taken out from the translator is put into the FIFO buffer, and the process returns to (A) (step S6).

一方、FIFOバッファに命令があれば、図4のステップS7にいき、FIFOバッファから命令を一個取り出し、FIFOバッファから取り出した命令とコードバッファの中の最後の数命令との間に干渉があるかを調べ(ステップS8)、干渉がなければ、命令をコードバッファに出力し、図3の(A)に戻る(ステップS9)。
また、FIFOバッファから取り出した命令とコードバッファの中の最後の数命令との間に干渉がある場合には、翻訳器からの命令があるかを調べる(ステップS10)。
翻訳器からの命令がなければ、命令をコードバッファに出力し図3の(A)に戻る(ステップS11)。
翻訳器からの命令があれば、翻訳器から命令を一個取り出し(ステップS12)、翻訳器から取り出した命令と、FIFOバッファの中の命令とに依存関係があるかを調べる(ステップS13)。
On the other hand, if there is an instruction in the FIFO buffer, the process proceeds to step S7 in FIG. 4, where one instruction is extracted from the FIFO buffer, and there is interference between the instruction extracted from the FIFO buffer and the last few instructions in the code buffer. If there is no interference, the instruction is output to the code buffer and the process returns to (A) of FIG. 3 (step S9).
If there is interference between the instruction fetched from the FIFO buffer and the last few instructions in the code buffer, it is checked whether there is an instruction from the translator (step S10).
If there is no instruction from the translator, the instruction is output to the code buffer and the process returns to (A) of FIG. 3 (step S11).
If there is a command from the translator, one command is fetched from the translator (step S12), and it is checked whether there is a dependency between the command fetched from the translator and the command in the FIFO buffer (step S13).

依存関係があれば、FIFOバッファが一杯であるかを調べ(ステップS16)、FIFOバッファが一杯でなければ、上記翻訳器から取り出した命令をFIFOバッファにいれる(ステップS18)。また、FIFOバッファが満杯であれば、FIFOバッファの中の命令を一つ取り出して、コードバッファに出力した後(ステップS17)、上記翻訳器から取り出した命令をFIFOバッファにいれる。
また、依存関係がなければ、上記翻訳器から取り出した命令とコードバッファの中の最後の数命令との間に干渉があるかを調べ(ステップS14)、干渉がなければ、命令をコードバッファに出力し、図3の(A)に戻る(ステップS15)。また、干渉があれば、上記翻訳器から取り出した命令をFIFOバッファに入れ、図3の(A)に戻る(ステップS19)
If there is a dependency, it is checked whether the FIFO buffer is full (step S16). If the FIFO buffer is not full, the instruction fetched from the translator is placed in the FIFO buffer (step S18). If the FIFO buffer is full, one instruction in the FIFO buffer is extracted and output to the code buffer (step S17), and then the instruction extracted from the translator is input to the FIFO buffer.
If there is no dependency, it is checked whether there is interference between the instruction fetched from the translator and the last several instructions in the code buffer (step S14). If there is no interference, the instruction is stored in the code buffer. The output is returned to (A) in FIG. 3 (step S15). If there is interference, the instruction fetched from the translator is placed in the FIFO buffer, and the process returns to (A) of FIG. 3 (step S19).

以下、具体例により本実施例による命令スケジュリング処理例を説明する。
図5は{(a×3)+(b×4)+(c×5)}の演算を行うジャバプログラムの1例を示し、同図は、コンパイル前のバイトコードとコンパイル後のネイティブコードを示し、命令スケジュリング前の命令列を示している。
また、図6は命令スケジュリング処理の際にコードバッファ、FIFOバッファに格納される命令を示し、同図中の(1) 〜(8) は図5の示した(1) 〜(8) の命令に対応する。また図7は命令スケジュリング後にコードバッファに格納された命令列を示す。
Hereinafter, an example of instruction scheduling processing according to the present embodiment will be described using a specific example.
FIG. 5 shows an example of a Java program that performs an operation of {(a × 3) + (b × 4) + (c × 5)}. FIG. 5 shows byte code before compilation and native code after compilation. The instruction sequence before instruction scheduling is shown.
FIG. 6 shows instructions stored in the code buffer and FIFO buffer during the instruction scheduling process, and (1) to (8) in FIG. 6 are (1) to (8) shown in FIG. Corresponds to the instruction. FIG. 7 shows an instruction sequence stored in the code buffer after instruction scheduling.

図5に示す各バイトコードは、翻訳器により同図に示す命令(ネイティブコード)に翻訳されて翻訳器から出力される。翻訳された各命令は、以下の処理を行う。
(1)ldi @(gr25,4),g16
バイトコードiload_1は上記命令(ネイティブコード)に翻訳される。上記命令は、レジスタ(gr25,4)[gr25はレジスタ番号、4はオフセット]によりポイントされるメモリアドレスから、”a”をレジスタg16にロードする命令である([g16]←”a”)。
(2)mul gr16,3,gr17
バイトコードiconst_3,imulは、上記命令(ネイティブコード)に翻訳される。上記命令は、レジスタgr16に保持された”a”と定数”3”を掛けて、レジスタgr17にロードする命令である([gr17]←”a×3”)。
なお、命令(1)(2)がこの順序で続けて実行されるとレジスタgr16へのアクセスが続いて発生するので、命令(1)(2)は干渉していることになる。
(3)ldi @(gr25,8 ),g18
バイトコードiload_2は上記命令(ネイティブコード)に翻訳される。上記命令は、レジスタ(gr25,8)によりポイントされるメモリアドレスから、”b”をレジスタg18にロードする命令である([g18]←”b”)。
Each byte code shown in FIG. 5 is translated into an instruction (native code) shown in the figure by the translator and output from the translator. Each translated instruction performs the following processing.
(1) ldi @ (gr25, 4), g16
The byte code iload_1 is translated into the above instruction (native code). The above instruction is an instruction to load “a” into the register g16 from the memory address pointed by the register (gr25, 4) [gr25 is the register number, 4 is the offset] ([g16] ← “a”).
(2) mul gr16,3, gr17
The byte code iconst_3, imul is translated into the above instruction (native code). The above instruction is an instruction that multiplies “a” held in the register gr16 by a constant “3” and loads it into the register gr17 ([gr17] ← “a × 3”).
Note that if the instructions (1) and (2) are successively executed in this order, the access to the register gr16 occurs continuously, so that the instructions (1) and (2) interfere with each other.
(3) ldi @ (gr25,8), g18
The bytecode iload_2 is translated into the above instruction (native code). The above instruction is an instruction for loading “b” into the register g18 from the memory address pointed by the register (gr25, 8) ([g18] ← “b”).

(4)slli,gr18,2,gr19
バイトコードiconst_4,imulは、上記命令(ネイティブコード)に翻訳される。上記命令は、レジスタgr18を2桁シフト(4倍することに相当)し、レジスタgr19にロードする命令である([gr19]←”b×4”)。
なお、命令(3)(4)がこの順序で続けて実行されるとレジスタgr18へのアクセスが続いて発生することになるので、命令(3)(4)は干渉していることになる。
(5)add gr17,gr19,gr20
バイトコードiaddは、上記命令(ネイティブコード)に翻訳される。上記命令は、 レジスタgr17の内容(”a×3”が保持されてい)とレジスタgr19の内容(”b×4”が保持されている)を加算して、レジスタgr20にロードする命令である([gr20]←”a×3+b×4”)。
なお、この(5)の命令は、(2)(4)の命令が実行された後でなければ実行できないので、命令(5)は、命令(2)(4)と依存関係にある。
(4) slli, gr18, 2, gr19
The bytecodes iconst_4, imul are translated into the above instruction (native code). The above instruction is an instruction to shift the register gr18 by two digits (corresponding to 4 times) and load it into the register gr19 ([gr19] ← “b × 4”).
Note that if the instructions (3) and (4) are successively executed in this order, the access to the register gr18 occurs continuously, so that the instructions (3) and (4) interfere with each other.
(5) add gr17, gr19, gr20
The byte code iadd is translated into the above instruction (native code). The above instruction adds the contents of the register gr17 (holding “a × 3”) and the contents of the register gr19 (holding “b × 4”), and loads the result into the register gr20 ( [Gr20] ← “a × 3 + b × 4”).
Since the instruction (5) can be executed only after the instructions (2) and (4) are executed, the instruction (5) is dependent on the instructions (2) and (4).

(6)ldi @(gr25,12),g21
バイトコードiload_3は上記命令(ネイティブコード)に翻訳される。上記命令は、レジスタ(gr25,12)によりポイントされるメモリアドレスから、”c”をレジスタg21にロードする命令である([g21]←”c”)。
(7)mul gr21,5,gr22
バイトコードiconst_5,imulは、上記命令(ネイティブコード)に翻訳される。上記命令は、レジスタgr21に保持された”c”と定数”5”を掛けて、レジスタgr22にロードする命令である([gr22]←”c×5”)
なお、命令(6)(7)がこの順序で続けて実行されるとレジスタgr21へのアクセスが続いて発生するので、命令(6)(7)は干渉していることになる。
(8)add gr20,gr22,gr23
バイトコードiaddは、上記命令(ネイティブコード)に翻訳される。上記命令は、レジスタgr20の内容(”a×3+b×4”が保持されてい)とレジスタgr22の内容(”c×5”が保持されている)を加算して、レジスタgr23にロードする命令である([gr23]←”a×3+b×4+c×5”)。
なお、この(8)の命令は、(5)(7)の命令が実行された後でなければ実行できないので、命令(8)は、命令(5)(7)と依存関係にある。
(6) ldi @ (gr25, 12), g21
The byte code iload — 3 is translated into the above instruction (native code). The above instruction is an instruction to load “c” into the register g21 from the memory address pointed by the register (gr25, 12) ([g21] ← “c”).
(7) mul gr21,5, gr22
The bytecodes iconst_5, imul are translated into the above instructions (native code). The above instruction multiplies “c” held in the register gr21 by a constant “5” and loads it into the register gr22 ([gr22] ← “c × 5”).
Note that if the instructions (6) and (7) are successively executed in this order, the access to the register gr21 occurs continuously, so that the instructions (6) and (7) interfere with each other.
(8) add gr20, gr22, gr23
The byte code iadd is translated into the above instruction (native code). The above instruction adds the contents of the register gr20 (holding “a × 3 + b × 4”) and the contents of the register gr22 (holding “c × 5”), and loads them into the register gr23. Yes ([gr23] ← “a × 3 + b × 4 + c × 5”).
Since the instruction (8) can be executed only after the instructions (5) and (7) are executed, the instruction (8) is dependent on the instructions (5) and (7).

本実施例により、上記命令列は図6に示すようにFIFOバッファ5に保持され、命令スケジュリングされた命令列はコードバッファ6に出力される。
(i) 翻訳器3から命令(1)が出力される。コードバッファ6には、命令が入っていないので、命令(1)はコードバッファに出力される。
(ii)翻訳器3から命令(2)が出力される。コードバッファ6の中には、命令(1)があり、命令(1)と命令(2)は干渉するで、命令(2)はFIFOバッファ5に入れられる。
(iii) FIFOバッファ5から命令(2)を取り出すが、FIFOバッファ5の中の命令(2)はコードバッファ6の中の命令(1)と干渉するので、翻訳器3から命令(3)が取り出される。コードバッファ6には、命令(1)が入っているが、命令(3)とは干渉しないので、命令(3)はコードバッファ5 に出力される。
(iv)FIFOバッファ5から命令(2)を取り出すが、FIFOバッファ5の中の命令(2)はコードバッファ6の中の命令(1)と干渉するので、翻訳器3から命令(4)が取り出される。
コードバッファ6の中には、命令(3)があり、命令(3)と命令(4)は干渉するで、命令(4)はFIFOバッファ5に入れられる。
According to this embodiment, the instruction sequence is held in the FIFO buffer 5 as shown in FIG. 6, and the instruction sequence that has been scheduled is output to the code buffer 6.
(i) Command (1) is output from the translator 3. Since no instruction is stored in the code buffer 6, the instruction (1) is output to the code buffer.
(ii) The command (2) is output from the translator 3. There is an instruction (1) in the code buffer 6, and the instruction (1) and the instruction (2) interfere with each other, so that the instruction (2) is put into the FIFO buffer 5.
(iii) The instruction (2) is taken out from the FIFO buffer 5, but since the instruction (2) in the FIFO buffer 5 interferes with the instruction (1) in the code buffer 6, the instruction (3) from the translator 3 is It is taken out. The code buffer 6 contains the instruction (1) but does not interfere with the instruction (3), so the instruction (3) is output to the code buffer 5.
(iv) The instruction (2) is taken out from the FIFO buffer 5, but since the instruction (2) in the FIFO buffer 5 interferes with the instruction (1) in the code buffer 6, the instruction (4) from the translator 3 is It is taken out.
There is an instruction (3) in the code buffer 6, and the instruction (3) and the instruction (4) interfere with each other, so that the instruction (4) is put into the FIFO buffer 5.

(v) FIFOバッファ5から命令(2)を取り出すが、FIFOバッファ5の中の命令(2)はコードバッファ6の中の命令(1)と干渉するので、翻訳器3から命令(5)が取り出される。
命令(5)とFIFOバッファ5の中の命令(2)(4)は依存関係にあるので、命令(5)はFIFOバッファ5に入れられる。
(vi)FIFOバッファ5から命令(2)を取り出すが、FIFOバッファ5の中の命令(2)はコードバッファ6の中の命令(1)と干渉するので、翻訳器3から命令(6)が取り出される。
コードバッファ6の命令は、命令(6)とは干渉しないので命令(6)はコードバッファ5 に出力される。
(vii) FIFOバッファ5から命令(2)を取り出す。FIFOバッファ5の中の命令(2)はコードバッファ6の中の命令(1)とは干渉しなくなったので、命令(2)をコードバッファ6に出力する。
(v) The instruction (2) is fetched from the FIFO buffer 5, but since the instruction (2) in the FIFO buffer 5 interferes with the instruction (1) in the code buffer 6, the instruction (5) from the translator 3 is It is taken out.
Since the instruction (5) and the instructions (2) and (4) in the FIFO buffer 5 are in a dependency relationship, the instruction (5) is put into the FIFO buffer 5.
(vi) The instruction (2) is taken out from the FIFO buffer 5. However, since the instruction (2) in the FIFO buffer 5 interferes with the instruction (1) in the code buffer 6, the instruction (6) from the translator 3 is It is taken out.
Since the instruction in the code buffer 6 does not interfere with the instruction (6), the instruction (6) is output to the code buffer 5.
(vii) The instruction (2) is taken out from the FIFO buffer 5. Since the instruction (2) in the FIFO buffer 5 does not interfere with the instruction (1) in the code buffer 6, the instruction (2) is output to the code buffer 6.

(viii)FIFOバッファ5から命令(4)を取り出す。FIFOバッファ5の中の命令(4)はコードバッファ6の中の命令(3)とは干渉しなくなったので、命令(4)をコードバッファ6に出力する。
(ix)FIFOバッファ5から命令(5)を取り出すが、FIFOバッファ5の中の命令(5)はコードバッファ6の中の命令(4)と干渉するので、翻訳器3から命令(7)が取り出される。
コードバッファ6の中には、命令(6)があり、命令(6)は命令(7)と干渉するで、命令(7)はFIFOバッファ5に入れられる。
(x) FIFOバッファ5から命令(5)を取り出すが、FIFOバッファ5の中の命令(5)はコードバッファ6の中の命令(4)と干渉するので、翻訳器3から命令(8)が取り出される。
命令(8)とFIFOバッファの中の命令(5)(7)は依存関係にあるので、命令(8)はFIFOバッファ5に入れられる。
(viii) The instruction (4) is taken out from the FIFO buffer 5. Since the instruction (4) in the FIFO buffer 5 does not interfere with the instruction (3) in the code buffer 6, the instruction (4) is output to the code buffer 6.
(ix) The instruction (5) is taken out from the FIFO buffer 5, but since the instruction (5) in the FIFO buffer 5 interferes with the instruction (4) in the code buffer 6, the instruction (7) from the translator 3 is It is taken out.
There is an instruction (6) in the code buffer 6 and the instruction (6) interferes with the instruction (7), so that the instruction (7) is put into the FIFO buffer 5.
(x) The instruction (5) is taken out from the FIFO buffer 5, but since the instruction (5) in the FIFO buffer 5 interferes with the instruction (4) in the code buffer 6, the instruction (8) from the translator 3 is It is taken out.
Since the instruction (8) and the instructions (5) and (7) in the FIFO buffer are in a dependency relationship, the instruction (8) is put into the FIFO buffer 5.

(xi)FIFOバッファ5から命令(5)を取り出す。翻訳器3からの命令はないので、命令(5)をコードバッファ6に出力する。
(xii) FIFOバッファ5から命令(7)を取り出す。翻訳器3からの命令はないので、命令(7)をコードバッファ6に出力する。
(xiii)FIFOバッファ5から命令(8)を取り出す。翻訳器3からの命令はないので、命令(8)をコードバッファ6に出力する。
以上の処理を行うことで、コードバッファ6には、命令が(1)(3)(6)(2)(4)(5)(7)(8)の順に出力される。
図7に上記命令スケジュリング後の命令列を示す。同図に示すように、できるだけ干渉が生じないように命令列が並べ替えられ、スケジュリング前の命令列に比べて、実行速度を向上させることができる。
(xi) The instruction (5) is taken out from the FIFO buffer 5. Since there is no instruction from the translator 3, the instruction (5) is output to the code buffer 6.
(xii) The instruction (7) is taken out from the FIFO buffer 5. Since there is no instruction from the translator 3, the instruction (7) is output to the code buffer 6.
(xiii) The instruction (8) is taken out from the FIFO buffer 5. Since there is no instruction from the translator 3, the instruction (8) is output to the code buffer 6.
By performing the above processing, instructions are output to the code buffer 6 in the order of (1) (3) (6) (2) (4) (5) (7) (8).
FIG. 7 shows an instruction sequence after the instruction scheduling. As shown in the figure, the instruction sequence is rearranged so that interference does not occur as much as possible, and the execution speed can be improved as compared with the instruction sequence before scheduling.

本発明のジャバ仮想マシンの全体構成を示す図である。It is a figure which shows the whole structure of the Java virtual machine of this invention. 本発明の実施例のJITコンパイラ12の機能構成を示すブロック図である。It is a block diagram which shows the function structure of the JIT compiler 12 of the Example of this invention. 本発明の実施例の命令スケジュリング処理を示すフローチャート(1)である。It is a flowchart (1) which shows the command scheduling process of the Example of this invention. 本発明の実施例の命令スケジュリング処理を示すフローチャート(2)である。It is a flowchart (2) which shows the command scheduling process of the Example of this invention. ジャバプログラムにおけるバイトコードとネイティブコード一例を示す図である。It is a figure which shows an example of the bytecode and native code in a Java program. 命令スケジュリング処理の際にコードバッファ、FIFOバッファに格納される命令を示す図である。It is a figure which shows the instruction | command stored in a code buffer and a FIFO buffer in the case of instruction scheduling processing. 命令スケジュリング後のネイティブコードを示す図である。It is a figure which shows the native code after instruction scheduling.

符号の説明Explanation of symbols

1 バイトコード
2 テンプレート
3 翻訳器
4 評価器
5 FIFOバッファ
6 コードバッファ
10 ジャバ仮想マシン

1 byte code 2 template 3 translator 4 evaluator 5 FIFO buffer 6 code buffer 10 Java virtual machine

Claims (2)

各バイトコードに一対一に対応したネイティブコードを保持したテンプレートを用いて、バイトコードをネイティブコードにコンパイルする機能を備えた仮想マシンであって、
上記テンプレートを用いてバイトコードをネイティブコードに翻訳する翻訳手段と、
上記翻訳手段により翻訳された命令を格納するFIFOバッファと、命令スケジュリング済みの命令を格納するコードバッファと、
上記翻訳手段により翻訳された命令または上記FIFOバッファに格納された命令と、上記コードバッファに格納された最後の数命令との干渉を評価する評価手段とを備え、
上記評価手段は、
上記翻訳された最新の命令と上記コードバッファの最後の数命令との間に干渉があるとき、もしくは上記翻訳された最新の命令と上記FIFOバッファに保持された命令との間に依存関係があるとき、上記最新の命令をFIFOバッファに出力し、
上記翻訳された最新の命令、もしくはFIFOバッファから取り出した命令と、コードバッファの最後の数命令との間に干渉がないとき、上記翻訳された最新の命令もしくはFIFOバッファの命令をコードバッファに出力する
ことを特徴とする仮想マシン。
A virtual machine having a function for compiling bytecode into native code using a template holding native code corresponding to each bytecode one-to-one,
A translation means for translating bytecode into native code using the template,
A FIFO buffer for storing instructions translated by the translation means; a code buffer for storing instructions scheduled for instruction;
An evaluation means for evaluating interference between the instruction translated by the translation means or the instruction stored in the FIFO buffer and the last few instructions stored in the code buffer;
The evaluation means is
There is a dependency between the translated latest instruction and the last few instructions in the code buffer, or between the translated latest instruction and the instruction held in the FIFO buffer. When the latest instruction is output to the FIFO buffer,
When there is no interference between the latest translated instruction or the instruction fetched from the FIFO buffer and the last few instructions in the code buffer, the translated latest instruction or the FIFO buffer instruction is output to the code buffer. A virtual machine characterized by
各バイトコードに一対一に対応したネイティブコードを保持したテンプレートを用いて、バイトコードをネイティブコードにコンパイラする機能を備えた仮想マシンにより実行されるプログラムであって、
上記プログラムは、上記テンプレートを用いてバイトコードをネイティブコードに翻訳する処理と、
上記翻訳された最新の命令と上記コードバッファの最後の数命令との間に干渉があるとき、もしくは上記翻訳された最新の命令と上記FIFOバッファに保持された命令との間に依存関係があるとき、上記最新の命令をFIFOバッファに出力する処理と、
上記翻訳された最新の命令、もしくはFIFOバッファから取り出した命令と、コードバッファの最後の数命令との間に干渉がないとき、上記翻訳された最新の命令もしくはFIFOバッファの命令をコードバッファに出力する処理をコンピュータに実行させる
ことを特徴とするプログラム。









A program executed by a virtual machine having a function of compiling bytecode into native code using a template holding native code corresponding to each bytecode one-to-one,
The program includes a process of translating bytecode into native code using the template,
There is a dependency between the translated latest instruction and the last few instructions in the code buffer, or between the translated latest instruction and the instruction held in the FIFO buffer. When the latest instruction is output to the FIFO buffer,
When there is no interference between the latest translated instruction or the instruction fetched from the FIFO buffer and the last few instructions in the code buffer, the translated latest instruction or the FIFO buffer instruction is output to the code buffer. A program that causes a computer to execute processing to be performed.









JP2004309225A 2004-10-25 2004-10-25 Virtual machine having compiler Withdrawn JP2006120043A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2004309225A JP2006120043A (en) 2004-10-25 2004-10-25 Virtual machine having compiler

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2004309225A JP2006120043A (en) 2004-10-25 2004-10-25 Virtual machine having compiler

Publications (1)

Publication Number Publication Date
JP2006120043A true JP2006120043A (en) 2006-05-11

Family

ID=36537849

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2004309225A Withdrawn JP2006120043A (en) 2004-10-25 2004-10-25 Virtual machine having compiler

Country Status (1)

Country Link
JP (1) JP2006120043A (en)

Similar Documents

Publication Publication Date Title
EP4099152B1 (en) Extending a virtual machine instruction set architecture
US6324686B1 (en) Just in time compiler technique
US7725883B1 (en) Program interpreter
Gal et al. HotpathVM: An effective JIT compiler for resource-constrained devices
US7380242B2 (en) Compiler and software product for compiling intermediate language bytecodes into Java bytecodes
US7877741B2 (en) Method and corresponding apparatus for compiling high-level languages into specific processor architectures
EP0806725B1 (en) Method and apparatus for early insertion of assembler code for optimization
JP5466601B2 (en) Code generation method, system and program
US20120198428A1 (en) Using Aliasing Information for Dynamic Binary Optimization
WO2012101530A1 (en) Dynamic binary optimization
JP2000035893A (en) Method for statically initializing arrangement of data processing system, data processing method, data processing system and computer readable storage medium storing program making computer execute its control procedure
Hummel et al. Annotating the Java bytecodes in support of optimization
CN106033370B (en) Method and device for realizing 64-bit Java virtual machine
US8230407B2 (en) Apparatus and method for accelerating Java translation
US7739674B2 (en) Method and apparatus for selectively optimizing interpreted language code
JP2018028777A (en) Emulation device, emulation method, and emulation program
US8490073B2 (en) Controlling tracing within compiled code
Mong et al. DynamoSim: a trace-based dynamically compiled instruction set simulator
KR101083271B1 (en) System and method for converting active x control
US7266811B2 (en) Methods, systems, and computer program products for translating machine code associated with a first processor for execution on a second processor
JP2006120043A (en) Virtual machine having compiler
Nadeem et al. GALS-JOP: A Java embedded processor for GALS reactive programs
Nakatani et al. Making compaction-based parallelization affordable
Brandner et al. Embedded JIT compilation with CACAO on YARI
El-Kharashi et al. The JAFARDD processor: a java architecture based on a folding algorithm, with reservation stations, dynamic translation, and dual processing

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20080108