JP2004280766A - Intermediate code execution system - Google Patents
Intermediate code execution system Download PDFInfo
- Publication number
- JP2004280766A JP2004280766A JP2003115033A JP2003115033A JP2004280766A JP 2004280766 A JP2004280766 A JP 2004280766A JP 2003115033 A JP2003115033 A JP 2003115033A JP 2003115033 A JP2003115033 A JP 2003115033A JP 2004280766 A JP2004280766 A JP 2004280766A
- Authority
- JP
- Japan
- Prior art keywords
- intermediate code
- accelerator
- execution system
- instruction
- program
- 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
- 238000000034 method Methods 0.000 claims description 49
- 238000010586 diagram Methods 0.000 abstract description 4
- 230000006870 function Effects 0.000 description 22
- 238000012545 processing Methods 0.000 description 11
- XUIMIQQOPSSXEZ-UHFFFAOYSA-N Silicon Chemical compound [Si] XUIMIQQOPSSXEZ-UHFFFAOYSA-N 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 229910052710 silicon Inorganic materials 0.000 description 1
- 239000010703 silicon Substances 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Images
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
【課題】アクセラレータを有するハードウェア構成において、中間コード実行時に極めて優れたパフォーマンスを達成することができる中間コード実行システムを提供すること。
【解決手段】中間コード実行システム1は、プロセッサ10と、メインメモリ12と、メインメモリ12よりも高速な内蔵メモリ15と、中間コードの実行を高速化するコプロセッサ16とを備え、コプロセッサ16を利用することができない命令を内蔵メモリ15に格納されたコアモジュール21およびサブモジュール21bを利用して実行する。
【選択図】 図1An intermediate code execution system capable of achieving extremely excellent performance when executing intermediate code in a hardware configuration having an accelerator.
An intermediate code execution system includes a processor, a main memory, a built-in memory that is faster than the main memory, and a coprocessor that speeds up execution of the intermediate code. Are executed using the core module 21 and the sub-module 21b stored in the internal memory 15.
[Selection diagram] Fig. 1
Description
【0001】
【発明の属する技術分野】
本発明は、ネィティブコードよりも抽象度の高い中間コード形式のプログラムを実行する中間コード実行システムに関する。より詳細には、Java(登録商標)クラスファイルを実行する中間コード実行システムに関する。
【0002】
【従来の技術】
ハードウェアやOSといった、コンピュータのプラットフォームに依存しないプログラムを提供することを目的として、各プラットフォーム上にソフトウェア的な手法またはハードウェア的な手法により仮想機械(VM;Virtual Machine)を構築し、この仮想機械上でネイティブコードよりも抽象度の高い中間コード形式のプログラムを実行する方法が提案されている。このような方法を採用したプログラム言語の一つとして、クラスファイルと呼ばれる中間コード形式を採用したJava(登録商標)を挙げることができる。なお、以下ではハードウェアと当該ハードウェア上に構築された仮想機械とを一体的に、中間コード実行システムと呼称する場合がある。
【0003】
上記の方法によれば、単一のプログラムコードを種々のプラットフォームに供給して実行させることが可能となるため、オブジェクトコードをプラットフォームの数だけ準備する必要がなくなる。これにより、プログラムの配信を簡潔化することができるばかりでなく、ソフトウェア開発を効率化することも可能である。このため、種々のコンピュータのプラットフォームにおいて仮想機械を構築することが行われている。さらに、近時ではプロセッサを搭載した種々の電子機器(以下、組込み機器という)においても、プロセッサ上に仮想計算機を構築することが行われはじめている。
【0004】
ここで、仮想計算機としては、プラットフォーム上にソフトウェア的に構築され、クラスファイルに含まれるバイトコード命令を逐次的に解釈して実行するインタープリター方式のものが知られている。
【0005】
しかしながら、インタープリター方式の仮想計算機は、クラスファイルから一つ一つバイトコード命令を取り出してはその内容を解釈するというプロセスが必要であり、このプロセスがシステムのオーバーヘッドとなる場合がある。このようなオーバーヘッドを軽減してパフォーマンスを向上するために、クラスファイルを各ハードウェアに固有のネイティブコードにコンパイルしてから実行するJITコンパイラ(Just In Time Compiler)方式や、AOTコンパイラ(Ahead Of Time Compiler)方式等が提案されている。さらに、バイトコード命令を直接実行することができるように特別に設計されたJava(登録商標)チップのように、仮想計算機をハードウェア的に構築することも試みられている。
【0006】
上記のJITやAOT等のコンパイラ方式ではプロセッサのネイティブコードを実行することになるので、命令実行の速度だけを見ればインタープリター方式よりも高いパフォーマンスを得ることができる。しかしながら、コンパイラ方式では、コンパイルの作業自体に必要なワークメモリや、クラスファイルに比べてサイズが4〜10倍と大きいネイティブコードを保存する領域も必要となるため、インタープリター方式よりも大量のメモリが必要となるという問題があり、特に通常のコンピュータよりもハードウェア資源の制約が厳しい組み込み機器において適用することは容易ではない。さらに、クラスファイルの実行を指示してからコンパイルを開始する場合には、コンパイルの作業がオーバーヘッドとなって十分なパフォーマンスが得られないおそれもある。
【0007】
また、上記のJava(登録商標)チップによれば、コンパイルすることもなく高いパフォーマンスでクラスファイルを実行することが可能であるが、Java(登録商標)で規定されるスタックマシンを完全にハードウェアで実現することは技術的に難しく、実現したとしても高コスト化を免れることはできない。また、Java(登録商標)チップを採用した場合には、他プログラミング言語でのソフトウェア開発は原則的に不可能となり、過去のプログラム資産を利用することができないという問題もある。
【0008】
このようなコンパイル方式やJava(登録商標)チップを組み込み機器における問題を回避しつつクラスファイル実行時のパフォーマンスを向上するために、クラスファイルの実行をハードウェア的に補助するハードウェア・アクセラレータ(以下、アクセラレータという)技術が提案されている。このようなアクセラレータとしては、クラスファイルに含まれるバイトコード命令の実行を高速化するために、クラスファイルに含まれるバイトコード命令の実行をプロセッサとは独立して行うものと、バイトコード命令をプロセッサのネィティブコードやマイクロコードに変換してプロセッサに引き渡す機能を有するものとを挙げることができる。これらは通常のプロセッサに併設されるコプロセッサや、通常のプロセッサアーキテクチャに追加されるハードウェアアーキテクチャとして実装される。
【0009】
しかし、アクセラレータで全てのバイトコード命令に対応するとゲート数が増えてコスト高となる等の不具合があるため、アクセラレータを利用して高速化することができるのは全バイトコード命令ではなく、一部のバイトコード命令についてはソフトウェア的な手法により実行しなければならないことが通常である。特に、メソッド呼び出しのように粒度が大きいバイトコード命令はアクセラレータで対応しないことが多い。このため、殆どのバイトコード命令がアクセラレータにより高速化されるにも関わらず、アクセラレータの対応していない一部のバイトコード命令が要因となって、クラスファイル実行時に所望のパフォーマンスが得られないことがある。
【0010】
【特許文献】
特開2002−163116
米国特許第6,332,215号
米国特許第6,338,160号
【0011】
【発明が解決しようとする課題】
本発明は、上述したアクセラレータの技術的な特徴を鑑みてなされたものであって、アクセラレータを有するハードウェア構成において、中間コード実行時に極めて優れたパフォーマンスを達成することができる中間コード実行システムを提供することを目的とする。
【0012】
【課題を解決するための手段】
上記課題を解決するために、本発明は、ネィティブコードよりも抽象度の高い中間コード形式のプログラムを実行する中間コード実行システムにおいて、
プロセッサと、前記プロセッサに接続されたメインメモリおよび前記メインメモリよりも高速な補助メモリと、中間コード形式のプログラムに含まれる命令の一部について実行を高速化するアクセラレータとを備え、
中間コード形式のプログラムに含まれる命令のうち、アクセラレータを利用することができない命令を実行するためのプログラムコードが前記補助メモリに格納されており、
中間コード形式のプログラムを実行するにあたり、アクセラレータを利用することができる命令はアクセラレータを利用して実行し、アクセラレータを利用することができない命令は前記プログラムコードを利用してソフトウェア的に実行することを特徴とする中間コード実行システムを提供する。
【0013】
上記構成によれば、アクセラレータを利用することができない命令を高速な補助メモリに格納されたプログラムコードを利用してソフトウェア的に実行するので、アクセラレータを利用することができない命令をより高速に実行することができ、これによりアクセラレータを備えた中間コード実行システムのパフォーマンスを向上することができる。
【0014】
本発明において、前記アクセラレータは、例えば、前記プロセッサと一体的に構成されているか、または、前記プロセッサに接続されたコプロセッサとする形態が可能であり、中間コード形式のプログラムをプロセッサとは独立して実行するものや、中間コード形式に含まれる一部の命令を前記プロセッサのネィティブコードないしマイクロコードに変換するものを用いることができる。
【0015】
また、前記中間コード形式のプログラムをJava(登録商標)クラスファイルとした場合には、少なくともメソッドを呼び出す命令は前記補助メモリに格納されたプログラムコードを利用して実行されることが好適である。このようにすることで、アクセラレータの利用が難しく、パフォーマンス低下の要因となりやすいメソッド呼び出し命令を高速化することができ、より優れたパフォーマンスの中間コード実行システムを提供することが可能となる。
【0016】
さらに、補助メモリに格納されるプログラムコードは、アクセラレータを利用することができない命令の実行にあたり、実行する命令に対応したソフトウェアモジュールを呼び出す機能を有するものとすることができる。
【0017】
上記の場合には、さらにまた、メソッドを呼び出す命令を実行する際に呼び出されるソフトウェアモジュールが前記補助メモリに格納されていることが好ましい。このようにすることで、アクセラレータで対応することが困難なメソッドを呼び出す命令を高速化することができる。このようなソフトウェアモジュールを、頻繁に呼び出されるメソッドの形式に応じて最適化すればさらに好ましい。例えば、一般には、バイトコード命令からなり、かつ、スタックフレームを追加する必要のないメソッドを呼び出す場合に最適化した構成とすることができる。
【0018】
【発明の実施の形態】
以下、本発明の実施の形態について、図面を参照しながら説明する。
図1は、本実施形態にかかる中間コード実行システムの概略図である。
この中間コード実行システム1は、Java(登録商標)クラスファイルを実行可能に構成されたものであり、その主なハードウェア構成は、CPU10と、このCPU10に外部バス11(External Bus)を介して接続されたメインメモリ12とを具備している。また、図示しないが、LCDや音声出力装置、キー入力装置等の入出力装置、カードリーダライタ等の補助記憶装置、所定の通信網に接続するためのネットワークインターフェイスをさらに具備してもよいし、この中間コード実行システム1を組み込み機器上に構成する場合には各機器に固有のハードウェアがさらに接続されていても構わない。
【0019】
CPU10は、CPU10の制御機能および演算機能を実装したプロセッサコア13と、このプロセッサコア13に内部バス14(Internal Bus)を介して接続された内蔵メモリ15(補助メモリ)とを有し、Java(登録商標)アクセラレータとしての機能を有するコプロセッサ16とメインメモリ12が接続されている。メインメモリ12はCPU10と外部バス17(external bus)を介して接続されており、ワークエリアとして使用される揮発性領域をなすRAM(例えばSRAM、DRAM、SDRAM等)と、プログラムが格納される不揮発性領域をなすROM(例えばFlashROM等)とからなっている(不図示)。また、内蔵メモリ15は揮発性のRAM(例えばSRAM等)からなっている。ここで、CPU10内に設けられた内部バス12は外部バス17よりもバス幅が広く、このためCPU10において内蔵メモリ15はメインメモリ12よりも高速にアクセスして読み書きすることが可能となっている。しかし、内蔵メモリ15はCPU10内に構成されている関係上、メインメモリ12よりもコストが高く、その容量は制限されたものとなっている。
【0020】
コプロセッサ16は、メインメモリ12とプロセッサコア13との間に設けられており、中間コード実行システム1におけるJava(登録商標)クラスファイルの実行を高速化する機能を有している。例えば、コプロセッサ16は、中間コード実行システム1がメインメモリ12からバイトコード命令をフェッチして実行するにあたり、メインメモリ12からフェッチされたバイトコード命令をCPU10固有のネィティブコード(マシン語)ないしマイクロコードに変換してCPU10に引き渡す処理を行う構成とすることができる。この場合、CPU10はプロセッサコア13にて直接実行することができるネィティブコードやマイクロコードを実行すればよいので、極めて高速にバイトコード命令を実行することが可能となる。本実施形態では、コプロセッサ16が、このようにバイトコード命令をCPU10のマイクロコードに変換する場合について説明する。
【0021】
ただし、ゲート数増大による高シリコンコストを回避するため、コプロセッサ16のアクセラレータ機能は全てのバイトコード命令に対応してはおらず、一部のバイトコード命令は、後述するコアモジュール21がサブモジュール22a,22bから所定のコードを呼び出すことにより実行される。本実施形態では、コプロセッサ16のアクセラレータ機能が、粒度の大きいinvokevirtual,invokespecial,invokestatic,invokeintefaceといったメソッド呼び出し命令を含むいくつかのバイトコード命令に対応していない場合について示す。
【0022】
次に、中間コード実行システム1のソフトウェア構成について説明する。中間コード実行システム1は、内蔵メモリ15に格納されたコアモジュール21と、このコアモジュール21から呼び出されるサブモジュール22a,22bとを有している。このうちサブモジュール22aは内蔵メモリ15に格納されており、サブモジュール22bはメインメモリ12に格納されている。コアモジュール21は、中間コード実行システム1でJava(登録商標)クラスファイルを実行中にコプロセッサ16の対応していないバイトコード命令が出現し、制御がコプロセッサ16からCPU10に移動した場合に実行され、サブモジュール22a,22bから出現したバイトコード命令に対応した処理を行うコードを選択して呼び出す機能を有している。
【0023】
コアモジュール21およびサブモジュール22a,22bは、いずれも独立したプログラムコードとしての体裁を取る必要はなく、CPU10で実行することにより上述の内容を含む種々の機能を奏するコードの集合であればよい。このような集合は、例えば、関数、手続き、サブルーチン等の概念を含んだ機能単位をなすコードの集合として解釈されることが相当である。
【0024】
サブモジュール22a,22bのうち、サブモジュール22aはinvokevirtual,invokespecial,invokestatic,invokeintefaceといったメソッドを呼び出すバイトコード命令を実行する際に、コアモジュール21から呼び出されるものである。本実施形態では、コアモジュール21に加えて、このサブモジュール22aを内蔵メモリ15に格納しているので、コプロセッサ16が対応していない、メソッド呼び出しに関するバイトコード命令の実行を、内蔵メモリ15に格納されたコードを利用して高速に行うことができる。
【0025】
このようにメソッド呼び出しを実行するためのサブモジュール22aだけを内蔵メモリ15に格納し、サブモジュール22bをメインメモリ12に格納するのは、容量の限られた内蔵メモリ15を有効に活用して、中間コード実行システム1のパフォーマンスに大きな影響を与えるメソッド呼び出しを効率的に高速化するためである。ただし、内蔵メモリ15の容量に余裕がある場合には、サブモジュール22aとサブモジュール22bとの双方を内蔵メモリ15に格納しても構わない。
【0026】
また、図示しないが、中間コード実行システム1はこれらの他に、クラスファイルをヒープに展開するクラスローダ、展開されたクラスファイルの検証を行うベリファイヤ、メインメモリ12に配置されたオブジェクトにガベージコレクションを施すガベージコレクタを含むヒープ管理モジュール、処理の流れをコントロールするスレッド管理モジュール、クラスファイル実行時に必要に応じて参照されるクラスライブラリ、JARファイルリーダ等をメインメモリに有している。これらについては、通常のソフトウェアJava(登録商標)VMにおける対応したモジュールを利用してもよい。
【0027】
本発明はこれらの他にソフトウェアが存在することを妨げるものではなく、オペレーティングシステム(OS)、種々のアプリケーション、サービスプログラム、プロトコルスタック、デバイスドライバ等を含んだソフトウェア構成であって構わない。また、中間コード実行システム1を組み込み機器上に構成する場合には、各機器に固有の機能を実現するためのソフトウェアを有することもできる。
【0028】
次に、以上のような構成の中間コード実行システム1において、メインメモリ12に格納されたクラスファイル103を実行する動作の概要について、図2を参照しながら説明する。クラスファイル103は、例えばクラスローダにより不図示のJARファイルから取り出されたものでもよいし、中間コード実行システム1外からロードされたもの等であっても構わない。また、以下の動作に先だっては、クラスファイル103が妥当なものであるかの検証と、staticフィールドの生成およびコンスタントプールの決定を含むリンクと、クラスの初期化とが行われているものとする。
【0029】
中間コード実行システム1におけるクラスファイル103の実行にあたっては、まず、中間コード実行システム1の初期化が行われる(STEP101)。これによりコプロセッサ16はクラスファイル103からバイトコード命令をフェッチしてマイクロコードに変換する処理が可能な状態となり、コプロセッサ16の制御により以降の動作が行われる。また、コアモジュール21およびサブモジュール22aは、このSTEP101において内蔵メモリに配置するようにしてもよいが、これに先だって配置するようにしても構わない。
【0030】
次に、コプロセッサ16がクラスファイル103からバイトコード命令をフェッチし(STEP102)、フェッチされたバイトコード命令にコプロセッサ16のアクセラレータ機能が対応しているかを判断する(STEP103)。ここでアクセラレータ機能の対応したバイトコード命令であると判断された場合には、バイトコード命令がCPU10の対応するマイクロコードに変換され(STEP104)、当該マイクロコードがCPU10のプロセッサコアに渡されて実行される(STEP105)。なお、STEP103とSTEP104とは厳密に区別されている必要はなく、コプロセッサ16によりフェッチされたバイトコード命令の変換を試行して、変換できる場合にはそのまま変換し、変換できない場合には変換できないという結果やフラグを出力して下記STEP108以降の処理に移るようにしてもよい。
【0031】
STEP103において、アクセラレータ機能の対応したバイトコード命令ではないと判断された場合には、制御がコプロセッサ16からCPU10に移動し、CPU10上で各々のコードを実行することににより以降の動作が行われる。まず、CPU10上でコアモジュール21が実行され、サブモジュール22a,22bからフェッチされたバイトコード命令に対応した処理を行うコードが呼び出される(STEP108)。ここで、コアモジュール21は高速な内蔵メモリ15に格納されているので、CPU10はSTEP108の処理を高速に行うことができる。
【0032】
次に、STEP108で呼び出されたコードがCPU10により実行され(STEP109)、これによりフェッチされたバイトコード命令に応じた処理が行われる。ここで、フェッチされたバイトコード命令がメソッドを呼び出す命令であった場合には、これらの命令に対応したサブモジュール22aは高速な内蔵メモリ15に格納されているので、CPU10はSTEP109の処理を高速に行うことができる。
【0033】
バイトコード命令の実行が終わった後は、いずれの場合も実行されたバイトコード命令が最後のものであったかが判断され(STEP106)、最後であると判断された場合にはクラスファイル103の実行は終了し、最後であると判断されなかった場合には対象を次のバイトコード命令に移動して(STEP107)、STEP102以降の処理を繰り返す。中間コード実行システム1は、以上のような概略で示される動作により、クラスファイル103を実行する。
【0034】
このような動作によれば、コプロセッサ16のアクセラレータ機能が対応したバイトコード命令を高速に実行することができるばかりでなく、コプロセッサ16のアクセラレータ機能が対応していないバイトコード命令を実行するためのSTEP108がCPU10により高速で実行され、さらに、メソッド呼び出し命令の場合にはSTEP109も同様に高速で実行されるので、コプロセッサ16のアクセラレータ機能が対応していないバイトコード命令(特にメソッド呼び出し命令)の実行速度を向上することができる。これにより本実施形態の中間コード実行システム1では、アクセラレータを有するハードウェア構成において、容量の限られた高速な内蔵メモリ15を有効に活用して、極めて優れたパフォーマンスを達成するこができる。
【0035】
以上のような構成の本実施形態においては、頻繁に呼び出される形式のメソッド呼び出しに応じてサブモジュール21aを最適化することによって、メソッド呼び出しの平均的な実行速度をさらに向上することができる。本発明者らが種々のクラスファイルを調査したところ、一般的に、呼び出される頻度が高いメソッドは、ネィティブメソッドではなくJava(登録商標)のメソッドであって、スタックフレームを追加しなくてもよいものであることが判明した。したがって、サブモジュール22a内に、そのようなメソッドを呼び出す場合の処理をインライン展開して条件分岐や関数呼び出しを行うことなく実行できる最適化コードを準備し、サブモジュール22aが呼び出された際に頻出パターンに該当するか否かを判断し、頻出パターンのメソッドであれば最適化コードを利用して実行し、頻出パターンのメソッドでなければ所定の条件分岐や関数呼び出しを含む通常の処理で実行するように、サブモジュール22aを構成することにより、中間コード実行システム1のパフォーマンスをさらに向上することが可能である。また、別パターンのメソッドが高頻度で呼び出される場合には、当該別パターンのメソッドを呼び出す処理をインライン展開したコードを準備し、同様にサブモジュール22aを構成すればよい。
【0036】
以上、本発明の実施形態に係る中間コード実行システムについて説明したが、本発明はこれに限定されることなく、その趣旨を逸脱しない範囲で種々の改良・変更が可能である。例えば、上記の実施形態では、補助メモリとして内蔵メモリ15を使用した場合を示したが、キャッシュメモリを補助メモリとしても構わないし、メインメモリをDRAMとして補助メモリをSRAMとする等の構成も可能である。
【0037】
また、本実施形態では、アクセラレータ機能を有するコプロセッサ16を使用した場合を示したが、プロセッサコアと一体的に構成されたアクセラレータを使用した場合にも上記実施形態と略同様に本発明を適用することによって、極めて高いパフォーマンスの中間コード実行システムを得ることができる。
【0038】
さらに、Java(登録商標)クラスファイルを実行する中間コード実行システムを構成する場合には、Java(登録商標)仮想マシン仕様(原題”TheJava(登録商標,原題ではTM) Virtual Machine Specification”)に基づいてハードウェアおよび/またはソフトウェアを設計すればよく、クラスファイルを実行可能なこと以外に制限はない。したがって、仕様と本発明の趣旨とを逸脱しない範囲において、自由に設計を行うことが可能である。さらにまた、本発明はJava(登録商標)クラスファイルを実行する中間コード実行システムに限られるものではない。
【0039】
【発明の効果】
本発明によれば、アクセラレータを利用することができない命令を高速な補助メモリに格納されたプログラムコードを利用してソフトウェア的に実行するので、アクセラレータを利用することができない命令をより高速に実行することができ、これによりアクセラレータを備えた中間コード実行システムのパフォーマンスを向上することができる。
【図面の簡単な説明】
【図1】本実施形態にかかる中間コード実行システムの概略図
【図2】中間コード実行システムでクラスファイルを実行する動作の概略図
【符号の説明】
1 中間コード実行システム
10 CPU
12 メインメモリ
13 プロセッサコア
14 内部バス
15 内蔵メモリ
16 コプロセッサ
17 外部バス
21 コアモジュール
22a,22b サブモジュール
23 クラスファイル[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to an intermediate code execution system that executes an intermediate code format program having a higher degree of abstraction than native code. More specifically, the present invention relates to an intermediate code execution system that executes a Java (registered trademark) class file.
[0002]
[Prior art]
In order to provide a program independent of a computer platform, such as hardware or an OS, a virtual machine (VM) is constructed on each platform by a software method or a hardware method, and this virtual machine is created. A method of executing a program in an intermediate code format having a higher degree of abstraction than a native code on a machine has been proposed. One of the programming languages that employs such a method is Java (registered trademark) that employs an intermediate code format called a class file. Hereinafter, the hardware and the virtual machine constructed on the hardware may be referred to as an intermediate code execution system.
[0003]
According to the above method, a single program code can be supplied to various platforms and executed, so that it is not necessary to prepare object codes for each platform. As a result, not only can the distribution of the program be simplified, but also the efficiency of software development can be increased. For this reason, virtual machines have been constructed on various computer platforms. Further, recently, in various electronic devices (hereinafter, referred to as embedded devices) equipped with a processor, construction of a virtual computer on the processor has begun.
[0004]
Here, as the virtual machine, an interpreter system which is constructed as software on a platform and sequentially interprets and executes bytecode instructions included in a class file is known.
[0005]
However, a virtual machine of the interpreter system needs a process of extracting bytecode instructions one by one from a class file and interpreting the contents thereof, and this process may be a system overhead. In order to reduce such overhead and improve performance, a JIT compiler (Just In Time Compiler) method that compiles a class file into a native code specific to each hardware and then executes it, or an AOT compiler (Ahead Of Time) Compiler) method and the like have been proposed. Further, it has been attempted to construct a virtual machine in hardware, such as a Java (registered trademark) chip specially designed to directly execute a bytecode instruction.
[0006]
In the above-mentioned compiler system such as JIT or AOT, the native code of the processor is executed. Therefore, if only the speed of instruction execution is considered, higher performance can be obtained than in the interpreter system. However, the compiler method requires a work memory required for the compilation operation itself and an area for storing native code whose size is 4 to 10 times larger than the class file, and therefore requires a larger amount of memory than the interpreter method. It is not easy to apply the method to an embedded device in which hardware resources are more restricted than a normal computer. Furthermore, when starting the compilation after instructing the execution of the class file, there is a possibility that a sufficient performance may not be obtained due to the overhead of the compilation work.
[0007]
Further, according to the above-mentioned Java (registered trademark) chip, it is possible to execute a class file with high performance without compiling, but the stack machine specified by Java (registered trademark) is completely implemented by hardware. It is technically difficult to realize this, and even if it is realized, it cannot be avoided from increasing costs. In addition, when a Java (registered trademark) chip is adopted, software development in another programming language becomes impossible in principle, and there is a problem that past program assets cannot be used.
[0008]
In order to improve the performance at the time of executing a class file while avoiding problems in a device incorporating such a compile method or a Java (registered trademark) chip, a hardware accelerator (hereinafter referred to as a hardware accelerator) which assists in executing a class file in terms of hardware. , An accelerator). In order to speed up the execution of bytecode instructions included in a class file, such an accelerator performs execution of bytecode instructions included in a class file independently of a processor. And a function having a function of converting the code into a native code or a microcode and delivering the converted code to a processor. These are implemented as a coprocessor attached to a normal processor or a hardware architecture added to a normal processor architecture.
[0009]
However, if the accelerator supports all bytecode instructions, the number of gates will increase and the cost will increase.Therefore, it is not all bytecode instructions that can be accelerated using accelerators. Is usually required to be executed by a software method. In particular, a bytecode instruction having a large granularity such as a method call is often not supported by the accelerator. For this reason, despite the fact that most bytecode instructions are accelerated by the accelerator, some bytecode instructions that are not supported by the accelerator may cause the desired performance when executing the class file. There is.
[0010]
[Patent Document]
JP-A-2002-163116
US Pat. No. 6,332,215 US Pat. No. 6,338,160
[Problems to be solved by the invention]
The present invention has been made in view of the technical characteristics of the accelerator described above, and provides an intermediate code execution system that can achieve extremely excellent performance when executing intermediate code in a hardware configuration having an accelerator. The purpose is to do.
[0012]
[Means for Solving the Problems]
In order to solve the above problems, the present invention provides an intermediate code execution system that executes a program in an intermediate code format having a higher degree of abstraction than native code.
A processor, a main memory connected to the processor and an auxiliary memory faster than the main memory, and an accelerator for accelerating execution of a part of instructions included in a program in an intermediate code format,
Among the instructions included in the program in the intermediate code format, a program code for executing an instruction that cannot use the accelerator is stored in the auxiliary memory,
When executing a program in the intermediate code format, instructions that can use an accelerator are executed using an accelerator, and instructions that cannot use an accelerator are executed as software using the program code. An intermediate code execution system is provided.
[0013]
According to the above configuration, since the instruction that cannot use the accelerator is executed in software using the program code stored in the high-speed auxiliary memory, the instruction that cannot use the accelerator is executed at higher speed. This can improve the performance of an intermediate code execution system having an accelerator.
[0014]
In the present invention, for example, the accelerator may be configured integrally with the processor, or may be configured as a coprocessor connected to the processor, and may execute a program in an intermediate code format independently of the processor. And a program that converts some instructions included in the intermediate code format into native code or microcode of the processor.
[0015]
When the program in the intermediate code format is a Java (registered trademark) class file, it is preferable that at least an instruction for calling a method is executed by using a program code stored in the auxiliary memory. By doing so, it is difficult to use an accelerator, and it is possible to speed up a method call instruction which is likely to cause a decrease in performance, and to provide an intermediate code execution system with higher performance.
[0016]
Further, the program code stored in the auxiliary memory may have a function of calling a software module corresponding to the instruction to be executed when executing an instruction that cannot use the accelerator.
[0017]
In the above case, it is preferable that a software module called when executing an instruction for calling a method is stored in the auxiliary memory. By doing so, it is possible to speed up the instruction for calling a method that is difficult to handle with the accelerator. More preferably, such software modules are optimized according to the type of frequently called method. For example, in general, an optimized configuration can be used when a method that is composed of bytecode instructions and does not need to add a stack frame is called.
[0018]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
FIG. 1 is a schematic diagram of an intermediate code execution system according to the present embodiment.
The intermediate code execution system 1 is configured to execute a Java (registered trademark) class file. The main hardware configuration of the intermediate code execution system 1 includes a
[0019]
The
[0020]
The
[0021]
However, in order to avoid a high silicon cost due to an increase in the number of gates, the accelerator function of the
[0022]
Next, a software configuration of the intermediate code execution system 1 will be described. The intermediate code execution system 1 has a
[0023]
Each of the
[0024]
Of the sub-modules 22a and 22b, the sub-module 22a is called from the
[0025]
Storing only the sub-module 22a for executing the method call in the built-in
[0026]
Although not shown, the intermediate code execution system 1 also includes a class loader for expanding the class file on the heap, a verifier for verifying the expanded class file, and garbage collection for the object arranged in the
[0027]
The present invention does not prevent the existence of software other than these, and may be a software configuration including an operating system (OS), various applications, service programs, protocol stacks, device drivers, and the like. When the intermediate code execution system 1 is configured on an embedded device, the intermediate code execution system 1 may have software for realizing a function unique to each device.
[0028]
Next, an outline of an operation of executing the class file 103 stored in the
[0029]
In executing the class file 103 in the intermediate code execution system 1, first, the intermediate code execution system 1 is initialized (STEP 101). As a result, the
[0030]
Next, the
[0031]
If it is determined in STEP 103 that the instruction is not a bytecode instruction corresponding to the accelerator function, the control moves from the
[0032]
Next, the code called in STEP 108 is executed by the CPU 10 (STEP 109), and processing corresponding to the fetched bytecode instruction is performed. Here, if the fetched bytecode instruction is an instruction for calling a method, the
[0033]
After the execution of the bytecode instruction is completed, it is determined whether the executed bytecode instruction is the last one (STEP 106). If it is determined that the bytecode instruction is the last one, the execution of the class file 103 is stopped. When the processing is completed and it is not determined that the processing is the last, the target is moved to the next bytecode instruction (STEP107), and the processing of STEP102 and thereafter is repeated. The intermediate code execution system 1 executes the class file 103 by the operation outlined above.
[0034]
According to this operation, not only can the accelerator function of the
[0035]
In the present embodiment having the above-described configuration, the average execution speed of the method call can be further improved by optimizing the submodule 21a according to the method call in a frequently called format. When the present inventors investigated various class files, it was found that, in general, the method that is frequently called is not a native method but a Java (registered trademark) method, and it is not necessary to add a stack frame. Turned out to be something. Therefore, in the sub-module 22a, processing for calling such a method is expanded inline to prepare optimized code that can be executed without performing a conditional branch or a function call, and frequently occurs when the sub-module 22a is called. Judge whether or not it corresponds to the pattern. If it is a method of a frequent pattern, execute it using the optimization code. If it is not a method of a frequent pattern, execute it by normal processing including predetermined conditional branches and function calls. By configuring the
[0036]
The intermediate code execution system according to the embodiment of the present invention has been described above. However, the present invention is not limited to this, and various modifications and changes can be made without departing from the gist of the present invention. For example, in the above-described embodiment, the case where the built-in
[0037]
Further, in the present embodiment, the case where the
[0038]
Furthermore, when configuring an intermediate code execution system that executes a Java (registered trademark) class file, it is based on the Java (registered trademark) virtual machine specification (original title “The Java (registered trademark, original name is TM) Virtual Machine Specification”). Hardware and / or software can be designed, and there is no restriction other than that the class file can be executed. Therefore, it is possible to design freely without departing from the specification and the spirit of the present invention. Furthermore, the present invention is not limited to an intermediate code execution system that executes a Java (registered trademark) class file.
[0039]
【The invention's effect】
According to the present invention, an instruction that cannot use an accelerator is executed as software using a program code stored in a high-speed auxiliary memory, so that an instruction that cannot use an accelerator is executed more quickly. This can improve the performance of an intermediate code execution system having an accelerator.
[Brief description of the drawings]
FIG. 1 is a schematic diagram of an intermediate code execution system according to the present embodiment. FIG. 2 is a schematic diagram of an operation of executing a class file in the intermediate code execution system.
1 Intermediate
12
Claims (8)
プロセッサと、前記プロセッサに接続されたメインメモリおよび前記メインメモリよりも高速な補助メモリと、中間コード形式のプログラムに含まれる命令の一部について実行を高速化するアクセラレータとを備え、
中間コード形式のプログラムに含まれる命令のうち、アクセラレータを利用することができない命令を実行するためのプログラムコードが前記補助メモリに格納されており、
中間コード形式のプログラムを実行するにあたり、アクセラレータを利用することができる命令はアクセラレータを利用して実行し、アクセラレータを利用することができない命令は前記プログラムコードを利用してソフトウェア的に実行することを特徴とする中間コード実行システム。In an intermediate code execution system that executes a program in an intermediate code format having a higher degree of abstraction than native code,
A processor, a main memory connected to the processor and an auxiliary memory faster than the main memory, and an accelerator for accelerating execution of a part of instructions included in a program in an intermediate code format,
Among the instructions included in the program in the intermediate code format, a program code for executing an instruction that cannot use the accelerator is stored in the auxiliary memory,
When executing a program in the intermediate code format, instructions that can use an accelerator are executed using an accelerator, and instructions that cannot use an accelerator are executed as software using the program code. Characterized intermediate code execution system.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2003115033A JP2004280766A (en) | 2003-03-15 | 2003-03-15 | Intermediate code execution system |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2003115033A JP2004280766A (en) | 2003-03-15 | 2003-03-15 | Intermediate code execution system |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JP2004280766A true JP2004280766A (en) | 2004-10-07 |
Family
ID=33296189
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2003115033A Pending JP2004280766A (en) | 2003-03-15 | 2003-03-15 | Intermediate code execution system |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP2004280766A (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2012512449A (en) * | 2008-12-16 | 2012-05-31 | インターナショナル・ビジネス・マシーンズ・コーポレーション | Arithmetic data structure |
| JP2016103252A (en) * | 2014-11-27 | 2016-06-02 | 正仁 櫨田 | Method for accelerating cpu of computer |
-
2003
- 2003-03-15 JP JP2003115033A patent/JP2004280766A/en active Pending
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2012512449A (en) * | 2008-12-16 | 2012-05-31 | インターナショナル・ビジネス・マシーンズ・コーポレーション | Arithmetic data structure |
| JP2016103252A (en) * | 2014-11-27 | 2016-06-02 | 正仁 櫨田 | Method for accelerating cpu of computer |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US9766867B2 (en) | Systems and methods for improving performance of mobile applications | |
| US7543285B2 (en) | Method and system of adaptive dynamic compiler resolution | |
| EP1451682B1 (en) | Platform-independent selective ahead-of-time compilation | |
| US20030084431A1 (en) | Intermediate code execution system, intermediate code execution method, and computer program product for executing intermediate code | |
| US8769511B2 (en) | Dynamic incremental compiler and method | |
| CN111768183B (en) | Method for executing intelligent contract, block chain node and storage medium | |
| JPH11296380A (en) | Method and system for giving dynamic optimizing information in code analyzing run-time environment | |
| US7213237B2 (en) | Intermediate code preprocessing apparatus, intermediate code execution apparatus, intermediate code execution system, and computer program product for preprocessing or executing intermediate code | |
| CN111815310A (en) | A method, blockchain node and storage medium for executing smart contracts | |
| JP2001202253A (en) | Data processing method and data processor | |
| US7003778B2 (en) | Exception handling in java computing environments | |
| WO2001090885A2 (en) | Method and apparatus for creating efficient native methods that extend a bytecode interpreter | |
| US6964033B2 (en) | Object band customization of Java runtime environments | |
| CN111770202A (en) | A method, blockchain node and storage medium for executing smart contracts | |
| US20100095102A1 (en) | Indirect branch processing program and indirect branch processing method | |
| JP2004280766A (en) | Intermediate code execution system | |
| US8341606B2 (en) | Method of invoking inlined method and java virtual machine using the method | |
| US20050246677A1 (en) | Native method invocation (NMI) custom marshalling stub service | |
| CN112214266A (en) | Spoofing call chain Android unpacking method, device, storage medium and computer equipment | |
| CN111966443B (en) | Smart card and working method thereof | |
| Glossner et al. | Sandbridge software tools | |
| US6934946B2 (en) | Lightweight native method invocation interface for java computing environments | |
| JP2005284729A (en) | A virtual machine that compiles bytecode into native code | |
| Brandner et al. | Embedded JIT compilation with CACAO on YARI | |
| JP4234976B2 (en) | Intermediate code execution system |