JP4234976B2 - Intermediate code execution system - Google Patents

Intermediate code execution system Download PDF

Info

Publication number
JP4234976B2
JP4234976B2 JP2002314986A JP2002314986A JP4234976B2 JP 4234976 B2 JP4234976 B2 JP 4234976B2 JP 2002314986 A JP2002314986 A JP 2002314986A JP 2002314986 A JP2002314986 A JP 2002314986A JP 4234976 B2 JP4234976 B2 JP 4234976B2
Authority
JP
Japan
Prior art keywords
intermediate code
instruction
code execution
unit
executed
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.)
Expired - Fee Related
Application number
JP2002314986A
Other languages
Japanese (ja)
Other versions
JP2003202995A (en
Inventor
哲之 小林
Original Assignee
株式会社アプリックス
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 株式会社アプリックス filed Critical 株式会社アプリックス
Priority to JP2002314986A priority Critical patent/JP4234976B2/en
Publication of JP2003202995A publication Critical patent/JP2003202995A/en
Application granted granted Critical
Publication of JP4234976B2 publication Critical patent/JP4234976B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Description

【0001】
【発明の属する技術分野】
本発明は、中間コードを実行する中間コード実行システムに関するものである。
【0002】
【従来の技術】
ハードウェアやOSといった、コンピュータのプラットフォームに依存しないプログラムを提供することを目的として、各プラットフォーム上にソフトウェア的な手法またはハードウェア的な手法により仮想機械(VM; Virtual Machine)を構築し、この仮想機械上でソースコードとオブジェクトコードとの間の中間的なコード(以下、中間コードという)を実行する方法が提案されている。このような方法を採用したプログラム言語の一つとしては、クラスファイルと呼ばれる中間コードの形式を採用したJava(R)が挙げられる。なお、以下ではハードウェアと当該ハードウェア上に構築された仮想機械とを一体的に、中間コード実行システムと呼称する場合がある。
【0003】
上記の方法によれば、単一のプログラムコードを種々のプラットフォームに供給して実行することが可能となるため、個々のプラットフォームでしか実行できないオブジェクトコードを準備する必要がなくなる。これにより、プログラムの配信を簡潔化することができるばかりでなく、ソフトウェア開発を効率化することも可能である。このため、種々のコンピュータのプラットフォームにおいて仮想機械を構築することが行われている。さらに、近時ではプロセッサを搭載した種々の電子機器(以下、組込み機器という)においても、プロセッサ上に仮想計算機を構築することが行われはじめている。
【0004】
ここで、仮想計算機としては、プラットフォーム上にソフトウェア的に構築され、クラスファイルに含まれるバイトコード命令を逐次的に解釈して実行するインタープリター方式のものが知られている。
【0005】
しかしながら、インタープリター方式の仮想計算機は、クラスファイルから一つ一つバイトコード命令を取り出してはその内容を解釈するというプロセスが必要であり、このプロセスがシステムのオーバーヘッドとなる場合がある。このようなオーバーヘッドを軽減してパフォーマンスを向上するために、クラスファイルを各ハードウェアに固有のネイティブコードにコンパイルしてから実行するJITコンパイラ(Just In Time Compiler)方式や、AOTコンパイラ(Ahead Of Time Compiler)方式等が提案されている。さらに、バイトコード命令を直接実行することができるように特別に設計されたJava(R)チップのように、仮想計算機をハードウェア的に構築することも試みられている。
【0006】
上記のJITやAOT等のコンパイラ方式ではプロセッサのネイティブコードを実行することになるので、命令実行の速度だけを見ればインタープリター方式よりも優れている。しかしながら、コンパイラ方式では、コンパイルの作業自体に必要なワークメモリや、クラスファイルに比べてサイズが4〜10倍と大きいネイティブコードを保存する領域も必要となるため、インタープリター方式よりも大量のメモリが必要となるという問題がある。
【0007】
このような問題は、特に通常のコンピュータよりもハードウェア資源の制約が厳しい組み込み機器において顕著となる。また、クラスファイルの実行を指示してからコンパイルを開始する場合には、コンパイルの作業がオーバーヘッドとなって十分なパフォーマンスが得られないという可能性もある。
【0008】
また、上記のJava(R)チップによれば、コンパイルすることもなく高パフォーマンスでクラスファイルを実行することが可能であるが、このような専用チップの開発には高額の開発費を要し、チップ自体の高コスト化を免れることはできない。また、技術の進歩や市場のニーズに応じた言語仕様のバージョンアップや修正が適宜行われることを鑑みると、仮想機械をハードウェア的に構成することは必ずしも好適ではないという一面もある。特に、組み込み機器における仮想機械には、低コスト化に対する強い要請と短サイクルで仕様がバージョンアップされることとが相俟って、Java(R)チップの採用は現実的ではない。
【0009】
以上説明したように、コンパイラ方式やJava(R)チップ等の技術は、コストおよび要求ハードウェア資源等の点で問題があり、特に、これらの制限が厳しい組み込み機器に適用することは難しい。このため、組み込み機器に適用することを視野に入れて、別の方法により仮想機械ないし中間コード実行システムのパフォーマンスを向上することが望まれている。
【0010】
【発明が解決しようとする課題】
本発明は、上記事情に鑑みてなされたものであって、前処理を施すことにより中間コード実行時のパフォーマンスを向上することができる、かかる前処理が組み込まれた中間コード実行システムを提供することを目的とする。
【0011】
【課題を解決するための手段】
上記課題を解決するために、本発明の第1の観点では、所定のプログラム言語で作成されたソースコードをコンパイルして得られた中間コードを実行する中間コード実行システムにおいて、前記中間コードを実行する複数の中間コード実行手段と、前記中間コードを記憶すると共に、当該中間コードに含まれる命令と当該命令の効率的実行に適切な前記中間コード実行手段との対応関係を記憶した記憶手段と、中間コード解析手段とを具備し、前記中間コード解析手段が、a)前記記憶手段に格納された中間コードに含まれる命令を特定する処理と、b)特定された命令と前記対応関係とに基づいて、前記中間コードの効率的実行に適切な中間コード実行手段を特定する処理と、c)前記中間コードと特定された中間コード実行手段との関係を記録する処理とを実行することを特徴とする中間コード 実行システムが提供される。
【0012】
本発明の第の観点によれば、中間コード実行システムに複数の中間コード実行手段を設け、中間コードに含まれる命令とその効率的実行に適切な前記中間コード実行手段との対応関係を記憶手段に記憶しておき、中間コード解析手段により中間コードを解析し、記憶手段に記憶してある対応関係に基づいて、当該中間コードの効率的実行に適切な中間コード実行手段を特定して記録するので、中間コード実行システムは個々の中間コードに対して最適な中間コード実行手段を識別できるようになる。
【0013】
したがって、本発明の第1の観点によれば、実行する中間コードに適した中間コード実行手段を用いて中間コードを実行することが可能となり、これにより複数設けられた中間コード実行手段のそれぞれを活用して、中間コード実行時のパフォーマンスを向上することができる。
【0014】
本発明の第の観点においては、前記記憶手段における命令と当該命令の効率的実行に適切な中間コード実行手段との対応関係は、各命令を前記中間コード実行手段のそれぞれで実行した場合の処理効率度のスコアテーブルを含み、前記b)の処理は、b1)前記スコアテーブルに基づいて、特定された命令を前記中間コード実行手段のそれぞれで実行した場合の処理効率度のスコアを取得する処理と、b2)取得されたスコアを中間コード実行手段ごとに合計する処理と、b3)中間コード実行手段ごとに合計されたスコアに基づいて、前記中間コードの実行に用いる前記中間コード実行手段を特定する処理とを含む構成とすることができる。
【0015】
また、前記記憶手段における命令と当該命令の効率的実行に適切な中間コード実行手段との対応関係は、各命令に割り当てられたポイントの値と、前記中間コード実行手段のそれぞれに対応した前記ポイントの合計値の範囲とを含み、前記b)の処理は、b1)前記対応関係に基づいて、特定された命令のポイントを取得する処理と、b2)取得されたポイントの合計値を求める処理と、b3)前記対応関係および求められた合計値に基づいて、前記中間コードの実行に用いる前記中間コード実行手段を特定する処理とを含む構成としてもよい。
【0016】
本発明の第の観点では、所定のプログラム言語で作成されたソースコードをコンパイルして得られた中間コードを実行する中間コード実行システムにおいて、全ての命令を実行可能な一般中間コード実行手段と、一部の命令のみを実行可能な特殊中間コード実行手段と、中間コードが格納された記憶手段と、中間コード解析手段とを具備し、前記中間コード解析手段が、a)前記記憶手段に格納された中間コードを解析し、前記中間コードに含まれる命令に前記特殊中間コード実行手段が実行不能な命令が含まれないかを判定する処理と、b)前記実行不能な命令が含まれないと判定したときには、前記中間コードを前記特殊中間コード実行手段で実行すべきことを記録し、前記実行不能な命令が含まれると判定したときには、前記中間コードを前記一般中間コード実行手段で実行すべきことを記録する処理とを実行することを特徴とする中間コード実行システムが提供される。
【0017】
本発明の第の観点によれば、全ての命令を実行可能な一般中間コード実行手段と、一部の命令のみを実行可能な特殊中間コード実行手段とを備えた中間コード実行システムにおいて、実行する中間コードに特殊中間コード実行手段で実行可能な命令が含まれているか否かに応じて、一般中間コード実行手段と特殊中間コード実行手段とのいずれで実行すべきかが記録される。
【0018】
したがって、本発明の第3の観点によれば、一部の命令のみに特化した特殊中間コード実行手段の追加された中間コード実行システムにおいて、一般中間コード実行手段と特殊中間コード実行手段とを使い分けることが可能となり、これにより中間コード実行時のパフォーマンスを向上することができる。
【0019】
本発明の第の観点では、所定のプログラム言語で作成されたソースコードをコンパイルして得られた中間コードをインタープリタ方式で実行する中間コード実行システムにおいて、中間コードが格納された記憶手段と、前記記憶手段に格納された中間コードに、当該中間コードに含まれる特定の命令パターンを、予め前記特定の命令パターンと関連付けられた代替命令に置換する処理を施す前処理手段と、前記代替命令を解釈して実行することができない第1のインタープリタと、前記代替命令を置換前の命令パターンと同等の内容に解釈して実行することができる第2のインタープリタと、前記前処理手段により処理された中間コードを解析し、当該中間コードに前記代替命令が含まれているか否かを判定し、前記代替命令が含まれている場合には当該中間コードを前記第1のインタープリタで実行すべきことを記録し、前記代替命令が含まれていない場合には当該中間コードを前記第2のインタープリタで実行すべきことを記録する中間コード解析手段とを具備することを特徴とする中間コード実行システムが提供される。
【0020】
本発明の第の観点によれば、特定の命令パターンを代替命令に置換する前処理を行う前処理手段と、代替命令に対応した第1のインタープリタと、代替命令に対応していない第2のインタープリタと、中間コード解析手段とを備えた構成において、中間コード解析手段によって前処理後の中間コードを解析し、前処理で特定の命令パターンが代替命令に置換された中間コードについては第1のインタープリタで実行すべきことを記録し、前処理を施しても置換が行われなかった中間コードについては第2のインタープリタで実行すべきことを記録する。
【0021】
したがって、本発明の第4の観点によれば、前処理手段と、第1のインタープリタと、第2のインタープリタとを備えた構成を有効に活用して中間コードを高いパフォーマンスで実行することができる。
【0022】
本発明の第の観点では、所定のプログラム言語で作成されたソースコードをコンパイルして得られた中間コードをインタープリタ方式で実行する中間コード実行システムにおいて、コンパイルにより生成される命令の全てを解釈して実行することができる第1のインタープリタを有する第1のサブシステムと、中間コードに含まれる複数の命令からなる命令パターンを代替命令に置換する前処理を施す前処理部と、当該代替命令を置換前の命令コードと実質的に同等の内容に解釈して実行することができる第2のインタープリタと、を有する第2のサブシステムと、実行する中間コードに応じて、前記第1のサブシステムにおいて前記第1のインタープリタにより中間コードを実行する処理と、前記第2のサブシステムにおいて前記前処理部により中間コードに前処理を施してから前記第2のインタープリタで実行する処理とのいずれか一方を選択する選択部とを具備することを特徴とする中間コード実行システムが提供される。
【0023】
本発明の第の観点によれば、通常のインタープリタを有する第1のサブシステムと、特定の命令パターンを代替命令に置換する前処理手段および当該前処理手段によって前処理の施された中間コードの実行に特化した第2のインタープリタを有する第2のサブシステムとを、実行する中間コードに応じて使い分ける
【0024】
これにより、本発明の第5の観点によれば、中間コード実行時のパフォーマンスを向上することができる。
【0025】
本発明の第の観点においては、前記第2のサブシステムは、前記第1のサブシステムにおいて特定の命令が割り付けられているオペコードに代替命令を割り付けており、前記選択部は、実行する中間コードに前記特定の命令が含まれている場合には前記第1のサブシステムによる処理を選択し、実行する中間コードに前記特定の命令が含まれていない場合には前記第2のサブシステムによる処理を選択する構成とすることができる。
【0026】
本発明の第の観点では、所定のプログラム言語で作成されたソースコードをコンパイルして得られた中間コードを実行する中間コード実行システムであって、中間コードに含まれる複数の命令からなる第1の命令パターンを第1の代替命令に置換する前処理を施す前処理部と、当該第1の代替命令を置換前の命令コードと実質的に同等の内容に解釈して実行することができる第1のインタープリタとを有する第1のサブシステムと、中間コードに含まれる第2の命令パターンを第2の代替命令に置換する前処理を施す前処理部と、当該第2の代替命令を置換前の命令コードと実質的に同等の内容に解釈して実行することができる第2のインタープリタとを有する第2のサブシステムと、実行する中間コードに応じて、前記第1のサブシステムにおいて前記第1のインタープリタにより中間コードを実行する処理と、前記第2のサブシステムにおいて前記前処理部により中間コードに前処理を施してから前記第2のインタープリタで実行する処理とのいずれか一方を選択する選択部とを具備することを特徴とする中間コード実行システムが提供される。
【0027】
本発明の第の観点によれば、特定の命令パターンを代替命令に置換する前処理手段および当該前処理手段によって前処理の施された中間コードの実行に特化したインタープリタを有するサブシステムを、互いに異なる命令パターンおよび代替命令について2系統備えた中間コード実行システムにおいて、2系統のサブシステムを実行する中間コードに応じて使い分けることにより、中間コード実行時のパフォーマンスを向上することができる
【0028】
本発明の第の観点においては、前記第1のサブシステムは前記第1の代替命令を第1のオペコードに割り付けており、前記第2のサブシステムは前記第2の代替命令を第2のオペコードに割り付けており、上記選択部は、実行する中間コードが第1のオペコードに係る命令を含んでいる場合には第2のサブシステムによる処理を選択し、実行する中間コードが第2のオペコードに係る命令を含んでいる場合には第1のサブシステムによる処理を選択する構成とすることができる。
【0029】
尚、上記各観点において、「命令パターン」とは、所定の命令の一連の集合である。また、「代替命令」とは、前記命令パターンに置換される命令をいい、当該命令パターンよりも短いコードで表現され、代替命令に対応した実行環境において実行される独自の命令である。
【0030】
【発明の実施の形態】
以下、図面を参照して本発明の実施形態について説明する。
[第1実施形態]
先ず、図1から4を参照して、本発明の第1実施形態に係る中間コード前処理装置について詳細に説明する。
図1は、中間コードとしてJava(R)のクラスファイルを前処理する第1実施形態に係る中間コード前処理装置1のハードウェア的な構成を示している。
【0031】
この中間コード前処理装置1は、記憶部101、処理部102、および入力部103を備えている。処理部102は、MPUやマイクロコントローラ等の演算装置である。この処理部102は、1つに限られるものではなく、複数のMPUや複数種類の演算装置により分散処理を可能とした構成としてもよい。
【0032】
入力部103は、この中間コード前処理装置1にクラスファイル等を入力するものである。この入力部103から入力されたクラスファイルは記憶部101に格納される。記憶部101は、例えばRAMやROM等のメモリからなる。ここでは、説明の便宜上、1つの記憶部101のみを記載しているが、複数の記憶部を分散配置した構成としてもよい。
【0033】
上記記憶部101の所定の領域には、複数の命令からなる命令パターン101aと代替命令101bとが関連付けられたテーブルが格納されており、さらにはクラスファイル101cが格納されている。ここで命令パターン101aは、複数のバイトコード命令からなるパターンのことである。
【0034】
以下、例えば整数同士の加算を行う場合を例に挙げて説明する。この場合には、Java(R)のクラスファイルに含まれるメソッドには、例えばFIG.3に示されるように、「iload」、「iload」、「iadd」という命令パターンが頻出することがある。そこで、第1実施形態に係る中間コード前処理装置1では、このように頻出する命令パターンを、当該命令パターンと同様の処理を行う代替命令、例えば「v_v_iadd」と関連付けたテーブルを記憶部101に格納する。ここで、「iload」は、ローカル変数の値をオペランドスタックにプッシュする2バイトからなる中間コードをニーモニック表記したものである。また、「iadd」は、オペランドスタックから値を2つポップし加算して、その結果をオペランドスタックにプッシュする1バイトの中間コードをニーモニック表記したものである。
【0035】
前記代替命令101bは、代替命令101bを実行可能な環境下において、前記命令パターン101aと同様の処理に解釈される命令である。逆に言えば、本実施形態は、代替命令101bを置換前の命令パターンと実質的に同等に解釈して実行することができる中間コード実行システムの存在を前提としたものである。そのような中間コード実行システムは、例えば上記の場合、代替命令「v_v_iadd」を上記「iload」、「iload」、「iadd」という命令パターンと同様の処理に解釈して実行する。なお、かかる代替命令の実行に際しては、メモリアクセスの頻発防止、冗長な処理の省略、レジスタの活用等により、命令実行にあたってのオーバーヘッド要因を最低減とすることが望ましい。
【0036】
また、代替命令101bは、前記命令パターン101aと比してコード長が短くなっている。例えば、前記代替命令「v_v_iadd」は3バイトのコード長であり、置換前のコード長である5バイトよりも短くなっている。
【0037】
したがって、このような前処理によれば、クラスファイル101cのサイズを小さくすることも可能である。
【0038】
なお、本実施形態は、主として請求項1または15に記載の発明に対応しており、前記記憶部等101は当該発明における記憶手段に相当し、前記処理部102は処理手段に相当している。
【0039】
以上のような構成において、処理部102により一連のソフトウェアプログラムを実行することにより、中間コード前処理装置1の各機能が実現され、クラスファイル101cに以下に述べるような前処理が施される。
【0040】
図2は、本実施形態における前処理の手順を説明するためのフローチャートである。ここでは、予め、入力部103からクラスファイル101cが中間コード前処理装置1に入力され、記憶部101に格納されていることが前提となっている。この前提の下に、以下の如き手順で処理を行う。
【0041】
即ち、先ず中間コード前処理を開始すると(S101)、処理部102は記憶部101から互いに関連付けられた命令パターン101aおよび代替命令101bのテーブルを読み出す(S102)。次いで、処理部102は、クラスファイル101cを検索して命令パターン101aを特定する(S103)。即ち、例えば、図3および図4に示すように、「iload」、「iload」、「iadd」の一連の命令パターン101aをクラスファイル101cの中で特定する。こうして命令パターンを特定すると、処理部102は、特定したクラスファイル101c中の命令パターン101aを、当該命令パターン101aに関連付けられた代替命令101bに置換する(S104)。
【0042】
図4は、S104における処理の一例を具体的に説明するための図である。この例では、特定した命令パターンに含まれる「iload 8」、「iload9」、「iadd」は、まず、「nop」、「nop」、「v_v_iadd8,9」に変換される(第1段階)。ここで、「nop」は、何も行わない命令である。このように、「v_v_iadd 8,9」の前に複数の「nop」を挿入したのは、変換されるクラスファイルのサイズを変更させず、クラスファイルに含まれる条件分岐の飛び先等を変更させないためである。この第1段階の処理を施した後に、条件分岐の飛び先等を変更しつつ「nop」を削除する処理を行う(第2段階)。これにより、S104の処理は完了する。
【0043】
以上のようにして、中間コードの前処理は終了する(S105)。
【0044】
この第1実施形態に係る中間コード前処理装置によれば、前述した一連の処理により、実行されるコードの長さが「iload」、「iload」、「iadd」の合計5バイトコードから、「v_v_iadd」の3バイトの1命令に短縮される。したがって、実行すべき命令の個数を少なくして命令間の冗長な処理を省することができるとともに、クラスファイルのサイズを低減することができる
【0045】
このようにして得られた中間コードは、「v_v_iadd」のような代替命令101bに対応した実行環境において、代替命令101bを置換前の命令パターン101aと同等かつメモリアクセス等のオーバーヘッド要因を最小とした処理に解釈して実行することにより、高速に実行することができる。また、以上のような中間コードの前処理は、単なるコードの置換であるため低オーバーヘッドで実行することができ、かつ、ネイティブコードにコンパイルする場合のようにクラスファイルのサイズを増大させることもないので、中間コード実行のパフォーマンスを有為に向上させることができる。
【0046】
例えば、第1実施形態を携帯電話等の組込み機器に適用する場合には、当該組み込み機器に上述の代替命令101bを実行可能な実行環境を搭載し、中間コード前処理装置1により前処理済みのクラスファイルを当該組み込み機器にプリインストールまたは配信するようにしてもよい。このようにすることで、組み込み機器上で実行されるJava(R)アプリケーションのパフォーマンスを向上することができる。
【0047】
また、当該組み込み機器に上述した前処理装置1および代替命令101bを実行可能な実行環境を搭載し、携帯電話上でクラスファイルの前処理と、前処理されたクラスファイルの実行との双方を行うようにしてもよい。
【0048】
なお、第1実施形態では、命令パターン101aと代替命令101bとが関連付けられたテーブルを記憶部101に格納することとしているが、このようなテーブルは前処理を行うためのソフトウェアプログラムの中に埋め込んだ形態としてもよいし、前処理を行うためのソフトウェアプログラムから独立して設けても構わない。
【0049】
また、上述した前処理の手順において、S104における処理は図4に示したものに限られない。例えば、図4に示した第1段階の処理の後、第2段階の処理を行わず、「nop」を削除しなくても構わない。このような場合には、「nop」を含んだ中間コードをそのまま実行環境において実行してもよいし、実行環境にて「nop」の削除および条件分岐の飛び先変更等を行いつつクラスファイルを実行してもよい。特に、後者の場合には、実行環境がアイドル時間を利用する等して上述の前処理を行うことが好適である。
【0050】
[第2実施形態]
次に、図5,6を参照して、本発明の第2実施形態に係る中間コード実行システムについて詳細に説明する。
図5は、中間コードとしてJava(R)のクラスファイルを実行する本発明の第2実施形態に係る中間コード実行システム2のハードウェア的な構成を示している。中間コード実行システム2は、記憶部201、処理部202、および入力部203を備えている。尚、これら記憶部201、処理部202、および入力部203は、第1実施形態に係る中間コード前処理装置1の記憶部101、処理部102、および入力部103と略同様である。また、記憶部201に格納される、命令パターン201a、代替命令201bおよびクラスファイル201cは、第1実施形態に係る中間コード前処理装置1の記憶部101に格納される、命令パターン101a、代替命令101b、およびクラスファイル101cと略同様である。従って、ここでは、これらについての重複した説明は省略する。
【0051】
なお、本実施形態は、主として請求項3または17に記載の発明に対応しており、前記記憶部等201は当該発明における記憶手段に相当し、前記処理部202は処理手段に相当している。
【0052】
以上のような構成において、処理部202により一連のソフトウェアプログラムを実行することにより、中間コード実行システム2の各機能が実現され、以下に述べるようにしてクラスファイル201cに前処理が施され、前処理の施されたクラスファイル201cが実行される。
【0053】
図6は、本実施形態におけるクラスファイル201cの前処理および実行の手順を説明するためのフローチャートである。この手順は、上記第1実施形態と同様に、予め入力部203から入力されたクラスファイル201cが記憶部201に格納されていることを前提としている。
【0054】
まず、中間コードの前処理が開始され(S201)、処理部202は記憶部201から互いに関連付けられた命令パターン201aおよび代替命令201bのテーブルを読み出す(S202)。次いで、処理部202はクラスファイル201cを検索して命令パターン201aを特定する(S203)。そして、処理部202は特定された命令パターン201aを代替命令201bに置換し(S204)、中間コードの前処理は終了する(S205)。以上の処理は、第1実施形態における前処理と同様の手順であるため、詳細な説明は省略する。
【0055】
次いで、以上のようにして前処理の施されたクラスファイル201cを実行する。ここでは、代替命令201bを命令パターン201aと同等の内容に解釈して実行することができるインタープリタをなすソフトウェアプログラムが実行され、これにより処理部202は記憶部201に格納されたクラスファイル201cから命令を取り出し(S206)、取り出された命令に相当する処理が処理部202により実行される(S207)。
【0056】
第2実施形態に係る中間コード実行システム2によれば、以上のような手順により、クラスファイル201cに命令パターン201aを代替命令201bに置換する前処理を施し、この前処理の施された中間コードを実行することができる。よって、クラスファイル201cのコード長を短縮し、かつ、命令間の冗長な処理を省略した中間コードを実行することができ、これにより中間コード実行時のパフォーマンスを向上することができる。さらに、前処理後の中間コードを実行するにあたり、代替命令をメモリアクセス等のオーバーヘッド要因を最小とした処理に解釈して実行することにより、中間コード実行時のパフォーマンスを一層向上することも可能である。
【0057】
なお、図6に示した手順では、前処理とクラスファイルの実行とを連続して行う場合を示したが、前処理とクラスファイルの実行とは必ずしも連続していなくてもよく、予めクラスファイルに前処理を施しておき、時間をおいてから前処理を施したクラスファイルを実行するようにしても構わない。
【0058】
また、代替命令201bの関連づけられた命令パターン201aは1種に限られるものではなく、2種以上であってもよい。このような場合に、図6に示したような手順で前処理とクラスファイルの実行とを連続して行う際には、前処理のオーバーヘッドをできるだけ小さくしてクラスファイルの実行を開始するために、代替命令201bの関連づけられた命令パターン201aのうち一部の命令パターンについてのみ代替命令と置換する前処理を行うようにしてもよい。
【0059】
さらに、中間コード実行システム2が搭載される機器によって処理部202をなすMPUやマイクロコントローラの性能は様々であり、また、状況に応じて前処理にかけられる時間的な余裕や機器システムの処理能力にも変化がある。したがって、代替命令の関連付けられた複数の命令パターンがある場合には、どれだけの命令パターンを置換するかを機器の特性や状況に応じて静的に調整するようにしてもよい。このようにすることで、中間コード実行システム2が搭載される機器の特性や状況に応じた前処理を実現することができる。例えば、本発明の中間コード実行システム2を携帯電話に搭載した場合、携帯電話にダウンロードしたクラスファイルを直ちに実行する際には一部の命令パターンだけを置換するようにし、直ちに実行しない場合には全命令パターンを置換するように調整するようにしてもよい。このようにすることで、携帯電話上にて、状況に応じた前処理を施しつつクラスファイルを実行することが可能となる。
【0060】
[第3実施形態]
次に、図7から9を参照して、本発明の第3実施形態に係る中間コード実行システムについて詳細に説明する。
図7は、中間コードとしてJava(R)のクラスファイルを実行する本発明の第3実施形態に係る中間コード実行システム100を概略的に示す図面である。この中間コード実行システム100は、MPUないしマイクロコントローラを含んだ演算部5と、前記演算部5に接続された記憶部10とを有している。
【0061】
演算部5は、所定のソフトウェアプログラムを実行することにより、中間コード解析部20と、中間コード実行部30A,30B,30Cとを構成する。そのようなソフトウェアプログラムは記憶部10に格納してもよいし、別の記憶部に格納するようにしても構わない。
【0062】
上記中間コード実行部30A,30B,30Cは、それぞれ中間コードを逐次的に解釈して実行するインタープリタとして機能する。そして、これらの中間コード実行部30A,30B,30Cは、それぞれの処理特性が互いに異なるタイプとなっている。例えば、中間コード実行部30Aはバイトコード命令Fの処理は速いがバイトコード命令Gの処理は遅く、中間コード実行部Bはバイトコード命令Gの処理は速いがバイトコード命令Fの処理は遅く、中間コード実行部Cはいずれのバイトコード命令においても平均的な処理速度となっているが如くである。
【0063】
さらに、中間コード解析部20は、記憶部10に記憶されたクラスファイル12に含まれるメソッドの性質を解析し、その性質に応じた中間コード実行部30を選択し、当該メソッドと選択された中間コード実行部30との組み合わせを記録する処理を行う。この中間コード解析部20が行う処理については、後に詳細に説明する。
【0064】
記憶部10は、RAMやROM等を有し、クラスファイル12と、対応関係データベース13とを格納している。記憶部10は、物理的に単一の構成としてもよいし、複数からなる構成としても構わない。
【0065】
クラスファイル12は、Java(R)言語により作成されたソースコードファイルをコンパイルして生成されたものであり、1以上のメソッドが含まれている。このメソッドは、特定の処理を実現するために複数のバイトコード命令が集合したものである。上記対応関係データベース13は、上記中間コード実行部30A,B,Cのそれぞれにおける各バイトコード命令の処理効率度のスコアを管理するデータベースである。
【0066】
なお、本実施形態は、主として請求項4に記載の発明に対応しており、前記中間コード実行部30A,30B,30Cは当該発明における中間コード実行手段に相当し、前記記憶部10は記憶手段に相当し、前記中間コード解析部20は中間コード解析手段に相当している。
【0067】
図8は、対応関係データベース13の具体的内容の一例を示したデータ構造図である。図8に示されるように、対応関係データベース13は、中間コード実行部30A,30B,30Cのそれぞれにおける各バイトコード命令の処理効率度のスコアを記憶している。ここで、処理効率度のスコアとは当該バイトコード命令をどの程度効率的に実行することができるかを数値化した値であり、このようなスコアは各中間コード実行部の40A,30B,30Cの仕様に応じて予め定義しておくことが好ましい。なお、図8に示したデータ構造は、主として請求項5に記載の発明に対応したものである。
【0068】
例えば、図8の最上段では、バイトコード命令aの中間コード実行部30A,30B,30Cのそれぞれにおける処理効率度のスコアが定義されている。詳細には、バイトコード命令aの中間コード実行部30Aにおける処理効率度のスコアは90、中間コード実行部30Bにおける処理効率度のスコアは10、中間コード実行部30Cにおける処理効率度のスコアは10と定義されている(ここでは、数値が高いほど効率がよいものとする)。従って、このような対応関係データベース13によれば、バイトコード命令aについては中間コード実行部30Aにより実行されるのが最も効率的であることが分かる。これと同様に、バイトコード命令b,c、さらには他の全てのバイトコード命令について各中間コード実行部30A、30B,30Cのそれぞれにおける処理効率度スコアが、対応関係データベース13に定義されている。なお、請求項5に記載の処理効率度のスコアテーブルは、この対応関係データベース13に蓄積されている。
【0069】
以下、図9のフローチャートを参照して、第3実施形態に係る中間コード実行システム100の中間コード解析部20が実行する処理の手順を説明する。まず、中間コード解析部20は、記憶部10のクラスファイル12からメソッドを読み出す(S301)。次に、中間コード解析部20は、当該読み出したメソッドを解析し、メソッドに含まれるバイトコード命令を特定する(S302)。一つのメソッドには、複数のバイトコード命令が含まれているので、中間コード解析部20はメソッドに含まれる複数のバイトコード命令を、個々に特定する手順を繰り返す。
【0070】
次いで、中間コード解析部20は、記憶部10における対応関係データベース13に問い合わせ、上記S102において特定した各バイトコード命令に対応する処理効率度のスコアを取得し、それらを合計する(S303)。
【0071】
その後、中間コード解析部20は、S303にて得られた中間コード実行部30A,30B,30Cのそれぞれにおける処理効率度の合計スコアに基づいて、クラスファイル12を最も効率よく実行することができる中間コード実行部を特定する(S304)。具体的には、中間コード解析部20にて中間コード実行部ごとの合計スコアを比較し、最も合計スコアの高いものを当該メソッドの実行に利用する中間コード実行部として特定するようにしてもよい。
【0072】
最後に、中間コード解析部20は、当該メソッドをS304において特定した中間コード実行部30で実行すべきことを記録する(S305)。具体的には、例えば、メソッド毎に保有されている管理情報に、実行すべき中間コード実行部30の種別を記録しておくようにしてもよいし、メソッドに実行すべき中間コード実行部30の種別をマークしておくようにしてもよい。以上の動作をクラスファイル12に含まれる全てのメソッドについて実行し、中間コード解析部20は処理を終了する。
【0073】
以下、図8に示した対応関係データベース13を例に、上記S303および上記S304における処理の内容をより具体的に説明する。メソッドにバイトコード命令a,dが含まれていた場合を想定すると、中間コード解析部20は、バイトコード命令aの中間コード実行部30Aにおける処理効率度のスコアである90、中間コード実行部30Bにおける処理効率度のスコアである10、中間コード実行部30Cにおける処理効率度のスコアである10をそれぞれ取得する。次いで、中間コード解析部20は、バイトコード命令dの中間コード実行部30Aにおける処理効率度スコアである50、中間コード実行部30Bにおける処理効率度スコアである40、中間コード実行部30Cにおける処理効率度スコアである90をそれぞれ取得し、バイトコード命令aのスコアに加算する。
【0074】
この場合には、中間コード実行部30Aにおける処理効率度の合計スコアは140、中間コード実行部30Bにおける合計スコアは50、中間コード実行部30Cにおける合計スコアは100となる。従って、中間コード解析部20は、中間コード実行部30Aを当該メソッドの実行に利用するものとして特定する。以上のような処理を行うことにより、中間コード実行システム100は、クラスファイル12に含まれるメソッドを実行する際に、中間コード解析部20にて記録した内容に基づいて、メソッドに含まれるバイトコード命令に応じて決定された最も効率的な中間コード実行部30A,30Bまたは30Cを用いることが可能となる。したがって、第3実施形態によれば、特性の異なる中間コード実行部30A,30B,30Cを活用して、クラスファイル12に含まれるメソッドの実行を効率よく行うことができるので、パフォーマンスの高い中間コード実行システム100が提供される。
【0075】
[第4実施形態]
次に、図10,11を参照して、本発明の第4実施形態に係る中間コード実行システムについて詳細に説明する。
第4実施形態に係る中間コード実行システムは、その基本構成は第3実施形態と同様である。ただし、第4実施形態に係る中間コード実行システムは、中間コード解析部20において、メソッドに含まれる各バイトコード命令に対して一意に定められたスコアの合計値を求め、その合計値のランクに応じて中間コード実行部30A,30b、30Cのいずれかを特定する点で第3実施形態と相違する。なお、本実施形態は主として請求項6に記載の発明に対応したものである。
【0076】
以下、この点について詳細に説明する。中間コード解析部20において、上記のような特定方法を実現するために、第4実施形態における対応関係データベース13は、図10に示すような各バイトコード命令と当該各バイトコード命令のスコアとの対応関係を定義するテーブルと、図11に示すような合計スコアの範囲と中間コード実行部30A,30B,30Cとの対応関係を定義するテーブルとを含んでいる。
【0077】
このうち、前者について図10の例に基づいて説明すると、図10の左側は各バイトコード命令を示しており、図10の右側はそれに対応して設定されたスコアの値を示している。ここでは、バイトコード命令aのスコアは40、バイトコード命令bのスコアは90、バイトコード命令cのスコアは55と一意に設定されている。また、後者について図11の例に基づいて説明すると、図11の左側は合計スコアの範囲を示しており、この図11の右側は当該合計スコアの範囲に対応して特定される中間コード実行部30A,30B,30Cのいずれかを示している。ここでは、あるメソッドに含まれるバイトコード命令に対応する合計スコアが201未満の範囲に属するときには中間コード実行部30Aが特定される。同様に、スコアの総計が201以上401未満のときには中間コード実行部30Bが、401以上のときは中間コード実行部30Cが、それぞれ特定されるように設定されている。
【0078】
第4実施形態において中間コード解析部20が実行する処理の基本手順は第3実施形態とほぼ同様である。すなわち、図7に示したように、中間コード解析部20は記憶部10のクラスファイル12からメソッドを読み出し(S101)、メソッドに含まれるバイトコード命令を特定し(S102)、対応関係データベース13に問い合わせて特定した各バイトコード命令に対応するスコアを取得し、合計する(S103)。その後、再度対応関係データベース13に問い合わせて合計スコアに応じた中間コード実行部を特定し(S104)、当該メソッドを特定した中間コード実行部で実行すべきことを記録し(S105)、処理を終了する。
【0079】
以下、図10および図11に示した対応関係データベース13を例に、上記S103および上記S104における処理の内容を具体的に説明する。メソッドにバイトコード命令a,cが含まれていた場合を想定すると、中間コード解析部20は、バイトコード命令aのスコアである40と、バイトコード命令cのスコアである55とを取得し、その合計値は95となる(ST103)。中間コード解析部20は、この合計値とFig.11のテーブルとから、中間コード実行部30Aを当該メソッドの実行に利用するものとして特定する。
【0080】
以上のような処理を行う第4実施形態においても、第3実施形態と同様に、メソッドに含まれるバイトコード命令に応じて決定された最も効率的な中間コード実行部30A,30Bまたは30Cを用いることが可能となるので、極めてパフォーマンスの高い中間コード実行システム100が提供される。
【0081】
[第5実施形態]
次に、図12,13を参照して、本発明の第5実施形態に係る中間コード実行システムについて詳細に説明する。
図12は、本発明の第5実施形態に係る中間コード実行システム200を概略的に示す図面である。この中間コード実行システム200は、その基本構成は第3および第4実施形態と同様であるが、一般中間コード実行部31と特殊中間コード実行部32とを有する点で第3および第4実施形態と相違している。
【0082】
この中間コード実行システムは、一般中間コード実行部31と特殊中間コード実行部32とによりクラスファイル12を実行する。一般中間コード実行部31は、クラスファイルを逐次的に解釈して実行するインタープリタであり、全てのバイトコード命令を実行する通常の機能を有している。これに対して、特殊中間コード実行部32は、特定のバイトコード命令を一般中間コード実行部31よりも高速に実行することができるが、一部の命令(例えば、浮動小数点演算に関するバイトコード命令)を実行することができない特殊なインタープリタである。
【0083】
また、第5実施形態における対応関係データベース13は、各バイトコード命令について、当該バイトコード命令が上記特殊中間コード実行部32によって実行可能であるか否かを識別するためのデータ構造となっている。
【0084】
なお、本実施形態は、主として請求項7に記載の発明に対応しており、前記特殊中間コード実行部32は当該発明における特殊中間コード実行手段に相当し、前記一般中間コード実行部31は一般中間コード実行手段に相当し、記憶部10は記憶手段に相当し、中間コード解析部20は中間コード解析手段に相当している。
【0085】
以下、図13のフローチャートを参照して、第5実施形態に係る中間コード実行システム200の中間コード解析部20が実行する処理の手順を説明する。先ず、中間コード解析部20は、記憶部10のクラスファイル12からメソッドを読み出す(S201)。次に、中間コード解析部20は、当該読み出したメソッドを解析し、メソッドに含まれるバイトコード命令を特定し(S202)、当該特定したバイトコード命令が特殊中間コード実行部32では実行不能なバイトコード命令か否かを対応関係データベース13の内容に基づいて判定する(S203)。このS203において、特殊中間コード実行部32では実行不能なバイトコード命令が含まれないと判定された場合には、中間コード解析部20は当該メソッドを特殊中間コード実行部32で実行すべきことを記録する(S204)。一方、S203において、特殊中間コード実行部32では実行不能なバイトコード命令が含まれると判定したとき、中間コード解析部20は当該メソッドを一般中間コード実行部31で実行すべきことを記録する(S205)。なお、記録の方法は第3および第4実施形態と同様でよい。以上の動作をクラスファイル12に含まれる全てのメソッドについて実行し、中間コード解析部20は処理を終了する。
【0086】
以上のような第5実施形態によれば、特定のバイトコード命令を高速に実行することができるが一部のバイトコード命令を実行不能な特殊中間コード実行部32と、全ての命令を実行することができる一般中間コード実行部31とを、メソッド毎に使い分けることにより、特定のバイトコード命令を高速に実行することができるとともに、全てのバイトコード命令を実行することの可能な中間コード実行システム200が提供される。
【0087】
[第6実施形態]
次に、図14を参照して、本発明の第6実施形態に係る中間コード実行システムについて詳細に説明する。
第6実施形態に係る中間コード実行システム300は、中間コードとしてJava(R)のクラスファイルを実行するものである。そして、図14に示すように、この中間コード実行システム300は、主としてクラスファイル302を格納した記憶部301と、不図示の処理部により所定のプログラムを実行することで仮想的に構成されるメソッド解析部307、第1のサブシステム308および第2のサブシステム310とから構成されている。
【0088】
上記記憶部301に格納されたクラスファイル302は、Java(R)言語により作成されたソースコードをコンパイルすることにより得られるものである。このクラスファイル302は、メソッド303〜305を含んでいる。
【0089】
クラスファイル302は圧縮されたjarファイルの状態で配信され、中間コード実行システム300により伸張される場合もある。尚、このjarファイルとは、Java(R)プログラムを動作させるために必要なクラスファイルを一つにまとめたアーカイブ・ファイルである。但し、図14では、既にクラスファイルの状態で記憶部301に格納されている。
【0090】
第1のサブシステム308は、第1のインタープリタ309を有している。そして、この第1のインタープリタ309によりJava(R)のクラスファイルに含まれるバイトコード命令を逐次的に解釈して実行することが可能である。この第1のインタープリタ309は、コンパイル時に生成される命令コードセット、即ち、ここではJava(R)言語により作成されたソースコードをコンパイルすることで生成されるバイトコード命令の全てに対応した通常のインタープリタである。
【0091】
一方、上記第2のサブシステム310は、前述の中間コード前処理装置と略同様の構成と機能とを有する前処理部311と、第2のインタープリタ312とを有している。前処理部311は、前述の通り、例えば「iload」、「iload」、「iadd」という命令パターンを「v_v_iadd」と置換するように、特定のバイトコード命令のパターンを対応する代替命令に置換する処理をクラスファイル302の各メソッドに施す。また、第2のインタープリタ312は、このように処理を施されたメソッドに対応するために、置換後にメソッドに追加される代替命令を解釈して実行することができるように構成されている。
【0092】
より具体的には、前処理部311において特定の命令パターンを代替命令に置換することは、特定の命令パターンをなすオペコードおよびオペランドの組み合わせを、新たに定義した代替命令のオペコードおよびオペランドのセットに置換するということを意味している。尚、オペコードは命令の動作を表しており、オペランドは命令の対象となるスタックやレジスタ等を表している。
【0093】
しかしながら、Java(R)の場合には、オペコード長は1バイトと限られているためオペコードの種類を自由に増やすことはできない。そこで、第6実施形態では、通常は別の命令が割り付けられているオペコードに代替命令を割り当て、実行時には当該オペコードを代替命令として解釈し、置換前の命令パターンがなすものと実質的に同様の手順を実行するようにする。
【0094】
すなわち、第6実施形態では、例えば、通常のバイトコード命令において浮動小数点演算の命令が割り付けられているオペコードに代替命令を割り付ける。そして、第2のインタープリタ312において、当該オペコードを代替命令に置換する前の命令パターンと同様の手順に解釈して実行する。
【0095】
以上のようにすることで、第2のサブシステム310において、メソッドを前処理部311で前処理してから第2のインタープリタ312で実行することが可能となる。但し、前述した例では、第2のサブシステム310で浮動小数点演算の命令を含むメソッドを実行することはできなくなる。
【0096】
上記メソッド解析部307は、実行されるメソッドに含まれる命令を解析しそれに応じてメソッドを第1のサブシステム308と第2のサブシステム310とのいずれで実行するかを選択する。そして、その結果を当該メソッドにマークする。即ち、第6実施形態におけるメソッド解析部307の機能は、第5実施形態における中間コード解析部20の機能に対応している。
【0097】
なお、本実施形態は主として請求項9ないし14に記載の発明に対応しており、前記記憶部301は当該発明における記憶手段に相当し、前記前処理部311は前処理手段に相当し、前記第1および第2のインタープリタ309,310は第1および第2のインタープリタに相当し、メソッド解析部307は中間コード解析手段または選択部に相当している。
【0098】
次に、以上のような構成の中間コード実行システム300により、クラスファイル312に含まれるメソッド303を実行する手順について説明する。先ずメソッド解析部307によりメソッド303に含まれる命令を解析する。例えば、上述のように第2のサブシステム310において代替命令のオペコードを浮動小数点演算命令のオペコードに割り付けている場合には、メソッド303が浮動小数点演算の命令を含むか否かを判断する。そして、その結果からメソッド303を実行に用いるべきサブシステムをメソッド303の所定位置306にマークする。すなわち、メソッド303が浮動小数点演算の命令を含むと判断した場合には、第1のサブシステム309で実行することを選択する。そして、メソッド303が浮動小数点演算の命令を含まないと判断した場合には、第2のサブシステム310で実行することを選択する。
【0099】
第1のサブシステム309で実行することを選択した時には、メソッド303をそのまま第1のインタープリタ309で逐次的に解釈して実行する。
【0100】
一方、第2のサブシステム310で実行することを選択した時には、前処理部311によりメソッド303に前処理を施して、メソッド303に含まれる複数の命令がなす一定のパターンを代替命令に置換する。そして、この後、当該代替命令に対応した第2のインタープリタ312で逐次的に解釈して実行する。
【0101】
そして、以上のようにしてメソッド303の実行を終了したら、クラスファイル302の内容に応じて、メソッド303〜305のいずれかを逐次実行することをプログラムを終了するまで続けることになる。
【0102】
第6実施形態に係る中間コード実行システム300の構成およびメソッド実行の手順によれば、一部の命令を実行することができないものの、メソッドに含まれる特定の命令パターンを代替命令に置換して実行することにより、命令間の冗長な処理を省いてメソッドを高速に実行することができる第2のサブシステム310と、メソッド実行の高速化は図られていないものの、全命令を実行することができる第1のサブシステム308とを有効に運用し、優れたパフォーマンスでクラスファイルを実行することができる。
【0103】
なお、上記第1から第6実施形態は、種々変形が可能である。例えば、上記第1および第2実施形態では、クラスファイル単位で前処理を施す場合を示したが、これらの実施形態でも第6実施形態と同様にメソッド単位で前処理を施すようにしても構わない。また、第3および第4実施形態における対応関係データベース13内のデータ構造や、そこでのスコア設定についても上記に限られるものではない。
【0104】
また、第6実施形態における第1のサブシステム309および第2のサブシステムの組み合わせに替えて、いずれも特定の命令パターンを代替命令に置換する前処理部および代替命令を実行可能なインタープリタを有する2つのサブシステムを用いてもよい。このようなサブシステムの組み合わせを用いる場合、両サブシステムで互いに異なるオペコードに代替命令を割り付けることで、両サブシステムの使い分けが可能となる。サブシステムの数が3以上であってもよい。
【0105】
さらに、第6実施形態では、第2のサブシステム310においてメソッドの実行時に前処理を施す場合を示したが、1度実行したメソッドについては前処理後のメソッドを記憶部301に保持することにより前処理を省略するようにしてもよい。また、クラスロードの際に全メソッドをメソッド解析部307により解析し、第2のサブシステム310で実行するものとされたメソッドについて予め前処理を施しておいてもよい。さらに、コンパイル時に前処理を施してもよい。
【0106】
また、メソッド解析部307による解析や、前処理部311による前処理でのメモリ消費やオーバーヘッド等を許容し難い状況においては、これらを省略して第1のサブシステム308においてメソッドを実行する構成としてもよい。さらにまた、第6実施形態では、一例として浮動小数点演算の命令を割り付けられたオペコードに代替命令を割り付ける場合を示したが、これに限られるものではない。他の命令を割り当てられたオペコードに代替命令を割り付けてもよい。
【0107】
そして、上記第1から第6実施形態は、いずれもJava(R)のクラスファイルをモディファイした中間コードに適用することも可能であるし、Java(R)以外の言語であってもソースコードとネイティブコードとの間の中間的なコードで実行することを想定したものであれば適用することが可能である。
【0108】
以上、本発明の第1から第6実施形態について説明した。即ち、第1および第2の実施形態によると、所定の命令パターンを特定し、当該特定された命令パターンを短縮されたコードである代替命令に置換する。したがって、命令の種類を少なくすることができると共に、命令間の冗長な処理が省かれた新たな中間コードを得ることができる。しかも、この前処理で中間コードのサイズは大きくなることがない。また、前処理自体は単純な置換を行っているだけなので高速で実行可能である。さらに、得られた新たな中間コードを、代替命令に対応した実行系で実行することで、中間コードを高速で実行できる。
【0109】
そして、第3実施形態によれば、装置内に複数の中間コード実行部を設ける一方、中間コード解析部が、実行対象となる中間コードを解析することにより当該中間コードの効率的実行に適切な中間コード実行部を選択して記録する。したがって、その記録された中間コード実行部を選択することにより、中間コードを高速で実行することができる。また、中間コードに含まれる各バイトコード命令と、各中間コード実行手段における処理効率度のスコアの対応関係を記憶し、これに基づいて中間コードの実行に利用する中間コード実行部を特定する。したがって、各中間コード実行部の性質を考慮した細かな設定に基づいて、バイトコード命令の効率的実行に適切な中間コード実行部を判断することが可能になる。
【0110】
また、第4実施形態によれば、中間コードに含まれる各バイトコード命令と中間コード実行部における処理効率度スコアとの対応関係、およびスコアの範囲とこれに応じて特定する中間コード実行部との対応関係を記憶し、これらに基づいて、中間コードの実行に利用する中間コード実行部を特定している。従って、準備される中間コード実行部が多数に及ぶ場合でも、各中間コード実行部毎の処理効率度スコアを設定、および積算する必要がなくなるというメリットを享受できる。
【0111】
また、第5実施形態によれば、特殊中間コード実行部と、一般中間コード実行部という2種類の中間コード実行部を設け、特殊中間コード実行部が実行不能なバイトコード命令を含む中間コードについてのみ一般中間コード実行部に実行させる一方で、他の中間コードは特殊中間コード実行部に実行させる。したがって、特定の処理に特化した中間コード実行部と汎用的に利用できる中間コード実行部との間で中間コードの出力先を二者択一的に選択するといったケースにおいて、中間コードの実行を極めて高速に実現するシステムを提供できる。
【0112】
そして、上記第6実施形態によれば、一部の命令を実行することができないものの、メソッドに含まれる特定の命令パターンを代替命令に置検して実行することにより、命令問の冗長な処理を省いてメソッドを高速に実行することができる第2のサブシステムと、メソッド実行の高速化は図られていないものの、全命令を実行することができる第1のサブシステムとを有効に運用し、優れたパフォーマンスでクラスファイルを実行することができる。
【0113】
尚、本発明は、上記第1から第6実施形態に限定されることなく、その目的の範囲内で種々の改良・変更が可能である。例えば、上述した第3から第5の実施形態では、当該中間コードに含まれるバイトコード命令と当該バイトコード命令の効率的実行に適切な前記中間コード実行部との対応関係を予め記憶した構成とした。しかし、これに限定されるものではなく、前記対応関係を状況に応じて変化させるように構成してもよい。また、インタープリタ機能の少なくとも一部をハードウェアアクセラレータで実現することで、実行速度の高速化を図ることもできる。このハードウェアアクセラレータを採用することには、メモリ要求量が増加せず、さらに組み込み機器に適した方法が取れる等、種々の利点がある。
【0114】
【発明の効果】
本発明によれば、仮想計算機により実行される中間コードに前処理を施すことで実行速度を向上させ、組み込み機器に好適に適用することができ、中間コードを高速に処理することが可能な中間コード実行システムを提供することができる。
【図面の簡単な説明】
【図1】本発明の第1実施形態に係る中間コード前処理装置の構成を示すブロック図である。
【図2】本発明の第1実施形態に係る中間コード前処理装置により中間コードに前処理を施す過程を説明するためのフローチャートである。
【図3】本発明の第1実施形態に係る中間コード前処理装置による中間コードと代替命令の関連付けを説明するための対応図である。
【図4】本発明の第1実施形態に係る中間コード前処理装置により中間コードに前処理を施す過程の各段階を説明するための図である。
【図5】本発明の第2実施形態に係る中間コード実行システムの構成を示すブロック図である。
【図6】本発明の第2実施形態に係る中間コード実行システムによる処理を説明するためのフローチャートである。
【図7】本発明の第3実施形態に係る中間コード実行システムの構成を示すブロック図である。
【図8】本発明の第3実施形態に係る中間コード実行システムが採用する対応関係データベース13のデータ構造図である。
【図9】本発明の第3実施形態に係る中間コード実行システムにおける中間コード解析部20による動作を示すフローチャートである。
【図10】本発明の第4実施形態に係る中間コード実行システムが採用する対応関係データベース13のデータ構造図である。
【図11】本発明の第4実施形態に係る中間コード実行システムが採用する対応関係データベース13のデータ構造図である。
【図12】本発明の第5実施形態に係る中間コード実行システムの構成を示すブロック図である。
【図13】本発明の第5実施形態に係る中間コード実行システムが採用する中間コード解析部20による動作を示すフローチャートである。
【図14】本発明の第6実施形態に係る中間コード実行システムの構成を示すブロック図である。
【符号の説明】
1 中間コード前処理装置
2 中間コード実行システム
5 演算部
10 記憶部
12 クラスファイル
13 対応関係D/B
20 中間コード解析部
30 中間コード実行部
31 一般中間コード実行部
32 特殊中間コード実行部
101 記憶部
102 処理部
103 入力部
201 記憶部
202 処理部
203 入力部
[0001]
BACKGROUND OF THE INVENTION
  The present invention provides intermediate code execution for executing intermediate code.To the systemIt is related.
[0002]
[Prior art]
  For the purpose of providing a program independent of a computer platform such as hardware and OS, a virtual machine (VM) is constructed on each platform by a software method or a hardware method. There has been proposed a method of executing intermediate code (hereinafter referred to as intermediate code) between source code and object code on a machine. One programming language that employs such a method is Java (R) that employs an intermediate code format called a class file. Hereinafter, hardware and a virtual machine built on the hardware may be referred to as an intermediate code execution system.
[0003]
  According to the above method, since a single program code can be supplied to various platforms and executed, it is not necessary to prepare an object code that can be executed only on each platform. This not only simplifies program distribution, but also makes software development more efficient. For this reason, virtual machines have been built on various computer platforms. Furthermore, recently, it has begun to construct virtual computers on processors in various electronic devices (hereinafter referred to as embedded devices) equipped with processors.
[0004]
  Here, as a virtual machine, an interpreter type that is constructed in software on a platform and sequentially interprets and executes bytecode instructions included in a class file is known.
[0005]
  However, an interpreter-type virtual machine requires a process of extracting byte code instructions one by one from a class file and interpreting the contents, and this process may become a system overhead. In order to reduce such overhead and improve performance, a JIT compiler (Just In Time Compiler) method in which a class file is compiled into native code specific to each hardware and then executed, or an AOT compiler (Ahead Of Time) Compiler) method has been proposed. Furthermore, an attempt has been made to construct a virtual computer in hardware like a Java (R) chip specially designed to directly execute bytecode instructions.
[0006]
  The compiler system such as JIT or AOT executes the native code of the processor, and is superior to the interpreter system if only the instruction execution speed is considered. However, since the compiler method requires a work memory necessary for the compilation work itself and an area for storing native code that is 4 to 10 times larger than the class file, a larger amount of memory than the interpreter method is required. There is a problem that is necessary.
[0007]
  Such a problem becomes prominent particularly in an embedded device in which hardware resources are more restrictive than a normal computer. In addition, when the compilation is started after instructing the execution of the class file, there is a possibility that the compilation work becomes an overhead and sufficient performance cannot be obtained.
[0008]
  In addition, according to the above-mentioned Java (R) chip, it is possible to execute a class file with high performance without compiling, but the development of such a dedicated chip requires a high development cost, The cost of the chip itself cannot be avoided. Moreover, in view of the fact that language specifications are upgraded and modified appropriately according to technological progress and market needs, it is not always preferable to configure a virtual machine in hardware. In particular, for a virtual machine in an embedded device, it is not practical to adopt a Java (R) chip due to a strong demand for cost reduction and a specification upgrade in a short cycle.
[0009]
  As described above, techniques such as the compiler method and Java (R) chip have problems in terms of cost, required hardware resources, and the like, and it is particularly difficult to apply them to embedded devices with severe restrictions. For this reason, it is desired to improve the performance of a virtual machine or an intermediate code execution system by another method with a view to being applied to an embedded device.
[0010]
[Problems to be solved by the invention]
  The present invention has been made in view of the above circumstances, and it is possible to improve the performance at the time of executing the intermediate code by performing the preprocessing, and the intermediate code execution in which such preprocessing is incorporated.SystemThe purpose is to provide.
[0011]
[Means for Solving the Problems]
  In order to solve the above problems, in the first aspect of the present invention, intermediate code obtained by compiling source code created in a predetermined programming languageIntermediate code execution systemInA plurality of intermediate code execution means for executing the intermediate code and the intermediate code are stored, and a correspondence relationship between an instruction included in the intermediate code and the intermediate code execution means appropriate for efficient execution of the instruction is stored. Storage means and intermediate code analysis means, wherein the intermediate code analysis means a) a process for specifying an instruction included in the intermediate code stored in the storage means, b) the specified instruction and the Based on the correspondence relationship, a process for specifying an intermediate code execution unit suitable for efficient execution of the intermediate code, and c) a process for recording the relationship between the intermediate code and the specified intermediate code execution unit Intermediate code characterized by Execution systemProvided byIs done.
[0012]
  The present inventionThe first1According to the above aspect, the intermediate code execution system is provided with a plurality of intermediate code execution means, and the correspondence between the instructions included in the intermediate code and the intermediate code execution means appropriate for efficient execution thereof is stored in the storage means. In addition, the intermediate code is analyzed by the intermediate code analysis means, and based on the correspondence stored in the storage means, the intermediate code execution means suitable for efficient execution of the intermediate code is specified and recorded. The execution system can identify the optimum intermediate code execution means for each intermediate code.
[0013]
  Therefore,According to a first aspect of the invention,It is possible to execute intermediate code using intermediate code execution means suitable for the intermediate code to be executed, thereby improving the performance at the time of executing the intermediate code by utilizing each of the plurality of intermediate code execution means. be able to.
[0014]
  First of the present invention2In this aspect, the correspondence between the instruction in the storage means and the intermediate code execution means suitable for efficient execution of the instruction is the score of the processing efficiency when each instruction is executed by each of the intermediate code execution means. B2) including a table, and b1) a process of obtaining a score of processing efficiency when each of the intermediate code execution means executes the specified instruction based on the score table; and b2) A process of summing the acquired scores for each intermediate code execution means; and b3) a process of specifying the intermediate code execution means used for execution of the intermediate code based on the scores totaled for each intermediate code execution means. It can be set as the structure containing.
[0015]
  Further, the correspondence between the instruction in the storage means and the intermediate code execution means suitable for efficient execution of the instruction includes the value of the point assigned to each instruction and the point corresponding to each of the intermediate code execution means And b2) a process for obtaining the point of the specified instruction based on the correspondence, and b2) a process for obtaining the total value of the acquired point. And b3) a process for specifying the intermediate code execution means used for executing the intermediate code based on the correspondence and the obtained total value.
[0016]
  First of the present invention3In the intermediate code execution system for executing intermediate code obtained by compiling source code created in a predetermined programming language, general intermediate code execution means capable of executing all instructions and some instructions A special intermediate code execution means capable of executing only the intermediate code, a storage means storing the intermediate code, and an intermediate code analysis means, wherein the intermediate code analysis means a) stores the intermediate code stored in the storage means Analyzing and determining whether the instruction included in the intermediate code does not include an instruction that cannot be executed by the special intermediate code execution unit; and b) when determining that the instruction that cannot be executed is not included, The fact that the intermediate code is to be executed by the special intermediate code execution means is recorded, and when it is determined that the inexecutable instruction is included, the intermediate code is stored in the one intermediate code. The intermediate code execution system and executes a process of recording should be performed in the intermediate code execution means.
[0017]
  First of the present invention3In the intermediate code execution system having general intermediate code execution means that can execute all instructions and special intermediate code execution means that can execute only a part of the instructions, the intermediate code to be executed is special. Depending on whether or not an instruction that can be executed by the intermediate code execution means is included, it is recorded which of the general intermediate code execution means and the special intermediate code execution means should be executed.
[0018]
  Therefore,According to a third aspect of the present invention,In an intermediate code execution system to which special intermediate code execution means specialized for only some instructions are added, it is possible to use general intermediate code execution means and special intermediate code execution means separately. Performance can be improved.
[0019]
  First of the present invention4In an intermediate code execution system for executing an intermediate code obtained by compiling a source code created in a predetermined programming language by an interpreter method, a storage unit storing the intermediate code and a storage unit storing the intermediate code Preprocessing means for performing processing for replacing the specific instruction pattern included in the intermediate code with the alternative instruction previously associated with the specific instruction pattern, and interpreting and executing the alternative instruction A first interpreter that cannot perform the analysis, a second interpreter that can interpret and execute the substitute instruction in the same content as the instruction pattern before replacement, and the intermediate code processed by the preprocessing means The intermediate code determines whether or not the alternative instruction is included, and if the intermediate instruction includes the alternative instruction, Intermediate code analysis means for recording that the intermediate code should be executed by the first interpreter, and for recording the intermediate code that should be executed by the second interpreter when the substitute instruction is not included; An intermediate code execution system is provided.
[0020]
  First of the present invention4According to this aspect, preprocessing means for performing preprocessing for replacing a specific instruction pattern with an alternative instruction, a first interpreter corresponding to the alternative instruction, a second interpreter not corresponding to the alternative instruction, and an intermediate In the configuration including the code analyzing means, the intermediate code after the preprocessing is analyzed by the intermediate code analyzing means, and the intermediate code in which the specific instruction pattern is replaced with the alternative instruction in the preprocessing is executed by the first interpreter. What is to be recorded is recorded, and what is to be executed by the second interpreter is recorded for intermediate code that has not been replaced even after preprocessing.
[0021]
  Therefore,According to a fourth aspect of the invention,The intermediate code can be executed with high performance by effectively utilizing the configuration including the preprocessing means, the first interpreter, and the second interpreter.
[0022]
  First of the present invention5In terms of the above, in an intermediate code execution system that executes an intermediate code obtained by compiling a source code created in a predetermined programming language by an interpreter system, it interprets and executes all instructions generated by the compilation A first subsystem having a first interpreter capable of performing the processing, a preprocessing unit for performing a preprocessing for replacing an instruction pattern made up of a plurality of instructions included in the intermediate code with an alternative instruction, and an instruction before the replacement of the alternative instruction A second interpreter having a second interpreter that can be interpreted and executed with substantially the same content as the code, and the first subsystem in the first subsystem depending on the intermediate code to be executed. The intermediate code is executed by the interpreter of the second subsystem and the intermediate processing is executed by the preprocessing unit in the second subsystem Intermediate code execution system is provided which is characterized by comprising a selector for selecting either the process to be executed by the second interpreter from pretreated to over de.
[0023]
  First of the present invention5In particular, the first subsystem having a normal interpreter, preprocessing means for replacing a specific instruction pattern with an alternative instruction, and execution of intermediate code preprocessed by the preprocessing means The second subsystem having the second interpreter is used according to the intermediate code to be executed..
[0024]
  Thereby, according to the fifth aspect of the present invention,Performance when executing intermediate code can be improved.
[0025]
  First of the present invention5In the above aspect, the second subsystem assigns an alternative instruction to the operation code to which the specific instruction is assigned in the first subsystem, and the selection unit assigns the specific instruction to the intermediate code to be executed. Configuration in which processing by the first subsystem is selected when an instruction is included, and processing by the second subsystem is selected when the specific instruction is not included in an intermediate code to be executed It can be.
[0026]
  First of the present invention6In an aspect of the present invention, there is provided an intermediate code execution system that executes an intermediate code obtained by compiling a source code created in a predetermined programming language, and includes a first instruction pattern including a plurality of instructions included in the intermediate code. A pre-processing unit that performs pre-processing for replacing with a first substitute instruction, and a first interpreter that can interpret and execute the first substitute instruction with substantially the same content as the instruction code before replacement A pre-processing unit that performs pre-processing to replace the second instruction pattern included in the intermediate code with a second alternative instruction, and an instruction code before replacing the second alternative instruction Depending on the intermediate code to be executed, a second subsystem having a second interpreter that can be interpreted and executed in substantially equivalent content, and in the first subsystem Select one of processing to execute intermediate code by the first interpreter and processing to be executed by the second interpreter after preprocessing the intermediate code by the preprocessing unit in the second subsystem An intermediate code execution system is provided.
[0027]
  First of the present invention6According to the above aspect, a sub-process having a pre-processing unit that replaces a specific instruction pattern with an alternative instruction and an interpreter specialized for execution of intermediate code that has been pre-processed by the pre-processing unit is configured with different instruction patterns. In the intermediate code execution system having two systems for alternative instructions, the performance during execution of the intermediate code can be improved by properly using the intermediate code for executing the two systems of subsystems..
[0028]
  First of the present invention6In this aspect, the first subsystem assigns the first substitute instruction to the first operation code, and the second subsystem assigns the second substitute instruction to the second operation code. The selecting unit selects processing by the second subsystem when the intermediate code to be executed includes an instruction related to the first opcode, and the intermediate code to be executed includes an instruction related to the second opcode. In such a case, the processing by the first subsystem can be selected.
[0029]
  In each of the above viewpoints, an “instruction pattern” is a set of predetermined instructions. The “alternative instruction” refers to an instruction that is replaced with the instruction pattern, and is an original instruction that is expressed by a code shorter than the instruction pattern and executed in an execution environment corresponding to the alternative instruction.
[0030]
DETAILED DESCRIPTION OF THE INVENTION
  Hereinafter, embodiments of the present invention will be described with reference to the drawings.
[First Embodiment]
  First, with reference to FIGS. 1 to 4, the intermediate code preprocessing apparatus according to the first embodiment of the present invention will be described in detail.
  FIG. 1 shows a hardware configuration of an intermediate code preprocessing apparatus 1 according to the first embodiment that preprocesses a Java (R) class file as an intermediate code.
[0031]
  The intermediate code preprocessing apparatus 1 includes a storage unit 101, a processing unit 102, and an input unit 103. The processing unit 102 is an arithmetic device such as an MPU or a microcontroller. The number of the processing units 102 is not limited to one, and may be configured such that distributed processing can be performed by a plurality of MPUs or a plurality of types of arithmetic devices.
[0032]
  The input unit 103 inputs a class file or the like to the intermediate code preprocessing apparatus 1. The class file input from the input unit 103 is stored in the storage unit 101. The storage unit 101 includes a memory such as a RAM or a ROM. Here, for convenience of explanation, only one storage unit 101 is illustrated, but a configuration in which a plurality of storage units are arranged in a distributed manner may be used.
[0033]
  The predetermined area of the storage unit 101 stores a table in which an instruction pattern 101a composed of a plurality of instructions and an alternative instruction 101b are associated with each other, and further stores a class file 101c. Here, the instruction pattern 101a is a pattern composed of a plurality of bytecode instructions.
[0034]
  Hereinafter, for example, a case where addition of integers is performed will be described as an example. In this case, methods included in the Java (R) class file include, for example, FIG. As shown in FIG. 3, the command patterns “iload”, “iload”, and “iadd” may occur frequently. Therefore, in the intermediate code preprocessing device 1 according to the first embodiment, the storage unit 101 stores a table in which an instruction pattern that frequently appears in this manner is associated with an alternative instruction that performs processing similar to the instruction pattern, for example, “v_v_iadd”. Store. Here, “iload” is a mnemonic representation of an intermediate code consisting of 2 bytes that pushes the value of a local variable onto the operand stack. “Iadd” is a mnemonic description of a 1-byte intermediate code that pops and adds two values from the operand stack and pushes the result onto the operand stack.
[0035]
  The alternative instruction 101b is an instruction that is interpreted in the same process as the instruction pattern 101a in an environment where the alternative instruction 101b can be executed. In other words, the present embodiment is premised on the existence of an intermediate code execution system capable of interpreting and executing the substitute instruction 101b substantially equivalent to the instruction pattern before replacement. For example, in such a case, such an intermediate code execution system interprets the alternative instruction “v_v_iadd” into a process similar to the instruction pattern “iload”, “iload”, and “iadd” and executes it. When executing such an alternative instruction, it is desirable to minimize the overhead factor in executing the instruction by preventing frequent memory access, omitting redundant processing, utilizing a register, and the like.
[0036]
  The alternative instruction 101b has a shorter code length than the instruction pattern 101a. For example, the substitute instruction “v_v_iadd” has a code length of 3 bytes and is shorter than 5 bytes which is the code length before replacement.
[0037]
  Therefore, according to such preprocessing, the size of the class file 101c can be reduced.
[0038]
  The present embodiment mainly corresponds to the invention described in claim 1 or 15, wherein the storage unit 101 corresponds to a storage unit in the invention, and the processing unit 102 corresponds to a processing unit. .
[0039]
  In the configuration as described above, by executing a series of software programs by the processing unit 102, each function of the intermediate code preprocessing device 1 is realized, and the preprocessing as described below is performed on the class file 101c.
[0040]
  FIG. 2 is a flowchart for explaining the pre-processing procedure in the present embodiment. Here, it is assumed that the class file 101 c is input from the input unit 103 to the intermediate code preprocessing apparatus 1 and stored in the storage unit 101 in advance. Under this premise, processing is performed in the following procedure.
[0041]
  That is, when the intermediate code preprocessing is started (S101), the processing unit 102 reads the table of the instruction pattern 101a and the alternative instruction 101b associated with each other from the storage unit 101 (S102). Next, the processing unit 102 searches the class file 101c and specifies the instruction pattern 101a (S103). That is, for example, as shown in FIGS. 3 and 4, a series of instruction patterns 101a of “iload”, “iload”, and “iadd” are specified in the class file 101c. When the command pattern is specified in this way, the processing unit 102 replaces the command pattern 101a in the specified class file 101c with a substitute command 101b associated with the command pattern 101a (S104).
[0042]
  FIG. 4 is a diagram for specifically explaining an example of the processing in S104. In this example, “iload 8”, “iload 9”, and “iadd” included in the specified instruction pattern are first converted to “nop”, “nop”, and “v_v_iadd8, 9” (first stage). Here, “nop” is an instruction that does nothing. As described above, inserting a plurality of “nops” before “v_v_iadd 8, 9” does not change the size of the class file to be converted, and does not change the jump destination of the conditional branch included in the class file. Because. After performing the first stage process, the process of deleting “nop” is performed while changing the jump destination of the conditional branch (second stage). Thereby, the process of S104 is completed.
[0043]
  As described above, the intermediate code preprocessing ends (S105).
[0044]
  According to the intermediate code pre-processing device according to the first embodiment, the length of the code to be executed by the series of processes described above is determined from the total 5-byte code of “iload”, “iload”, and “iadd”. v_v_iadd ”is shortened to one instruction of 3 bytes. Therefore, it is possible to reduce the number of instructions to be executed, omit redundant processing between instructions, and reduce the size of the class file.
[0045]
  The intermediate code obtained in this way is equivalent to the instruction pattern 101a before the replacement of the alternative instruction 101b in the execution environment corresponding to the alternative instruction 101b such as “v_v_iadd”, and minimizes overhead factors such as memory access. By interpreting and executing the processing, it can be executed at high speed. In addition, the preprocessing of intermediate code as described above is a simple code replacement, so it can be executed with low overhead, and does not increase the size of the class file as when compiling to native code. Therefore, the performance of intermediate code execution can be improved significantly.
[0046]
  For example, when the first embodiment is applied to an embedded device such as a mobile phone, an execution environment capable of executing the above-described alternative instruction 101b is mounted on the embedded device, and the intermediate code preprocessing device 1 performs the preprocessing. The class file may be preinstalled or distributed to the embedded device. By doing in this way, the performance of the Java (R) application executed on the embedded device can be improved.
[0047]
  In addition, an execution environment capable of executing the above-described preprocessing device 1 and the alternative instruction 101b is installed in the embedded device, and both the preprocessing of the class file and the execution of the preprocessed class file are performed on the mobile phone. You may do it.
[0048]
  In the first embodiment, a table in which the instruction pattern 101a and the alternative instruction 101b are associated with each other is stored in the storage unit 101. Such a table is embedded in a software program for performing preprocessing. It is also possible to use a configuration that is independent of a software program for performing preprocessing.
[0049]
  In the pre-processing procedure described above, the processing in S104 is not limited to that shown in FIG. For example, after the first stage process shown in FIG. 4, the second stage process is not performed, and “nop” may not be deleted. In such a case, the intermediate code including “nop” may be executed in the execution environment as it is, or the class file is deleted while deleting “nop” and changing the jump destination of the conditional branch in the execution environment. May be executed. In particular, in the latter case, it is preferable to perform the above-described preprocessing by using an idle time for the execution environment.
[0050]
[Second Embodiment]
  Next, an intermediate code execution system according to the second embodiment of the present invention will be described in detail with reference to FIGS.
  FIG. 5 shows a hardware configuration of the intermediate code execution system 2 according to the second embodiment of the present invention that executes a Java (R) class file as intermediate code. The intermediate code execution system 2 includes a storage unit 201, a processing unit 202, and an input unit 203. The storage unit 201, the processing unit 202, and the input unit 203 are substantially the same as the storage unit 101, the processing unit 102, and the input unit 103 of the intermediate code preprocessing device 1 according to the first embodiment. The instruction pattern 201a, the alternative instruction 201b, and the class file 201c stored in the storage unit 201 are stored in the storage unit 101 of the intermediate code preprocessing apparatus 1 according to the first embodiment. 101b and substantially the same as the class file 101c. Therefore, the duplicate description about these is omitted here.
[0051]
  Note that this embodiment mainly corresponds to the invention described in claim 3 or 17, wherein the storage unit 201 corresponds to the storage unit in the invention, and the processing unit 202 corresponds to the processing unit. .
[0052]
  In the configuration as described above, each function of the intermediate code execution system 2 is realized by executing a series of software programs by the processing unit 202, and pre-processing is performed on the class file 201c as described below. The processed class file 201c is executed.
[0053]
  FIG. 6 is a flowchart for explaining the preprocessing and execution procedure of the class file 201c in the present embodiment. This procedure is based on the premise that the class file 201c input in advance from the input unit 203 is stored in the storage unit 201, as in the first embodiment.
[0054]
  First, preprocessing of the intermediate code is started (S201), and the processing unit 202 reads a table of instruction patterns 201a and alternative instructions 201b associated with each other from the storage unit 201 (S202). Next, the processing unit 202 searches the class file 201c to identify the instruction pattern 201a (S203). Then, the processing unit 202 replaces the specified instruction pattern 201a with the substitute instruction 201b (S204), and the intermediate code pre-processing ends (S205). Since the above processing is the same procedure as the preprocessing in the first embodiment, detailed description thereof is omitted.
[0055]
  Next, the pre-processed class file 201c is executed as described above. Here, a software program that constitutes an interpreter capable of interpreting and executing the substitute instruction 201b with the same content as the instruction pattern 201a is executed, whereby the processing unit 202 receives instructions from the class file 201c stored in the storage unit 201. Is extracted (S206), and processing corresponding to the extracted instruction is executed by the processing unit 202 (S207).
[0056]
  According to the intermediate code execution system 2 according to the second embodiment, the preprocessing for replacing the instruction pattern 201a with the alternative instruction 201b is performed on the class file 201c by the procedure as described above, and the intermediate code subjected to this preprocessing is performed. Can be executed. Therefore, it is possible to execute intermediate code in which the code length of the class file 201c is shortened and redundant processing between instructions is omitted, thereby improving the performance during execution of the intermediate code. Furthermore, when executing pre-processed intermediate code, it is possible to further improve the performance during execution of the intermediate code by interpreting and executing the alternative instruction as processing that minimizes overhead factors such as memory access. is there.
[0057]
  The procedure shown in FIG. 6 shows the case where the preprocessing and the execution of the class file are performed continuously. However, the preprocessing and the execution of the class file do not necessarily have to be performed continuously. Alternatively, pre-processing may be performed, and the class file subjected to the pre-processing may be executed after a certain time.
[0058]
  Further, the instruction pattern 201a associated with the alternative instruction 201b is not limited to one type, and may be two or more types. In such a case, when the preprocessing and the class file execution are successively performed according to the procedure shown in FIG. 6, in order to start the class file execution with as little preprocessing overhead as possible. Alternatively, only a part of the instruction patterns 201a associated with the alternative instruction 201b may be subjected to preprocessing for replacement with the alternative instruction.
[0059]
  Furthermore, the performance of the MPU and microcontroller constituting the processing unit 202 varies depending on the device on which the intermediate code execution system 2 is mounted, and the time margin required for preprocessing and the processing capacity of the device system depending on the situation. There are also changes. Therefore, when there are a plurality of instruction patterns associated with alternative instructions, how many instruction patterns are to be replaced may be statically adjusted according to the characteristics and situation of the device. By doing in this way, the pre-processing according to the characteristic and condition of the apparatus in which the intermediate code execution system 2 is mounted can be realized. For example, when the intermediate code execution system 2 of the present invention is installed in a mobile phone, only a part of the command pattern is replaced when the class file downloaded to the mobile phone is immediately executed, and when the class file is not immediately executed. You may make it adjust so that all the command patterns may be replaced. By doing so, it is possible to execute the class file on the mobile phone while performing preprocessing according to the situation.
[0060]
[Third Embodiment]
  Next, an intermediate code execution system according to the third embodiment of the present invention will be described in detail with reference to FIGS.
  FIG. 7 is a diagram schematically showing an intermediate code execution system 100 according to the third embodiment of the present invention that executes a Java (R) class file as intermediate code. The intermediate code execution system 100 includes a calculation unit 5 including an MPU or a microcontroller and a storage unit 10 connected to the calculation unit 5.
[0061]
  The calculation unit 5 constitutes an intermediate code analysis unit 20 and intermediate code execution units 30A, 30B, and 30C by executing a predetermined software program. Such a software program may be stored in the storage unit 10 or may be stored in another storage unit.
[0062]
  The intermediate code execution units 30A, 30B, and 30C each function as an interpreter that sequentially interprets and executes the intermediate code. These intermediate code execution units 30A, 30B, and 30C are of different types from each other. For example, the intermediate code execution unit 30A is fast in processing the bytecode instruction F but is slow in processing the bytecode instruction G, and the intermediate code execution unit B is fast in processing the bytecode instruction G but slow in processing the bytecode instruction F. The intermediate code execution unit C seems to have an average processing speed for any bytecode instruction.
[0063]
  Further, the intermediate code analysis unit 20 analyzes the property of the method included in the class file 12 stored in the storage unit 10, selects the intermediate code execution unit 30 according to the property, and selects the method and the selected intermediate code. Processing to record the combination with the code execution unit 30 is performed. The processing performed by the intermediate code analysis unit 20 will be described in detail later.
[0064]
  The storage unit 10 includes a RAM, a ROM, and the like, and stores a class file 12 and a correspondence relationship database 13. The storage unit 10 may have a physically single configuration or a plurality of configurations.
[0065]
  The class file 12 is generated by compiling a source code file created in the Java (R) language, and includes one or more methods. This method is a collection of a plurality of bytecode instructions for realizing a specific process. The correspondence database 13 is a database that manages the processing efficiency score of each bytecode instruction in each of the intermediate code execution units 30A, 30B, and 30C.
[0066]
  The present embodiment mainly corresponds to the invention described in claim 4. The intermediate code execution units 30A, 30B, and 30C correspond to the intermediate code execution means in the invention, and the storage unit 10 stores the storage means. The intermediate code analysis unit 20 corresponds to intermediate code analysis means.
[0067]
  FIG. 8 is a data structure diagram showing an example of specific contents of the correspondence relationship database 13. As shown in FIG. 8, the correspondence database 13 stores the processing efficiency score of each bytecode instruction in each of the intermediate code execution units 30A, 30B, and 30C. Here, the score of the processing efficiency is a value obtained by quantifying how efficiently the bytecode instruction can be executed, and such a score is 40A, 30B, 30C of each intermediate code execution unit. It is preferable to define in advance according to the specifications. The data structure shown in FIG. 8 mainly corresponds to the invention described in claim 5.
[0068]
  For example, at the top of FIG. 8, the processing efficiency score is defined in each of the intermediate code execution units 30A, 30B, and 30C of the bytecode instruction a. Specifically, the score of the processing efficiency in the intermediate code execution unit 30A of the bytecode instruction a is 90, the score of the processing efficiency in the intermediate code execution unit 30B is 10, and the score of the processing efficiency in the intermediate code execution unit 30C is 10 (Here, the higher the value, the better the efficiency). Therefore, according to such a correspondence database 13, it can be seen that it is most efficient that the byte code instruction a is executed by the intermediate code execution unit 30A. Similarly, the processing efficiency score in each of the intermediate code execution units 30A, 30B, and 30C is defined in the correspondence database 13 for the bytecode instructions b and c and all the other bytecode instructions. . Note that the processing efficiency score table according to claim 5 is stored in the correspondence database 13.
[0069]
  Hereinafter, with reference to a flowchart of FIG. 9, a procedure of processing executed by the intermediate code analysis unit 20 of the intermediate code execution system 100 according to the third embodiment will be described. First, the intermediate code analysis unit 20 reads a method from the class file 12 in the storage unit 10 (S301). Next, the intermediate code analysis unit 20 analyzes the read method and specifies a bytecode instruction included in the method (S302). Since one method includes a plurality of byte code instructions, the intermediate code analysis unit 20 repeats a procedure for individually specifying the plurality of byte code instructions included in the method.
[0070]
  Next, the intermediate code analysis unit 20 inquires the correspondence database 13 in the storage unit 10, acquires the processing efficiency score corresponding to each byte code instruction specified in S102, and sums them (S303).
[0071]
  Thereafter, the intermediate code analysis unit 20 can execute the class file 12 most efficiently based on the total score of the processing efficiencies in each of the intermediate code execution units 30A, 30B, and 30C obtained in S303. A code execution unit is specified (S304). More specifically, the intermediate code analysis unit 20 may compare the total score for each intermediate code execution unit, and identify the one with the highest total score as the intermediate code execution unit used for executing the method. .
[0072]
  Finally, the intermediate code analysis unit 20 records that the method should be executed by the intermediate code execution unit 30 specified in S304 (S305). Specifically, for example, the type of the intermediate code execution unit 30 to be executed may be recorded in the management information held for each method, or the intermediate code execution unit 30 to be executed for the method. The type may be marked. The above operation is executed for all methods included in the class file 12, and the intermediate code analysis unit 20 ends the processing.
[0073]
  Hereinafter, the contents of the processing in S303 and S304 will be described more specifically, taking the correspondence database 13 shown in FIG. 8 as an example. Assuming that the method includes byte code instructions a and d, the intermediate code analysis unit 20 has a processing efficiency score of 90 in the intermediate code execution unit 30A of the byte code instruction a, and the intermediate code execution unit 30B. 10 is obtained as the score of the processing efficiency in, and 10 as the score of the processing efficiency in the intermediate code execution unit 30C. Next, the intermediate code analysis unit 20 performs processing efficiency score 50 of the byte code instruction d in the intermediate code execution unit 30A, 40 processing efficiency score in the intermediate code execution unit 30B, and processing efficiency in the intermediate code execution unit 30C. The degree score of 90 is acquired and added to the score of the bytecode instruction a.
[0074]
  In this case, the total score of processing efficiency in the intermediate code execution unit 30A is 140, the total score in the intermediate code execution unit 30B is 50, and the total score in the intermediate code execution unit 30C is 100. Therefore, the intermediate code analysis unit 20 specifies that the intermediate code execution unit 30A is used to execute the method. By performing the processing as described above, the intermediate code execution system 100 executes the method included in the class file 12 based on the content recorded by the intermediate code analysis unit 20 when executing the method included in the class file 12. It becomes possible to use the most efficient intermediate code execution unit 30A, 30B or 30C determined according to the instruction. Therefore, according to the third embodiment, it is possible to efficiently execute the methods included in the class file 12 by utilizing the intermediate code execution units 30A, 30B, and 30C having different characteristics. An execution system 100 is provided.
[0075]
[Fourth Embodiment]
  Next, the intermediate code execution system according to the fourth embodiment of the present invention will be described in detail with reference to FIGS.
  The intermediate code execution system according to the fourth embodiment has the same basic configuration as that of the third embodiment. However, in the intermediate code execution system according to the fourth embodiment, the intermediate code analysis unit 20 obtains a total value of scores uniquely determined for each byte code instruction included in the method, and sets the rank of the total value. Accordingly, it is different from the third embodiment in that any one of the intermediate code execution units 30A, 30b, and 30C is specified. The present embodiment mainly corresponds to the invention described in claim 6.
[0076]
  Hereinafter, this point will be described in detail. In the intermediate code analysis unit 20, in order to realize the above-described specifying method, the correspondence database 13 in the fourth embodiment includes each bytecode instruction as shown in FIG. 10 and the score of each bytecode instruction. A table for defining the correspondence relationship and a table for defining the correspondence relationship between the total score range and the intermediate code execution units 30A, 30B, and 30C as shown in FIG. 11 are included.
[0077]
  Among these, the former will be described based on the example of FIG. 10. The left side of FIG. 10 shows each byte code instruction, and the right side of FIG. 10 shows the score value set corresponding thereto. Here, the score of the bytecode instruction a is uniquely set to 40, the score of the bytecode instruction b is 90, and the score of the bytecode instruction c is 55. The latter will be described based on the example of FIG. 11. The left side of FIG. 11 shows the range of the total score, and the right side of FIG. 11 shows the intermediate code execution unit specified corresponding to the range of the total score. One of 30A, 30B, and 30C is shown. Here, the intermediate code execution unit 30A is specified when the total score corresponding to the bytecode instructions included in a certain method belongs to a range less than 201. Similarly, the intermediate code execution unit 30B is set to be specified when the total score is 201 or more and less than 401, and the intermediate code execution unit 30C is set to be specified when the total score is 401 or more.
[0078]
  The basic procedure of processing executed by the intermediate code analysis unit 20 in the fourth embodiment is almost the same as that in the third embodiment. That is, as shown in FIG. 7, the intermediate code analysis unit 20 reads a method from the class file 12 of the storage unit 10 (S101), specifies a bytecode instruction included in the method (S102), and stores it in the correspondence database 13 The score corresponding to each bytecode instruction specified by inquiry is acquired and summed (S103). After that, the correspondence relation database 13 is again inquired to identify the intermediate code execution unit corresponding to the total score (S104), and the fact that the method should be executed by the identified intermediate code execution unit is recorded (S105), and the process is terminated. To do.
[0079]
  Hereinafter, the contents of the processing in S103 and S104 will be described in detail using the correspondence database 13 shown in FIGS. 10 and 11 as an example. Assuming that the method includes byte code instructions a and c, the intermediate code analysis unit 20 acquires 40 as the score of the byte code instruction a and 55 as the score of the byte code instruction c. The total value is 95 (ST103). The intermediate code analysis unit 20 calculates the total value and FIG. 11, the intermediate code execution unit 30A is identified as being used for executing the method.
[0080]
  In the fourth embodiment that performs the processing as described above, as in the third embodiment, the most efficient intermediate code execution unit 30A, 30B, or 30C determined according to the bytecode instruction included in the method is used. Therefore, the intermediate code execution system 100 with extremely high performance is provided.
[0081]
[Fifth Embodiment]
  Next, an intermediate code execution system according to the fifth embodiment of the present invention will be described in detail with reference to FIGS.
  FIG. 12 is a diagram schematically illustrating an intermediate code execution system 200 according to the fifth embodiment of the present invention. The intermediate code execution system 200 has the same basic configuration as the third and fourth embodiments, but the third and fourth embodiments have a general intermediate code execution unit 31 and a special intermediate code execution unit 32. Is different.
[0082]
  In this intermediate code execution system, the general intermediate code execution unit 31 and the special intermediate code execution unit 32 execute the class file 12. The general intermediate code execution unit 31 is an interpreter that sequentially interprets and executes a class file, and has a normal function of executing all bytecode instructions. On the other hand, the special intermediate code execution unit 32 can execute a specific byte code instruction at a higher speed than the general intermediate code execution unit 31, but some instructions (for example, byte code instructions related to floating point arithmetic) ) Is a special interpreter that cannot execute.
[0083]
  The correspondence database 13 in the fifth embodiment has a data structure for identifying whether or not each bytecode instruction can be executed by the special intermediate code execution unit 32 for each bytecode instruction. .
[0084]
  The present embodiment mainly corresponds to the invention described in claim 7, wherein the special intermediate code execution unit 32 corresponds to the special intermediate code execution means in the invention, and the general intermediate code execution unit 31 is a general The storage unit 10 corresponds to intermediate code execution means, the storage unit 10 corresponds to storage means, and the intermediate code analysis unit 20 corresponds to intermediate code analysis means.
[0085]
  Hereinafter, with reference to a flowchart of FIG. 13, a procedure of processing executed by the intermediate code analysis unit 20 of the intermediate code execution system 200 according to the fifth embodiment will be described. First, the intermediate code analysis unit 20 reads a method from the class file 12 in the storage unit 10 (S201). Next, the intermediate code analysis unit 20 analyzes the read method, specifies a bytecode instruction included in the method (S202), and the specified bytecode instruction cannot be executed by the special intermediate code execution unit 32. Whether it is a code command or not is determined based on the contents of the correspondence database 13 (S203). If it is determined in S203 that the special intermediate code execution unit 32 does not include an inexecutable bytecode instruction, the intermediate code analysis unit 20 determines that the special intermediate code execution unit 32 should execute the method. Record (S204). On the other hand, when it is determined in S203 that the special intermediate code execution unit 32 includes a bytecode instruction that cannot be executed, the intermediate code analysis unit 20 records that the method should be executed by the general intermediate code execution unit 31 ( S205). The recording method may be the same as in the third and fourth embodiments. The above operation is executed for all methods included in the class file 12, and the intermediate code analysis unit 20 ends the processing.
[0086]
  According to the fifth embodiment as described above, a specific bytecode instruction can be executed at a high speed, but a part of the bytecode instructions cannot be executed, and all instructions are executed. The intermediate code execution system that can execute a specific bytecode instruction at a high speed and can execute all the bytecode instructions by using the general intermediate code execution unit 31 that can be used for each method. 200 is provided.
[0087]
[Sixth Embodiment]
  Next, an intermediate code execution system according to the sixth embodiment of the present invention will be described in detail with reference to FIG.
  The intermediate code execution system 300 according to the sixth embodiment executes a Java (R) class file as intermediate code. As shown in FIG. 14, the intermediate code execution system 300 is a method that is virtually configured by executing a predetermined program by a storage unit 301 that mainly stores a class file 302 and a processing unit (not shown). It comprises an analysis unit 307, a first subsystem 308, and a second subsystem 310.
[0088]
  The class file 302 stored in the storage unit 301 is obtained by compiling a source code created in the Java (R) language. This class file 302 includes methods 303 to 305.
[0089]
  The class file 302 is distributed in the form of a compressed jar file and may be decompressed by the intermediate code execution system 300. The jar file is an archive file in which class files necessary for operating the Java (R) program are combined. However, in FIG. 14, the class file is already stored in the storage unit 301.
[0090]
  The first subsystem 308 has a first interpreter 309. The first interpreter 309 can sequentially interpret and execute the bytecode instructions included in the Java (R) class file. The first interpreter 309 is a normal instruction code set corresponding to all of the bytecode instructions generated by compiling the instruction code set generated at the time of compilation, that is, the source code created in the Java (R) language here. It is an interpreter.
[0091]
  On the other hand, the second subsystem 310 includes a preprocessing unit 311 having a configuration and functions substantially the same as those of the intermediate code preprocessing device described above, and a second interpreter 312. As described above, the pre-processing unit 311 replaces a specific byte code instruction pattern with a corresponding alternative instruction so as to replace the instruction pattern “iload”, “iload”, “iadd” with “v_v_iadd”, for example. Processing is applied to each method of the class file 302. Further, the second interpreter 312 is configured to be able to interpret and execute an alternative instruction added to the method after replacement in order to correspond to the method subjected to the processing in this way.
[0092]
  More specifically, replacing a specific instruction pattern with an alternative instruction in the pre-processing unit 311 converts the combination of an operation code and an operand forming the specific instruction pattern into a newly defined set of an operation code and an operand of the alternative instruction. It means to replace. The operation code represents the operation of the instruction, and the operand represents the stack, register, or the like that is the target of the instruction.
[0093]
  However, in the case of Java (R), the length of the operation code is limited to 1 byte, so the number of operation codes cannot be increased freely. Therefore, in the sixth embodiment, an alternative instruction is assigned to an operation code to which another instruction is normally assigned, and the execution code is interpreted as an alternative instruction at the time of execution, which is substantially the same as that formed by the instruction pattern before replacement. Make sure you follow the steps.
[0094]
  That is, in the sixth embodiment, for example, an alternative instruction is assigned to an operation code to which a floating point arithmetic instruction is assigned in a normal byte code instruction. Then, in the second interpreter 312, the operation code is interpreted and executed in the same procedure as that of the instruction pattern before replacing the operation code with the substitute instruction.
[0095]
  As described above, in the second subsystem 310, the method can be executed by the second interpreter 312 after being preprocessed by the preprocessing unit 311. However, in the above-described example, the second subsystem 310 cannot execute a method including a floating point arithmetic instruction.
[0096]
  The method analysis unit 307 analyzes an instruction included in the method to be executed, and selects whether to execute the method in the first subsystem 308 or the second subsystem 310 according to the instruction. The result is then marked on the method. That is, the function of the method analysis unit 307 in the sixth embodiment corresponds to the function of the intermediate code analysis unit 20 in the fifth embodiment.
[0097]
  The present embodiment mainly corresponds to the invention described in claims 9 to 14, wherein the storage unit 301 corresponds to a storage unit in the invention, the preprocessing unit 311 corresponds to a preprocessing unit, and The first and second interpreters 309 and 310 correspond to first and second interpreters, and the method analysis unit 307 corresponds to intermediate code analysis means or a selection unit.
[0098]
  Next, a procedure for executing the method 303 included in the class file 312 by the intermediate code execution system 300 having the above configuration will be described. First, the method analysis unit 307 analyzes an instruction included in the method 303. For example, as described above, in the second subsystem 310, when the operation code of the alternative instruction is assigned to the operation code of the floating-point operation instruction, it is determined whether or not the method 303 includes a floating-point operation instruction. Then, from the result, a subsystem to be used for executing the method 303 is marked at a predetermined position 306 of the method 303.IeIf it is determined that the method 303 includes a floating point arithmetic instruction, it is selected to be executed by the first subsystem 309. If it is determined that the method 303 does not include a floating point arithmetic instruction, the method 303 is selected to be executed by the second subsystem 310.
[0099]
  When it is selected to be executed by the first subsystem 309, the method 303 is sequentially interpreted and executed by the first interpreter 309 as it is.
[0100]
  On the other hand, when it is selected to be executed by the second subsystem 310, the preprocessing unit 311 performs preprocessing on the method 303, and replaces a certain pattern formed by a plurality of instructions included in the method 303 with an alternative instruction. . Thereafter, the second interpreter 312 corresponding to the substitute instruction is sequentially interpreted and executed.
[0101]
  Then, when the execution of the method 303 is completed as described above, one of the methods 303 to 305 is sequentially executed according to the contents of the class file 302 until the program ends.
[0102]
  According to the configuration of the intermediate code execution system 300 and the method execution procedure according to the sixth embodiment, although some instructions cannot be executed, a specific instruction pattern included in the method is replaced with an alternative instruction and executed. By doing so, the second subsystem 310 that can execute the method at high speed without redundant processing between instructions can be executed, but all the instructions can be executed although the method execution speed is not increased. The class file can be executed with excellent performance by effectively operating the first subsystem 308.
[0103]
  The first to sixth embodiments can be variously modified. For example, in the first and second embodiments, preprocessing is performed in units of class files. However, in these embodiments, preprocessing may be performed in units of methods as in the sixth embodiment. Absent. Further, the data structure in the correspondence database 13 and the score setting there in the third and fourth embodiments are not limited to the above.
[0104]
  Further, instead of the combination of the first subsystem 309 and the second subsystem in the sixth embodiment, each has a pre-processing unit for replacing a specific instruction pattern with an alternative instruction and an interpreter capable of executing the alternative instruction. Two subsystems may be used. When such a combination of subsystems is used, both subsystems can be used properly by assigning alternative instructions to different operation codes in both subsystems. The number of subsystems may be three or more.
[0105]
  Furthermore, in the sixth embodiment, a case is shown in which preprocessing is performed when a method is executed in the second subsystem 310. However, for a method that has been executed once, by storing the preprocessed method in the storage unit 301. The preprocessing may be omitted. Alternatively, all methods may be analyzed by the method analysis unit 307 during class loading, and pre-processing may be performed in advance for methods that are to be executed by the second subsystem 310. Furthermore, preprocessing may be performed at the time of compilation.
[0106]
  In a situation where it is difficult to allow memory consumption or overhead in the analysis by the method analysis unit 307 or the preprocessing by the preprocessing unit 311, the first subsystem 308 executes the method by omitting these. Also good. Furthermore, in the sixth embodiment, as an example, a case where an alternative instruction is assigned to an operation code to which a floating-point operation instruction is assigned has been described, but the present invention is not limited to this. An alternative instruction may be assigned to an opcode to which another instruction is assigned.
[0107]
  The first to sixth embodiments can be applied to intermediate code obtained by modifying a Java (R) class file, and even if it is a language other than Java (R), Anything can be applied as long as it is assumed that the code is executed in an intermediate code with the native code.
[0108]
  The first to sixth embodiments of the present invention have been described above. That is, according to the first and second embodiments, a predetermined instruction pattern is specified, and the specified instruction pattern is replaced with a substitute instruction that is a shortened code. Accordingly, it is possible to reduce the types of instructions and obtain a new intermediate code in which redundant processing between instructions is omitted. Moreover, the size of the intermediate code does not increase by this preprocessing. In addition, the preprocessing itself can be executed at high speed because only simple replacement is performed. Furthermore, the intermediate code can be executed at high speed by executing the obtained new intermediate code in the execution system corresponding to the alternative instruction.
[0109]
  According to the third embodiment, a plurality of intermediate code execution units are provided in the apparatus, and the intermediate code analysis unit analyzes the intermediate code to be executed so that it is suitable for efficient execution of the intermediate code. Select and record the intermediate code execution unit. Accordingly, by selecting the recorded intermediate code execution unit, the intermediate code can be executed at high speed. In addition, the correspondence relationship between each bytecode instruction included in the intermediate code and the score of the processing efficiency in each intermediate code execution means is stored, and based on this, an intermediate code execution unit used for execution of the intermediate code is specified. Therefore, it is possible to determine an appropriate intermediate code execution unit for efficient execution of bytecode instructions based on detailed settings in consideration of the properties of each intermediate code execution unit.
[0110]
  Further, according to the fourth embodiment, the correspondence relationship between each bytecode instruction included in the intermediate code and the processing efficiency score in the intermediate code execution unit, the range of the score, and the intermediate code execution unit specified in accordance with the score range, The intermediate code execution unit to be used for the execution of the intermediate code is specified based on these. Therefore, even when a large number of intermediate code execution units are prepared, it is possible to enjoy the advantage that it is not necessary to set and accumulate the processing efficiency score for each intermediate code execution unit.
[0111]
  According to the fifth embodiment, two types of intermediate code execution units, a special intermediate code execution unit and a general intermediate code execution unit, are provided, and the intermediate code including byte code instructions that cannot be executed by the special intermediate code execution unit. Only the general intermediate code execution unit is executed, while the other intermediate code is executed by the special intermediate code execution unit. Therefore, in the case where the intermediate code output unit is selected alternatively between the intermediate code execution unit specialized for specific processing and the intermediate code execution unit that can be used for general purposes, the intermediate code is executed. A system that can be realized at extremely high speeds can be provided.
[0112]
  According to the sixth embodiment, although a part of the instructions cannot be executed, a specific instruction pattern included in the method is replaced with an alternative instruction and executed, thereby performing redundant processing of the instruction question. The second subsystem that can execute the method at a high speed without the above and the first subsystem that can execute all the instructions, although the method execution is not accelerated, is effectively operated. Can execute class files with good performance.
[0113]
  The present invention is not limited to the first to sixth embodiments, and various improvements and changes can be made within the scope of the object. For example, in the third to fifth embodiments described above, a correspondence relationship between a bytecode instruction included in the intermediate code and the intermediate code execution unit appropriate for efficient execution of the bytecode instruction is stored in advance. did. However, the present invention is not limited to this, and the correspondence relationship may be changed according to the situation. Also, it is possible to increase the execution speed by realizing at least a part of the interpreter function with a hardware accelerator. Employing this hardware accelerator has various advantages such as an increase in memory requirement and a method suitable for an embedded device.
[0114]
【The invention's effect】
  According to the present invention, the intermediate code executed by the virtual machine is preprocessed to improve the execution speed, and can be suitably applied to an embedded device. The intermediate code can process the intermediate code at high speed. Code executionSystemCan be provided.
[Brief description of the drawings]
FIG. 1 is a block diagram showing a configuration of an intermediate code preprocessing apparatus according to a first embodiment of the present invention.
FIG. 2 is a flowchart for explaining a process of preprocessing intermediate code by the intermediate code preprocessing apparatus according to the first embodiment of the present invention;
FIG. 3 is a correspondence diagram for explaining the association between an intermediate code and an alternative instruction by the intermediate code preprocessing apparatus according to the first embodiment of the present invention;
FIG. 4 is a diagram for explaining each stage of a process of preprocessing an intermediate code by the intermediate code preprocessing apparatus according to the first embodiment of the present invention.
FIG. 5 is a block diagram showing a configuration of an intermediate code execution system according to a second embodiment of the present invention.
FIG. 6 is a flowchart for explaining processing by the intermediate code execution system according to the second embodiment of the present invention;
FIG. 7 is a block diagram showing a configuration of an intermediate code execution system according to a third embodiment of the present invention.
FIG. 8 is a data structure diagram of a correspondence database 13 employed by an intermediate code execution system according to a third embodiment of the present invention.
FIG. 9 is a flowchart showing an operation by the intermediate code analysis unit 20 in the intermediate code execution system according to the third embodiment of the present invention.
FIG. 10 is a data structure diagram of a correspondence database 13 employed by an intermediate code execution system according to a fourth embodiment of the present invention.
FIG. 11 is a data structure diagram of a correspondence database 13 employed by an intermediate code execution system according to a fourth embodiment of the present invention.
FIG. 12 is a block diagram showing a configuration of an intermediate code execution system according to a fifth embodiment of the present invention.
FIG. 13 is a flowchart showing an operation by the intermediate code analysis unit 20 employed by the intermediate code execution system according to the fifth embodiment of the present invention.
FIG. 14 is a block diagram showing a configuration of an intermediate code execution system according to a sixth embodiment of the present invention.
[Explanation of symbols]
  1 Intermediate code pre-processing device
  2 Intermediate code execution system
  5 Calculation unit
10 storage unit
12 class files
13 Correspondence D / B
20 Intermediate code analysis section
30 Intermediate code execution part
31 General intermediate code execution part
32 Special intermediate code execution section
101 storage unit
102 processing unit
103 Input section
201 Storage unit
202 processing unit
203 Input section

Claims (2)

所定のプログラム言語で作成されたソースコードをコンパイルして得られた中間コードを実行する中間コード実行システムにおいて、
前記中間コードを実行する複数の中間コード実行手段と、
前記中間コードを記憶すると共に、当該中間コードに含まれる命令と当該命令の効率的実行に適切な前記中間コード実行手段との対応関係を記憶した記憶手段と、
中間コード解析手段とを具備し、
前記中間コード解析手段が、
a)前記記憶手段に格納された中間コードに含まれる命令を特定する処理と、
b)特定された命令と前記対応関係とに基づいて、前記中間コードの効率的実行に適切な中間コード実行手段を特定する処理と、
c)前記中間コードと特定された中間コード実行手段との関係を記録する処理とを実行することを特徴とする中間コード実行システム。
In an intermediate code execution system that executes intermediate code obtained by compiling source code created in a predetermined programming language,
A plurality of intermediate code execution means for executing the intermediate code;
Storage means for storing the intermediate code, and storing a correspondence relationship between an instruction included in the intermediate code and the intermediate code execution means suitable for efficient execution of the instruction;
Intermediate code analysis means,
The intermediate code analyzing means is
a) processing for specifying an instruction included in the intermediate code stored in the storage means;
b) a process of identifying an intermediate code execution unit suitable for efficient execution of the intermediate code based on the identified instruction and the correspondence relationship;
c) An intermediate code execution system for executing a process of recording a relationship between the intermediate code and the specified intermediate code execution means.
前記記憶手段における命令と当該命令の効率的実行に適切な中間コード実行手段との対応関係は、各命令を前記中間コード実行手段のそれぞれで実行した場合の処理効率度のスコアテーブルを含み、
前記b)の処理は、
b1)前記スコアテーブルに基づいて、特定された命令を前記中間コード実行手段のそれぞれで実行した場合の処理効率度のスコアを取得する処理と、
b2)取得されたスコアを中間コード実行手段ごとに合計する処理と、
b3)中間コード実行手段ごとに合計されたスコアに基づいて、前記中間コードの実行に用いる前記中間コード実行手段を特定する処理と
を含むことを特徴とする請求項1に記載の中間コード実行システム。
The correspondence relationship between the instruction in the storage means and the intermediate code execution means suitable for efficient execution of the instruction includes a score table of processing efficiency when each instruction is executed by each of the intermediate code execution means,
The process of b)
b1) Based on the score table, a process for obtaining a score of the processing efficiency when the identified instruction is executed by each of the intermediate code execution means;
b2) a process of summing up the obtained scores for each intermediate code execution means;
2. The intermediate code execution system according to claim 1, further comprising: b3) a process of identifying the intermediate code execution unit used for executing the intermediate code based on the score totaled for each intermediate code execution unit. .
JP2002314986A 2001-10-31 2002-10-29 Intermediate code execution system Expired - Fee Related JP4234976B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2002314986A JP4234976B2 (en) 2001-10-31 2002-10-29 Intermediate code execution system

Applications Claiming Priority (5)

Application Number Priority Date Filing Date Title
JP2001-334825 2001-10-31
JP2001-334823 2001-10-31
JP2001334823 2001-10-31
JP2001334825 2001-10-31
JP2002314986A JP4234976B2 (en) 2001-10-31 2002-10-29 Intermediate code execution system

Publications (2)

Publication Number Publication Date
JP2003202995A JP2003202995A (en) 2003-07-18
JP4234976B2 true JP4234976B2 (en) 2009-03-04

Family

ID=27670249

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2002314986A Expired - Fee Related JP4234976B2 (en) 2001-10-31 2002-10-29 Intermediate code execution system

Country Status (1)

Country Link
JP (1) JP4234976B2 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100763177B1 (en) * 2005-04-21 2007-10-04 삼성전자주식회사 Method for executing Java virtual machine instructions, and apparatus for the same
JP5042487B2 (en) * 2005-11-22 2012-10-03 株式会社日立ソリューションズ Computer operating method, program, computer
JP6447219B2 (en) * 2015-02-18 2019-01-09 大日本印刷株式会社 Electronic information storage medium, application replacement method, program, and IC card
US9798527B1 (en) * 2017-01-06 2017-10-24 Google Inc. Loop and library fusion

Also Published As

Publication number Publication date
JP2003202995A (en) 2003-07-18

Similar Documents

Publication Publication Date Title
US7213237B2 (en) Intermediate code preprocessing apparatus, intermediate code execution apparatus, intermediate code execution system, and computer program product for preprocessing or executing intermediate code
EP1728155B1 (en) Method and system for performing link-time code optimization without additional code analysis
US8769511B2 (en) Dynamic incremental compiler and method
CN1134731C (en) Technology of reducing cost of primary examination to dynamic kinds in compiled codes
US7543285B2 (en) Method and system of adaptive dynamic compiler resolution
JP4018158B2 (en) Variable instruction set computer
US6766513B2 (en) Method and system of memory management using stack walking
EP1145120B1 (en) Generating compiled programs for interpretive runtime environments
JP4699580B2 (en) Method for static initialization of data processing system array, data processing method, and computer-readable storage medium storing data processing system and program for causing computer to execute control procedure thereof
KR100503077B1 (en) A java execution device and a java execution method
US6973644B2 (en) Program interpreter
KR20040081379A (en) Extreme pipeline and optimized reordering technique
US8056061B2 (en) Data processing device and method using predesignated register
EP1283465A2 (en) Transforming & caching computer programs
CN114816417B (en) Cross compiling method, device, computing equipment and storage medium
JP2001034483A (en) Numbering operational code for encoding metadata
US7739674B2 (en) Method and apparatus for selectively optimizing interpreted language code
JP4234976B2 (en) Intermediate code execution system
KR100597413B1 (en) Method for translating Java bytecode and Java interpreter using the same
WO2002091175A1 (en) Specialized heaps for creation of objects in object-oriented environments
US20010042241A1 (en) Apparatus and method for executing program using just-in time-compiler system
US7240341B2 (en) Global constant pool to allow deletion of constant pool entries
US7698534B2 (en) Reordering application code to improve processing performance
EP1481320B1 (en) Two tier clusters for representation of objects in java programming environments
Brandner et al. Embedded JIT compilation with CACAO on YARI

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20050810

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20080227

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20080513

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20080711

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20080819

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20081020

A911 Transfer of reconsideration by examiner before appeal (zenchi)

Free format text: JAPANESE INTERMEDIATE CODE: A911

Effective date: 20081023

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20081125

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20081212

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111219

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121219

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20131219

Year of fee payment: 5

LAPS Cancellation because of no payment of annual fees