JP2006195644A - Device and method for executing virtual machine - Google Patents
Device and method for executing virtual machine Download PDFInfo
- Publication number
- JP2006195644A JP2006195644A JP2005005322A JP2005005322A JP2006195644A JP 2006195644 A JP2006195644 A JP 2006195644A JP 2005005322 A JP2005005322 A JP 2005005322A JP 2005005322 A JP2005005322 A JP 2005005322A JP 2006195644 A JP2006195644 A JP 2006195644A
- Authority
- JP
- Japan
- Prior art keywords
- virtual machine
- class
- runtime
- execution
- storage device
- 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
Links
Images
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
Description
本発明は、計算機のハードウェアアーキテクチャに依存しない中間コードを実行し、例えばJava仮想マシンなどの仮想マシンを実行する仮想マシン実行装置及び方法に関する。 The present invention relates to a virtual machine execution apparatus and method for executing an intermediate code independent of a hardware architecture of a computer and executing a virtual machine such as a Java virtual machine.
中間コード方式とは、人間が理解できる表面言語から機械が理解できる実行コードへ変換し実行するまでにおいて、一旦予め定められたコード体系である中間コードへ変換し、実行時は実行処理モジュールが中間コードを読み込み解釈しながら処理を実現していく方式である。これらの技術は、Java技術の出現によって一般的なものとなった(ここで、JavaはSun Microsystems社の登録商標である。)。中間コード実行装置を「仮想マシン」と呼び、中間コードをまた「バイトコード」と呼ぶこともある。 The intermediate code method converts from a surface language that can be understood by humans to an executable code that can be understood by a machine, and then converts it into an intermediate code that is a predetermined code system. This is a method that implements processing while reading and interpreting code. These technologies have become commonplace with the advent of Java technology (where Java is a registered trademark of Sun Microsystems). The intermediate code execution device is sometimes called a “virtual machine”, and the intermediate code is sometimes called a “byte code”.
非特許文献1では、Java仮想マシンの仕様について説明しており、非特許文献1の第6章ではバイトコードの命令セットを定義している。例えば算術命令に関しては、加算では(iadd/ladd/fadd/dadd)、乗算では(imul/lmul/fmul/dmul)といった命令を用意している。このように整数と浮動小数点数に対する命令では、オーバーフロー及びゼロ除算の際における振る舞いが異なるため、従来の仮想マシンでは、それぞれに対して命令を用意する。
Non-Patent
また、中間コード方式によって異なる種類の計算機に対して同一のプログラムを配信することを可能とする。ワークステーションやパソコンなど、強力な処理能力を持つCPU及び充分なメモリを搭載した計算機がある一方、組込みシステムなどのように処理能力の劣るCPU及び限られたメモリを搭載した計算機でも利用される。また、仮想マシンなどの中間コード実行装置は多くの場合、インタプリタ方式で実現されており、実行速度はネイティブコードによる実行速度と比較して遅いという問題点があった。 Further, the same program can be distributed to different types of computers depending on the intermediate code system. While some computers such as workstations and personal computers have powerful processing capability and computers with sufficient memory, they are also used in CPUs with inferior processing capability and computers with limited memory, such as embedded systems. Further, in many cases, an intermediate code execution device such as a virtual machine is realized by an interpreter method, and there is a problem that an execution speed is slower than an execution speed by a native code.
この問題点に対して、特許文献1では、「限られたリソースにおいて高速にJavaのバイトコードを実行可能とするコンパイラを提供するために、バイトコードを、各バイトコードに対応する処理ルーチンのアドレスをオペコードとする中間コードに変換し、中間コードの順番に処理ルーチンを実行し、この時中間コードを固定長にし、その中でオペコードのビット位置も固定する。また処理ルーチンを、メモリ上の連続領域に配置し、オペコードには処理ルーチン群104の先頭アドレスからのオフセットを用いる。さらに、CPUのパイプラインの空きを利用して、中間コードのための本来の処理に並行して、次の中間コードの処理ルーチンにジャンプするための命令群の一部(オペランドの生成及びジャンプ)、及び次の次の中間コードの処理ルーチンにジャンプするための命令群の一部(中間コードのプリフェッチと処理ルーチンのアドレス計算)を実行する。」すなわち、特許文献1に開示された装置(以下、第1の従来例という。)では、中間コード列をロード時に高速実行可能な内部中間コード列に変換することで高速化しており、具体的には、ロード時の中間コード変換処理により、各命令に対して、該当する命令実行モジュールの基準アドレスからのオフセットを算出し変換する。そして実行時には取得オフセットと基準アドレスを加算し、命令実行モジュール開始アドレスを算出する。 In order to solve this problem, Japanese Patent Application Laid-Open No. 2005-228561 discloses that “in order to provide a compiler capable of executing Java bytecode at high speed with limited resources, the bytecode is an address of a processing routine corresponding to each bytecode. Is converted to an intermediate code having an operation code, and the processing routine is executed in the order of the intermediate code, and at this time, the intermediate code is set to a fixed length, and the bit position of the operation code is also fixed therein. The offset from the start address of the processing routine group 104 is used for the operation code, and the next intermediate is used in parallel with the original processing for the intermediate code by utilizing the CPU pipeline free space. Part of the instruction group for jumping to the code processing routine (operand generation and jump), and the next intermediate code A part of the instruction group for jumping to the processing routine of the host (execution of prefetch of intermediate code and address calculation of the processing routine) is executed. ”That is, the device disclosed in Patent Document 1 (hereinafter referred to as the first conventional example) )), The intermediate code string is converted to an internal intermediate code string that can be executed at the time of loading at a high speed. Specifically, the intermediate code conversion process at the time of loading corresponds to each instruction. An offset from the reference address of the instruction execution module is calculated and converted. At the time of execution, the obtained offset and the reference address are added to calculate the instruction execution module start address.
また、特許文献2では、「計算機のハードウェアアーキテクチャに依存しない中間コードを実行する中間コード実行装置において、中間コードの実行を高速化しながら、中央処理装置のレジスタを高速化目的に使用することを避け、なおかつ使用記憶領域の増加を抑制するために、入力された中間コード列中の各命令を、直前命令実行モジュール終端アドレスから当該命令実行モジュール開始アドレスへの相対アドレスに置換する置換手段により内部中間コード列を用意しておき、前記相対アドレスの取得手段と、前記相対アドレスを用いる相対ジャンプ手段により内部中間コードを順次実行すること」を特徴としている。すなわち、特許文献2に開示された中間コード実行装置(以下、第2の従来例という。)においては、各モジュールの開始アドレス及び終了アドレスのテーブルを持たせ、現在モジュールから次期モジュールへ移行する場合、現在モジュールの終了アドレス及び次期モジュールの開始アドレスから、相対アドレスを算出し、相対ジャンプをすることによって、次期モジュールへ移動する。
Further,
さらに、特許文献3では、「共通のアルゴリズムに基づく異なったデータ型に対する計算を、同一の実行プログラムで実行することができる情報処理装置を提供するために、演算を行うデータのデータ型を指示するレジスタと、当該レジスタにデータ型を設定する手段を有し、複数のデータ型のうちの少なくとも1つに対して共通の命令手段を持ち、当該命令手段と上記レジスタの内容に対応させてそれぞれのデータ型の演算を行うことにより、共通のアルゴリズムに基づく異なったデータ型に対する計算を同一の実行プログラムで実行すること」を特徴としている。すなわち、特許文献3に開示された情報処理装置(以下、第3の従来例という。)では、高級言語によるソースプログラムを機械語プログラムに変換して出力するコンパイラ装置においてレジスタを用意することにより、コンパイラ装置自体を簡素化している。
Further, in
整数と浮動小数点数とでは振る舞いが異なることから、Java仮想マシンをはじめとして、従来技術に係る中間コード実行装置では、それぞれに対して命令を用意している。加算・減算・乗算・除算・剰余・符号反転など、あらゆる算術命令に対して、データ型に対応した命令セットを必要とするため、テーブルサイズが膨れ上がり、中間コード実行装置をコンパクトなものとすることが困難であった。第1の従来例に開示されている手法では、実行時に基準アドレスと取得されているオフセットを加算し、命令実行モジュール開始アドレスを算出する必要がある。従って、実行時に依然として演算処理を必要とするという問題点があった。 Since the behavior differs between an integer and a floating-point number, an intermediate code execution device according to the prior art including a Java virtual machine prepares an instruction for each. An instruction set corresponding to the data type is required for all arithmetic instructions such as addition, subtraction, multiplication, division, remainder, and sign inversion, so the table size increases and the intermediate code execution device is made compact. It was difficult. In the technique disclosed in the first conventional example, it is necessary to calculate the instruction execution module start address by adding the reference address and the acquired offset at the time of execution. Therefore, there has been a problem that it still requires arithmetic processing at the time of execution.
また、第2の従来例に係る中間コード実行装置においては、実行速度を高速化するための技術が開示されているが、上述のように、各モジュールの開始アドレス及び終了アドレスのテーブルを持たせ、現在モジュールから次期モジュールへ移行する場合、現在モジュールの終了アドレス及び次期モジュールの開始アドレスから、相対アドレスを算出し、相対ジャンプをすることによって、次期モジュールへ移動しているために、いまだ実行速度を大幅に向上できないという問題点があった。さらに、第3の従来例に係る情報処理装置においては、コンパイラの構成を簡素化できるが、インタプリタ型の仮想マシンの構成を簡素化できないという問題点があった。 In addition, in the intermediate code execution device according to the second conventional example, a technique for increasing the execution speed is disclosed, but as described above, a table of the start address and end address of each module is provided. When moving from the current module to the next module, the relative speed is calculated from the end address of the current module and the start address of the next module, and the relative speed is used to move to the next module. There was a problem that could not be improved significantly. Furthermore, in the information processing apparatus according to the third conventional example, the configuration of the compiler can be simplified, but the configuration of the interpreter type virtual machine cannot be simplified.
本発明の目的は以上の問題点を解決し、従来技術に比較して、仮想マシンの実行時の演算処理を高速化できる仮想マシン実行装置及び方法を提供することにある。 An object of the present invention is to provide a virtual machine execution apparatus and method that can solve the above problems and can speed up the arithmetic processing at the time of execution of the virtual machine as compared with the prior art.
また、本発明の別の目的は以上の問題点を解決し、従来技術に比較して、仮想マシンの構成を簡素化できる仮想マシン実行装置及び方法を提供することにある。 Another object of the present invention is to provide a virtual machine execution apparatus and method capable of solving the above-described problems and simplifying the configuration of the virtual machine as compared with the prior art.
第1の発明に係る仮想マシン実行装置は、中間コードを二次記憶装置から主記憶装置にロードして実行する仮想マシン実行装置において、
中間コードを主記憶装置にロードされた少なくとも1つのクラスを有するクラス配列と、実行時の情報を格納する少なくとも1つのランタイムを有するランタイム配列とを含む仮想マシンエンジンを備え、
上記クラスは、オペコードを含む処理手順情報を記述した少なくとも1つのメソッドを有するメソッドメンバーと、数値データ又は文字列データもしくは他のクラスへの少なくとも1つの参照情報を有するフィールドメンバーとを備え、
上記中間コードを主記憶装置にロードしたときに、上記メソッドに含まれるオペコードのアドレスを上記主記憶装置のアドレスで表しかつ上記各クラスのデータ領域に格納したことを特徴とする。
A virtual machine execution device according to a first aspect of the present invention is a virtual machine execution device that loads and executes an intermediate code from a secondary storage device to a main storage device.
A virtual machine engine comprising a class array having at least one class loaded with intermediate code in main memory and a runtime array having at least one runtime for storing runtime information;
The class includes a method member having at least one method describing processing procedure information including an operation code, and a field member having at least one reference information to numeric data or character string data or another class,
When the intermediate code is loaded into the main storage device, the address of the operation code included in the method is expressed by the address of the main storage device and stored in the data area of each class.
上記仮想マシン実行装置において、上記ランタイムは、実行メソッドへのアドレス及びメソッド内だけで生成され使用される変数を格納するローカル変数領域を確保することが可能であり、処理途中の計算結果を一時的に格納するスタック領域を備え、
上記スタック領域にデータ型とその値の形式で表されたオペランドが格納されることを特徴とする。
In the virtual machine execution device, the runtime can secure a local variable area for storing an address to an execution method and a variable generated and used only in the method, and temporarily calculates a calculation result during the process. With a stack area to store
Operands expressed in a data type and a value format are stored in the stack area.
第2の発明に係る仮想マシン実行装置は、中間コードを二次記憶装置から主記憶装置にロードして実行する仮想マシン実行装置において、
中間コードを主記憶装置にロードされた少なくとも1つのクラスを有するクラス配列と、実行時の情報を格納する少なくとも1つのランタイムを有するランタイム配列とを含む仮想マシンエンジンを備え、
上記クラスは、オペコードを含む処理手順情報を記述した少なくとも1つのメソッドを有するメソッドメンバーと、数値データ又は文字列データもしくは他のクラスへの少なくとも1つの参照情報を有するフィールドメンバーとを備え、
上記ランタイムは、実行メソッドへのアドレス及びメソッド内だけで生成され使用される変数を格納するローカル変数領域を確保することが可能であり、処理途中の計算結果を一時的に格納するスタック領域を備え、
上記スタック領域にデータ型とその値の形式で表されたオペランドが格納されることを特徴とする。
A virtual machine execution device according to a second aspect of the present invention is a virtual machine execution device that loads an intermediate code from a secondary storage device to a main storage device and executes the intermediate code.
A virtual machine engine comprising a class array having at least one class loaded with intermediate code in main memory and a runtime array having at least one runtime for storing runtime information;
The class includes a method member having at least one method describing processing procedure information including an operation code, and a field member having at least one reference information to numeric data or character string data or another class,
The runtime can secure an address to the execution method and a local variable area for storing variables that are generated and used only within the method, and has a stack area for temporarily storing calculation results during processing. ,
Operands expressed in a data type and a value format are stored in the stack area.
第3の発明に係る仮想マシン実行方法は、中間コードを二次記憶装置から主記憶装置にロードして実行する仮想マシン実行方法において、
中間コードを主記憶装置にロードされた少なくとも1つのクラスを有するクラス配列と、実行時の情報を格納する少なくとも1つのランタイムを有するランタイム配列とを含む仮想マシンエンジンを備え、
上記クラスは、オペコードを含む処理手順情報を記述した少なくとも1つのメソッドを有するメソッドメンバーと、数値データ又は文字列データもしくは他のクラスへの少なくとも1つの参照情報を有するフィールドメンバーとを備え、
上記中間コードを主記憶装置にロードしたときに、上記メソッドに含まれるオペコードのアドレスを上記主記憶装置のアドレスで表しかつ上記各クラスのデータ領域に格納するステップを含むことを特徴とする。
According to a third aspect of the present invention, there is provided a virtual machine execution method in which an intermediate code is loaded from a secondary storage device to a main storage device and executed.
A virtual machine engine comprising a class array having at least one class loaded with intermediate code in main memory and a runtime array having at least one runtime for storing runtime information;
The class includes a method member having at least one method describing processing procedure information including an operation code, and a field member having at least one reference information to numeric data or character string data or another class,
When the intermediate code is loaded into the main memory, the address of the operation code included in the method is represented by the address of the main memory and stored in the data area of each class.
上記仮想マシン実行方法において、上記ランタイムは、実行メソッドへのアドレス及びメソッド内だけで生成され使用される変数を格納するローカル変数領域を確保することが可能であり、処理途中の計算結果を一時的に格納するスタック領域を備え、
上記スタック領域にデータ型とその値の形式で表されたオペランドが格納されることを特徴とする。
In the virtual machine execution method, the runtime can secure a local variable area for storing an address to an execution method and a variable generated and used only in the method, and temporarily calculates a calculation result during the process. With a stack area to store
Operands expressed in a data type and a value format are stored in the stack area.
第4の発明に係る仮想マシン実行方法は、中間コードを二次記憶装置から主記憶装置にロードして実行する仮想マシン実行方法において、
中間コードを主記憶装置にロードされた少なくとも1つのクラスを有するクラス配列と、実行時の情報を格納する少なくとも1つのランタイムを有するランタイム配列とを含む仮想マシンエンジンを備え、
上記クラスは、オペコードを含む処理手順情報を記述した少なくとも1つのメソッドを有するメソッドメンバーと、数値データ又は文字列データもしくは他のクラスへの少なくとも1つの参照情報を有するフィールドメンバーとを備え、
上記ランタイムは、実行メソッドへのアドレス及びメソッド内だけで生成され使用される変数を格納するローカル変数領域を確保することが可能であり、処理途中の計算結果を一時的に格納するスタック領域を備え、
上記スタック領域にデータ型とその値の形式で表されたオペランドが格納されることを特徴とする。
According to a fourth aspect of the present invention, there is provided a virtual machine execution method in which an intermediate code is loaded from a secondary storage device to a main storage device and executed.
A virtual machine engine comprising a class array having at least one class loaded with intermediate code in main memory and a runtime array having at least one runtime for storing runtime information;
The class includes a method member having at least one method describing processing procedure information including an operation code, and a field member having at least one reference information to numeric data or character string data or another class,
The runtime can secure an address to the execution method and a local variable area for storing variables that are generated and used only within the method, and has a stack area for temporarily storing calculation results during processing. ,
Operands expressed in a data type and a value format are stored in the stack area.
従って、本発明によれば、上記中間コードを主記憶装置にロードしたときに、上記メソッドに含まれるオペコードのアドレスを上記主記憶装置のアドレスで表しかつ上記各クラスのデータ領域に格納するので、仮想マシンの実行時においてアドレス変換処理を行う必要がないので、従来技術に比較して仮想マシンを高速で実行できる。 Therefore, according to the present invention, when the intermediate code is loaded into the main storage device, the address of the operation code included in the method is represented by the address of the main storage device and stored in the data area of each class. Since it is not necessary to perform address translation processing when the virtual machine is executed, the virtual machine can be executed at a higher speed than in the prior art.
また、本発明によれば、上記スタック領域に格納されたオペランドは、そのデータ型とその値の形式で表すので、データ型の組み合わせによる命令コードの増大をおさえ、コンパクトな仕様を有する仮想マシンを実現することができる。 Further, according to the present invention, since the operand stored in the stack area is expressed in the form of its data type and its value, a virtual machine having a compact specification can be suppressed without increasing the instruction code due to the combination of the data types. Can be realized.
以下、本発明に係る実施形態について図面を参照して説明する。なお、同様の構成要素については同一の符号を付している。 Hereinafter, embodiments according to the present invention will be described with reference to the drawings. In addition, the same code | symbol is attached | subjected about the same component.
実施形態.
図1は本発明の一実施形態に係る仮想マシン実行装置1000の構成を示すブロック図である。本実施形態に係る仮想マシン実行装置1000は、ディジタル計算機のハードウェアアーキテクチャに依存しない中間コードを実行する仮想マシンの実行装置であって、図1に示すように、中央処理装置1100と、二次記憶装置1200と、主記憶装置1300とを備え、これら装置1100,1200,1300がバスを介して接続されて構成され、二次記憶装置1200には、実行内容を記述したクラス中間コード1201が予め格納されている。
Embodiment.
FIG. 1 is a block diagram showing a configuration of a virtual
図2は図1の中央処理装置1100によって実行される仮想マシンのインストール処理を示すフローチャートである。また、図4は図2のステップS1の処理後の仮想マシン実行装置1000の構成を示すブロック図であり、図5は図2のステップS3の処理後の仮想マシン実行装置1000の構成を示すブロック図である。
FIG. 2 is a flowchart showing a virtual machine installation process executed by the
図2において、まず、ステップS1では、図4に示すように、クラス中間コード1201に含まれる仮想マシンエンジン1400及び処理ルーチン群1410を、二次記憶装置1200から主記憶装置1300にロードする。ここで、ロードされた仮想マシン1400では、後にロードされるクラスを登録するクラス配列を有している。クラスとは少なくとも1つのメンバー変数と少なくとも1つのメンバー関数を有しており、ある程度概念的に関連ある変数及び関数をまとめたソフトウェアである。また、処理ルーチン群1410は、仮想マシン1400で提供する基本的な処理であり、各処理に番号が割り振られている。クラスにおけるメンバー関数は、具体的には実行する処理ルーチン群1410で割り当てたれている番号とそれに対するパラメータを、実行順に並べた配列である。図4の例では、処理ルーチン群1410は、オペコードa実行モジュール1410aと、オペコードb実行モジュール1410bと、オペコードc実行モジュール1410cなどを含む。
2, first, in step S1, as shown in FIG. 4, the
次いで、ステップS2において、図5に示すように、二次記憶装置1200から、クラス中間コード1201に含まれ、仮想マシンの実行時に使用されるクラスファイル群を主記憶装置1300にロードする。二次記憶装置1200には少なくとも1つのクラスが保存されている。クラスはすべてロードするのではなく、必要なクラスのみをロードする。ユーザ又は仮想マシンを使用する他のシステムは、最初どのクラスのどのメンバー関数を起動関数とするかを指定する。これによって、二次記憶装置1200からロードするべきクラスが決定されてロードされる。クラスは、他のクラスの機能を利用することもあり、その情報もロードするファイル内に記述されている。この情報に基づいて、さらに必要なクラスがロードされる。
Next, in step S2, as shown in FIG. 5, the class file group included in the class
そして、ステップS3では、主記憶装置1300にロードしたクラスファイル群で、お互いに名前で参照している箇所を、実際の主記憶装置1300上のメモリアドレスに置き換えることによりリンク処理を行って、当該仮想マシンによる実行準備処理を終了する。当該ステップS3では、すべての必要なクラスのロードが完了した時点でリンク作業が実行される。二次記憶装置1200で保存されている状態では、クラス内における他クラス参照情報は、クラス名や関数名という文字列情報で記述されている。二次記憶装置1200から主記憶装置1400へロードが完了すると、主記憶装置1400におけるクラスのアドレスが明らかとなるので、他クラス参照情報に基づいて、主記憶装置1400におけるアドレスへ置き換える処理を実行する。
In step S3, the class file group loaded in the
すなわち、主記憶装置1300では、図4及び図5に示すように、仮想マシンの実行時にすべての情報を管理する仮想マシンエンジン1400が存在し、仮想マシンエンジン1400はクラス配列及びランタイム配列を有する。仮想マシンエンジン1400は、中間コードのバイナリデータであるクラス中間コード1201を、実行に必要なコードだけ二次記憶装置1200から主記憶装置1300へロードし、少なくとも1つのクラス1500を生成して配列として管理する。また、ランタイム配列は実際に所定の起動メソッドから処理を実行する段階で、必要な情報を格納するために生成される。ここで、クラス1500とは、ある概念に基づいたデータ及び関数を1つのグループにまとめたプログラムモジュールのことであり、クラス1500は、図5に示すように、オペコードを含む処理手順情報を記述した少なくとも1つのメソッドを有するメソッドメンバー1510と、数値データ又は文字列データもしくは他のクラスへの少なくとも1つの参照情報を含む少なくとも1つのフィールドデータ(少なくとも1つのオペランドを含む)を有するフィールドメンバー1520と、後述するようにオペコードのアドレスを含むデータ領域とを含む。クラス配列とは、このようなクラスを1個以上有する配列である。仮想マシン実行装置1000によって、なんらかの処理を実行するときは必ず1個以上のクラスが仮想マシンエンジン1400にロードされる。クラスの関数内で他のクラスが利用されている場合は、さらに利用しているクラスがロードされる。
That is, in the
上述のように、起動時の処理では、初期化した後、二次記憶装置1200よりクラスファイル群をロードし、リンク処理を実行しており、クラスファイルをロードする前段階の仮想マシン起動直後の主記憶装置1300の状態が図4に図示されている。この時点では、データ管理用の配列を有する仮想マシンエンジン1400や、プリミティブ機能の処理ルーチン及びプリミティブなデータ型とその値を含むオペランド1420のみが存在している。これに対して、二次記憶装置1200よりクラスファイル群をロードし、リンク処理を実行した後の主記憶装置1300の状態を図5に図示している。このとき、ファイルではオペコード(整数)で示されていたメソッドの処理手順は、オペコードに対応する処理関数へのポインタへ置き換えられている。すなわち、メソッドにアドレス管理用配列(クラス内のデータ領域にあるオペコードのアドレス)を用意し、配列に格納されている関数ポインタを順々に実行して行くことで処理が実現できる。また、実際にはクラスファイルが複数存在し、自己のメソッドや自己以外のメソッドを呼び出す。このようなメソッド呼び出し機能については、メソッドが管理している関数配列へのポインタを呼び出し側が知っていることで、直接に呼び出すことが可能となる。以上のような、実メモリ(主記憶装置1300)上におけるアドレスを検索し、利用側にその情報を記録することをリンク処理と呼ぶ。これらは起動直後に行い、実際の処理が始まった段階ではアドレスへダイレクトにジャンプするのみとなっており、従って、本実施形態は、従来技術における相対アドレスの計算などの余分なアドレス計算が発生しないことを特徴としている。
As described above, in the process at the time of startup, after initialization, the class file group is loaded from the
また、図5に示すように、各メソッドメンバー1510の各メソッドに対応するメソッド1530は、複数のオペコードを含み、そのアドレスがメソッド内に記載されており、処理ルーチン群1410の各オペコード実行モジュールとリンクされている。図9は本実施形態に係る仮想マシンエンジン1400中のクラスの構成を示すブロック図である。図9において、クラスA1500Aにおいて、クラスBのオペコードQを引用している場合、クラスA1500Aにおけるデータ領域においてオペコードQのアドレスを格納することによりリンクされている。さらに、図5に示すように、フィールドメンバー1520の各オペランド1420はデータ型とその値との形式を有する。
Further, as shown in FIG. 5, a
図3は図1の中央処理装置1100によって実行される仮想マシンの実行処理を示すフローチャートである。また、図6は図3の仮想マシンの実行処理時の仮想マシン実行装置1000の構成を示すブロック図である。
FIG. 3 is a flowchart showing virtual machine execution processing executed by the
図3において、まず、ステップS11において、仮想マシンエンジン1400のクラス配列から所定の起動メンバー関数アドレスを取得し、ステップS12でそれに対応するランタイムを生成する。次いで、ステップS13において、当該ランタイム1600においてメソッドフレーム1610を生成し、実行するメンバー関数のアドレスを登録し、ステップS14においてメソッドフレーム1610のプログラムカウンタ値を0に初期化する。さらに、ステップS22において、現在のメソッドフレーム1610のプログラムカウンタ値に登録されている初期化ルーチンを取得する。ステップS23では、当該処理ルーチン1410が関数呼び出しであるか否かが判断され、YESのときはステップS13に戻る一方、NOのときはステップS15に進む。ステップS15において、現在のメソッドフレームの1610のプログラムカウンタ値に登録されている処理ルーチン1410はジャンプ命令であるか否かが判断され、YESのときはステップS16に進む一方、NOのときはステップS17に進む。ステップS16では、ジャンプ命令に従ってプログラムカウンタ値を増減した後、ステップS19に進む。一方、ステップS17では、当該処理ルーチン1410を実行し、ステップS18においてプログラムカウンタ値を1だけインクリメントし、ステップS19に進む。ステップS19では、当該メンバー関数の終了であるか否かが判断され、YESのときはステップS20に進む一方、NOのときはステップS22に戻る。ステップS20では、当該メソッドフレーム1610を開放し、呼び出し元のメソッドフレームに戻り、ステップS21では、プログラムの終了であるか否かが判断され、NOであるときはステップS22に戻る一方、YESのときは当該仮想マシンの実行処理を終了する。
In FIG. 3, first, in step S11, a predetermined activation member function address is acquired from the class array of the
図6には、仮想マシンがクラスメソッドを実行するときの主記憶装置1300の状態を図示している。図6を参照して、図3の実行処理について以下に詳述する。
FIG. 6 illustrates a state of the
仮想マシンの実行時処理では、上述のように、ランタイム1600及びメソッドフレーム1610を生成し主記憶装置1400へロードしたクラス情報から、処理ルーチン群1410を実行していく。まず、最初に実行する起動クラスの起動メンバー関数のアドレスを取得し、ランタイム1600を生成する。ランタイム1600は、1つの処理の流れに対して1つ生成される。すなわち、マルチタスクで実行したい場合は、複数のランタイム1600が生成される。ここでは、シングルタスクのケースで説明する。次に、メソッドフレーム1610を生成し、先に取得してある起動クラスの起動メンバー関数を登録する。メソッドフレーム1610とは、1つのメンバー関数の実行時に1つ用意される。メソッドフレーム1610は、プログラムカウンタ、ローカル変数配列、スタック領域を所有する。メンバー関数は処理ルーチン群1610で割り振られている番号を実行順に格納した配列であることを上述したが、プログラムカウンタは本配列において、どこまで実行したかを示すものである。ローカル変数配列は、メンバー関数内でのみ使用される変数の配列である。また、スタック領域とは処理ルーチン群を順々に実行していく段階で生じる途中の計算結果などを格納する領域である。さらに、メソッドフレーム1610を生成し、起動メンバー関数が登録されたら、プログラムカウンタを初期化する。関数に登録されている処理ルーチン1410を順に実行する。関数終了まで到達すると、本メソッドフレームの実行を完了したこととなる。ただし、処理ルーチン1410の中には関数コールの機能があり、これを実行すると、該当するクラスのメンバー関数取得が行われ、新たなメソッドフレーム1610を生成しメンバー関数のアドレスを登録した後、実行は生成したメソッドフレームへ移行する。関数呼び出しによって生成されたメソッドフレームは、同様に処理ルーチンを実行しながらプログラムカウンタを進め、関数終了と同時に、メソッドフレームを開放し、呼び出しもとのメソッドフレームへ戻ってくる。以上のようにして、関数実行がすべて終了し、残っているメソッドフレームもない状態になるとプログラム実行を完了する。
In the runtime processing of the virtual machine, as described above, the
仮想マシンの実行時におけるランタイム配列とは、上述のように、実際にクラスのメソッドを実行する段階で生成され、ランタイム1600で格納する情報は起動メソッドへのアドレス及びメソッドフレームの配列である。仮想マシンエンジン1400が複数のランタイム1600を格納するためにランタイム配列を具備する理由は、マルチタスク処理を実現するためである。また、ランタイム1600において生成されるメソッドフレーム1610とは、新たにメソッドを実行するたびに生成される。例えば起動メソッド内で別のメソッドを起動した場合、メソッドフレーム配列には2つのメソッドフレームが格納される。メソッドフレーム1610では、実行メソッドへのアドレス、メソッド内で何番目のオペコードを実行中であるかを示すプログラムカウンタ、実行メソッドへのアドレス及びメソッド内だけで生成され使用される少なくとも1つの変数を格納するローカル変数領域1620、及び少なくとも1つのオペランドを含み処理途中の計算結果を一時的に格納するスタック領域1630を情報として格納する。メソッドフレーム1610によるメソッド実行の動作原理では、まずメソッドを起動すると、プログラムカウンタ値を初期化し、ローカル変数が用意される。そして実行メソッドアドレスへアクセスし、オペコードのアドレスを実行順に格納した配列をプログラムカウンタ値に従って実行していく。ローカル変数に対する演算を実施した途中経過はスタック領域へ格納する。オペコードの処理が完了するたびにプログラムカウンタ値を1つずつ増やし、次のオペコードを実行する。また、ジャンプ命令を意味するオペコードでは、プログラムカウンタを増減させることで実現し、余計なアドレス計算を不要なものとしている。
As described above, the runtime array at the time of execution of the virtual machine is generated at the stage of actually executing the method of the class, and information stored in the
本実施形態においては、各クラス1500毎に生成されるフィールドメンバー1520と、各メソッドフレーム1610に対して生成されるローカル変数領域1620及びスタック領域1630において、データタグ及びデータ値とを格納したオペランド1420をプリミティブなデータ型とその値とを含む形式で構成したことを特徴としている。すなわち、特に、メソッドフレーム1610が有するローカル変数領域1620、スタック領域1630及び各クラスのフィールドメンバー1520のデータはオペランドの配列であることを特徴としている。通常、スタック領域へ記録する内容はデータ値のみを格納する。このため仮想マシンのプリミティブな命令では、整数用の加算であるiaddや浮動小数点用の加算であるfaddといった具合にデータ型を区別して命令を用意し、スタックの値を操作する。そのため、オペコードの増加を招くが、本実施形態に係る仮想マシンでは、図8に示すように、スタック領域1630にもデータ型を区別する当該データコードを配置し、コードを一本化することによって、命令体系の簡素化を実現した。
In this embodiment, the
図7は本実施形態に係る仮想マシン実行装置1000で用いるオペコードの一例を示す表である。図7に示すように、オペコードは非負の整数で表され、例えば0x0001ならば仮想マシンに対して加算処理を、0x0002ならば仮想マシンに対して減算処理を実行させる。実際の処理内容は、オペコードごとに処理ルーチン群1410として存在し、オペコードaに対する実行モジュール1410a、オペコードbに対する実行モジュール1410b、オペコードcに対する実行モジュール1410cなどという具合に、オペコードのIDごとに実行モジュールが存在する。クラス中間コード1201を二次記憶装置に記録している段階では、クラスのメソッドはオペコードのIDを記録するが、メモリへロードするタイミングで、オペコードのIDから実行モジュールへのアドレスへ変更する。例えばメソッドの最初の実行がオペコードcであるならば、オペコードの実行モジュール1410cのアドレスへ変換する。これによって、実行時にIDによる検索を無くし高速な実行を可能とする。また、直接的に主記憶装置1300のアドレスを記述することによって、(基準アドレス+オフセット)といったアドレス計算を不要なものとしている。
FIG. 7 is a table showing an example of an opcode used in the virtual
図8は本実施形態に係る仮想マシン実行装置1000で用いるデータコードの一例を示す表である。図8に示すように、データコードは非負の整数で表され、例えば0x0002ならば2バイト整数を示し、0x0003ならば4バイト整数を示す。本実施形態に係る仮想マシンでは、スタック領域1630にもデータ型を区別する当該データコードを配置し、コードを一本化することによって、命令体系の簡素化を実現した。
FIG. 8 is a table showing an example of data codes used in the virtual
変形例.
図10は本発明の変形例に係る仮想マシン実行装置1000Aの構成を示すブロック図である。図1の実施形態に係る仮想マシン実行装置1000では、仮想マシン実行装置1000に設けた二次記憶装置1200に格納されているクラス中間コードをロードし、主記憶装置1300へ展開して実行しているが、本発明はこれに限らず、図10の仮想マシン実行装置1000Aのごとく構成してもよい。すなわち、仮想マシン実行装置1000Aにおいて通信インターフェース回路1710を備え、例えばインターネットなどのネットワーク1800を経由してリモートにあるディジタル計算機のサーバ装置1900内の二次記憶装置からクラス中間コードを、ネットワーク1800を介して主記憶装置1300にダウンロードして展開した後実行してもよい。
Modified example.
FIG. 10 is a block diagram showing a configuration of a virtual machine execution device 1000A according to a modification of the present invention. In the virtual
以上の実施形態において、ランタイム1600は、実行メソッドへのアドレス及びメソッド内だけで生成され使用される変数を格納するローカル変数領域1620を確保することが可能であるように構成され、また、ランタイム1600は、処理途中の計算結果を一時的に格納するスタック領域1630を備え、スタック領域1630にデータ型とその値の形式で表されたオペランド1420が格納されるように構成してもよい。
In the above embodiment, the
以上詳述したように、本発明によれば、上記中間コードを主記憶装置にロードしたときに、上記メソッドに含まれるオペコードのアドレスを上記主記憶装置のアドレスで表しかつ上記各クラスのデータ領域に格納するので、仮想マシンの実行時においてアドレス変換処理を行う必要がないので、従来技術に比較して仮想マシンを高速で実行できる。 As described above in detail, according to the present invention, when the intermediate code is loaded into the main storage device, the address of the operation code included in the method is represented by the address of the main storage device, and the data area of each class. Therefore, it is not necessary to perform an address conversion process when the virtual machine is executed, so that the virtual machine can be executed at a higher speed than in the prior art.
また、本発明によれば、上記スタック領域に格納されたオペランドは、そのデータ型とその値の形式で表すので、データ型の組み合わせによる命令コードの増大をおさえ、コンパクトな仕様を有する仮想マシンを実現することができる。 Further, according to the present invention, since the operand stored in the stack area is expressed in the form of its data type and its value, a virtual machine having a compact specification can be suppressed without increasing the instruction code due to the combination of the data types. Can be realized.
1000…仮想マシン実行装置、
1100…中央処理装置、
1200…二次記憶装置、
1201…クラス中間コード、
1300…主記憶装置、
1400…仮想マシンエンジン、
1410…処理ルーチン群、
1410a…オペコードa実行モジュール、
1410b…オペコードb実行モジュール、
1410c…オペコードc実行モジュール、
1420…オペランド、
1500,1500A,1500B…クラス、
1510…メソッドメンバー、
1520…フィールドメンバー、
1530…メソッド、
1600…ランタイム、
1610…メソッドフレーム、
1620…ローカル変数領域、
1630…スタック領域、
1700…バス、
1710…通信インターフェース回路、
1800…ネットワーク、
1900…サーバ装置。
1000 ... virtual machine execution device,
1100: Central processing unit,
1200 ... secondary storage device,
1201 ... Class intermediate code,
1300 ... main memory,
1400: Virtual machine engine,
1410 ... Processing routine group,
1410a ... Opcode a execution module,
1410b ... Opcode b execution module,
1410c ... Opcode c execution module,
1420 ... Operand,
1500, 1500A, 1500B ... class,
1510 ... Method member,
1520 ... Field members,
1530 ... Method,
1600 ... runtime,
1610 ... Method frame,
1620 ... Local variable area,
1630 ... Stack area,
1700 ... Bus
1710: Communication interface circuit,
1800 ... network,
1900: Server device.
Claims (6)
中間コードを主記憶装置にロードされた少なくとも1つのクラスを有するクラス配列と、実行時の情報を格納する少なくとも1つのランタイムを有するランタイム配列とを含む仮想マシンエンジンを備え、
上記クラスは、オペコードを含む処理手順情報を記述した少なくとも1つのメソッドを有するメソッドメンバーと、数値データ又は文字列データもしくは他のクラスへの少なくとも1つの参照情報を有するフィールドメンバーとを備え、
上記中間コードを主記憶装置にロードしたときに、上記メソッドに含まれるオペコードのアドレスを上記主記憶装置のアドレスで表しかつ上記各クラスのデータ領域に格納したことを特徴とする仮想マシン実行装置。 In a virtual machine execution device that loads and executes an intermediate code from a secondary storage device to a main storage device,
A virtual machine engine comprising a class array having at least one class loaded with intermediate code in main memory and a runtime array having at least one runtime for storing runtime information;
The class includes a method member having at least one method describing processing procedure information including an operation code, and a field member having at least one reference information to numeric data or character string data or another class,
A virtual machine execution device characterized in that when the intermediate code is loaded into a main storage device, an address of an operation code included in the method is represented by the address of the main storage device and stored in the data area of each class.
上記スタック領域にデータ型とその値の形式で表されたオペランドが格納されることを特徴とする請求項1記載の仮想マシン実行装置。 The runtime can secure an address to the execution method and a local variable area for storing variables that are generated and used only within the method, and has a stack area for temporarily storing calculation results during processing. ,
2. The virtual machine execution device according to claim 1, wherein operands expressed in a data type and a value format are stored in the stack area.
中間コードを主記憶装置にロードされた少なくとも1つのクラスを有するクラス配列と、実行時の情報を格納する少なくとも1つのランタイムを有するランタイム配列とを含む仮想マシンエンジンを備え、
上記クラスは、オペコードを含む処理手順情報を記述した少なくとも1つのメソッドを有するメソッドメンバーと、数値データ又は文字列データもしくは他のクラスへの少なくとも1つの参照情報を有するフィールドメンバーとを備え、
上記ランタイムは、実行メソッドへのアドレス及びメソッド内だけで生成され使用される変数を格納するローカル変数領域を確保することが可能であり、処理途中の計算結果を一時的に格納するスタック領域を備え、
上記スタック領域にデータ型とその値の形式で表されたオペランドが格納されることを特徴とする仮想マシン実行装置。 In a virtual machine execution device that loads and executes an intermediate code from a secondary storage device to a main storage device,
A virtual machine engine comprising a class array having at least one class loaded with intermediate code in main memory and a runtime array having at least one runtime for storing runtime information;
The class includes a method member having at least one method describing processing procedure information including an operation code, and a field member having at least one reference information to numeric data or character string data or another class,
The runtime can secure an address to the execution method and a local variable area for storing variables that are generated and used only within the method, and has a stack area for temporarily storing calculation results during processing. ,
A virtual machine execution device, wherein an operand expressed in a data type and a value format is stored in the stack area.
中間コードを主記憶装置にロードされた少なくとも1つのクラスを有するクラス配列と、実行時の情報を格納する少なくとも1つのランタイムを有するランタイム配列とを含む仮想マシンエンジンを備え、
上記クラスは、オペコードを含む処理手順情報を記述した少なくとも1つのメソッドを有するメソッドメンバーと、数値データ又は文字列データもしくは他のクラスへの少なくとも1つの参照情報を有するフィールドメンバーとを備え、
上記中間コードを主記憶装置にロードしたときに、上記メソッドに含まれるオペコードのアドレスを上記主記憶装置のアドレスで表しかつ上記各クラスのデータ領域に格納するステップを含むことを特徴とする仮想マシン実行方法。 In a virtual machine execution method for loading and executing an intermediate code from a secondary storage device to a main storage device,
A virtual machine engine comprising a class array having at least one class loaded with intermediate code in main memory and a runtime array having at least one runtime for storing runtime information;
The class includes a method member having at least one method describing processing procedure information including an operation code, and a field member having at least one reference information to numeric data or character string data or another class,
A virtual machine including a step of storing an address of an operation code included in the method by an address of the main storage device and storing it in the data area of each class when the intermediate code is loaded into the main storage device Execution method.
上記スタック領域にデータ型とその値の形式で表されたオペランドが格納されることを特徴とする請求項4記載の仮想マシン実行方法。 The runtime can secure an address to the execution method and a local variable area for storing variables that are generated and used only within the method, and has a stack area for temporarily storing calculation results during processing. ,
5. The virtual machine execution method according to claim 4, wherein operands expressed in a data type and a value format are stored in the stack area.
中間コードを主記憶装置にロードされた少なくとも1つのクラスを有するクラス配列と、実行時の情報を格納する少なくとも1つのランタイムを有するランタイム配列とを含む仮想マシンエンジンを備え、
上記クラスは、オペコードを含む処理手順情報を記述した少なくとも1つのメソッドを有するメソッドメンバーと、数値データ又は文字列データもしくは他のクラスへの少なくとも1つの参照情報を有するフィールドメンバーとを備え、
上記ランタイムは、実行メソッドへのアドレス及びメソッド内だけで生成され使用される変数を格納するローカル変数領域を確保することが可能であり、処理途中の計算結果を一時的に格納するスタック領域を備え、
上記スタック領域にデータ型とその値の形式で表されたオペランドが格納されることを特徴とする仮想マシン実行方法。
In a virtual machine execution method for loading and executing an intermediate code from a secondary storage device to a main storage device,
A virtual machine engine comprising a class array having at least one class loaded with intermediate code in main memory and a runtime array having at least one runtime for storing runtime information;
The class includes a method member having at least one method describing processing procedure information including an operation code, and a field member having at least one reference information to numeric data or character string data or another class,
The runtime can secure an address to the execution method and a local variable area for storing variables that are generated and used only within the method, and has a stack area for temporarily storing calculation results during processing. ,
A virtual machine execution method characterized in that an operand represented by a data type and a value format is stored in the stack area.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2005005322A JP2006195644A (en) | 2005-01-12 | 2005-01-12 | Device and method for executing virtual machine |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2005005322A JP2006195644A (en) | 2005-01-12 | 2005-01-12 | Device and method for executing virtual machine |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2006195644A true JP2006195644A (en) | 2006-07-27 |
Family
ID=36801699
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2005005322A Withdrawn JP2006195644A (en) | 2005-01-12 | 2005-01-12 | Device and method for executing virtual machine |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2006195644A (en) |
-
2005
- 2005-01-12 JP JP2005005322A patent/JP2006195644A/en not_active Withdrawn
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6324686B1 (en) | Just in time compiler technique | |
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 | |
JP2002508560A (en) | Combining multiple class files into a runtime image | |
JP3606561B2 (en) | Method, system, program, and data structure for converting first bit architecture instructions to second bit architecture instructions | |
JP2001034483A (en) | Numbering operational code for encoding metadata | |
KR101407629B1 (en) | Apparatus and method for accelerating java translation | |
US8407678B2 (en) | Method of array interception using data-flow analysis | |
FR3011354A1 (en) | METHOD FOR EXECUTING A MICROPROCESSOR OF A POLYMORPHIC BINARY CODE OF A PREDETERMINED FUNCTION | |
JP5496792B2 (en) | Code conversion program, method and system | |
Perez et al. | A hybrid just-in-time compiler for android: comparing jit types and the result of cooperation | |
KR100771057B1 (en) | Device and method for transforming WIPI into intermediate language | |
US20080104372A1 (en) | Method, apparatus and computer program for executing a program | |
US7207036B2 (en) | Preprocessing of interfaces to allow fast call through | |
JP2002229778A (en) | Pc relative branching method with high-speed displacement | |
Courbot et al. | Efficient off-board deployment and customization of virtual machine-based embedded systems | |
JP7295469B2 (en) | Function generation program, function generation method, and information processing device | |
JP2006195644A (en) | Device and method for executing virtual machine | |
Parsons et al. | The java story | |
JP2000122876A (en) | Information processor | |
US7314491B2 (en) | Encapsulation of large native operating system functions as enhancements of the instruction set in an emulated central processor system | |
JP3727039B2 (en) | Multiplication method in compiler | |
WO2024029174A1 (en) | Processor for controlling pipeline processing based on jump instruction, and program storage medium | |
Davis et al. | Portable parallelized blowfish via RenderScript | |
Di Cataldo et al. | Executables and Libraries |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Effective date: 20070928 Free format text: JAPANESE INTERMEDIATE CODE: A621 |
|
A761 | Written withdrawal of application |
Free format text: JAPANESE INTERMEDIATE CODE: A761 Effective date: 20081226 |