WO2001013223A1 - Method and apparatus for operating virtual computer - Google Patents

Method and apparatus for operating virtual computer Download PDF

Info

Publication number
WO2001013223A1
WO2001013223A1 PCT/JP2000/005540 JP0005540W WO0113223A1 WO 2001013223 A1 WO2001013223 A1 WO 2001013223A1 JP 0005540 W JP0005540 W JP 0005540W WO 0113223 A1 WO0113223 A1 WO 0113223A1
Authority
WO
WIPO (PCT)
Prior art keywords
code
intermediate code
instruction
executing
virtual machine
Prior art date
Application number
PCT/JP2000/005540
Other languages
French (fr)
Japanese (ja)
Inventor
Ryota Kunisawa
Original Assignee
Access Co., Ltd.
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Access Co., Ltd. filed Critical Access Co., Ltd.
Priority to AU65957/00A priority Critical patent/AU6595700A/en
Publication of WO2001013223A1 publication Critical patent/WO2001013223A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45516Runtime code conversion or optimisation

Definitions

  • the present invention relates to a method and an apparatus for executing a virtual machine for executing an intermediate code called a note code.
  • Java VM Java is a trademark of Sun Microsystems
  • a program (source code) written in the Java language is compiled and converted into intermediate code called a byte code.
  • Byte code is suitable for distributing programs over a network because it does not depend on specific hardware or OS (Operating System) and is relatively small in size. It is also suitable for use as software for embedding in specific devices.
  • the bytecode is not executed directly by the CPU of each computer, but by a virtual machine, which is an engine created by software.
  • the code that cpu can execute directly on the note code is called native code.
  • a method according to the present invention is a method for executing a virtual machine that executes intermediate code, comprising: dynamically detecting a loop portion repeatedly executed during execution of the intermediate code during the execution; It is characterized by comprising a step of converting code into native code, and a step of directly executing the native code by a CPU for the loop portion of the intermediate code.
  • the loop portion can be reliably detected by dynamically detecting the loop portion during execution of the intermediate code. Also, since only the loop part is converted to native code, the time required for the conversion is relatively short, and the memory capacity for holding the native code is relatively small.
  • the intermediate code when the intermediate code is loaded into a memory, an instruction whose control flow is upward is detected, and when the instruction is detected, the instruction is rewritten to a first special instruction.
  • the control jumps when executing the first special instruction, confirms the destination, and when the same first special instruction is executed again, the control jumps. If they match, it is determined that the jump source from the jump destination is the loop portion, and the intermediate code of the loop portion is converted into a native code. In this way, when loading the intermediate code, it is possible to incorporate in the intermediate code the work for detecting the loop portion during later execution.
  • the step of rewriting to the first special instruction may be performed at the time of execution instead of at the time of loading the intermediate code.
  • the method may further include a step of rewriting, and a step of invalidating the jump destination information at the time of executing the second special instruction when executing the intermediate code on the memory. This corresponds to a case where the loop processing has not been performed or has been interrupted, and this configuration prevents the subsequent useless processing from being performed as described above.
  • the step of rewriting to the second special instruction may be performed at the time of execution instead of at the time of loading the intermediate code.
  • FIG. 1 is a conceptual diagram of an execution method of a virtual machine according to the present invention.
  • FIG. 2 is a block diagram showing a hardware configuration of an apparatus in which the method of the present invention is performed.
  • FIG. 3 is a flowchart of a process performed when a bytecode is loaded on a memory in the embodiment of the present invention.
  • FIG. 4 is a flowchart of a process at the time of executing a program according to the embodiment of the present invention.
  • 5 is a flowchart showing the operation of the system.
  • Figure 5 shows an example of a very simple source program with one basic block.
  • FIG. 6 is a diagram showing an example of a bytecode obtained by compiling the source program of FIG.
  • FIG. 7 is a diagram showing a state in which the instruction in the bytecode string in FIG.
  • FIG. 8 is a diagram showing a state in which the instruction at the head of the loop in the bytecode string in FIG. 7 has been rewritten as “instruction for jumping to native code”.
  • FIG. 9 is a flowchart showing a flow chart of a process at the time of executing a program according to another embodiment of the present invention.
  • Figure 10 is a conceptual diagram showing how a program (source code) written in the Java language is compiled and converted to intermediate code called a byte code.
  • FIG. 1 is a conceptual diagram of an execution method of a virtual machine according to the present invention.
  • An application program (source code) 20 written in Java language or the like is converted into a class file 21 composed of an intermediate code (byte code) by a compiler.
  • a class is a block of a program including a plurality of functions (called methods) for realizing various functions, and a plurality of class filters 5 can be created for one application.
  • the intermediate code of each class file is loaded into memory 11 before execution. At the time of loading, it is possible to perform a special operation to detect the loop portion that is repeatedly executed when executing the byte code during program execution. This specific example will be described later.
  • the byte code 111 on the memory 11 is sequentially interpreted and executed by a virtual machine (VM) 101 on the CPU 10. During this execution, if a loop portion is detected based on the above trick, the bytecode of the loop portion is changed to native code 112. And put it on memory 1 1. When this loop is executed, the CPU 10 directly executes the native code instead of executing the bytecode by the virtual machine 101. As will be described later, the above “work” can be performed during execution.
  • VM virtual machine
  • the size of such a repetition part is relatively small, so the time required to convert the bytecode to native code is small. Also, since the size of the native code 112 corresponding to only the loop portion can be small, the large capacity of the memory 11 due to the native code 112 does not occur.
  • FIG. 2 is a block diagram showing a hardware configuration of an apparatus for executing the method of the present invention.
  • This is a general computer system, which includes CPU 10, memory 11, external storage device (such as hard disk) 12, input device 13 such as keyboard, display device 14, Internet device and external device.
  • FIG. 3 is a flowchart of a process performed when a note code is loaded on a memory.
  • first find the first instruction in the function (S13). Check if this instruction is an “upward instruction”, that is, an instruction to return control to the top of the program (S14, Yes). This can be determined based on the description before executing the instruction. If the instruction is an upward instruction, the instruction is rewritten as an instruction for performing profiling (first special instruction) (S17). This first special order adds the ability to profile “upward orders”.
  • a "profile” is generally a force that is information about how many times a particular basic block or a particular line in the source has been executed, and if there are branches, in which direction and how many times. s ', where the code location of the branch, and where and how many times it jumped. “Profile” refers to confirming and storing such information.
  • step S14 the instruction If it is not the "command to head", it is checked whether it is a "command to change the flow of other controls" (S15). This “instruction that changes the flow of control” corresponds to a case where the loop exits at a place other than the end condition in the loop. In the case of such an instruction, the instruction is rewritten as “an instruction for invalidating the profile” (S 18). This instruction also adds the functionality s to invalidate the function of the original instruction.
  • step S15 if the instruction is not an "instruction to change the flow of control", it is checked whether the end of the function has been reached (S16). If the end has not been reached, step S1 is executed. Returning to step 3, the above processing is repeated.
  • FIG. 4 shows a flowchart of a process when the program is executed.
  • the first bytecode instruction is obtained (S31), and it is checked whether or not this instruction is an "instruction for performing profiling" (S32). If so, create a profile (S33). It is checked whether or not this profile (particularly, the branch destination) matches the profile stored earlier (S34). If they do not match, the previous profile is overwritten with the new profile obtained this time (S39). When the first command to perform profiling appears, there is no “first profile”, so the current profile is stored as it is. In step S34, if the current profile matches the previous profile, it can be determined that the flight has jumped from the same source to the same destination, so the counter (variable) is incremented (S35). The initial value is set to "0". Until the counter value reaches a predetermined value (predetermined value), the process goes to step S44, bypassing steps S37 and S38.
  • Waiting for a predetermined number of loop iterations is empirical or based on the contents of the application when the number of loop iterations reaches the predetermined number of times. Is based on the assumption that the repetitive force s will continue, and if the repetition does not reach the predetermined number of times, there is a high possibility that the repetitive force stops or the flow changes. Thus, the "predetermined value" of the counter may change from case to case. When the counter value reaches a predetermined value, it is determined whether or not it is worth compiling the loop portion (from the jump destination to the jump source) (S37). The details of this determination will be described later. If it is judged that it is not worth compiling, the “instruction to perform profiling” is returned to the original ordinary instruction (instruction without the above additional functions) (S38) o
  • the bytecode of the loop is compiled to create native code (S41).
  • the first bytecode instruction of this loop is rewritten to an instruction for jumping to the native code (S42).
  • the native code is directly executed by CPU for this loop part. After executing the native code, it returns to the bytecode instruction following the last bytecode instruction in the loop. Therefore, the "instruction to do the opening file" at the end of the loop is bypassed.
  • the relevant native code is preserved, and the same native code is used the next time the same loop is re-entered. If the native code created once is saved in this way, the memory capacity of the native code may eventually become excessive, so the maximum capacity of the memory for storing the native code is determined in advance. Avoid generating native code that exceeds this. Alternatively, keep track of the number of executions of each natively coded loop, and if the maximum memory capacity is exceeded, disable the native code of the loop with the lowest number of executions. Well ,.
  • step S32 if the instruction is not the “instruction to perform profiling”, and if the instruction is “instruction to invalidate profile” (S43, Yes), the profile information currently stored is invalidated. Yes (S45).
  • step S44 If it is not the "instruction to invalidate the profile", the instruction is executed (S44). After the previous steps S38, S45, S42, the process also proceeds to step S44. After step S44, return to the first step S31 and follow the byte code The above process is repeated for the instruction.
  • the above judgment conditions (a) and (b) may be employed independently or may be employed under AND conditions. Also, if some number of iterations force of the loop? Expected, the effect of reducing the execution time can be expected that the embodiment does not perform the determination of both conditions it is also contemplated. That is, the above step S37 is deleted, and the counter value reaches a predetermined value. Then, the conversion to the native code may be performed immediately.
  • Figure 5 shows an example of a very simple source program with one basic block.
  • Figure 6 shows an example of a bytecode obtained by compiling this source program.
  • the variable i is assigned to var [8]
  • a is assigned to var [9]
  • b is assigned to var [10].
  • the code for initializing variables a and b is omitted.
  • the loop from address 34 to address 52 in Figure 6 is the loop, which is the target of compilation into native code.
  • the loop portion from address 34 to address 52 is returned a predetermined number of times, and the corresponding portion is converted to native code by compiling.
  • the instruction at address 34 at the beginning of the loop is rewritten as “instruction to jump to native code” as shown in FIG.
  • Specific examples of the native code differ depending on the CPU used, and have a large capacity.
  • FIG. 9 shows a process flow when a program is executed in another embodiment according to the present invention.
  • the work for detecting the loop portion was performed.
  • the processing in FIG. 3 is included in the program execution processing. is there. By doing so, the time required until the program execution starts can be reduced. This is suitable for cases where the startup is fast but you don't care much about the time it takes to run (eg for interactive processing).
  • steps S51 to S71 processing steps S54, S55, S58, and S60 at the time of loading the program in the previous embodiment are described. It is. Steps S52 to S56 are in no particular order.
  • step S57 In the error processing in step S57, when an impossible instruction is detected, the instruction is skipped or the virtual machine is abnormally terminated. This step may be included in the processing of FIG. 4 not shown in the execution processing of FIG.
  • the conversion processing time from the intermediate code to the native code can be reduced, and the execution speed can be generally improved even in an apparatus having a relatively small memory capacity.

Abstract

The loop part repeated during execution of an intermediate code (111) is detected dynamically during the execution and the intermediate code of the loop part is converted into a native code (112). The native code (112) is executed directly by means of a CPU (10) for the loop part of the intermediate code. More specifically, an instruction for directing the control flow upward is detected when the intermediate code (111) is loaded in a memory (11) and rewritten into a first special instruction when it is detected. When the intermediate code (111) in the memory (11) is executed, the jump destination of control is confirmed before the first special instruction is executed. If the jump destinations of control agree with each other when the same first special instruction is executed again, the jump destination judges that the branch point is the loop part and converts the bite code (111) of the loop part is converted into the native code (112). The time required to convert the intermediate code (111) into the native code (112) is shortened and the overall execution speed is enhanced even in an apparatus having a relatively small memory capacity.

Description

明 細 書  Specification
仮想計算機の実行方法および装置 技術分野  Method and apparatus for executing a virtual machine
本発明は、 ノ ィトコ一ドと呼ばれる中間コードを実行する仮想計算機の実行方 法および装置に関する。 背景技術  The present invention relates to a method and an apparatus for executing a virtual machine for executing an intermediate code called a note code. Background art
このような仮想計算機としては、 J a v a VM ( J a v aはサンマイクロシス テムズ社の商標) が知られている。  As such a virtual machine, Java VM (Java is a trademark of Sun Microsystems) is known.
図 1 0に示すように、 J a V a言語で書かれたプログラム (ソースコード) は コンパイルされてバイトコ一ドと呼ばれる中間コードに変換される。 バイトコ一 ドは特定のハードウエアや 0 S (Operating System)に依存せず、 また比較的サイ ズが小さいため、 ネットワーク上でプログラムを配布するのに適している。 ま た、 特定の装置への組み込み用のソフトウェアとしての利用にも適している。 バイトコードは個々の計算機の C P Uが直接実行するのではなく、 ソフトゥェ ァで作られた エンジンである仮想計算機により実行される。 なお、 ノ イト コードに対して、 c p uが-直接実行できるコ一ドはネィティブコードと呼ばれ る。  As shown in Figure 10, a program (source code) written in the Java language is compiled and converted into intermediate code called a byte code. Byte code is suitable for distributing programs over a network because it does not depend on specific hardware or OS (Operating System) and is relatively small in size. It is also suitable for use as software for embedding in specific devices. The bytecode is not executed directly by the CPU of each computer, but by a virtual machine, which is an engine created by software. The code that cpu can execute directly on the note code is called native code.
バイトコードはソフトウェアによつて逐次解析され実行されるので、 実行速度 が遅いという難点がある。 従来、 この問題を解決する手法として J I T (Just In Time)コンパイラというものが知られている。 これは、 バイトコードをネイティブ コードに変換し (この処理もコンパイルと呼ばれる) 、 このネイティブコードを 直接 C P U力5 行するものである。 Since bytecode is analyzed and executed sequentially by software, it has the disadvantage of slow execution speed. Conventionally, a JIT (Just In Time) compiler has been known as a method for solving this problem. This converts the byte code into native code (this process is also referred to as compiling) is for five rows directly CPU force the native code.
しかしながら、 この J I Tには次のような問題があった。 すなわち、 第 1に、 このバイトコードからネイティブコードへのコンパイル処理に時間がかかる。 第 2に、 バイトコードよりネイティブコードの方がサイズ力 s大きいので、 メモリ容 量が比較的小さく C P Uが比較的低速である組み込み機器や民生機器では問題と なる。 本発明はこのような背景においてなされたものであり、 その目的とする ところは、 中間コードからネイティブコ一ドへの変換処理時間を軽減するととも に、 比較的小さいメモリ容量の装置においても実行速度を総体的に向上させるこ とができる仮想計算機の実行方法および装置を提供することにある。 発明の開示 However, this JIT had the following problems. First, it takes time to compile this bytecode into native code. Second, the size of native code is larger than that of bytecode, which is a problem for embedded and consumer devices with relatively small memory capacity and relatively low CPU speed. The present invention has been made in such a background, and its object is to However, a virtual computer execution method and apparatus that can reduce the processing time for converting intermediate code to native code and can generally improve the execution speed even on a device with a relatively small memory capacity are proposed. To provide. Disclosure of the invention
本発明による方法は、 中間コードを実行する仮想計算機の実行方法であって、 中間コードの実行時に繰り返し実行されるループ部分を、 該実行中に動的に検出 するステップと、 当該ループ部分の中間コードをネイティブコードに変換するス テツプと、 前記中間コードの当該ループ部分については、 前記ネイティブコード を C P Uにより直接実行するステップとを備えることを特徵とする。  A method according to the present invention is a method for executing a virtual machine that executes intermediate code, comprising: dynamically detecting a loop portion repeatedly executed during execution of the intermediate code during the execution; It is characterized by comprising a step of converting code into native code, and a step of directly executing the native code by a CPU for the loop portion of the intermediate code.
本発明では、 中間コ一ドの実行時に動的にループ部分を検出することにより、 確実にループ部分を検出できる。 また、 ループ部分のみをネイティブコードに変 換するので、 その変換に要する時間は比較的短く、 かつ、 ネイティブコードを保 持するメモリ容量も比較的小さくて済む。  According to the present invention, the loop portion can be reliably detected by dynamically detecting the loop portion during execution of the intermediate code. Also, since only the loop part is converted to native code, the time required for the conversion is relatively short, and the memory capacity for holding the native code is relatively small.
より具体的には、 前記中間コードをメモリ上にロードする際に、 制御の流れが 上に向かう命令を検出し、 該命令の検出時に該命令を第 1の特別の命令に書き換 えるステップと、 前記メモリ上の中間コードを実行する際、 前記第 1の特別の命 令の実行時に制御の飛び、先を確認し、 再度同じ第 1の特別の命令を実行したとき に制御の飛び先が一致したならば、 当該飛び先から飛び元を前記ル一プ部分であ ると判断し、 該ループ部分の中間コードをネイティブコードに変換するステップ とを有する。 これにより、 中間コードのロード時に、 後の実行中におけるループ 部分検出のための細工を中間コードに組み込んでおくことができる。  More specifically, when the intermediate code is loaded into a memory, an instruction whose control flow is upward is detected, and when the instruction is detected, the instruction is rewritten to a first special instruction. When executing the intermediate code on the memory, the control jumps when executing the first special instruction, confirms the destination, and when the same first special instruction is executed again, the control jumps. If they match, it is determined that the jump source from the jump destination is the loop portion, and the intermediate code of the loop portion is converted into a native code. In this way, when loading the intermediate code, it is possible to incorporate in the intermediate code the work for detecting the loop portion during later execution.
但し、 前記第 1の特別の命令に書き換えるステップを、 中間コードのロード時 に代えて実行時に行うようにすることも可能である。  However, the step of rewriting to the first special instruction may be performed at the time of execution instead of at the time of loading the intermediate code.
前記飛び先が一致した回数をカウントし、 該カウント値が予め定めた値に達し たとき、 さらに、 当該ループ部分のネイティブコードへの変換の可否を予め定め た判断基準で判断し、 該判断基準が満足されたとき前記ネイティブコ一ドへの変 換を行うようにしてもよい。 これによりアプリケーションや用途に応じて、 より 適切なネイティブコ一ドへの変換の条件を設定できる。 前記判断基準が満足さ れなかったとき、 当該第 1の特別の命令を元の普通の命令に戻すことにより、 当 該ループについて以後、 ネイティブコードへの変換に関する無駄な処理を行わな いようにすることができる Counting the number of times the jump destinations match, and when the count value reaches a predetermined value, further determines whether or not the loop portion can be converted to native code according to a predetermined determination criterion. When the condition is satisfied, the conversion to the native code may be performed. This makes it possible to set more appropriate conditions for conversion to native code depending on the application and application. The criteria are satisfied If not, by returning the first special instruction to the original ordinary instruction, it is possible to prevent the loop from performing useless processing related to conversion to native code thereafter.
前記中間コードをメモリ上にロードする際に、 前記 「制御の流れが上に向かう 命令」 以外の制御の流れを変える命令を検出し、 該命令の検出時に該命令を第 2 の特別の命令に書き換えるステップと、 前記メモリ上の中間コードを実行する 際、 前記第 2の特別の命令の実行時に前記飛び先の情報を無効にするステップと をさらに備えてもよい。 これは、 ループ処理か ^行われなかった、 または中断され た場合に相当し、 この構成により上記と同様、 以後の無駄な処理の実行を防止す る。  When loading the intermediate code into the memory, an instruction that changes the control flow other than the “instruction for upward control flow” is detected, and when the instruction is detected, the instruction is converted to a second special instruction. The method may further include a step of rewriting, and a step of invalidating the jump destination information at the time of executing the second special instruction when executing the intermediate code on the memory. This corresponds to a case where the loop processing has not been performed or has been interrupted, and this configuration prevents the subsequent useless processing from being performed as described above.
前記第 2の特別の命令に書き換えるステップは、 中間コードのロード時に代え て実行時に行うようにすることも可能である。  The step of rewriting to the second special instruction may be performed at the time of execution instead of at the time of loading the intermediate code.
上記方法を実行するための本発明による装置は、 中間コードを実行する仮想計 算機の実行装置であって、 ネイティブコードを実行する C P Uと、 中間コードを 記憶するメモリと、 該メモリ上に中間コードをロードする手段と、 該中間コード を解釈して実行する、 前記 C P U上の仮想計算機手段と、 該仮想計算機手段によ る前記中間コードの実行時に繰り返し実行されるループ部分を、 該実行中に動的 に検出し、 当該ループ部分の中間コ一ドをネイティブコードに変換する手段とを 備え、 前記中間コードの当該ループ部分については、 前記ネイティブコードを前 記 C P Uにより直接実行することを特徴とする。  An apparatus according to the present invention for performing the above method is an execution device of a virtual machine for executing intermediate code, comprising: a CPU for executing native code; a memory for storing intermediate code; Means for loading code; interpreting and executing the intermediate code; virtual computer means on the CPU; and a loop portion repeatedly executed when the intermediate code is executed by the virtual computer means. Means for dynamically detecting the intermediate code of the loop portion into native code, and executing the native code directly by the CPU for the loop portion of the intermediate code. And
図面の簡単な説明 BRIEF DESCRIPTION OF THE FIGURES
図 1は、 本発明の仮想計算機の実行方法の概念図である。  FIG. 1 is a conceptual diagram of an execution method of a virtual machine according to the present invention.
図 2は、 本発明の方法が実行される装置のハ一ドゥエァ構成を示すプロック図 である。  FIG. 2 is a block diagram showing a hardware configuration of an apparatus in which the method of the present invention is performed.
図 3は、 本発明の実施の形態において、 バイトコードをメモリ上にロードする 際に行う処理のフローチヤ一トである。  FIG. 3 is a flowchart of a process performed when a bytecode is loaded on a memory in the embodiment of the present invention.
図 4は、 本発明の実施の形態におけるプログラム実行時の処理のフローチヤ一 トを示すフローチヤ一トである。 FIG. 4 is a flowchart of a process at the time of executing a program according to the embodiment of the present invention. 5 is a flowchart showing the operation of the system.
図 5は、 ベーシックブロックが 1個の極めて簡単なソースプログラムの例を示 す図である。  Figure 5 shows an example of a very simple source program with one basic block.
図 6は、 図 5ののソースプログラムをコンパイルして得られたバイトコードの 例を示す図である。  FIG. 6 is a diagram showing an example of a bytecode obtained by compiling the source program of FIG.
図 7は、 図 6のバイトコード列の中の命令が 「プロファイルを行う命令」 に書 き換えられた様子を示す図である。  FIG. 7 is a diagram showing a state in which the instruction in the bytecode string in FIG.
図 8は、 図 7のバイトコード列中のループの先頭の命令が 「ネイティブコード に飛ぶための命令」 に書き換えられた様子を示す図である。  FIG. 8 is a diagram showing a state in which the instruction at the head of the loop in the bytecode string in FIG. 7 has been rewritten as “instruction for jumping to native code”.
図 9は、 本発明の他の実施の形態におけるプログラム実行時の処理のフロー チャートを示すフローチヤ一トである。  FIG. 9 is a flowchart showing a flow chart of a process at the time of executing a program according to another embodiment of the present invention.
図 1 0は、 J a V a言語で書かれたプログラム (ソースコード) はコンパイル されてバイトコ一ドと呼ばれる中間コードに変換される様子を示す概念図であ る。 発明を実施するための最良の形態  Figure 10 is a conceptual diagram showing how a program (source code) written in the Java language is compiled and converted to intermediate code called a byte code. BEST MODE FOR CARRYING OUT THE INVENTION
以下、 本発明の実施の形態を詳細に説明する。  Hereinafter, embodiments of the present invention will be described in detail.
図 1は、 本発明の仮想計算機の実行方法の概念図である。 J a v a言語等で記 載されたアプリケーションプログラム (ソースコード) 2 0は、 コンパイラによ り中間コード (バイトコード) からなるクラスファイル 2 1に変換される。 クラ スとは、 種々の機能を実現する複数の関数 (メソッドと呼ばれる) を含むプログ ラムのかたまりであり、 ひとつのアプリケ一ションに対して複数のクラスフアイ ルカ 5作成されうる。 各クラスファイルの中間コードは、 実行に先立ってメモリ 1 1内にロードされる。 バイ トコードの実行時に繰り返し実行されるループ部分 を、 プログラム実行時に検出するための細工を、 このロード時に行うことができ る。 この具体例については後述する。 FIG. 1 is a conceptual diagram of an execution method of a virtual machine according to the present invention. An application program (source code) 20 written in Java language or the like is converted into a class file 21 composed of an intermediate code (byte code) by a compiler. A class is a block of a program including a plurality of functions (called methods) for realizing various functions, and a plurality of class filters 5 can be created for one application. The intermediate code of each class file is loaded into memory 11 before execution. At the time of loading, it is possible to perform a special operation to detect the loop portion that is repeatedly executed when executing the byte code during program execution. This specific example will be described later.
メモリ 1 1上のバイトコード 1 1 1は、 C P U 1 0上の仮想計算機 (VM) 1 0 1により逐次解釈され実行される。 この実行中、 上記細工に基づいてループ部 分を検出したら、 そのループ部分のバイトコードをネイティブコード 1 1 2に変 換してメモリ 1 1上に置く。 このループ部分の実行時は、 仮想計算機 1 0 1によ るバイトコードの実行に代わり、 C P U 1 0が当該ネイティブコードを直接実行 する。 後述するように、 上記 「細工」 は実行中に行うことも可能である。 The byte code 111 on the memory 11 is sequentially interpreted and executed by a virtual machine (VM) 101 on the CPU 10. During this execution, if a loop portion is detected based on the above trick, the bytecode of the loop portion is changed to native code 112. And put it on memory 1 1. When this loop is executed, the CPU 10 directly executes the native code instead of executing the bytecode by the virtual machine 101. As will be described later, the above “work” can be performed during execution.
通常、 このような繰り返し部分は比較的小さいサイズなので、 バイトコードを ネイティブコードに変換する処理に要する時間は小さい。 また、 ループ部分のみ に対応したネイティブコード 1 1 2のサイズは小さくて済むので、 ネイティブ コード 1 1 2のためにメモリ 1 1の大容量ィ匕を招来することもない。  Usually, the size of such a repetition part is relatively small, so the time required to convert the bytecode to native code is small. Also, since the size of the native code 112 corresponding to only the loop portion can be small, the large capacity of the memory 11 due to the native code 112 does not occur.
図 2は、 本発明の方法が実行される装置のハードウエア構成を示すブロック図 である。 これは、 一般的なコンピュータシステムであり、 C P U 1 0、 メモリ 1 1、 外部記憶装置 (ハードディスク等) 1 2、 キーポード等の入力装置 1 3、 ディスプレイである^装置 1 4、 インターネットゃ外部装置との通信インタ フェース部 1 5を有する。  FIG. 2 is a block diagram showing a hardware configuration of an apparatus for executing the method of the present invention. This is a general computer system, which includes CPU 10, memory 11, external storage device (such as hard disk) 12, input device 13 such as keyboard, display device 14, Internet device and external device. Communication interface 15.
図 3は、 ノ ィトコ一ドをメモリ上に口一ドする際に行う処理のフローチヤ一ト である。  FIG. 3 is a flowchart of a process performed when a note code is loaded on a memory.
まず、 ひとつの関数のエントリを見つける (S 1 1 ) 。 ロードするバイトコ一 ドのプログラム中に複数の関数が 在する場合、 未処理の関数がなくなるまで、 以下の処理を繰り返す (S 1 2 ) 。  First, find the entry of one function (S11). If there are multiple functions in the bytecode program to be loaded, the following processing is repeated until there are no unprocessed functions (S12).
関数があれば、 まず、 その関数中の最初の命令を見つける (S 1 3 ) 。 この命 令が 「上に向かう命令」 すなわち制御をプログラムの上方に戻す命令であるかを 調べる (S 1 4, Y e s ) 。 これは、 命令を実行する前にその記述に基づいて判 断できる。 「上に向かう命令」 であった場合、 この命令を 「プロファイルを行う 命令 (第 1の特別の命令) 」 に書き換える (S 1 7 ) 。 この第 1の特別の命令 は、 「上に向かう命令」 に対してプロファイルを行う機能を追加したものであ る。 ここに、 「プロファイル」 とは、 一般に、 特定のベーシックブロックや、 ソース中のある特定の行が、 何回実行されたか、 分岐があれば、 どの方向に何回 飛んだか、 に関する情報である力 s'、 ここでは、 分岐のコードの場所、 ならびに飛 ぴ先およびその回数である。 「プロファイルを行う」 とはこのような情報を確認 し記憶することをいう。 If there is a function, first find the first instruction in the function (S13). Check if this instruction is an “upward instruction”, that is, an instruction to return control to the top of the program (S14, Yes). This can be determined based on the description before executing the instruction. If the instruction is an upward instruction, the instruction is rewritten as an instruction for performing profiling (first special instruction) (S17). This first special order adds the ability to profile “upward orders”. Here, a "profile" is generally a force that is information about how many times a particular basic block or a particular line in the source has been executed, and if there are branches, in which direction and how many times. s ', where the code location of the branch, and where and how many times it jumped. “Profile” refers to confirming and storing such information.
その後、 後述するステップ S 1 6へ進む。 ステップ S 1 4で当該命令が 「上 に向かう命令」 ではなかった場合、 「その他の制御の流れを変える命令」 か否か を調べる (S 1 5 ) 。 この 「その他の制御の流れを変える命令」 は、 ループ中の 終了条件以外の場所でループから抜ける場合に相当する。 このような命令であれ ば、 当該命令を 「プロファイルを無効にする命令」 に書き換える (S 1 8 ) 。 こ の命令も、 当該元の命令の機能に対して無効にする機能力 s追加されたものであ る。 ここでプロファイルを無効にする理由は、 「その他の制御の流れを変える命 令」 によって、 先に 「上に向かう命令」 について 「プロファイル」 を作成してい ても、 当該 「上に向かう命令」 でのループの繰り返しが実行されないこと力判明 したことになるからである。 Then, the process proceeds to step S16 described later. In step S14, the instruction If it is not the "command to head", it is checked whether it is a "command to change the flow of other controls" (S15). This “instruction that changes the flow of control” corresponds to a case where the loop exits at a place other than the end condition in the loop. In the case of such an instruction, the instruction is rewritten as “an instruction for invalidating the profile” (S 18). This instruction also adds the functionality s to invalidate the function of the original instruction. The reason for disabling the profile here is that even if a “profile” was created for the “upward instruction” first by “an instruction to change the flow of control”, the “upward instruction” would not This is because it became clear that the repetition of the loop was not executed.
ステップ S 1 5で当該命令が 「その他の制御の流れを変える命令」 でもなかつ た場合には、 当該関数の終わりに達したかを調べ (S 1 6 ) 、 終わりに達してい なければステップ S 1 3に戻って上記処理を繰り返す。  In step S15, if the instruction is not an "instruction to change the flow of control", it is checked whether the end of the function has been reached (S16). If the end has not been reached, step S1 is executed. Returning to step 3, the above processing is repeated.
このようにして、 次に説明するプログラム (パ、イ トコード) の実行時に動的に ループを見つけだす細工が、 口一ド時に行われたことになる。  In this way, the trick to find the loop dynamically when executing the program (paragraphs, it code) described below was done at the time of the mouth.
図 4は、 プログラム実行時の処理のフローチャートを示す。  FIG. 4 shows a flowchart of a process when the program is executed.
この処理では、 まず、 最初のバイトコード命令を取得し (S 3 1 ) 、 この命令 「プロファイルを行う命令」 であるか否かを調べる (S 3 2 ) 。 そうであれ ば、 プロファイルを作成する (S 3 3 ) 。 このプロファイル (特に、 分岐の飛び 先) が先に記憶されているプロファイルと一致するか否かを調べる (S 3 4 ) 。 不一致ならば、 今回得られた新たなプロファイルで先のプロファイルを上書きす る (S 3 9 ) 。 最初にプロファイルを行う命令が出現したときには 「先のプロ ファイル」 は存在しないので、 そのまま、 今回のプロファイルを記憶する。 ステップ S 3 4で、 今回のプロファイルが先のプロファイルと一致したら、 同 じ飛び元から同じ飛び先に飛んだと判定できるので、 カウンタ (変数) をインク リメントする (S 3 5 ) o このカウンタの初期値は" 0 " としておく。 このカウ ンタ値が予め定めた値 (所定値) に達するまでは、 ステップ S 3 7, S 3 8を迂 回してステツプ S 4 4へ進む。  In this process, first, the first bytecode instruction is obtained (S31), and it is checked whether or not this instruction is an "instruction for performing profiling" (S32). If so, create a profile (S33). It is checked whether or not this profile (particularly, the branch destination) matches the profile stored earlier (S34). If they do not match, the previous profile is overwritten with the new profile obtained this time (S39). When the first command to perform profiling appears, there is no “first profile”, so the current profile is stored as it is. In step S34, if the current profile matches the previous profile, it can be determined that the flight has jumped from the same source to the same destination, so the counter (variable) is incremented (S35). The initial value is set to "0". Until the counter value reaches a predetermined value (predetermined value), the process goes to step S44, bypassing steps S37 and S38.
所定回数のループの繰り返しを待つのは、 経験的に、 あるいはそのアプリケー ションの内容に基づいて、 ループの繰り返しが当該所定回数に達するような場合 はさらに繰り返し力 s続くであろう、 かつ、 繰り返しが当該所定回数に達しない場 合には途中で繰り返し力停止または流れが変わる可能性が高いという想定に基づ いている。 したがって、 カウンタの 「所定値」 は場合によって変わりうる。 カウンタ値が所定値に達したら、 当該ループ部分 (飛び先から飛び元まで) の コンパイルを行う価値があるか否かを判断する (S 3 7 ) 。 この判断の内容につ いては、 後述する。 コンパイルを行う価値がないと判断されれば、 「プロフアイ ルを行う命令」 を元の普通の命令 (上記追加機能のない命令) に戻す (S 3 8 ) o Waiting for a predetermined number of loop iterations is empirical or based on the contents of the application when the number of loop iterations reaches the predetermined number of times. Is based on the assumption that the repetitive force s will continue, and if the repetition does not reach the predetermined number of times, there is a high possibility that the repetitive force stops or the flow changes. Thus, the "predetermined value" of the counter may change from case to case. When the counter value reaches a predetermined value, it is determined whether or not it is worth compiling the loop portion (from the jump destination to the jump source) (S37). The details of this determination will be described later. If it is judged that it is not worth compiling, the “instruction to perform profiling” is returned to the original ordinary instruction (instruction without the above additional functions) (S38) o
コンパイルを行う価値があると判断されれば、 当該ループ部分のバイトコ一ド をコンパイルしてネイティブコードを作成する (S 4 1 ) 。 ついで、 このループ の先頭のバイトコード命令を、 ネイティブコードにジャンプする命令に書き換え る (S 4 2 ) 。 以後、 このループ部分については C P Uによりネイティブコード を直接実行する。 ネイティブコードの実行後は、 ループ内の最後のバイトコード 命令の次のバイトコード命令に戻る。 したがって、 そのループの最後にある 「プ 口ファイルを行う命令」 は迂回される。  If it is determined that the compilation is worthwhile, the bytecode of the loop is compiled to create native code (S41). Next, the first bytecode instruction of this loop is rewritten to an instruction for jumping to the native code (S42). After that, the native code is directly executed by CPU for this loop part. After executing the native code, it returns to the bytecode instruction following the last bytecode instruction in the loop. Therefore, the "instruction to do the opening file" at the end of the loop is bypassed.
なお、 ループを抜けた後も、 当該ネイティブコードは保存されており、 次に同 じループに再度突入したときに同じネイティブコードが'利用される。 このように 一度作成したネイティブコ一ドを保存していくと、 最終的にネイティブコ一ドの メモリ容量が過大になりうるので、 ネイティブコードを保存するメモリの最大容 量を予め定めておき、 それを超えるようなネイティブコードの生成は行わないよ うにする。 あるいは、 ネイティブコード化された各ループの実行回数を記録管理 しておき、 メモリの最大容量を超えるような場合には、 最も実行回数の低いルー プのネイティブコ一ドを無効化するようにしてもよレ、。  Note that even after exiting the loop, the relevant native code is preserved, and the same native code is used the next time the same loop is re-entered. If the native code created once is saved in this way, the memory capacity of the native code may eventually become excessive, so the maximum capacity of the memory for storing the native code is determined in advance. Avoid generating native code that exceeds this. Alternatively, keep track of the number of executions of each natively coded loop, and if the maximum memory capacity is exceeded, disable the native code of the loop with the lowest number of executions. Well ,.
先のステップ S 3 2において、 命令が 「プロファイルを行う命令」 でない場 合、 「プロファイルを無効にする命令」 であれば (S 4 3, Y e s ) 、 現在記憶 されているプロファイル情報を無効にする (S 4 5 ) 。  In step S32, if the instruction is not the “instruction to perform profiling”, and if the instruction is “instruction to invalidate profile” (S43, Yes), the profile information currently stored is invalidated. Yes (S45).
「プロファイルを無効にする命令」 でなければ、 その命令を実行する (S 4 4 ) 。 先のステップ S 3 8, S 4 5 , S 4 2の後にも、 このステップ S 4 4に進 む。 ステップ S 4 4の後は、 最初のステップ S 3 1に戻り、 後続のバイトコ一ド 命令について上記処理を繰り返す。 If it is not the "instruction to invalidate the profile", the instruction is executed (S44). After the previous steps S38, S45, S42, the process also proceeds to step S44. After step S44, return to the first step S31 and follow the byte code The above process is repeated for the instruction.
上記ステップ S 3 7のコンパイルの実行可否を決めるための判断条件について 説明する。 このような判断条件の例として次の 2つを挙げる。  The judgment conditions for deciding whether or not to execute the compilation in step S37 will be described. The following two are examples of such judgment conditions.
( a ) ループ内部の大きさとネイティブコードの読み出しのオーバーへッドを比 較する。 ループ内部の大きさは、 そのバイトコードの命令数で決まり、 これに適 当な値を掛けることにより、 実際にループ 1回の実行に要する時間を概算でき る。 ネイティブコードの読み出しのオーバーヘッドとは、 ネイティブコードを実 行するために余分に実行しなければならないコードで消費される時間に相当す る。 これは一定ではないが、 一定と仮定する。 「オーバ一ヘッド +ネイティブ コードを C P Uで実行する時間」 力 s 「ループ内部の大きさ」 より小さい場合、 ネ ィティブコ一ドを実行した方が時間短縮できるので、 コンパイルを行うべきと判 断する。 そうでなければ、 バイトコードを仮想計算機で実行した方力5'速レゝか等し いので、 コンパイルを行わないと判断する。 なお、 上記判断条件では、 「ネィ ティブコ一ドを C P Uで実行する時間」 は 0とみなしている。 (a) Compare the loop inner size with the native code read overhead. The size inside the loop is determined by the number of instructions of the bytecode, and by multiplying this by an appropriate value, the time required for actually executing one loop can be estimated. The overhead of reading native code is the time spent in extra code that must be executed to execute the native code. This is not constant, but is assumed to be. If it is smaller than "overhead + time to execute native code on CPU" s If it is smaller than "the size of the inside of the loop", it is judged that compiling should be performed because executing the native code saves time. Otherwise, it is determined that the compilation is not performed because the byte code executed by the virtual machine is 5 'faster. Note that, in the above-described determination conditions, “the time for executing the native code by the CPU” is regarded as 0.
( b ) ループ内部の大きさにジャンプした回数 (ループを実行した回数) を掛け て、 関数内部のコードの静的な大きさと比較する。 ここで 「ループ内部の大き さ」 は上記の通りである。 「ループ内部の大きさ」 にジャンプした回数を掛ける ことにより、 ループ内部のバイ トコード命令を仮想計算機で実行した場合の消費 時間が概算される。 「関数内部のコードの静的な大きさ」 は、 「ループを 1回だ け実行する時間 +ループ以外の部分の実行時間」 を推定するものである。 「ルー プ内部の大きさ」 と 「関数内部のコードの静的な大きさ」 は、 その関数内で当該 ループの実行の占める時間の割合を表す。 この割合が大きければ、 コンパイルの 対象にすべきと判断する。 ある関数を実行する時間のうち、 特定のループを実行 する時間が大きければ、 当該ループのコンパイルによる実行速度向上の寄与分が 大きくなるからである。  (b) Multiply by the number of jumps (the number of times the loop was executed) by the size inside the loop and compare it with the static size of the code inside the function. Here, “the size inside the loop” is as described above. By multiplying the number of jumps by the “size inside the loop”, the time consumed when the bytecode instruction inside the loop is executed by the virtual machine is estimated. "Static size of code inside function" estimates "time to execute loop only once + execution time of parts other than loop". “Loop size” and “Static size of code inside a function” indicate the percentage of time the loop executes in the function. If this ratio is large, it is determined that it should be compiled. This is because if the time to execute a specific loop is longer than the time to execute a certain function, the contribution of improving the execution speed by compiling the loop increases.
上記判断条件 (a ) ( b ) はそれぞれ単独で採用しても、 あるいは、 A N D条 件で採用してもよい。 また、 ループのある程度の繰り返し回数力 ?見込めるなら ば、 実行時間短縮の効果が見込めるので、 両条件の判断を行わない実施の形態も 考えられる。 すなわち、 上記ステップ S 3 7は削除し、 カウンタ値が所定値に達 したら直ちにネイティブコ一ドへの変換を行うようにしてもよい。 The above judgment conditions (a) and (b) may be employed independently or may be employed under AND conditions. Also, if some number of iterations force of the loop? Expected, the effect of reducing the execution time can be expected that the embodiment does not perform the determination of both conditions it is also contemplated. That is, the above step S37 is deleted, and the counter value reaches a predetermined value. Then, the conversion to the native code may be performed immediately.
以下、 図 5〜図 8により、 具体的なプログラム例を挙げて説明する。  Hereinafter, a specific program example will be described with reference to FIGS.
図 5は、 ベーシックブロックが 1個の極めて簡単なソースプログラムの例を示 す。 この例は、 整数 i, a, bについて、 a, bの初期値をそれぞれ 0と 1 0 0 0とし、 i = 0から初めて、 aに a + bの値を代入し、 iをインクリメントする 処理を繰り返し、 iの値が 1 0 0 0に達したら、 このループを抜けるものであ る。  Figure 5 shows an example of a very simple source program with one basic block. In this example, for the integers i, a, and b, the initial values of a and b are 0 and 1 0 0 0, respectively, and starting from i = 0, assigning the value of a + b to a and incrementing i When the value of i reaches 100, the process exits from this loop.
図 6は、 このソースプログラムをコンパイルして得られたバイトコ一ドの例を 示す。 この例では、 変数 iは var [8]、 aは var [9]、 bは var [10]に割り付けられて いる。 変数 a, bの初期化のコードは省略してある。 図 6の番地 3 4から番地 5 2の前までがループ部分であり、 これがネイティブコードへのコンパイルの対象 となる。  Figure 6 shows an example of a bytecode obtained by compiling this source program. In this example, the variable i is assigned to var [8], a is assigned to var [9], and b is assigned to var [10]. The code for initializing variables a and b is omitted. The loop from address 34 to address 52 in Figure 6 is the loop, which is the target of compilation into native code.
これらのバイトコ一ド列の口一ド時に、 番地 4 9に上の番地 3 4に向かう命令 があるため、 図 7に示すように、 この番地 4 9の命令力 s前記 「プロファイルを行 う命令」 に書き換えられる。 また、 「プロファイルを無効にする命令」 は存在し ない。 Since there is an instruction at address 49 to address 34 above at the time of these byte code strings, as shown in FIG. 7, the instruction power of this address 49 s Is rewritten as In addition, there is no “instruction to invalidate a profile”.
この図 7のバイトコ一ド列のプログラムを仮想計算機で実行する際、 番地 3 4 から番地 5 2の前までのループ部分を所定回 «り返した時点でコンパィルによ り当該部分がネイティブコードに変換され、 図 8に示すように、 ループの先頭の 番地 3 4の命令が 「ネイティブコードに飛ぶための命令」 に書き換えられる。 ネ ィティブコードの具体例については、 使用する C P Uにより異なり、 また、 容量 も大きいので、 ここでは特に例示はしない。  When the byte code sequence program shown in FIG. 7 is executed by the virtual machine, the loop portion from address 34 to address 52 is returned a predetermined number of times, and the corresponding portion is converted to native code by compiling. After conversion, the instruction at address 34 at the beginning of the loop is rewritten as “instruction to jump to native code” as shown in FIG. Specific examples of the native code differ depending on the CPU used, and have a large capacity.
図 9は、 本癸明による他の実施の形態におけるプログラム実行時の処理フ口一 を示す。 先の実施の形態では、 バイトコードのロード時 (図 3 ) に、 ループ部分 検出のための細工を行ったが、 この実施の形態ではプログラム実行処理の中に図 3の処理を含めたものである。 このようにすることにより、 プログラム実行開始 までに要する時間を短縮することができる。 これは、 起動が速いことか^まれる 一方、 実行時にかかる時間はそれほど気にしない場合 (例えば、 インタラクティ ブな処理の場合) に適している。 これに対して、 先の実施の形態は、 実行開始ま でに時間がかかっても実行時の処理時間は極力短縮したいような場合 (例えば、 リアルタイム処理の場合) に適している。 FIG. 9 shows a process flow when a program is executed in another embodiment according to the present invention. In the previous embodiment, when the bytecode was loaded (FIG. 3), the work for detecting the loop portion was performed. In this embodiment, the processing in FIG. 3 is included in the program execution processing. is there. By doing so, the time required until the program execution starts can be reduced. This is suitable for cases where the startup is fast but you don't care much about the time it takes to run (eg for interactive processing). On the other hand, in the above embodiment, It is suitable for cases where it is necessary to reduce the processing time during execution as much as possible (for example, in the case of real-time processing).
図 9において、 具体的には、 全ステップ S 5 1〜S 7 1のうち、 S 5 4, S 5 5 , S 5 8, S 6 0力 先の実施の形態におけるプログラムロード時の処理ス テツプである。 ステップ S 5 2〜S 5 6は順不同である。 また、 ステップ S 5 7 のエラー処理では、 あり得ない命令の検知時にその命令をスキップするか、 ある いは仮想計算機を異常終了するものである。 このステップは図 4の実行処理には 示さなかった力 図 4の処理において含めてもよい。  In FIG. 9, specifically, among all steps S51 to S71, processing steps S54, S55, S58, and S60 at the time of loading the program in the previous embodiment are described. It is. Steps S52 to S56 are in no particular order. In the error processing in step S57, when an impossible instruction is detected, the instruction is skipped or the virtual machine is abnormally terminated. This step may be included in the processing of FIG. 4 not shown in the execution processing of FIG.
以上、 本発明の好適な実施の形態について説明したが、 本発明の要旨を逸脱す ることなく、 種々の変形 ·変更を行うことカ 能である。 例えば、 上記では J a V aアプリケーションの処理について説明したが、 いわゆるアブレツトと呼 ばれるプログラムを処理する W e bブラゥザに内蔵された仮想計算機にも本発明 は同様に適用可能である。 産業上の利用可能性  The preferred embodiment of the present invention has been described above, but various modifications and changes can be made without departing from the gist of the present invention. For example, although the processing of the JaVa application has been described above, the present invention can be similarly applied to a virtual machine built in a Web browser that processes a so-called program. Industrial applicability
本癸明の仮想計算機の実行方法および装置によれば、 中間コードからネィティ ブコードへの変換処理時間を軽減するとともに、 比較的小さいメモリ容量の装置 においても実行速度を総体的に向上させることができる。  According to the execution method and apparatus of the present invention, the conversion processing time from the intermediate code to the native code can be reduced, and the execution speed can be generally improved even in an apparatus having a relatively small memory capacity. .

Claims

請 求 の 範 囲 The scope of the claims
1 . 中間コードを実行する仮想計算機の実行方法であって、 1. A method of executing a virtual machine that executes intermediate code,
中間コードの実行時に繰り返し実行されるループ部分を、 該実行中に動的に検 出するステップと、  Dynamically detecting, during the execution of the intermediate code, a loop portion that is repeatedly executed;
当該ループ部分の中間コードをネイティブコードに変換するステップと、 前記中間コードの当該ループ部分については、 前記ネイティブコードを C P U により直接実行するステップと、  Converting the intermediate code of the loop portion into native code; and executing the native code directly by CPU for the loop portion of the intermediate code;
を備えることを特徴とする仮想計算機の実行方法。  A method for executing a virtual machine, comprising:
2 . 前記中間コードをメモリ上にロードする際に、 制御の流れが上に向かう命 令を検出し、 該命令の検出時に該命令を第 1の特別の命令に書き換えるステップ と、 2. When loading the intermediate code into the memory, detecting an instruction whose control flow is upward, and rewriting the instruction to a first special instruction upon detecting the instruction;
前記メモリ上の中間コードを実行する際、 前記第 1の特別の命令の実行時に制 御の飛び先を確認し、 再度同じ第 1の特別の命令を実行したときに制御の飛び先 力 s—致したならば、 当該飛び先から飛び元を前記ループ部分であると判断し、 該 ループ部分の中間コードをネイティブコードに変換するステップと、 When executing the intermediate code on the memory, the control jump destination is checked when the first special instruction is executed, and the control jump target power s — when the same first special instruction is executed again. If so, determining that the jump source from the jump destination is the loop portion, and converting the intermediate code of the loop portion into native code;
を有することを特徴とする請求の範囲 1記載の仮想計算機の実行方法。  2. The method for executing a virtual machine according to claim 1, comprising:
3 . 前記第 1の特別の命令に書き換えるステップを、 中間コードのロード時に 代えて実行時に行うことを特徴とする請求の範囲 2記載の仮想計算機の実行方 3. The method according to claim 2, wherein the step of rewriting the first special instruction is performed at the time of execution instead of at the time of loading the intermediate code.
4 . 前記飛ひ、先が一致した回数をカウントし、 該カウント値が予め定めた値に 達したとき、 さらに、 当該ループ部分のネイティブコードへの変換の可否を予め 定めた判断基準で判断し、 該判断基準力 s満足されたとき前記ネイティブコードへ の変換を行うことを特徴とする請求の範囲 2または 3記載の仮想計算機の実行方 法。 4. Count the number of times the jump and the end match, and when the count value reaches a predetermined value, determine whether or not the loop part can be converted to native code according to predetermined criteria. 4. The method according to claim 2, wherein the conversion to the native code is performed when the judgment criterion s is satisfied.
5 . 前記判断基準が満足されなかつたとき、 当該第 1の特別の命令を元の普通 の命令に戻すことを特徴とする請求の範囲 4記載の仮想計算機の実行方法。 5. The method according to claim 4, wherein the first special instruction is returned to an original ordinary instruction when the judgment criterion is not satisfied.
6 . 前記中間コードをメモリ上にロードする際に、 前記 「制御の流れが上に向 かう命令」 以外の制御の流れを変える命令を検出し、 該命令の検出時に該命令を 第 2の特別の命令に書き換えるステップと、 6. When loading the intermediate code into the memory, an instruction that changes the control flow other than the “instruction for upward control flow” is detected, and when the instruction is detected, the instruction is changed to a second special instruction. Rewriting to the instruction of
前記メモリ上の中間コードを実行する際、 前記第 2の特別の命令の実行時に前 記飛び先の情報を無効にするステップと、  When executing the intermediate code in the memory, invalidating the jump destination information at the time of executing the second special instruction;
を有することを特徴とする請求の範囲 2記載の仮想計算機の実^ 1方法。 Real ^ 1 process virtual machine according to claim 2, wherein characterized in that it comprises a.
7 . 前記第 2の特別の命令に書き換えるステップを、 中間コードのロード時に 代えて実行時に行うことを特徴とする請求の範囲 2記載の仮想計算機の実行方 法。 7. The execution method of a virtual machine according to claim 2, wherein the step of rewriting to the second special instruction is performed at the time of execution instead of at the time of loading the intermediate code.
8 . 中間コードを実行する仮想計算機の実行装置であって、 8. An execution device of a virtual machine for executing intermediate code,
ネイティブコードを実行する C P Uと、  C P U that runs native code,
中間コードを記憶するメモリと、  A memory for storing intermediate code,
該メモリ上に中間コ一ドを口一ドする手段と、  Means for loading an intermediate code on the memory;
該中間コードを解釈して実行する、 前記 C P U上の仮想計算機手段と、 該仮想 機手段による前記中間コ一ドの実行時に繰り返し実行されるループ 部分を、 該実行中に動的に検出し、 当該ループ部分の中間コードをネイティブ コードに変換する手段とを備え、  Virtual machine means on the CPU for interpreting and executing the intermediate code, and a loop portion repeatedly executed when the intermediate code is executed by the virtual machine means, dynamically detecting during the execution, Means for converting the intermediate code of the loop portion into native code,
前記中間コードの当該ループ部分については、 前記ネイティブコードを前記 For the loop portion of the intermediate code, the native code is
C P Uにより直接実行することを特徴とする仮想計算機の実行装置。 An execution device of a virtual machine, which is directly executed by CPU.
9 . 中間コードを実行する仮想計算機の実行のためのコンピュータプログラム を格納した記録媒体であつて、 9. A recording medium storing a computer program for executing a virtual machine for executing an intermediate code,
中間コードを記'億するメモリ上に中間コードをロードするステップと、 該中間コードを解釈して実行する、 C P U上の仮想計算機による前記中間コー ドの実行時に繰り返し実行されるループ部分を、 該実行中に動的に検出し、 当該 ループ部分の中間コードをネイティブコードに変換するステップと、 Loading the intermediate code on a memory that stores the intermediate code; and interpreting and executing the intermediate code by a virtual machine on a CPU. Dynamically detecting a loop portion repeatedly executed during execution of the code during the execution, and converting intermediate code of the loop portion into native code;
前記中間コードの当該ループ部分については、 前記ネイティブコードを前記 C P Uにより直接実行するステップと、  Directly executing the native code by the CPU for the loop portion of the intermediate code;
を備えるコンピュータプログラムを格納した記録媒体。  A recording medium storing a computer program comprising:
PCT/JP2000/005540 1999-08-18 2000-08-18 Method and apparatus for operating virtual computer WO2001013223A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
AU65957/00A AU6595700A (en) 1999-08-18 2000-08-18 Method and apparatus for operating virtual computer

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP23164999A JP2001056764A (en) 1999-08-18 1999-08-18 Method and device for executing virtual machine
JP11/231649 1999-08-18

Publications (1)

Publication Number Publication Date
WO2001013223A1 true WO2001013223A1 (en) 2001-02-22

Family

ID=16926815

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2000/005540 WO2001013223A1 (en) 1999-08-18 2000-08-18 Method and apparatus for operating virtual computer

Country Status (3)

Country Link
JP (1) JP2001056764A (en)
AU (1) AU6595700A (en)
WO (1) WO2001013223A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1313012A1 (en) * 2001-11-15 2003-05-21 Texas Instruments France Java DSP acceleration by byte-code optimization

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20040044655A (en) * 2002-11-21 2004-05-31 한국전자통신연구원 Method of generating bytecodes for loop in java virtual machine and processing the bytecodes
KR100506522B1 (en) * 2003-02-24 2005-08-03 삼성전자주식회사 System and method for shortening time in compiling of byte code in java program
JP4846226B2 (en) * 2004-10-26 2011-12-28 株式会社日立ソリューションズ Information processing apparatus, information processing method, and program
KR100763177B1 (en) 2005-04-21 2007-10-04 삼성전자주식회사 Method for executing Java virtual machine instructions, and apparatus for the same
KR100678912B1 (en) 2005-10-18 2007-02-05 삼성전자주식회사 Method for interpreting method bytecode and system by the same

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH10240546A (en) * 1997-02-28 1998-09-11 Hitachi Ltd Execution time program translation method
US5815720A (en) * 1996-03-15 1998-09-29 Institute For The Development Of Emerging Architectures, L.L.C. Use of dynamic translation to collect and exploit run-time information in an optimizing compilation system
JP2000222220A (en) * 1999-01-28 2000-08-11 Internatl Business Mach Corp <Ibm> Dynamically compiling time setting method, byte code executing mode selecting method and computer

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5815720A (en) * 1996-03-15 1998-09-29 Institute For The Development Of Emerging Architectures, L.L.C. Use of dynamic translation to collect and exploit run-time information in an optimizing compilation system
JPH10240546A (en) * 1997-02-28 1998-09-11 Hitachi Ltd Execution time program translation method
JP2000222220A (en) * 1999-01-28 2000-08-11 Internatl Business Mach Corp <Ibm> Dynamically compiling time setting method, byte code executing mode selecting method and computer

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
SHIMURA ET AL.: "Yava(TM) JIT compiler no shisaku", TECHNICAL RESEARCH REPORT OF INFORMATION PROCESSING SOCIETY OF JAPAN(IPSJ), SHADAN HOUJIN INFORMATION PROCESSING SOCIETY OF JAPAN(IPSJ), vol. 96, no. 106 (96-ARC-120), 31 October 1996 (1996-10-31), pages 37 - 42, XP002933970 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1313012A1 (en) * 2001-11-15 2003-05-21 Texas Instruments France Java DSP acceleration by byte-code optimization
US7146613B2 (en) 2001-11-15 2006-12-05 Texas Instruments Incorporated JAVA DSP acceleration by byte-code optimization

Also Published As

Publication number Publication date
AU6595700A (en) 2001-03-13
JP2001056764A (en) 2001-02-27

Similar Documents

Publication Publication Date Title
US6289446B1 (en) Exception handling utilizing call instruction with context information
US8769511B2 (en) Dynamic incremental compiler and method
US6078744A (en) Method and apparatus for improving compiler performance during subsequent compilations of a source program
US7039738B2 (en) Method and system for handling device driver interrupts
US7840950B2 (en) Programmatic compiler optimization of glacial constants
JP3470948B2 (en) Dynamic compilation timing determination method, bytecode execution mode selection method, and computer
US7698697B2 (en) Transforming code to expose glacial constants to a compiler
US20030005271A1 (en) System and method using a hardware embedded run-time optimizer
US10216497B2 (en) Selective compiling method, device, and corresponding computer program product
JP2003140909A (en) Virtual computer having jit compiler
US9038039B2 (en) Apparatus and method for accelerating java translation
US8056061B2 (en) Data processing device and method using predesignated register
US6931638B2 (en) Method and apparatus to facilitate sharing optimized instruction code in a multitasking virtual machine
JP2004507832A (en) A system that executes virtual machine instructions
WO2001013223A1 (en) Method and apparatus for operating virtual computer
JP4093484B2 (en) Compiler, compilation method, compilation program, and recording medium
JP2005284729A (en) Virtual machine compiling byte code into native code
JPH0877021A (en) Device and method for interruption processing
JP2002073345A (en) Information processing system and storage medium
Bebenita Trace-Based Compilation and Optimization in Meta-Circular Virtual Execution Environments
JP2002251288A (en) Compiling method

Legal Events

Date Code Title Description
AK Designated states

Kind code of ref document: A1

Designated state(s): AU BR CA CN KR SG US

AL Designated countries for regional patents

Kind code of ref document: A1

Designated state(s): GH GM KE LS MW MZ SD SL SZ TZ UG ZW AM AZ BY KG KZ MD RU TJ TM AT BE CH CY DE DK ES FI FR GB GR IE IT LU MC NL PT SE BF BJ CF CG CI CM GA GN GW ML MR NE SN TD TG

121 Ep: the epo has been informed by wipo that ep was designated in this application
122 Ep: pct application non-entry in european phase