JP2007233472A - Information processor, and control method and control program of information processor - Google Patents
Information processor, and control method and control program of information processor Download PDFInfo
- Publication number
- JP2007233472A JP2007233472A JP2006051166A JP2006051166A JP2007233472A JP 2007233472 A JP2007233472 A JP 2007233472A JP 2006051166 A JP2006051166 A JP 2006051166A JP 2006051166 A JP2006051166 A JP 2006051166A JP 2007233472 A JP2007233472 A JP 2007233472A
- Authority
- JP
- Japan
- Prior art keywords
- code
- native code
- native
- program
- order
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Withdrawn
Links
Images
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
Description
本発明は、中間コードで記述されたプログラムを実行するための仮想マシン技術に関するものである。 The present invention relates to a virtual machine technique for executing a program described in intermediate code.
従来から、中間コードにより記述されたプログラムを実行するための仮想マシン(Virtual Machine)技術が知られている。仮想マシン環境は逐次実行するインタプリタとして実現されることが多いが、一般的にインタプリタを用いたプログラムの実行処理速度は遅い。そこで、プログラムを構成する中間コードをネイティブコードに変換する(以下、コンパイルと呼ぶ)方法が用いられることがある。すなわち、プログラムを構成する中間コードを仮想マシンを実現しているCPUで直接実行可能なデータ形式に変換するのである。 Conventionally, a virtual machine technology for executing a program described by an intermediate code is known. The virtual machine environment is often realized as an interpreter that executes sequentially, but generally, the execution processing speed of a program using the interpreter is slow. Therefore, a method of converting intermediate code constituting the program into native code (hereinafter referred to as compilation) may be used. That is, the intermediate code constituting the program is converted into a data format that can be directly executed by the CPU that implements the virtual machine.
コンパイル方法としては、AOT(Ahead Of Time)コンパイルとJIT(Just In Time)コンパイルがある。AOTコンパイルでは、仮想マシンがプログラムをロードする前に前もってコンパイル処理がなされ前もってされる。つまり、ロードされる時点で既にネイティブコードになっている。一方、JITコンパイルでは、中間コードでプログラムをロードした後、実行時にネイティブコードにコンパイルする。そのため、コンパイル後の動作は速いものの、最初の実行時にはコンパイルの処理が必要なため必要な処理量が多くなる。 Compiling methods include AOT (Ahead Of Time) compilation and JIT (Just In Time) compilation. In the AOT compilation, a compilation process is performed in advance before the virtual machine loads a program. In other words, it is already native code when it is loaded. On the other hand, in JIT compilation, a program is loaded with intermediate code and then compiled into native code at the time of execution. Therefore, although the operation after compilation is fast, the amount of processing required increases because compilation processing is required at the first execution.
ところで、JITコンパイルの場合、たいていは、コンパイルされたネイティブコードはメモリ中に置かれ、当該プログラムを仮想マシン上で実行する時にのみ利用される。そして、プログラムの実行が終了した時、ネイティブコードは破棄(以降、デコンパイルと呼ぶ)される。従って、再度同じプログラムを動作させるときには、新たにプログラムの同じ部分をコンパイル処理する必要がある。 By the way, in the case of JIT compilation, the compiled native code is usually placed in a memory and used only when the program is executed on a virtual machine. When the execution of the program ends, the native code is discarded (hereinafter referred to as decompilation). Therefore, when the same program is operated again, it is necessary to newly compile the same part of the program.
その問題に対処するため、特許文献1には、コンパイルされたネイティブコードのプレロードクラスを生成し、次回の仮想マシンの起動時に再利用できる技術が提案されている。
しかしながら、コンパイルされたネイティブコードは中間コードに比較し容量が大きい。そのため、中間コードのプログラムに対応するネイティブコードを全てメモリ中に記憶する場合、膨大なメモリが必要になる。通常は、コンパイルされたネイティブコードの一時記憶用に確保されたメモリ領域(コードキャッシュとも呼ばれる)が一杯になると、たとえば実行頻度の少ないネイティブコードから順にコードキャッシュから破棄される。そして、新たにコンパイルされたネイティブコードのための空きメモリが確保される。そのため、プレロードクラスを出力しようとした時点で既にデコンパイルされてしまったネイティブコードはプレロードクラスの中に入れることができない。そのため、特許文献1に開示される技術には以下のような課題が存在する。すなわち、プレロードクラスの中に保存されるネイティブコードは、プレロードクラスを出力しようとした時点でコードキャッシュに記憶されているネイティブコードのみということである。 However, the compiled native code has a larger capacity than the intermediate code. Therefore, when all the native codes corresponding to the intermediate code program are stored in the memory, a huge amount of memory is required. Normally, when a memory area (also referred to as a code cache) reserved for temporary storage of compiled native code becomes full, the code cache is discarded from the code cache in order of execution frequency, for example. Then, a free memory for a newly compiled native code is secured. For this reason, native code that has already been decompiled when attempting to output the preload class cannot be included in the preload class. Therefore, the technique disclosed in Patent Document 1 has the following problems. In other words, the native code stored in the preload class is only the native code stored in the code cache when the preload class is output.
比較的性能の低いCPUを用いてプログラムの起動を高速化しようとしたとき、プログラムの起動に関する処理(以降、初期化処理と呼ぶ)を予めコンパイルしておくことが望ましい。しかし、初期化処理が大規模である場合、あるいは、コードキャッシュの容量が小さい場合は、上述したデコンパイルが発生してしまう。 When attempting to speed up program startup using a CPU with relatively low performance, it is desirable to compile in advance processing related to program startup (hereinafter referred to as initialization processing). However, when the initialization process is large-scale or when the code cache capacity is small, the above-described decompilation occurs.
特に、搭載メモリ容量が少ない機器では、必然的にコードキャッシュの容量も小さくなるので、JITコンパイラを利用した際のデコンパイルは避けられないものとなる。そのため、結果的にプログラムの起動時には毎回中間コードのコンパイルが必要となり初期化処理の高速化を実現することができない。 In particular, in a device with a small installed memory capacity, the capacity of the code cache is inevitably small, so that decompilation when using the JIT compiler is inevitable. Therefore, as a result, the intermediate code must be compiled every time the program is started, and the initialization process cannot be speeded up.
本発明は上記問題点に鑑みなされたものであり、中間コードで記述されたプログラムの初期化処理の高速化を実現可能な技術を提供することに有る。 The present invention has been made in view of the above problems, and it is an object of the present invention to provide a technique capable of realizing high-speed initialization processing of a program described in intermediate code.
上記課題を解決すべく、本発明の情報処理装置は以下の構成を備える。第1命令群に基づいて構成されたネイティブコードを実行するネイティブ環境と前記第1命令群とは独立に定義された第2命令群に基づいて構成された中間コードを実行する仮想マシン環境とを備え、少なくとも前記中間コードにより構成されるプログラムを記憶する記憶手段を備える情報処理装置において、プログラムを読み込み当該プログラムを構成する1以上のメソッドを逐次解釈するインタプリタ手段と、インタプリタ手段によりプログラムの起動時に実行されると解釈されたメソッドをネイティブコードに変換する変換手段と、変換手段により得られたネイティブコードをメソッドと関連付けて記憶手段に登録する登録手段と、メソッドを実行する際記憶手段に当該メソッドに対応するネイティブコードが登録されているか否かを確認しネイティブコードが登録されている場合には当該ネイティブコードを読み出しネイティブ環境で実行し、ネイティブコードが登録されていない場合にはメソッドを仮想マシン環境で実行するよう制御する制御手段と、を備える。 In order to solve the above problems, the information processing apparatus of the present invention has the following configuration. A native environment for executing native code configured based on a first instruction group, and a virtual machine environment for executing intermediate code configured based on a second instruction group defined independently of the first instruction group And an information processing apparatus comprising at least a storage means for storing a program composed of the intermediate code, an interpreter means for reading the program and sequentially interpreting one or more methods constituting the program, and when the program is started by the interpreter means A conversion means for converting a method interpreted to be executed into native code, a registration means for registering the native code obtained by the conversion means in association with the method in the storage means, and a method in the storage means when executing the method Whether the native code corresponding to is registered And a control unit that controls to read the native code when it is registered and execute it in the native environment, and to execute the method in the virtual machine environment when the native code is not registered. .
本発明によれば、中間コードで記述されたプログラムの初期化処理の高速化を実現可能とする技術を提供することができる。 ADVANTAGE OF THE INVENTION According to this invention, the technique which can implement | achieve high-speed of the initialization process of the program described by the intermediate code can be provided.
以下に、図面を参照して、この発明の好適な実施の形態を例示的に詳しく説明する。ただし、この実施の形態に記載されている構成要素はあくまで例示であり、この発明の範囲をそれらのみに限定する趣旨のものではない。 Hereinafter, exemplary embodiments of the present invention will be described in detail with reference to the drawings. However, the constituent elements described in this embodiment are merely examples, and are not intended to limit the scope of the present invention only to them.
(第1実施形態)
本発明に係る情報処理装置の第1実施形態として、Java(登録商標)仮想マシン(VM:Virtual Machine)を例に挙げて以下に説明する。Java(登録商標)VMは、Java(登録商標)における中間コードであるJava(登録商標)バイトコードで記述されたアプリケーションプログラムを実行する。
(First embodiment)
As a first embodiment of the information processing apparatus according to the present invention, a Java (virtual machine) virtual machine (VM) will be described below as an example. The Java (registered trademark) VM executes an application program described in Java (registered trademark) bytecode, which is an intermediate code in Java (registered trademark).
<装置構成>
図1は、第1実施形態に係る仮想マシンが動作している情報処理機器の内部構成を示すブロック図である。
<Device configuration>
FIG. 1 is a block diagram illustrating an internal configuration of an information processing device in which a virtual machine according to the first embodiment is operating.
情報処理機器100は、機器全体を制御するためのCPU101、各種制御プログラムを格納したROM102、プログラム実行中の一時記憶に用いるRAM103を備えている。そして、各種時間を計測するタイマ104、各種設定メニューなどを表示するディスプレイ105、音声の入力に用いるマイク106、音声出力に用いるスピーカ107を備える。また、各種操作ボタン108、各種設定ファイルなどを保存しておくための書き換え可能な不揮発性メモリであるFlashROM109、ネットワークを介して機器外部と接続するインタフェースであるネットワークI/F110、各種データファイルを保存しておくためのハードディスク111を備える。
The
<仮想マシン(VM)およびアプリケーションプログラムの構成と基本動作>
図2は、第1実施形態に係る仮想マシンの内部構成を示すブロック図である。なお、仮想マシン環境は、ネイティブ環境で動作する仮想マシンプログラムを実行することにより実現される。
<Configuration and basic operation of virtual machine (VM) and application program>
FIG. 2 is a block diagram illustrating an internal configuration of the virtual machine according to the first embodiment. The virtual machine environment is realized by executing a virtual machine program that operates in a native environment.
201はVM(仮想マシン)であり、220はVM201が実行するアプリケーションプログラム(以降、単にアプリケーションと呼ぶ)である。なお、アプリケーション220は1以上のクラス231から構成されている。なお、クラス231はJava(登録商標)バイトコード(以降、単にバイトコードと呼ぶ)で記述されている。さらに、クラス231はメソッド、フィールド、定数プール及びその他の情報から構成される。なお、メソッドとはクラスを構成している実行単位の命令のことを示している。
アプリケーション220には、バイトコードがコンパイルされた結果であるネイティブコード232と、使用順序及びデコンパイル順序についての情報が格納された順序情報233も併せて格納される。ただし、ネイティブコード232および順序情報233は、後述するアプリケーションの実行により、生成されるものであり、アプリケーション未実行時には存在しない。詳細は後述する。
The
また、アプリケーション220の格納場所としては、FlashROM109やハードディスク111の他、ROM102やRAM103でもよい。または、ネットワークI/F110を経由して不図示の外部機器からアプリケーション120を読み込むよう構成してもよい。なお、メモリ205は仮想マシンがRAM103内に確保した領域として実現されている。
Further, the storage location of the
なお、上述したようにアプリケーション220には、クラス231、ネイティブコード232、順序情報233は格納される。しかし、クラス231、ネイティブコード232、順序情報233は、全てまとまって一つの記憶媒体に格納されていなければならないということはない。つまり、図におけるアプリケーション120を示す矩形は、上記3つのデータが同じアプリケーション220に関連付けられていることを概念的に示しているだけである。
As described above, the
そのため、クラス231、ネイティブコード232、順序情報233は、実際には異なる記憶媒体に格納されていても良い。例えば、アプリケーション220がハードディスク111において、上記3つのデータが各々異なるファイルとして格納されるよう構成しても良い。あるいは、一般に変更が少ないクラス231はROM102上に記憶され、更新されうるネイティブコード232および順序情報233は書き換え可能な媒体であるFlashROM109に記憶されるようにしてもよい。
Therefore, the
VM201は、アプリケーションプログラム220を構成するクラス231を外部からロードするためのクラスローダ202を備える。そして、クラス231の中の実行単位であるメソッドを逐次解釈し実行するためのインタプリタ203を備える。さらに、中間コードをCPUのネイティブコードにコンパイルするJIT(Just In Time)コンパイラ(以降、単にコンパイラと呼ぶ)204を備える。
The VM 201 includes a
また、各種データを一時記憶するためのメモリ205、アプリケーション220のネイティブコード232をメモリ205にロードし、かつ、アプリケーション220の順序情報233をメモリ205に読み出すためのネイティブコードローダ210を備える。そして、メモリ205に格納されたネイティブコード232を外部に保存するためのネイティブコードセーバ211を備える。さらに、メモリ205の所定の場所に格納されたネイティブコード232を破棄するためのデコンパイラ212及びその他の制御部(以降ではVM201で総称する)を備える。
Further, a
メモリ205には、クラスローダ202がロードしたクラス206が一時記憶される。また、コンパイラ204がコンパイルしたメソッドであるネイティブコード207が一時記憶される。さらに、ネイティブコードローダ210がロードしたネイティブコード215および順序情報216が一時記憶される。そして、デコンパイラ212が破棄したネイティブコード217が一時記憶される。
The
図2においては、ネイティブコード207およびネイティブコード215は別々に表記してあるが、区別せずにメモリ205内の一つの領域で実現してもよい。なお、以下では、ネイティブコード207およびネイティブコード215が一時記憶される領域をコードキャッシュ218と呼ぶ。前述したように、コードキャッシュ218に置かれたネイティブコードはCPU101によって直接、実行可能なコードである。
In FIG. 2, the
デコンパイラ212はコードキャッシュ218中のネイティブコードを後述する条件のもとでコードキャッシュ218から破棄し、破棄したネイティブコードをデコンパイルしたネイティブコード217として記憶する。ただし、ネイティブコード217はCPUにより直接実行されることは無い領域に記憶される。
The
<アプリケーションプログラム実行時の仮想マシンの動作(ネイティブコード生成・登録)>
図3は、第1実施形態に係る仮想マシン上でアプリケーションを実行する際の動作フローチャートである。特に、ここでは、アプリケーションを最初に実行する際の動作について説明する。前述したように、アプリケーション120を最初に動作させるときは、クラス231のみ存在している。ここでは、主に、2回目以降の実行時に利用されるネイティブコード232および順序情報233の生成手順・登録手順を主に説明する。
<Virtual machine operation (native code generation / registration) during application program execution>
FIG. 3 is an operation flowchart when an application is executed on the virtual machine according to the first embodiment. In particular, here, the operation when the application is first executed will be described. As described above, when the application 120 is operated for the first time, only the
ステップS301では、ユーザによる操作ボタン108によるアプリケーション220の実行指示などに基づき、CPU101はVM201環境を動作開始する。例えば、CPU101がVM201環境を実現するためのVMプログラムを実行することにより実現される。
In step S301, the
ステップS302では、VM201は、ユーザにより指定されたアプリケーション220を開始する。このとき、クラスローダ202がクラス231をメモリ205にロードする。
In step S302, the
ステップS303では、VM201は、このアプリケーション220のネイティブコード232がロード可能か否か判断する。ここては、アプリケーション220のネイティブコード232は存在しないため、ステップS304に進む。なお、存在する場合の動作については後述する。
In step S303, the
ステップS304では、ステップS302でロードしたクラス206のバイトコードをインタプリタ203が解釈、実行する。あるいは、コンパイラ204がコンパイルしたネイティブコード(メソッド207)をCPU101が直接実行する。なお、インタプリタ203はクラス206を構成する1以上のメソッドの実行頻度(実行回数)の情報(不図示)をメモリ205の中に蓄積している。
In step S304, the
ステップS305では、VM201はアプリケーション220の初期化が完了したか否かを判断する。初期化が完了していなければステップS306に進み、完了したならばステップS316に進む。なお、アプリケーション220の初期化完了の判断は、初期化終了をVM201に通知するようなメソッド呼び出しを行ったか、あるいは、アプリケーション220の最初の表示画面を表示し終えたかというようなことから行うことができる。
In step S305, the
ステップS306では、ステップS302でロードしたクラス206内のメソッドのコンパイルを必要としているかどうかを調べる。前述の実行頻度情報に基づいて、実行頻度が高いと判断されると、そのメソッドはコンパイルが必要と判断される。なお、コンパイルが必要と判断されるのは実行頻度が高い場合に限らない。例えば、初期化が終了するまでに実行されるメソッドを全てコンパイルしてもよい。その際、1回目のアプリケーション220の初期化にはコンパイル処理を要するため、より多くの時間を必要とする。しかし、2回目以降のアプリケーション220の初期化には一切コンパイル処理が走らず、ネイティブコードがCPU101により直接実行されるため、より短い時間に収まる。コンパイルが必要であると判断された場合はステップS307に進み、必要でないと判断された場合は、ステップS304に戻る。
In step S306, it is checked whether the method in the
ステップS307では、VM201はコードキャッシュ218に空きがあるかどうかを調べる。すなわち、コードキャッシュ218の空き容量が、新たなメソッドをコンパイルして生成したネイティブコード207を格納するのに十分なものかどうかを判定する。コードキャッシュ218に空きがある場合ステップS313に進み、空きがない場合ステップS308に進む。
In step S307, the
ステップS308では、VM201はデコンパイルするネイティブコード(メソッド207)を決定する。なお、VM201は、コンパイルした後もメソッドの実行頻度情報を蓄積し続けており、実行頻度が低いメソッドがデコンパイル対象となる。
In step S308, the
ステップS309では、VM201は、現在のデコンパイル順序をデコンパイル順序553に記憶する。デコンパイル順序については図5を用いて後述するが、当該メソッドが何番目にデコンパイルされたかという順序を示し、VM201開始時(S301)に0に初期化される。
In step S309, the
ステップS310では、VM201は、デコンパイル順序の数字をインクリメントする。
In step S310, the
ステップS311では、デコンパイラ212は、デコンパイル対象メソッドのネイティブコードをコードキャッシュ218外の領域117にコピーする。なお、ここではデコンパイルされたネイティブコードをメモリ205の内部として説明するが、もちろん他の場所に格納しても良い。例えばハードディスク111上に格納しても良い。
In step S311, the
ステップS312では、デコンパイラ212はデコンパイル対象メソッドをコードキャッシュ218から破棄する。その後、ステップS307に戻って、コードキャッシュ218に十分空きができるまで、上述のステップ(S307〜S312)を繰り返す。
In step S312, the
なお、上述のステップ(S307〜S312)ではデコンパイル順序が重複してメソッドに付加されることはないが、重複させるよう構成しても良い。そのためには、ステップS310のインクリメント処理を行わなければ良い。このように構成することにより、同じデコンパイル順序が付加されたメソッドを後でまとめてデコンパイルするのが容易になる。 In the above steps (S307 to S312), the decompilation order is not duplicated and added to the method. For that purpose, the increment process of step S310 may not be performed. By configuring in this way, it becomes easy to collectively decompile methods to which the same decompile order is added later.
ステップS313では、コンパイラ204はコンパイルが必要になったメソッドのバイトコードをコンパイルしてネイティブコードを生成し、コードキャッシュ218に記憶する。なお、後でリロケータブルなネイティブコード232を生成するためにシンボル情報が必要であれば、ここでシンボル情報とネイティブコードからの参照情報を生成・記憶しておき、メモリ205の図示しない部分あるいは他の記憶媒体に格納しておくとよい。
In
ステップS314では、VM201は、現在の使用順序を使用順序552に記憶する。使用順序については図5を用いて後述するが、当該メソッドのネイティブコードが何番目に使用(実行)されたかという順序を示し、VM201開始時(S301)に0に初期化される。
In step S314, the
ステップS315では、VM201は、現在の使用順序の数字をインクリメントする。その後、ステップS304に戻る。
In step S315, the
ステップS316では、ネイティブコードセーバ211は、使用順序552およびデコンパイル順序553などに基づいて生成される順序情報216を順序情報233として登録する。詳しく述べると、まずネイティブコードセーバ211はメモリ205に蓄えられた各メソッドについてのメソッド情報551を走査し、使用順序552の若い方からソートし、メモリ205内に新たに順序情報216を作成する。
In step S316, the
ステップS317では、ネイティブコードセーバ211はコードキャッシュ218からネイティブコードを読み出し、ネイティブコード232として登録する。シンボル情報をメモリ205から読み出し、リロケータブルなコードとして合わせて保存するようにしても良い。
In step S 317, the
ステップS318では、デコンパイルされたネイティブコード217をネイティブコード232の中に追加保存する。
In step S 318, the decompiled
なお、上述の手順では初期化終了と判断された時点で、順序情報216およびネイティブコードの登録を行った。しかし、登録処理のタイミングは必要に応じて任意に決定してよい。例えば、ある特定の処理までの時間がかかるので、それまでの処理をネイティブコードを実行することで高速化を図りたい場合には、そのタイミングに達したときに保存を行うようにしてもよい。
In the above procedure, the
<データ構造>
図4は、ネイティブコードおよび順序情報の関係および内部構造(構造体)を説明する図である。なお、ネイティブコードおよび順序情報に関するデータフォーマットはVM201の外部及び内部において共通である。但し、ポインタデータ等の値については変化する。
<Data structure>
FIG. 4 is a diagram for explaining the relationship between the native code and the order information and the internal structure (structure). The data format related to the native code and order information is common outside and inside the
順序情報401は、その順序情報401が含むメソッドの数を示すメソッド個数402を含む。さらに、メソッド毎に、使用順序403、デコンパイル順序404、メソッド名ポインタ405、コードポインタ406、コード長407を含む。これらメソッド毎に存在するデータはメソッド個数402が示す個数分、存在する。さらに、メソッドの名前を示すテキストデータであるメソッド名413がメソッド個数402が示す個数分、連続する。なお、メソッド名413は可変長データである。データの終端はヌル文字で表される。
The order information 401 includes a
メソッド0のメソッド名ポインタ405には、メソッド名0 413の先頭を指すポインタが格納される。この値は、順序情報401の格納場所によって変わる。例えば、順序情報401がハードディスク111のファイルとして存在する場合、メソッド名ポインタ405にはメソッド名0 413先頭のファイル先頭からのオフセットが格納される。順序情報401がメモリ205の中に存在する場合、メソッド名ポインタ405にはメソッド名0 413先頭のアドレスが格納される。ネイティブコードローダ210が順序情報233を読み出して順序情報216としてメモリ205に格納する際、上述したようにメソッド名ポインタ405が書き換えられる。
In the method name pointer 405 of the method 0, a pointer indicating the head of the method name 0 413 is stored. This value varies depending on the storage location of the order information 401. For example, when the order information 401 exists as a file on the hard disk 111, the method name pointer 405 stores an offset from the beginning of the method name 0 413 at the beginning of the file. When the order information 401 exists in the
ネイティブコード451は、各メソッドに対応するネイティブコードである。ところで、ここに格納されるネイティブコードはリロケータブルである場合と、リロケータブルでない場合がある。なお、リロケータブルであるとはメモリ上の位置について再配置可能であることを意味する。 The native code 451 is a native code corresponding to each method. Incidentally, the native code stored here may be relocatable or not relocatable. Note that being relocatable means that it can be rearranged at a position on the memory.
コンパイラ204がバイトコードをネイティブコードに変換するとき、あるいは、ネイティブコードローダ210がネイティブコード232をロードするとき、ネイティブコード451はコードキャッシュ218中に置かれる。ただし、ネイティブコード451は、CPU101による直接実行を可能とするためアドレス解決がなされた非リロケータブルなコードである。一方、ネイティブコードセーバ211が登録するネイティブコード232は、コードキャッシュ218のどのアドレスにも配置可能とするために、リロケータブルなコードとなっている。
When the
順序情報401とネイティブコード451が共にハードディスク111上のファイルとして置かれる場合は、メソッド0のコードポインタ406には、ネイティブコード451中のメソッドコード0 452先頭のファイル先頭からのオフセットが格納される。また、メソッド0のコード長407には、メソッドコード0のバイトレングスが格納される。他のメソッドについても同様である。
When the order information 401 and the native code 451 are both placed as files on the hard disk 111, the method pointer 0 of the method code 0 452 in the native code 451 stores the offset from the beginning of the file. The
一方、順序情報401とネイティブコード451が共にメモリ205中に置かれる場合は、メソッド0のコードポインタ406には、ネイティブコード451中のメソッドコード0 452先頭アドレスが格納される。また、メソッド0のコード長407には、メソッドコード0のバイトレングスが格納される。
On the other hand, when both the order information 401 and the native code 451 are placed in the
ところで、ネイティブコード451がハードディスク111上のファイルとして置かれるか、メモリ205中に置かれるかで、メソッドコード452の長さが変わる場合がある。例えば、リロケータブルなネイティブコードの場合シンボル情報を含むため、非リロケータブルな場合に比べより長くなる。その場合は、ネイティブコード451がメモリ205に読み出されたときに、メソッドコード452自身の変更に基づき、コード長407に格納する値の更新がなされる。つまり、アドレス解決が済むとシンボル情報は不要になるので取り除かれ、コード長は短くなるからである。
Incidentally, the length of the
メモリ205に格納された順序情報401は図4ではメソッド0、1、...と並んでいるが、この並びは事前に使用順序403の昇順にソートされているものとする。また、メソッド毎に用意された使用順序403からコード長407までのデータは固定長サイズである。このようにすることによって、使用順序403の若い順にメソッドを選択する操作を高速に行うことができる。
The order information 401 stored in the
図5は、デコンパイル順序情報、デコンパイルメソッド情報及びメソッド情報のデータ内部構造(構造体)を説明する図である。いずれもメモリ205に一時記憶されるデータの構造を示す。
FIG. 5 is a diagram for explaining the data internal structure (structure) of decompile order information, decompile method information, and method information. Both show the structure of data temporarily stored in the
デコンパイル順序情報501は、デコンパイル順序の昇順に並べられたデータであり、その各々のデータはデコンパイル順序502とデコンパイルメソッドポインタ503から構成される。デコンパイル順序502には、デコンパイル順序404の値が格納される。ネイティブコードローダ210が順序情報233を読み出したとき、順序情報401がメモリ105に格納されると共に、順序情報401が有する全メソッドを走査し、デコンパイル順序404を調べ、デコンパイル順序404の若い方から並べていく。なお、デコンパイル順序404は重複することがあり得る、すなわち、同じデコンパイル順序404を持ったメソッドが複数存在し得る。デコンパイルメソッドポインタ503には、デコンパイル順序502に格納された値をデコンパイル順序として持つメソッドについて情報を格納した、デコンパイルメソッド情報531の先頭アドレスが格納される。
The
デコンパイルメソッド情報531のメソッド個数532には、同じデコンパイル順序を持つメソッドの個数が格納される。その後ろには、メソッド個数分のメソッドポインタ533が続く。メソッドポインタ533には、対応するメソッドについてのメソッド情報551の先頭アドレスが格納される。
The
メソッド情報551は各メソッドについての情報を格納したもので、多くのデータは順序情報401から持ってこられる。メソッド情報551は、実際にメソッドを実行した時点での使用順序を格納する使用順序552、実際にメソッドを実行した時点でのデコンパイル順序を格納するデコンパイル順序553が格納される。また、そのメソッドについてのメソッド名ポインタ405を格納したメソッド名ポインタ554が格納される。また、そのメソッドについてのコードポインタ406を格納したコードポインタ555が格納される。さらに、そのメソッドについてのコード長407を格納したコード長556が格納される。そして、デコンパイルされたネイティブコード217中のネイティブコードへのポインタを格納するデコンパイルドコードポインタ557が格納される。さらに、そのメソッドについての使用順序403を格納したロードされた使用順序558、及びそのメソッドについてのデコンパイル順序404を格納したロードされたデコンパイル順序559が格納される。
The
図5においては、各メソッドについての情報にどんなものがあるか分かりやすく示すために、あえて順序情報401と重複するデータをメソッド情報551中にも置いている。しかし、重複させなければならないということはない。もちろん、同じメソッドについての情報であるということで、両者をリンクさせ、重複したデータはどちらか一方にだけ持つようにしても良い。
In FIG. 5, data that overlaps with the order information 401 is also placed in the
<アプリケーションプログラム実行時の仮想マシンの動作(ネイティブコード読出による実行)>
図6は、第1実施形態に係る仮想マシン上でアプリケーションを実行する際の動作フローチャートである。2回目以降のアプリケーション実行においては、クラス231の他、ネイティブコード232及び順序情報233が保存・登録されている。ここでは、主に、ネイティブコード232および順序情報233を用いたアプリケーションの実行を主に説明する。なお、ここでは、前述したステップS303において、ネイティブコード232がロード可能と判断された後の手順について説明を行う。
<Virtual machine operation during execution of application program (execution by reading native code)>
FIG. 6 is an operation flowchart when an application is executed on the virtual machine according to the first embodiment. In the second and subsequent application executions, the
ステップS601では、ネイティブコードローダ210は順序情報233を読み出し、メモリ205中に順序情報216として記憶する。図4に示した通り、順序情報401は、予め使用順序の昇順にソートされているが、デコンパイル順序の昇順にはソートされていない。通常、使用順序とデコンパイル順序の間に関連性はないので、使用順序をキーにソートすればデコンパイル順序の順に並ぶことは無い。ただし、この場合、デコンパイル順序の若い順からメソッドを走査が実行しにくい。そこでネイティブコードローダ210は読み出した順序情報401を解析してデコンパイル順序の昇順にソートされたデコンパイル順序情報601のデータとデコンパイルメソッド情報631のデータを生成する。また、各メソッドについての情報であるメソッド情報651のデータも生成する。その際、使用順序403の値はロードされた使用順序558に格納される。デコンパイル順序404はロードされたデコンパイル順序559に格納される。
In step S <b> 601, the
なお、使用順序にしてもデコンパイル順序にしてもソート処理は後に行うメソッド探索処理を高速化するためであり、必須の処理ではない。そのため、ソート処理自体の時間がかかるのを避けたい、あるいは、消費メモリを少なくしたいということであればソート処理はしなくともよい。 Note that the sort process is for speeding up the method search process to be performed later, regardless of the order of use or the order of decompilation, and is not an essential process. Therefore, if it is desired to avoid the time required for the sorting process itself or to reduce the consumption memory, the sorting process may not be performed.
ステップS602では、ネイティブコードローダ210は、使用順序403の若い方からコードキャッシュ218がフルになるまでネイティブコード232をロードする。コードポインタ406に、目指すメソッドのネイティブコード232におけるオフセットが格納されており、コード長407に、目指すメソッドのネイティブコード232における長さが格納されている。そのため、ネイティブコード232中の個々のメソッドデータにアクセスできる。なお、ロードの際には、ネイティブコードローダ210はアドレス解決処理を行い、CPU101が直接実行可能な形式に変換する。また、コードポインタ406とコード長407をコードキャッシュ218におけるメソッドコード452に適合するように更新する。
In step S602, the
ステップS603では、VM201はアプリケーション220のコードを実行する。
In step S603, the
ステップS604では、VM201はアプリケーション120の初期化が完了したか否かを調べる。初期化が完了した場合については、図8を用いて後述する。初期化が完了していない場合はステップS605に進む。
In step S604, the
ステップS605では、VM201は、次のコード実行がメソッド呼び出しであり、かつ、そのメソッドのネイティブコードを実行すべきかどうかを判断する。Yesの場合はステップS606に進み、Noの場合はステップS603に戻る。
In step S605, the
ステップS606では、VM201は、メソッドのネイティブコードがコードキャッシュ218の中に存在するかどうかを調べる。コードキャッシュ218の中に存在する場合はステップS607に進み、無い場合はステップS611に進む。
In step S606, the
ステップS607では、メソッドが既に一度実行されたことのあるネイティブコードかどうかを調べる。実行されたことがある場合はステップS603に戻り、実行されたことのないメソッドの場合にはステップS608に進む。 In step S607, it is checked whether the method is a native code that has already been executed once. If the method has been executed, the process returns to step S603. If the method has not been executed, the process proceeds to step S608.
ステップS608では、VM201は現在の使用順序の番号を使用順序552に記憶する。
In step S608, the
ステップS609では、VM201は現在の使用順序の番号をインクリメントする。
In step S609, the
ステップS610では、使用順序ずれ評価ポイント702を更新する。使用順序ずれ評価ポイント702は、ステップS608で記憶された使用順序552とロードされた使用順序558のずれ状態を示すデータである。具体的には、ずれ状態を各メソッド毎に評価、点数化したものをVM201全体で加算したものである。例えば、単純に使用順序552とロードされた使用順序558の差の絶対値をそのメソッドのポイントとしてもよい。そして、そのポイントを現在の使用順序ずれ評価ポイントに加算することで更新処理とする。
In step S610, the use order
図7は、メモリ205上に置かれる図2に示したデータ以外のデータの例を示している。これらのデータはVM201に対し各々存在し、例えば、新たにコンパイルしたメソッドの数701、使用順序ずれ評価ポイント702、及びデコンパイル順序ずれ評価ポイント703がある。
FIG. 7 shows an example of data other than the data shown in FIG. These pieces of data exist for each
ステップS611では、VM201はメソッドのネイティブコードは登録先であるネイティブコード232の中に存在するかどうかを調べる。これは順序情報401を調べることによって判断される。必要とするメソッドが順序情報401の中にあれば、そのネイティブコードはネイティブコード232の中に存在する。存在する場合はステップS612に進み、存在しない場合はステップS616に進む。
In step S611, the
ステップS612では、VM201はコードキャッシュ218に十分な空き領域があるか否かを判断する。空きがある場合はステップS613に進み、無い場合はステップS620に進む。
In step S612, the
ステップS613では、VM201は使用順序が若い他のネイティブコードもロードすべきかどうかを判定する。なお、判定の基準となる情報は、VM201起動時あるいは他の方法による指定によって予め設定されている。例えば、起動するアプリケーション220が毎回同じで、かつ、アプリケーション220のコマンドオプションやコンフィギュレーションも同じである場合、VM201が実行するメソッドの順番も変わらないということはしばしば起こり得る。そのような場合、メソッドの使用順序は同じであるから、メソッドのネイティブコードを一つづつロードするよりも、まとめてロードした方が保存先にアクセスする回数、時間が減って高速化される。特に、FlashROM109、ネットワークI/F110、及びハードディスク111等へのI/Oアクセスは非常に時間がかかる処理なので、できるだけ回数を減らした方がよい。そのために、使用順序が若い他のネイティブコードもロードすべきと設定しておくのは有用である。他のコードもロードすべきと判断した場合はステップS615に進み、ロードしないと判断した場合はステップS614に進む。
In step S613, the
ステップS614では、VM201はステップS605で指定されたメソッドに対応するネイティブコードをロードする。その後、ステップS608に戻る。
In step S614, the
ステップS615では、順序情報401の中でまだロードしていないメソッドを使用順序403の若い方から順にコードキャッシュ218にロードする。もちろん、使用順序403の若い方から探索されるネイティブコードのロードは、コードキャッシュ218の容量に制限される。その後、ステップS608に戻る。
In step S615, the methods that have not yet been loaded in the order information 401 are loaded into the code cache 218 in order from the
ステップS620では、VM201は順序情報301の中にデコンパイル順序404があるかどうかを判断する。デコンパイル順序404がある場合はステップS621に進み、ない場合はステップS629に進む。なお、図3に示した手順ではデコンパイル順序を保存するよう構成したが、保存しなければならないということはない。その場合、ステップS620があることで、例えデコンパイル順序が保存されなくても動作することができる。
In step S620, the
ステップS621では、VM201はデコンパイル順序404の若い方からコードキャッシュ218中のネイティブコードを選択する。この若い方から選択する処理に、上述のデコンパイル順序情報601、デコンパイルメソッド情報631、及びメソッド情報651が用いられる。なお、同じ値のデコンパイル順を持つ複数のメソッドが存在する場合は複数のネイティブコードが選択される。
In step S621, the
ステップS622では、VM201は選択したネイティブコードの実行頻度は予め指定された頻度より低いかどうかを判断する。低い場合はステップS823に進み、高い場合はステップS830に進む。なお、ステップS621で複数のネイティブコードが選択されている場合は各々に対し判断される。
In step S622, the
ステップS623では、VM201は、現在のデコンパイル順序の番号をデコンパイル順序553に記憶する。
In step S623, the
ステップS624では、VM201は現在のデコンパイル順序の番号をインクリメントする。
In step S624, the
ステップS625では、デコンパイラ212は、デコンパイル対象メソッドのネイティブコードをコードキャッシュ218外の領域117にコピーする。
In step S625, the
ステップS626では、デコンパイラ212はデコンパイル対象メソッドをコードキャッシュ218から破棄する。
In step S626, the
ステップS627では、VM201はデコンパイル順序ずれ評価ポイント703を更新する。デコンパイル順序ずれ評価ポイント703は上述した使用順序ずれ評価ポイントと同様に評価され、ポイントが更新される。
In step S627, the
ステップS628では、VM201はコードキャッシュ218に十分な空きがあるか否かを確認する。十分な空きがある場合にはステップS613に戻り、無い場合にはステップS620に戻る。
In step S628, the
ステップS629では、VM201はデコンパイル順序404の実行頻度情報を参照してデコンパイル対象メソッドを決定する。以降はそのネイティブコードに対し前述のステップS623から始まるデコンパイル処理を行う。
In step S629, the
但し、ステップS627のデコンパイル順序ずれ評価ポイントの更新処理に関しては、このシーケンスの場合、ロードされたデコンパイル順序559が存在しない。そのため、デコンパイル順序553とロードされたデコンパイル順序559の差の絶対値を取るなどということはできない。従って、この場合の処理としては、例えばデコンパイル順序ずれ評価ポイント703を最大値に設定する。このようにすることで、後で必ずデコンパイル順序が保存されるようになる。なお、デコンパイル順序を保存しなくてよい場合はデコンパイル順序ずれ評価ポイント703を変化させないようにしてもよい。
However, with regard to the update processing of the decompilation order deviation evaluation point in step S627, in the case of this sequence, the loaded
ステップS630では、デコンパイル順序ずれ評価ポイント703は更新する。この場合、実際にデコンパイルされたわけではないので、デコンパイル順序553は有効な値が設定されていない。そのため、デコンパイル順序553とロードされたデコンパイル順序559の差の絶対値を取る操作は行えない。しかし、デコンパイル順序404(すなわち、ロードされたデコンパイル順序559)は若い値を示している。にもかかわらずデコンパイルすべきでないということは、やはりデコンパイル順序として異変があったとことを示している。
In step S630, the decompilation order deviation evaluation point 703 is updated. In this case, since the actual decompilation is not performed, a valid value is not set in the
そこで、ここでは、例えばある定数値からロードされたデコンパイル順序559の値を差し引いた値を加算することによりデコンパイル順序ずれ評価ポイント703を更新する。このようにすることにより、デコンパイル順序の若いネイティブコードほど、大きいずれとしてデコンパイル順序ずれ評価ポイント703に加算することができる。
Therefore, here, for example, the decompile order deviation evaluation point 703 is updated by adding a value obtained by subtracting the value of the
ステップS616では、コンパイラ204はコンパイルが必要になったメソッドのバイトコードをコンパイルしてネイティブコードを生成し、コードキャッシュ218に記憶する。
In
ステップS617では、VM201は現在の使用順序の番号を使用順序552に記憶する。
In step S617, the
ステップS618では、VM201は現在の使用順序の番号をインクリメントする。
In step S618, the
ステップS631では、VM201は使用順序ずれ評価ポイント702を更新する。ここでは新たなメソッドのコンパイルが必要になっているため、このメソッドに対しロードされた使用順序558は存在しない。従って、使用順序552とロードされた使用順序558の差の絶対値を取ることはできない。そこで、上述のデコンパイル順序ずれ評価ポイント703についての処理と同様に、使用順序ずれ評価ポイントを最大値に設定するなどの方法が考えられる。
In step S631, the
ステップS619では、新たにコンパイルしたメソッドの数701の数字をインクリメントする。その後、ステップS603に戻る。 In step S619, the number of newly compiled methods 701 is incremented. Thereafter, the process returns to step S603.
<アプリケーションプログラム実行後の仮想マシンの動作(ネイティブコードの更新)>
ところで、アプリケーションの初期化動作に必要なメソッドはパラメータの変更などにより変化する。つまり、同一のアプリケーションに対して、異なるネイティブコードが必要となることがある。以下では、そのような場合における仮想マシンの動作、特にネイティブコードの更新動作について説明する。
<Virtual machine operation after application program execution (update of native code)>
By the way, the method required for the initialization operation of the application changes due to a change of parameters or the like. In other words, different native codes may be required for the same application. In the following, the operation of the virtual machine in such a case, in particular, the native code update operation will be described.
図8は、第1実施形態に係る仮想マシン上でアプリケーションを実行する際の動作フローチャートである。図6の場合と同様、2回目以降のアプリケーション実行においては、クラス231の他、ネイティブコード232及び順序情報233が保存・登録されている。なお、ここでは、前述したステップS604において、アプリケーション220の初期化が完了したと判断された後の手順について説明を行う。つまり、以下の動作は、アプリケーション220が起動した後のタイミングで実行される動作である。
FIG. 8 is an operation flowchart when an application is executed on the virtual machine according to the first embodiment. As in the case of FIG. 6, in the second and subsequent application executions, the
ステップS801では、VM201はデコンパイル順序ずれ評価ポイント703が予め指定された値を超えたか否かを判断する。超えた場合はステップS802に進み、超えていない場合はステップS803に進む。
ステップS802では、VM201はデコンパイル順序553が設定されているメソッドについて、メモリ205中の順序情報401のデコンパイル順序404をデコンパイル順序553の値で更新する。
In step S801, the
In step S <b> 802, the
ステップS803では、VM201は使用順序ずれ評価ポイント702が予め指定された値を超えたか否かを判断する。超えた場合はステップS804に進み、超えていない場合はステップS805に進む。
In step S803, the
ステップS804では、VM201は使用順序552が設定されているメソッドについて、メモリ205中の順序情報401の使用順序403を使用順序552の値で更新する。
In step S804, the
ステップS805では、VM201は新たにコンパイルしたメソッドの数701が予め指定された数を超えたか否かを判断する。超えた場合はステップS806に進み、超えていない場合はステップS807に進む。
In step S805, the
ステップS806では、VM201は新たにコンパイルしたメソッドについて、順序情報401を作成する。
In step S806, the
ステップS807では、VM201はメソッド情報551を走査する。そして、ロードされた使用順序558がセットされているにも関わらず、使用順序552がセットされていないメソッド、つまりロードされたが使用されなかったメソッドの数が予め指定された数を超えたか否かを判断する。超えた場合はステップS808に進み、超えていない場合はステップS809に進む。
In step S807, the
ステップS808では、VM201は該当するメソッドに関する順序情報401を削除する。また、VM201は順序情報401を削除したメソッドは何かを記憶しておく。
In step S808, the
ステップS809では、VM201は順序情報401のコードポインタ406がファイルオフセットのままで、アドレスに変換されていないメソッドの数が予め指定された数を超えたか否かを判断する。つまり、順序情報401は読み出されたが、ネイティブコード232からそのネイティブコードは読み出されなかったメソッドの数が予め指定された数を超えたか否かを判断する。超えた場合はステップS810に進み、超えていない場合はステップS811に進む。なお、コードポインタ406がファイルオフセットかアドレスか区別がつかない場合は、順序情報401のメソッド毎にネイティブコードをロード済みか否か示す情報を追加し、それによって判断してもよい。
In step S809, the
ステップS810では、VM201はネイティブコード132を削除する。この場合は、ネイティブコード132を完全に入れ替えることになる。
In step S810, the
ステップS811では、VM201は、ステップS801、ステップS803、ステップS805、ステップS807、ステップS809のいずれかでYesになったか否かを判断する。つまり、順序情報401およびネイティブコードの何れか保存が必要になったかどうかを判断する。保存が必要でないと判断されれば、終了する。
In step S811, the
ステップS812では、VM201はステップS805またはステップS809でYになった、つまりネイティブコードの保存が必要になったかどうかを判断する。ネイティブコードの保存が必要になったと判断されればステップS813へ進み、ネイティブコードの保存が必要でないと判断された場合はステップS815に進む。
In step S812, the
ステップS813では、VM201は保存対象のネイティブコードのセットを生成する。なお、保存対象のネイティブコードはコードキャッシュ218あるいはデコンパイルされたネイティブコード217に記憶されている。このステップにより、非リロケータブルなネイティブコードはリロケータブルなネイティブコードになる。また、ネイティブコード451のように各メソッドが連続した領域に配置すると好適である。つまり、このように配置することにより、後述する保存が容易になる。
In step S813, the
ステップS814では、VM201は順序情報401中の各メソッドに関する情報を設定する。ここでコードポインタ406、コード長407はネイティブコード232として保存されるときに合わせて更新される。メソッド名ポインタ405も順序情報401が保存されるときに併せて更新される。
In step S814, the
ステップS815では、VM201は使用順序403の値で順序情報401のメソッド毎のデータ部分をソートする。
In step S <b> 815, the
ステップS816では、ネイティブコードセーバ211は順序情報401を順序情報233として保存する。
In step S816, the
ステップS817では、VM201はネイティブコードの全保存が必要かどうかを判定する。具体的には、ステップS810で保存先のネイティブコード232を削除した場合に全保存が必要と判定される。全保存が必要な場合はステップS818に進み、全保存が必要でない場合はステップS819に進む。
In step S817, the
ステップS818では、ネイティブコードセーバ211はネイティブコードをネイティブコード232に全保存して、終了する。
In step S818, the
ステップS819では、VM201はネイティブコードの追加が必要かどうかを判定する。具体的には、ステップS806で新たなメソッドの順序情報401を生成した場合、追加が必要と判定される。必要な場合はステップS820に進み、不必要な場合はステップS821に進む。
In step S819, the
ステップS820では、ネイティブコードセーバ211はステップS806で順序情報401を作成したメソッドのネイティブコードをネイティブコード232に追加する。
In
ステップS821では、VM201はネイティブコードの削除が必要かどうかを判定する。具体的には、ステップS808で順序情報401が削除されたメソッドがある場合、削除が必要と判定される。必要な場合はステップS822に進み、不必要な場合は終了する。
In step S821, the
ステップS822では、VM201はネイティブコード232からステップS808で記憶した削除対象メソッドについて、ネイティブコードを削除する。その後終了する。
In step S822, the
以上説明したように、第1実施形態の情報処理装置によれば、バイトコードで記述されたプログラムをより速く初期化完了することが可能となる。また、アプリケーション220の初期化完了後に初期化時のネイティブコードの利用状態に応じて更新処理を行うことにより、より効率的なネイティブコード232を保存することが可能となる。
As described above, according to the information processing apparatus of the first embodiment, it is possible to complete initialization of a program written in byte code more quickly. Further, by performing update processing according to the use state of the native code at the time of initialization after the initialization of the
すなわち、コードキャッシュのサイズが小さく、初期化処理の際にデコンパイル処理が避けられないような場合でも、デコンパイルされたコードが再利用でき、次回のプログラムの起動を高速化することが可能となる。従って、PCあるいは複写機や複合機といった比較的メモリ資源に余裕のある機器だけでは無く、パーソナルプリンタやデジタルカメラなどのメモリが少ないコンシューマ向け機器にも利用可能である。特に、コンシューマ向け機器では製造コストを抑えるため、中央演算処理装置などに必要最低限の性能のものが使用されており、本発明のような高速化技法は有効である。 In other words, even if the code cache size is small and decompilation is unavoidable during initialization, the decompiled code can be reused and the next program startup can be accelerated. Become. Therefore, it can be used not only for devices having a relatively large memory resource, such as PCs, copiers, and multifunction devices, but also for consumer devices with little memory, such as personal printers and digital cameras. In particular, in consumer equipment, in order to reduce manufacturing costs, a central processing unit having a minimum performance is used, and a high-speed technique such as the present invention is effective.
また、外部記憶装置に記憶されたコンパイル済みコードをコードキャッシュにロードしてプログラムを実行する場合、使用順序を参照しコードをロードすることにより効率の良いロードが可能となり高速化に寄与する。 Also, when the compiled code stored in the external storage device is loaded into the code cache and the program is executed, efficient loading is possible by referring to the order of use and loading the code, which contributes to speeding up.
(第2実施形態)
第2実施形態では、アプリケーション220毎にネイティブコード232および順序情報233の管理を行うことにより、複数のアプリケーションに対し、効率的なネイティブコードの管理を可能としている。なお、装置構成および、個々のアプリケーションに対する実行時の仮想マシン201の動作については第1実施形態と同様であるため、詳細な説明は省略する。
(Second Embodiment)
In the second embodiment, by managing the
<仮想マシン(VM)およびアプリケーションプログラムの構成>
図9は、複数のアプリケーションを実行する際のソフトウェア階層構造の概念図である。図9において、VM201の上でアプリケーション管理マネージャ901が動作しており、複数のアプリケーション220a〜cはアプリケーション管理マネージャ901により管理され実行される。
<Configuration of virtual machine (VM) and application program>
FIG. 9 is a conceptual diagram of a software hierarchical structure when a plurality of applications are executed. In FIG. 9, an
図10は、第2実施形態に係る仮想マシンの内部構成を示すブロック図である。なお、仮想マシン環境は、ネイティブ環境で動作する仮想マシンプログラムを実行することにより実現される。なお、図が煩雑になるのを避けるため、図10においては図2に比較しいくつか矢印を削除してある。以下では、図2に対して追加された部分について説明を行う。 FIG. 10 is a block diagram illustrating an internal configuration of the virtual machine according to the second embodiment. The virtual machine environment is realized by executing a virtual machine program that operates in a native environment. In order to avoid complication of the figure, some arrows are deleted in FIG. 10 compared to FIG. Below, the part added with respect to FIG. 2 is demonstrated.
アプリケーション管理マネージャ901は、インストーラ1001、アンインストーラ1002、実行開始指示部1003、停止指示部1004および初期化完了通知部1005を備えている。インストーラ1001は、1つ以上のアプリケーション220をインストール(登録)する機能を有する。アンインストーラ1002、インストールされているアプリケーション220をアンインストール(登録解除)する機能を有する。また、実行開始指示部1003は、アプリケーション220を指定し実行開始を指示する機能を有する。停止指示部1004は、実行中のアプリケーション220を指定し停止を指示する機能を有する。さらに、初期化完了通知部1005は、アプリケーション220の初期化完了をVM201に通知する機能を有する。
The
一方、VM201は、図2に示された各部に加え、ネイティブコード削除部1021、順序情報削除部1022、メモリ順序情報削除部1023および初期化終了検出部1024を備えている。ネイティブコード削除部1021は、ネイティブコード232を削除する機能を有する。順序情報削除部1022は、順序情報233を削除する機能を有する。メモリ順序情報削除部1023は、順序情報216の中にある各メソッドについての順序情報を削除する機能を有する。初期化完了検出部1024は、アプリケーション220の初期化完了を検出する機能を有する。
On the other hand, the
<アプリケーションのインストール(登録)および管理>
図11は、第2実施形態に係る仮想マシン上でアプリケーションを実行する際の動作フローチャートである。ここでは、アプリケーションとして220a、220bおよび220cの3つがROM102に記憶され、予めインストーラ1001によりアプリケーション管理マネージャ901に登録されているとする。なお、インストーラ1001による登録動作はアプリケーションの起動とは独立して行っても良いが、あるアプリケーションが最初に実行指示される際に自動的に登録動作がなされるように構成しても良い。
<Installation (registration) and management of application>
FIG. 11 is an operation flowchart when an application is executed on the virtual machine according to the second embodiment. Here, it is assumed that three
ステップS1101では、ユーザによる操作ボタン108によるアプリケーション220の実行指示などに基づき、CPU101はVM201環境を動作開始する。例えば、CPU101がVM201環境を実現するためのVMプログラムを実行することにより実現される。
In step S1101, the
ステップS1102では、VM201は、アプリケーション管理マネージャ901を開始する。
In step S1102, the
ステップS1103では、実行開始指示部1003は、既にインストールされたアプリケーション220a〜cの中から、ユーザにより指定されたアプリケーション220を選んで開始する。以下では、アプリケーション220aが選択されたものとして説明をする。
In step S1103, the execution
ステップS1104では、VM201はアプリケーション220aを実行開始する。具体的には、第1実施形態において、図3および図6を用いて説明した動作を行う。つまり、アプリケーション220aのネイティブコード232及び順序情報233のロード及び読み出し、順序情報401の更新処理等を行う。 ステップS1105では、アプリケーション220aの初期化が完了したか否かを判断する。完了していなければ、引き続き初期化動作を行う。完了した場合はステップS1106に進む。なお、初期化の完了は、例えば、初期化完了通知部1005によるVM201への通知、あるいは、初期化完了検出部1024による初期化完了の検出により実現される。
In step S1104, the
ステップS1106では、VM201は、アプリケーション220aのネイティブコード232および順序情報233を保存する。
In step S1106, the
ステップS1107では、VM201は、コードキャッシュ218に十分な空きがあるか否かを判断する。空きがある場合はステップS1114に進み、無い場合はステップS1108に進む。なお、このステップは第1実施形態で述べたステップ(例えば、S307)とは意味合いが異なる。つまり、ここでは、他のアプリケーション(220b、c)を起動するために必要なコードキャッシュ218に十分な空きがあるか否かを判断するのである。
In step S1107, the
ステップS1108では、VM201はデコンパイル対象と判定する実行頻度の基準を決定する。決定方法としてはユーザからの入力を受け付けるよう構成しても良いし、予め指定した初期パラメータ(不図示)を用いて決定しても良い。
In step S <b> 1108, the
ステップS1109では、VM201は、複数のアプリケーション220の中で、アプリケーション220aのクラス231のみが有するメソッドで、かつ、実行頻度が前述の実行頻度より低いものがあるか否かを判断する。低いものがない場合はステップS1110に進み、低いものがある場合はステップS1112に進む。
In step S <b> 1109, the
ステップS1110では、VM201は、複数のアプリケーション220間で共通に使用されるのメソッド(以降、共通メソッドと呼ぶ)でかつ、実行頻度が前述の実行頻度より低いものがあるか否かを判断する。低いものがない場合はステップS1111に進み、低いものがある場合はステップS1112に進む。ステップS1110をステップS1109と分けることにより、共通メソッドのデコンパイルの優先度を、アプリケーション220a固有のメソッドに比較し下げることが可能となる。
In step S1110, the
ステップS1111では、VM201はデコンパイル対象と判定する実行頻度の基準を上げる。その後、ステップS1109に戻る。ステップS1109〜ステップS1111のステップを繰り返すことによりにより、ステップS1109またはステップS1110によりデコンパイル対象となるメソッドが決定される。
In step S <b> 1111, the
ステップS1112では、デコンパイラ212はデコンパイル対象として選択されたメソッドのネイティブコードをデコンパイルする。これは第1実施形態で説明したデコンパイルと同様の処理である。ただし、デコンパイルされたネイティブコードは領域217にコピーはされない。なぜなら次回の起動に必要なネイティブコードは既にステップS1106で保存されているためコピーは必要ないからである。
In step S1112, the
ステップS1113では、メモリ順序情報削除部1023はデコンパイルしたメソッドの順序情報216を削除する。そしてステップS1107に戻る。
In step S1113, the memory order
ステップS1114では、VM201はアプリケーション120aのメソッド及び共通メソッドの順序情報(使用順序552及びデコンパイル順序553)を初期化する。次に起動するアプリケーション120a〜cの実行時に、古い順序情報が残らないようにするためである。
In step S1114, the
ステップS1115では、実行開始指示部1003は、既にインストールされたアプリケーション220a〜cの中から、ユーザにより指定された2つ目のアプリケーション220を選んで開始する。そして、2つ目のアプリケーション(例えば、220b)について、ステップS1103に戻り同様に処理を行う。
In step S1115, the execution
<アプリケーションのアンインストール(登録削除)>
図12は、第2実施形態に係る仮想マシン上でアプリケーションをアンインストールする際の動作フローチャートである。ここでは、アプリケーションとして220a、220bおよび220cの3つがROM102に記憶され、予めインストーラ1001によりアプリケーション管理マネージャ901に登録されているとする。
<Uninstall (delete registration)>
FIG. 12 is an operation flowchart when the application is uninstalled on the virtual machine according to the second embodiment. Here, it is assumed that three
ステップS1201では、ユーザによる操作ボタン108によるアプリケーション220の実行指示などに基づき、CPU101はVM201環境を動作開始する。例えば、CPU101がVM201環境を実現するためのVMプログラムを実行することにより実現される。
In step S1201, the
ステップS1202では、VM201は、アプリケーション管理マネージャ901を開始する。
In step S1202, the
ステップS1203では、アンインストーラ1002は例えばユーザにより指定されたアプリケーション(例えば220c)のアンインストールを開始する。具体的には、ショートカットの削除などアプリケーション220cを即座に起動できない状態にする。
In step S1203, the
ステップS1204では、ネイティブコード削除部1021はアプリケーション220cに対応するネイティブコード232cを削除する。
In step S1204, the native code deletion unit 1021 deletes the native code 232c corresponding to the
ステップS1205では、順序情報削除部1022はアプリケーション220cに対応する順序情報233cを削除する。
In step S1205, the order
以上のステップを経て、アプリケーション220cをインストールしていない状態に戻すのである。なお、停止指示部1004の指示によりネイティブコード削除部1021および順序情報削除部1022を動作させるようにしても良い。その場合、ネイティブコード232cおよび順序情報233cのみ削除され、ショートカットなどは削除されず、残すことが可能となる。
Through the above steps, the
<共通メソッドに対応するネイティブコードの保存>
前述したように、複数のアプリケーション220が存在する場合、2以上のアプリケーションに共通するメソッド(共通メソッド)が存在する場合がある。特に、第1実施形態で述べたように、初期化処理に対応したメソッドの場合共通メソッドの存在する確率は高いものとなる。
<Save native code corresponding to common methods>
As described above, when there are a plurality of
その場合、例えば、アプリケーション220aのネイティブコード232aとアプリケーション220bのネイティブコード232bに共通メソッドが存在しているとする。その場合、アプリケーション220aの初期化完了時、アプリケーション220bを初期化開始する場合、共通メソッドに対応するネイティブコード232bをさらにロードするのは効率が悪い。また、記憶領域に対する効率も悪いものになってしまうことになる。
In this case, for example, it is assumed that a common method exists in the
そこで、共通メソッドが存在する際には、当該メソッドに対応するネイティブコードは1つにまとめて登録するのが望ましい。そして、それぞれのアプリケーションに対応するコード領域には、共通コードの位置(ポインタ)のみを格納するように構成するとよい。 Therefore, when there is a common method, it is desirable to register the native codes corresponding to the method as one. And it is good to comprise so that only the position (pointer) of a common code may be stored in the code field corresponding to each application.
図13は、共通メソッドに対応するネイティブコードの保存形式を説明する図である。 FIG. 13 is a diagram for explaining the storage format of the native code corresponding to the common method.
1301は、アプリケーション220aのネイティブコード232aの内部構造を示している。また、1321は、アプリケーション220bのネイティブコード232bの内部構造を示している。アプリケーション220aに特有のメソッドに対応するネイティブコード1302は、ネイティブコード232aに直接格納されている。また、アプリケーション220bに特有のメソッドに対応するネイティブコード1322は、ネイティブコード232bに直接格納されている。
一方、アプリケーション220aおよびアプリケーション220bの共通メソッドに対応するネイティブコード1352は、共通ネイティブコード1351の内部に格納される。そして、ネイティブコード232aおよびネイティブコード232bの内部には、ネイティブコード1352に対するポインタのみ格納されている。
On the other hand, the native code 1352 corresponding to the common method of the
なお、共通ネイティブコード1351は、VM201からアクセスできる場所に記憶される。ただし、アプリケーション220a関連ネイティブコード1301およびアプリケーション220b関連ネイティブコード1321などと同じ場所に置く必要はない。
The
以上説明したように、第2実施形態の情報処理装置によれば、第1実施形態で述べた利点に加え、複数のアプリケーションを動作させる際により効率よくコードキャッシュを利用することが可能となる。その結果、初期化の高速化にも寄与することとなる。 As described above, according to the information processing apparatus of the second embodiment, in addition to the advantages described in the first embodiment, it is possible to use the code cache more efficiently when operating a plurality of applications. As a result, it also contributes to speeding up initialization.
また複数のアプリケーションに共通するメソッドについて、ネイティブコードを共用領域に記憶することにより、より少ない記憶容量でより多くのネイティブコードを記憶可能となる。 Further, by storing native code in a common area for methods common to a plurality of applications, it is possible to store more native code with less storage capacity.
(他の実施形態)
なお、本発明は、前述した実施形態の機能を実現するプログラムを、システム或いは装置に直接或いは遠隔から供給し、そのシステム或いは装置が、供給されたプログラムコードを読み出して実行することによっても達成される。従って、本発明の機能処理をコンピュータで実現するために、コンピュータにインストールされるプログラムコード自体も本発明の技術的範囲に含まれる。
(Other embodiments)
The present invention can also be achieved by supplying a program that realizes the functions of the above-described embodiments directly or remotely to a system or apparatus, and the system or apparatus reads and executes the supplied program code. The Accordingly, the program code itself installed in the computer in order to realize the functional processing of the present invention by the computer is also included in the technical scope of the present invention.
プログラムを供給するための記録媒体としては、例えば、フロッピー(登録商標)ディスク、ハードディスク、光ディスク(CD,DVD)、光磁気ディスク、MO、磁気テープ、不揮発性の半導体メモリなどがある。 Examples of the recording medium for supplying the program include a floppy (registered trademark) disk, a hard disk, an optical disk (CD, DVD), a magneto-optical disk, an MO, a magnetic tape, and a nonvolatile semiconductor memory.
また、コンピュータが、読み出したプログラムを実行することによって、前述した実施形態の機能が実現される他、そのプログラムの指示に基づき、コンピュータ上で稼動しているOSなどが、実際の処理の一部または全部を行い、その処理によっても前述した実施形態の機能が実現され得る。 In addition to the functions of the above-described embodiments being realized by the computer executing the read program, the OS running on the computer based on the instruction of the program is a part of the actual processing. Alternatively, the functions of the above-described embodiment can be realized by performing all of them and performing the processing.
さらに、記録媒体から読み出されたプログラムが、コンピュータに挿入された機能拡張ボードやコンピュータに接続された機能拡張ユニットに備わるメモリに書き込まれた後、そのプログラムの指示に基づき、その機能拡張ボードや機能拡張ユニットに備わるCPUなどが実際の処理の一部または全部を行い、その処理によっても前述した実施形態の機能が実現される。 Furthermore, after the program read from the recording medium is written in a memory provided in a function expansion board inserted into the computer or a function expansion unit connected to the computer, the function expansion board or The CPU or the like provided in the function expansion unit performs part or all of the actual processing, and the functions of the above-described embodiments are realized by the processing.
Claims (8)
前記プログラムを読み込み、該プログラムを構成する1以上のメソッドを逐次解釈するインタプリタ手段と、
前記インタプリタ手段により、前記プログラムの起動時に実行されると解釈されたメソッドを、ネイティブコードに変換する変換手段と、
前記変換手段により得られた前記ネイティブコードを前記メソッドと関連付けて前記記憶手段に登録する登録手段と、
前記メソッドを実行する際、前記記憶手段に該メソッドに対応するネイティブコードが登録されているか否かを確認し、ネイティブコードが登録されている場合には該ネイティブコードを読み出しネイティブ環境で実行し、ネイティブコードが登録されていない場合には前記メソッドを仮想マシン環境で実行するよう制御する制御手段と、
を備えることを特徴とする情報処理装置。 A native environment for executing native code configured based on a first instruction group; and a virtual machine environment for executing intermediate code configured based on a second instruction group defined independently of the first instruction group; An information processing apparatus comprising storage means for storing a program composed of at least the intermediate code,
Interpreter means for reading the program and sequentially interpreting one or more methods constituting the program;
Conversion means for converting the method interpreted by the interpreter means to be executed when the program is started into native code;
A registration unit that registers the native code obtained by the conversion unit in the storage unit in association with the method;
When executing the method, check whether the native code corresponding to the method is registered in the storage means, if the native code is registered, read the native code and execute it in the native environment, Control means for controlling execution of the method in a virtual machine environment when native code is not registered;
An information processing apparatus comprising:
前記管理手段は、アプリケーションを登録管理対象からはずす場合、前記ネイティブコードを併せて削除することを特徴とする請求項1乃至請求項4の何れか1項に記載の情報処理装置。 Management means for managing registration of the native code corresponding to one or more programs in the storage means;
The information processing apparatus according to any one of claims 1 to 4, wherein the management unit deletes the native code together when the application is removed from the registration management target.
前記プログラムを読み込み、該プログラムを構成する1以上のメソッドを逐次解釈するインタプリタ工程と、
前記インタプリタ工程により、前記プログラムの起動時に実行されると解釈されたメソッドを、ネイティブコードに変換する変換工程と、
前記変換工程により得られた前記ネイティブコードを前記メソッドと関連付けて前記記憶手段に登録する登録工程と、
前記メソッドを実行する際、前記記憶手段に該メソッドに対応するネイティブコードが登録されているか否かを確認し、ネイティブコードが登録されている場合には該ネイティブコードをネイティブ環境で実行し、ネイティブコードが登録されていない場合には前記メソッドを仮想マシン環境で実行するよう制御する制御工程と、
を備えることを特徴とする制御方法。 A native environment for executing native code configured based on a first instruction group; and a virtual machine environment for executing intermediate code configured based on a second instruction group defined independently of the first instruction group; A method of controlling an information processing apparatus comprising storage means for storing a program composed of at least the intermediate code,
An interpreter step of reading the program and sequentially interpreting one or more methods constituting the program;
A conversion step of converting a method interpreted by the interpreter step to be executed when the program is started into a native code;
A registration step of registering the native code obtained by the conversion step in the storage means in association with the method;
When executing the method, it is confirmed whether or not the native code corresponding to the method is registered in the storage means. If the native code is registered, the native code is executed in the native environment, A control process for controlling the method to be executed in a virtual machine environment when the code is not registered;
A control method comprising:
前記プログラムを読み込み、該プログラムを構成する1以上のメソッドを逐次解釈するインタプリタ工程を実行するためのプログラムコードと、
前記インタプリタ工程により、前記プログラムの起動時に実行されると解釈されたメソッドを、ネイティブコードに変換する変換工程を実行するためのプログラムコードと、
前記変換工程により得られた前記ネイティブコードを前記メソッドと関連付けて前記記憶手段に登録する登録工程を実行するためのプログラムコードと、
前記メソッドを実行する際、前記記憶手段に該メソッドに対応するネイティブコードが登録されているか否かを確認し、ネイティブコードが登録されている場合には該ネイティブコードをネイティブ環境で実行し、ネイティブコードが登録されていない場合には前記メソッドを仮想マシン環境で実行するよう制御する制御工程を実行するためのプログラムコードと、
を備えることを特徴とする制御プログラム。 A native environment for executing native code configured based on a first instruction group; and a virtual machine environment for executing intermediate code configured based on a second instruction group defined independently of the first instruction group; A control program for an information processing device comprising storage means for storing at least a program composed of the intermediate code,
Program code for reading the program and executing an interpreter step for sequentially interpreting one or more methods constituting the program;
A program code for executing a conversion step of converting a method interpreted by the interpreter step to be executed when the program is started into a native code;
Program code for executing a registration step of registering the native code obtained by the conversion step in the storage means in association with the method;
When executing the method, it is confirmed whether or not the native code corresponding to the method is registered in the storage means. If the native code is registered, the native code is executed in the native environment, A program code for executing a control process for controlling the method to be executed in a virtual machine environment when the code is not registered;
A control program comprising:
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2006051166A JP2007233472A (en) | 2006-02-27 | 2006-02-27 | Information processor, and control method and control program of information processor |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2006051166A JP2007233472A (en) | 2006-02-27 | 2006-02-27 | Information processor, and control method and control program of information processor |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2007233472A true JP2007233472A (en) | 2007-09-13 |
Family
ID=38554040
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2006051166A Withdrawn JP2007233472A (en) | 2006-02-27 | 2006-02-27 | Information processor, and control method and control program of information processor |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2007233472A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009015830A (en) * | 2007-06-07 | 2009-01-22 | Canon Inc | Program start-up device and program start-up method |
JP2016537755A (en) * | 2013-10-18 | 2016-12-01 | マイクロソフト テクノロジー ライセンシング,エルエルシー | Incrementally compiling software artifacts from an interactive development environment |
JP2018510428A (en) * | 2015-05-29 | 2018-04-12 | グーグル エルエルシー | Code caching system |
-
2006
- 2006-02-27 JP JP2006051166A patent/JP2007233472A/en not_active Withdrawn
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009015830A (en) * | 2007-06-07 | 2009-01-22 | Canon Inc | Program start-up device and program start-up method |
JP2016537755A (en) * | 2013-10-18 | 2016-12-01 | マイクロソフト テクノロジー ライセンシング,エルエルシー | Incrementally compiling software artifacts from an interactive development environment |
JP2018510428A (en) * | 2015-05-29 | 2018-04-12 | グーグル エルエルシー | Code caching system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8099729B2 (en) | Method and device for creating and using pre-internalized program files | |
JP6018590B2 (en) | Application compatibility with library operating system | |
CN101763279B (en) | BootLoader architectural design method | |
KR101051872B1 (en) | Program execution control device | |
JP4881023B2 (en) | Information processing apparatus, method for executing object-oriented program in the apparatus, and program therefor | |
JP6398725B2 (en) | Compile program, compile method, and compiler apparatus | |
JP2012527027A (en) | System and method for building a runtime environment | |
KR100725386B1 (en) | Method for executing virtual machine application, and the digital broadcast receiver thereof | |
KR100577366B1 (en) | Method and apparatus for executing different forms of java methods | |
JP2018092383A (en) | Compilation program, compilation method and information processor | |
CN102289380A (en) | firefox starting acceleration method | |
JP2007233472A (en) | Information processor, and control method and control program of information processor | |
JP4986598B2 (en) | Application management system and control method thereof | |
KR20000002446A (en) | Apparatus and method for swapping between main memory device and auxiliary memory device and web video phone having thereof | |
JP2017126293A (en) | Information processing apparatus and resource management method | |
CN103927207A (en) | Software acceleration method and device | |
KR100478463B1 (en) | Dynamic Linking Method for Application Program | |
US7558810B2 (en) | System and method for managing a path environment variable | |
JP2004013536A (en) | Flash memory rewrite control system and method, program for operating processe in flash memory rewrite control method, and information storage medium | |
JP4504756B2 (en) | Memory management method and memory management program in Java (registered trademark) execution environment | |
JP6143476B2 (en) | Application processing apparatus, method, and program thereof | |
JP3774051B2 (en) | Compiling device, loading device, program transmitting device, and program recording medium | |
KR100945151B1 (en) | Mobile media device for effectively executing VM-based mobile application programs on external memory, and operating method for the same | |
JP2021184208A (en) | Information processing device, information processing method and program | |
JP2002063096A (en) | Terminal device, provision source, and information processing device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A300 | Withdrawal of application because of no request for examination |
Free format text: JAPANESE INTERMEDIATE CODE: A300 Effective date: 20090512 |