JP2001092672A - Method and device for rewriting instruction code and information recording medium - Google Patents

Method and device for rewriting instruction code and information recording medium

Info

Publication number
JP2001092672A
JP2001092672A JP26834699A JP26834699A JP2001092672A JP 2001092672 A JP2001092672 A JP 2001092672A JP 26834699 A JP26834699 A JP 26834699A JP 26834699 A JP26834699 A JP 26834699A JP 2001092672 A JP2001092672 A JP 2001092672A
Authority
JP
Japan
Prior art keywords
name
instruction
program
side effect
resolved
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP26834699A
Other languages
Japanese (ja)
Inventor
Ryuji Sakai
隆二 境
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Toshiba Corp
Original Assignee
Toshiba Corp
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 Toshiba Corp filed Critical Toshiba Corp
Priority to JP26834699A priority Critical patent/JP2001092672A/en
Publication of JP2001092672A publication Critical patent/JP2001092672A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a method for rewriting an instruction code whose executing efficiency is improved. SOLUTION: A compiler for compiling a source program to an execution program generates a name reference and solution calling instruction for calling a name solution procedure for solving a name which can be solved only at the time of program execution and an instruction without any side effect having name identification information for identifying the name which can be solved only at the time of program execution and the number of a target register for storing a solved name. Then, the instruction without any side effect generated by the compiler is distributed to a delayed slot. Then, at the time of executing an execution program, the name solution procedure is called according to the name reference and solution calling instruction, and the name reference and solution calling instruction and the instruction without any side effect are rewritten into an instruction for storing a value obtained by solving the name in the target register based on the instruction without any side effect.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、プログラム実行時
に、実行されるプログラムの命令を書き換えながら処理
を行うプログラムの命令コード書き換え方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a method of rewriting an instruction code of a program which performs processing while rewriting an instruction of the program to be executed when the program is executed.

【0002】また、本発明は、このような方法の命令コ
ード書き換えを行なう命令コード書き換え装置及び情報
記録媒体に関する。
[0002] The present invention also relates to an instruction code rewriting device and an information recording medium for rewriting an instruction code by such a method.

【0003】[0003]

【従来の技術】プログラム実行時に、実行されるプログ
ラムの命令コードを書き換えることの主な目的は、プロ
グラム実行時にしか解決できない値を、実行時に解決し
て、プログラムコード上に埋め込むことである。
2. Description of the Related Art The main purpose of rewriting an instruction code of a program to be executed at the time of executing the program is to solve at execution time a value which can be solved only at the time of executing the program and to embed the value in the program code.

【0004】プログラム実行時にしかわからない値とい
うのは、ランタイムライブラリのエントリアドレスや、
システムのグローバルな変数名などであるが、その他に
オブジェクト指向プログラムにおけるオブジェクトの特
定のフィールドのオフセットや、クラスのスタティック
変数のアドレスなどがある。
[0004] The values that can be known only at the time of program execution include the entry address of the runtime library and the
This is the global variable name of the system, but also the offset of a specific field of an object in an object-oriented program, the address of a static variable of a class, and the like.

【0005】これらの情報は、プログラムロード時に解
決できるものもあるが、Java言語のように、変数へ
の最初のアクセス時に解決しなければならないような状
況では、プログラムを実行中に、その変数へ最初にアク
セスしたまさにそのときに、名前の解決を行う必要があ
る。
[0005] Some of this information can be resolved at the time of loading the program. However, in a situation where the variable must be resolved at the first access to the variable, such as the Java language, the variable is stored during execution of the program. Just when you first access it, you need to resolve the name.

【0006】このとき、名前情報および、解決した値を
データセクションに保持するようにすれば、実行時にプ
ログラムの命令コードを書き換える必要はないが、この
場合、名前を解決するための処理を呼び出すためのコー
ドを埋め込む必要があり、名前が解決された後でも、そ
の部分を実行する度に、この呼び出し処理を実行しなけ
ればならない。
At this time, if the name information and the resolved value are held in the data section, it is not necessary to rewrite the instruction code of the program at the time of execution. In this case, however, a process for resolving the name is called. Code, and this call must be performed each time the part is executed, even after the name is resolved.

【0007】以上のような問題点を解決するために、プ
ログラム実行時に名前解決した結果をプログラムの命令
コードへ反映させるという方式がとられている。
In order to solve the above problems, a method has been adopted in which the result of name resolution during program execution is reflected in the instruction code of the program.

【0008】図27は、従来の名前解決処理を説明する
ための図である。
FIG. 27 is a diagram for explaining a conventional name resolution process.

【0009】同図において、「arg」は、手続き呼び
出しにおいて第一引数となるレジスタまたはスタックア
ドレス、「val」は、リターン値を返すためのレジス
タである。
In FIG. 1, "arg" is a register or stack address which becomes a first argument in a procedure call, and "val" is a register for returning a return value.

【0010】また、「call」は、手続き呼び出し命
令(jump&link)、「NameID」は、名前
を識別するためのIDである。
“Call” is a procedure call instruction (jump & link), and “NameID” is an ID for identifying a name.

【0011】「resolveName」は、名前解決
処理のエントリアドレス、「resolvedValu
e」は、名前解決した値である。
"ResolveName" is an entry address for name resolution processing, "resolvedValue"
"e" is a name-resolved value.

【0012】「dstReg」は、解決した値を格納す
るべきレジスタ(valと同じ場合は、このレジスタへ
のコピー命令は不要)である。
"DstReg" is a register in which the resolved value is to be stored (if it is the same as val, a copy instruction to this register is unnecessary).

【0013】通常、32ビットデータをレジスタへ書き
込むためには、2命令必要なため、名前解決後の命令列
も、同じ命令数必要となる。仮に、1命令で解決した値
をレジスタへ書き込むことが出来る場合でも、nop命
令を配置して、書き換え前と同じ命令数としなければな
らない。
Usually, two instructions are required to write 32-bit data to a register, and therefore, the same number of instructions are required for an instruction sequence after name resolution. Even if a value resolved by one instruction can be written to a register, a nop instruction must be arranged to have the same number of instructions as before rewriting.

【0014】この方法は、手続き呼び出し規則に従った
ものであるため、以降では、「手続き呼び出し規則に従
った名前解決処理呼び出し方式」と呼ぶことにする。
Since this method complies with the procedure calling rule, hereinafter, it is referred to as "name resolution processing calling method according to the procedure calling rule".

【0015】ここで、「手続き呼び出し規則」(リンケ
ージ規約、ABIなどともいわれる)について簡単に説
明する。
Here, the "procedure calling rule" (also called linkage convention, ABI, etc.) will be briefly described.

【0016】手続き呼び出し規則とは、各マイクロプロ
セッサの命令セットアーキテクチャ毎に規定されている
規則で、この規則に従う限り、どの言語でプログラムを
書いても、相互にプログラムの手続きを呼び出すことが
可能となるものである。
The procedure calling rule is a rule defined for each instruction set architecture of each microprocessor. As long as the rules are followed, it is possible to write a program in any language and call the program procedure mutually. It becomes.

【0017】手続き呼び出し規則は、手続き呼び出しに
おいて、引数の何個目までのデータをどのレジスタに保
持するのか、その他の引数のデータをどのようにスタッ
ク上に保持するのか、リターンアドレスはどのレジスタ
(或いはスタック上の特定の相対位置)に保持するの
か、リターン値はどのレジスタ(或いはスタック上の相
対位置)に保持するのかを定めている。ここで、リター
ンアドレスとは、呼び出された手続きを完了した後、呼
び出した元に戻るためのアドレスである。
In the procedure call rule, in a procedure call, up to what number of argument data is held in which register, how other argument data is held on the stack, and the return address is determined by which register ( Or, the return value defines which register (or relative position on the stack) to hold in a specific relative position on the stack. Here, the return address is an address for returning to the calling source after completing the called procedure.

【0018】そして、いくつかのレジスタについて手続
き呼び出しの前後で、レジスタの内容が同じであること
を保証する。例えば、mipsアーキテクチャでは、$
0〜$31の32個のレジスタのうち、$16〜$23
の8個と、$29(=$spスタックポインタ)、$3
0の値、が手続き呼び出しの前後で、値が同一であるこ
とが保証されている。
Then, it is guaranteed that the contents of some registers are the same before and after the procedure call. For example, in the mips architecture,
Of the 32 registers 0 to $ 31, $ 16 to $ 23
, $ 29 (= $ sp stack pointer), $ 3
A value of 0 is guaranteed to be the same before and after the procedure call.

【0019】この規約を守るために、手続き内で上記の
レジスタを使用する場合は、手続きの入り口でレジスタ
の内容をスタックへセーブし、手続きから戻るときに、
セーブした値を元のレジスタへリストアする処理を行な
う。これらのレジスタをcalle−savedレジス
タという。
In order to comply with this convention, when using the above register in a procedure, the contents of the register are saved on the stack at the entry of the procedure, and when returning from the procedure,
A process of restoring the saved value to the original register is performed. These registers are called call-saved registers.

【0020】逆に、手続き呼び出しをまたがって、ある
値をレジスタに保持したい場合には、手続き呼び出しの
前後で、値の保証されているレジスタを使わなければな
らない。この制約も名前解決処理を手続き呼び出し規則
にしたがって行なった場合に、効率のよい処理を実現す
るための障害となる。
Conversely, if it is desired to hold a certain value in a register across a procedure call, a register whose value is guaranteed must be used before and after the procedure call. This restriction also becomes an obstacle for realizing efficient processing when the name resolution processing is performed according to the procedure calling rules.

【0021】例えば、 $x ← ベースアドレス $v ← 名前解決(名前解決処理呼び出し) $t ← $x + $v という一連の処理では、$xはcallee−save
dレジスタとしなければならない。すると、この上記の
一連の処理を含む手続きの入口と出口で、このcall
ee−savedレジスタをセーブ、リストアする処理
を行なわなければならない。
For example, in a series of processing of $ x ← base address $ v ← name resolution (name resolution processing call) $ t ← $ x + $ v, $ x is a call-save
Must be a d register. Then, at the entrance and exit of the procedure including the above series of processes, this call
Processing for saving and restoring the ee-saved register must be performed.

【0022】次に、「手続き呼び出し規則に従った名前
解決処理」について説明する。
Next, "name resolution processing according to procedure calling rules" will be described.

【0023】手続き呼び出し規則においては、名前解決
した結果が、特定のレジスタに保持されて返ってくるの
で、その値を他のレジスタへコピーしておかなければな
らない状況がある。
According to the procedure calling rules, the result of name resolution is returned in a specific register, and the value must be copied to another register.

【0024】特定のレジスタをRVとし、テンポラリに
使用するレジスタをTとすると、図29に示すような一
連の処理があったとき、最後のXの参照を行なうため
に、図30に示すように、解決した値をテンポラリレジ
スタTへコピーしておかなければならない。
Assuming that a specific register is RV and a register temporarily used is T, when a series of processing as shown in FIG. 29 is performed, the last X is referred to as shown in FIG. , The resolved value must be copied to the temporary register T.

【0025】[0025]

【発明が解決しようとする課題】図27に示した方法に
よると、名前を解決した値を保持するためのレジスタ
は、手続き呼び出しにおいて、リターン値を返すための
レジスタ(val)としなければならない。
According to the method shown in FIG. 27, a register for holding a value whose name has been resolved must be a register (val) for returning a return value in a procedure call.

【0026】また、解決する値がオブジェクトのフィー
ルドオフセット情報のような場合、解決して得たオフセ
ット値によって、メモリアクセスすることになるが、オ
ブジェクトのベースアドレス情報を名前解決処理へ渡す
ことが出来ないため、メモリアクセスのための命令コー
ドは、図28に示すように、名前解決処理呼び出しの後
に配置しなければならない。
When the value to be resolved is the field offset information of the object, the memory is accessed by the offset value obtained by the resolution. However, the base address information of the object can be passed to the name resolution processing. Therefore, the instruction code for memory access must be placed after the name resolution processing call as shown in FIG.

【0027】さらに、名前を解決した値を保持するため
のレジスタをリターン値を返すためのレジスタとしなけ
ればならないし、引数レジスタに名前IDを格納しなけ
ればならないし、名前解決処理をまたがって参照するデ
ータはcallee−savedレジスタとしなければ
ならないなど、従来の手続き呼び出し規則に従った名前
解決処理呼び出し方式では制約がきつく、効率的な命令
コードにすることが困難であった。
Further, the register for holding the value whose name has been resolved must be a register for returning a return value, the name ID must be stored in the argument register, and reference is made across the name resolution processing. For example, the data to be processed must be a call-save register, and the name resolution processing calling method according to the conventional procedure calling rules has a severe limitation, and it has been difficult to make an efficient instruction code.

【0028】本発明は、上記実情に鑑みてなされたもの
であり、プログラム実行時の名前解決及び命令コード書
き換えの結果生成される目的コードの実行効率を向上さ
せることができる命令コード書き換え方法を提供するこ
とを目的とする。
The present invention has been made in view of the above circumstances, and provides an instruction code rewriting method capable of improving the execution efficiency of a target code generated as a result of name resolution and instruction code rewriting during program execution. The purpose is to do.

【0029】また、本発明は、このような命令コード書
き換え方法によって命令コードを書き換える命令コード
書き換え装置及びコンピュータ読み取り可能な情報記録
媒体を提供することを目的とする。
Another object of the present invention is to provide an instruction code rewriting device for rewriting an instruction code by such an instruction code rewriting method and a computer-readable information recording medium.

【0030】[0030]

【課題を解決するための手段】したがって、上記目的を
達成するために、本発明の第1の発明は、ソースプログ
ラムを実行プログラムにコンパイルするコンパイラにお
いて、プログラム実行時にしか解決することのできない
名前を解決するための名前解決手続きを呼び出す名前参
照解決呼び出し命令と、前記プログラム実行時にしか解
決することのできない名前を識別するための名前識別情
報及び解決した名前をストアするための目的レジスタの
番号を有する副作用のない命令とを生成し、前記コンパ
イラにおいて、生成された副作用のない命令をディレイ
ドスロットに配置し、前記実行プログラムの実行時に、
前記名前参照解決呼び出し命令において呼び出される名
前解決手続きにおいて、前記副作用のない命令に基づい
て、前記名前参照解決呼び出し命令及び前記副作用のな
い命令を目的レジスタに名前解決した値を読み込む命令
に書きかえることを特徴とする命令コード書き換え方
法、である。
Therefore, in order to achieve the above object, a first aspect of the present invention is to provide a compiler which compiles a source program into an executable program, by using a name which can be resolved only when the program is executed. A name reference resolution call instruction for calling a name resolution procedure for resolution; name identification information for identifying a name that can be resolved only when the program is executed; and a target register number for storing the resolved name. An instruction having no side effect is generated, and in the compiler, the generated instruction having no side effect is arranged in a delayed slot, and when the execution program is executed,
In the name resolution procedure called by the name reference resolution call instruction, rewriting the name reference resolution call instruction and the instruction having no side effect into an instruction for reading a value obtained by resolving the name into a target register based on the instruction having no side effect. And a method of rewriting an instruction code.

【0031】このような発明によれば、コンパイラによ
って生成されるディレイドスロットに配置された副作用
のない命令に基づいて、名前解決手続きにおいて、名前
参照解決呼び出し命令及び前記副作用のない命令を目的
レジスタに名前解決した値をストアする命令に書きかえ
るので、目的コードの実行効率を向上させることができ
る。
According to the invention, in the name resolution procedure, the name reference resolution call instruction and the instruction having no side effect are stored in the target register based on the instruction having no side effect, which is generated by the compiler and is arranged in the delayed slot. Since the instruction for storing the name-resolved value is rewritten, the execution efficiency of the target code can be improved.

【0032】また、第2の発明は、ソースプログラムを
実行プログラムにコンパイルするコンパイラにおいて、
プログラム実行時にしか解決することのできないオブジ
ェクトフィールドの名前を解決するための名前解決手続
きを呼び出す名前参照解決呼び出し命令と、前記プログ
ラム実行時にしか解決することのできないオブジェクト
フィールドの名前を識別するための名前識別情報、解決
した名前をストアするための目的レジスタの番号及びオ
ブジェクトのベースアドレスを有する副作用のない命令
とを生成し、前記コンパイラにおいて、生成された副作
用のない命令をディレイドスロットに配置し、前記実行
プログラムの実行時に、前記名前参照解決呼び出し命令
において呼び出される名前解決手続きにおいて、前記副
作用のない命令に基づいて、前記名前参照解決呼び出し
命令及び前記副作用のない命令を、オブジェクトのベー
スアドレスに名前解決した値を加算したアドレスのデー
タを目的レジスタに読み込む命令に書きかえることを特
徴とする命令コード書き換え方法、である。
According to a second aspect of the present invention, there is provided a compiler for compiling a source program into an execution program.
A name reference resolution call instruction that calls a name resolution procedure for resolving the name of an object field that can only be resolved at program execution, and a name for identifying a name of the object field that can be resolved only at the time of program execution Generating an instruction having no side effect having identification information, a number of a destination register for storing the resolved name and a base address of the object, and placing the generated instruction having no side effect in a delayed slot in the compiler; In executing the execution program, in the name resolution procedure called in the name reference resolution call instruction, the name reference resolution call instruction and the instruction without side effect are named in the base address of the object based on the instruction without side effect. Instruction code rewriting method characterized by rewriting the instruction to read the data of the address obtained by adding the value persists in the destination register is.

【0033】このような発明によれば、コンパイラによ
って生成されるディレイドスロットに配置された副作用
のない命令に基づいて、名前解決手続きにおいて、名前
参照解決呼び出し命令及び前記副作用のない命令をオブ
ジェクトのベースアドレスに名前解決した値を加算した
アドレスのデータを目的レジスタにロードする命令に書
きかえるので、目的コードの実行効率を向上させること
ができる。
According to the invention, in the name resolution procedure, the name reference resolution call instruction and the instruction having no side effect are converted into the base of the object based on the instruction having no side effect arranged in the delayed slot generated by the compiler. Since the data at the address obtained by adding the value obtained by resolving the name to the address is rewritten to the instruction for loading the target register, the execution efficiency of the target code can be improved.

【0034】さらに、第3の発明は、ソースプログラム
を実行プログラムにコンパイルするコンパイラにおい
て、プログラム実行時にしか解決することのできない名
前を解決するための名前解決手続きを呼び出す名前参照
解決呼び出し命令と、オブジェクトのベースアドレス、
前記プログラム実行時にしか解決することのできない名
前を識別するための名前識別情報、オブジェクトフィー
ルドへストアする値を保持するレジスタ番号を有する副
作用のない命令とを生成し、前記コンパイラにおいて、
生成された副作用のない命令をディレイドスロットに配
置し、前記実行プログラムの実行時に、前記名前参照解
決呼び出し命令において呼び出される名前解決手続きに
おいて、前記副作用のない命令に基づいて、前記名前参
照解決呼び出し命令及び前記副作用のない命令を、前記
レジスタ番号のレジスタに保持されている値を前記オブ
ジェクトのベースアドレスに名前解決した値を加算した
アドレスへストアする命令に書きかえることを特徴とす
る命令コード書き換え方法、である。
Further, a third invention provides a compiler for compiling a source program into an execution program, a name reference resolution call instruction for calling a name resolution procedure for resolving a name that can be resolved only at the time of program execution, Base address of the
The compiler generates name identification information for identifying a name that can be resolved only at the time of program execution, and an instruction without a side effect having a register number that holds a value to be stored in an object field.
The generated instruction having no side effect is arranged in a delayed slot, and in executing the execution program, in the name resolution procedure called by the name reference resolution call instruction, the name reference resolution call instruction is executed based on the instruction having no side effect. And rewriting the instruction having no side effect into an instruction for storing a value held in the register of the register number to an address obtained by adding a value obtained by resolving a name to a base address of the object, and rewriting the instruction code. ,.

【0035】このような発明によれば、コンパイラによ
って生成されるディレイドスロットに配置された副作用
のない命令に基づいて、名前解決手続きにおいて、名前
参照解決呼び出し命令及び前記副作用のない命令をレジ
スタ番号のレジスタに保持されている値を前記オブジェ
クトのベースアドレスに名前解決した値を加算したアド
レスへストアする命令に書きかえるので、目的コードの
実行効率を向上させることができる。
According to such an invention, in the name resolution procedure, the name reference resolution call instruction and the instruction having no side effect are registered in the register number based on the instruction having no side effect arranged in the delayed slot generated by the compiler. Since the value stored in the register is rewritten into the instruction for storing the value obtained by adding the value obtained by resolving the name to the base address of the object, the execution efficiency of the target code can be improved.

【0036】さらに、第4の発明は、第2の発明又は第
3の発明において、前記コンパイラは、オブジェクトフ
ィールドアクセスの先行関係を解析し、前記名前解決手
続きは、前記コンパイラによる先行関係の解析結果に基
づいて、複数の名前を解決することを特徴とする。
Further, in a fourth invention based on the second invention or the third invention, the compiler analyzes a precedence relationship of an object field access, and the name resolution procedure includes a result of the precedence analysis by the compiler. A plurality of names are resolved based on

【0037】このような発明によれば、オブジェクトフ
ィールドアクセスが複数ある場であっても、コンパイラ
の先行解析結果に基づいて、複数の名前を解決すること
ができるので、第2又は第3の発明に比して、より実行
効率を向上させることができる。
According to such an invention, even when there are a plurality of object field accesses, a plurality of names can be resolved based on the pre-analysis result of the compiler. The execution efficiency can be further improved as compared with.

【0038】また、本発明の第5の発明は、これらプロ
グラムコード書き換え方法を実行するプログラムコード
書き換え装置及びプログラムコード書き換え方法を実行
するプログラムを記録したコンピュータ読み取り可能な
情報記録媒体である。
The fifth invention of the present invention is a program code rewriting device for executing the program code rewriting method and a computer readable information recording medium recording a program for executing the program code rewriting method.

【0039】なお、上述の発明において、名前は、オブ
ジェクト指向プログラムのスタティック変数、オブジェ
クトフィールドアクセスに関する変数及びオブジェクト
指向プログラムのスタティックメソッド呼び出しに関す
る変数であってもよい。
In the above-described invention, the name may be a static variable of an object-oriented program, a variable related to object field access, or a variable related to a static method call of the object-oriented program.

【0040】[0040]

【発明の実施の形態】次に、本発明の実施の形態に係る
命令コード書き換え方法について説明する。
Next, an instruction code rewriting method according to an embodiment of the present invention will be described.

【0041】まず、最初に、本発明の実施の形態に係る
命令コード書き換え方法の大まかな処理の流れについて
説明する。
First, a rough processing flow of the instruction code rewriting method according to the embodiment of the present invention will be described.

【0042】図1に示すように、ソースプログラム1
は、コンパイラ2によるコンパイル処理により、名前解
決前の実行プログラム3に変換される。そして、この名
前解決前の実行プログラム3は、実行されながら、手続
き呼出し命令によって呼び出される名前解決処理の手続
きにおいて、名前解決処理が行なわれるとともに、命令
コードが書き換えられ(命令コード書き換え処理4)、
名前解決後(命令コード書き換え後)の実行プログラム
5が生成される。
As shown in FIG. 1, the source program 1
Is converted into an execution program 3 before name resolution by a compiling process by the compiler 2. Then, the execution program 3 before the name resolution is executed, while executing the name resolution processing in the procedure of the name resolution processing called by the procedure call instruction, and the instruction code is rewritten (instruction code rewriting processing 4).
The execution program 5 after the name resolution (after rewriting the instruction code) is generated.

【0043】本発明の命令コード書き換え方法の特徴
は、上述のコンパイラにおけるコンパイル処理及び名前
解決処理における命令コード書き換え方法にある。
The feature of the instruction code rewriting method of the present invention lies in the instruction code rewriting method in the compile processing and the name resolution processing in the compiler described above.

【0044】以下、コンパイラにおけるコンパイル処理
(コード生成処理)について説明する。
The compile process (code generation process) in the compiler will be described below.

【0045】本実施の形態の命令コード書き換え方法に
おいては、コンパイラのコード生成処理において、プロ
グラム実行中に、名前解決する変数へのアクセスのコー
ドを生成するときに、以下の手順で行なう。
In the instruction code rewriting method according to the present embodiment, in the code generation processing of the compiler, during the execution of the program, the code for accessing the variable whose name is to be resolved is generated in the following procedure.

【0046】1. アクセスする名前が、スタティック
変数のとき 名前解決処理を呼び出す命令と、名前IDと解決した名
前の値を格納したいレジスタ番号を使って、副作用のな
い命令を生成する。
1. When the name to be accessed is a static variable, an instruction having no side effect is generated by using the instruction for calling the name resolution processing and the register number in which the name ID and the value of the resolved name are to be stored.

【0047】2. アクセスする名前が、オブジェクト
変数のとき A. オブジェクト変数の読み出し(ロード) 名前解決処理を呼び出す命令と、名前IDとオブジェク
トのベースアドレスが格納されているレジスタ番号と変
数の値をロードした値を格納するレジスタ番号を使っ
て、副作用のない命令を生成する。
2. When the name to be accessed is an object variable A. Reading (loading) of object variables Instructions that call name resolution processing, instructions that have no side effects, using the register number that stores the name ID, the register number that stores the base address of the object, and the value that loads the value of the variable Generate

【0048】B. オブジェクト変数の書き込み(スト
ア) 名前解決処理を呼び出す命令と、名前IDとオブジェク
トのベースアドレスが格納されているレジスタ番号とス
トアする値が格納されたレジスタ番号を使って、副作用
のない命令を生成する。
B. Write (Store) Object Variable Generates an instruction without side effects using an instruction that calls the name resolution process, a register number that stores the name ID, the base number of the object, and a register number that stores the value to be stored. .

【0049】Javaなどのオブジェクト指向言語で
は、変数名だけではなく、手続き名(メソッド)もプロ
グラム実行中に解決される。スタティックなメソッドの
呼び出しについては、スタティック変数の場合と同様
に、メソッド名を解決して値(手続きのエントリアドレ
ス)を得て、その値を格納したレジスタを使ってメソッ
ドを呼び出せばよい。
In an object-oriented language such as Java, not only variable names but also procedure names (methods) are resolved during program execution. In the case of calling a static method, as in the case of the static variable, the method name may be resolved to obtain a value (entry address of the procedure), and the method may be called using the register storing the value.

【0050】バーチャルメソッド(オブジェクトメソッ
ド)の呼び出しについては、オブジェクト変数の場合と
同様に、呼び出すバーチャルメソッドをオブジェクトの
ベースアドレスが格納されたレジスタ番号と名前ID、
メソッドのエントリアドレスを格納するためのレジスタ
番号を使って命令を生成する。このとき生成されるコー
ドは、オブジェクトのベースアドレスからメソッドテー
ブルをロードする命令と、メソッドテーブルから名前I
Dを解決して得られるインデックスを使ってメソッドの
エントリアドレスをロードする命令である。
When calling a virtual method (object method), the virtual method to be called is registered with the register number and name ID storing the base address of the object, as in the case of the object variable.
Generates an instruction using a register number to store the method's entry address. At this time, the generated code includes an instruction to load the method table from the base address of the object and a name I from the method table.
This is an instruction for loading an entry address of a method using an index obtained by solving D.

【0051】本実施の形態においては、副作用のない命
令をディレイドスロットへ配置することで、NameI
Dの他に、目的レジスタ番号や、baseアドレスの入
ったレジスタ番号を、名前解決処理resolveNa
meへ知らせることにする。
In this embodiment, an instruction having no side effect is arranged in a delayed slot, so that a NameI
In addition to D, the target register number and the register number containing the base address are entered in the name resolution process resolveNa
Let me know.

【0052】ここで、「副作用のある命令」とは、メモ
リをアクセスするロード、ストア命令や、0割でトラッ
プを引き起こす割り算命令、メモリ内容をソースオペラ
ンドとして持つ命令、ディスティネーションオペランド
にメモリアドレスをもち、メモリへ結果を書き込む命
令、加減乗除算で、オーバフロー、又はアンダーフロー
を検出し、トラップを引き起こす命令、システムコール
命令、システム共有のリソースの状態を変更する命令な
どである。また、そうでないものを副作用のない命令と
いう。
Here, "instructions having side effects" include load and store instructions for accessing memory, division instructions for causing a trap at 0%, instructions having memory contents as source operands, and memory addresses for destination operands. More specifically, there are an instruction to write a result to a memory, an instruction to detect an overflow or an underflow by addition, subtraction, multiplication and division to cause a trap, a system call instruction, and an instruction to change the state of a system-shared resource. Those that are not are called instructions without side effects.

【0053】手続き呼び出し命令callは、戻り番地
を特定のレジスタへ保持するので、この戻り番地から、
ディレイドスロットに配置された命令コードを得て、N
ameIDや、目的レジスタ番号、baseアドレスを
得る。
The procedure call instruction call holds the return address in a specific register.
Obtain the instruction code arranged in the delayed slot and obtain N
ameID, a target register number, and a base address are obtained.

【0054】ディレイドスロットの命令は、resol
veNameを呼び出すときに一度、実行されてしまう
が、これによって情報が失われたり、例外が起きないよ
うになっている。
The instruction of the delayed slot is resol
It is executed once when calling vName, but this prevents information loss or exceptions.

【0055】図9は、名前がスタティックアドレスの場
合及び名前がオブジェクトフィールドの場合の名前解決
前の命令セット及び名前解決した後の命令セットを示す
図である。図22は、スタティック変数の値をロードす
る場合及びストアする場合の名前解決前の命令セット及
び名前解決後の命令セットを示す図である。また、図2
3は、スタティック変数の値をロードする場合及びスト
アする場合の名前解決前の命令セット及び名前解決後の
命令セットをmips命令で示した図である。
FIG. 9 is a diagram showing an instruction set before name resolution and an instruction set after name resolution when the name is a static address and when the name is an object field. FIG. 22 is a diagram showing an instruction set before name resolution and an instruction set after name resolution when loading and storing the value of a static variable. FIG.
3 is a diagram showing an instruction set before name resolution and an instruction set after name resolution by a mips instruction when loading and storing the value of a static variable.

【0056】同図において、「op」は、‘|’(=
「OR」),‘^’(=「XOR」),‘&’(=「A
ND」),‘+’,‘−’のいずれかである。
In the figure, “op” is represented by “|” (=
“OR”), '^' (= “XOR”), '&' (= “A
ND "), '+' or '-'.

【0057】また、「call」は、手続き呼び出し命
令(jump&link)、「resolveNam
e」は、名前解決処理のエントリアドレス、「dstR
eg」は、解決した値を格納するべきレジスタ、「re
solvedValue」は、名前解決した値、であ
る。
"Call" is a procedure call instruction (jump & link), "resolveNam
"e" is the entry address of the name resolution process, "dstR
“eg” is a register to store the resolved value, “re”
"solvedValue" is a value whose name has been resolved.

【0058】A.名前がスタティック変数の場合 1.名前がスタティックアドレスの場合 名前解決前においては、名前解決処理のエントリアドレ
スを呼び出す命令コード(call resolve
Name)及びzero op Name IDの値を
目的レジスタ(dstReg)に格納する命令コード
(dstReg←zero op Name ID)
が、名前解決後においては、目的レジスタ(dstRe
g)に名前解決した値(resolvedValue)
を格納する命令コード(dstReg ← resol
vedValue)に書き換えられる。
A. When the name is a static variable In the case where the name is a static address Before the name resolution, an instruction code (call resolve) for calling the entry address of the name resolution processing is called.
Instruction code (dstReg ← zero op Name ID) for storing the values of “Name” and “zero op Name ID” in the destination register (dstReg)
However, after name resolution, the destination register (dstRe
g) Resolved value (resolvedValue)
(DstReg ← resol)
vedValue).

【0059】ここで、名前解決前において、zero
op Name IDの値を目的レジスタ(dstRe
g)に格納しているのは、目的レジスタは、解決した値
で上書きされるので、Name IDが書きこまれてし
まっても影響がないからである。
Here, before name resolution, zero
The value of the op Name ID is stored in the destination register (dstRe
The reason for storing in g) is that the target register is overwritten with the resolved value, so that writing the Name ID has no effect.

【0060】名前解決処理では、このdstReg ←
zero op NameIDという命令コードか
ら、NameIDと目的レジスタ番号を得て、命令コー
ドを書き換える。
In the name resolution processing, this dstReg ←
The instruction code is rewritten by obtaining the NameID and the target register number from the instruction code of zero op NameID.

【0061】図2は、名前がスタティックアドレスの場
合の名前解決処理(命令コード書き換え処理)を示すフ
ロチャートである。
FIG. 2 is a flowchart showing name resolution processing (instruction code rewriting processing) when the name is a static address.

【0062】同図に示すように、まず、この処理で使用
する全てのレジスタをセーブする(S1)。次に、リタ
ーンアドレスから命令コード(dstReg ← ze
roop NameID)をロードする(S2)。
As shown in the figure, first, all registers used in this processing are saved (S1). Next, the instruction code (dstReg ← ze
load Name (ID) is loaded (S2).

【0063】次に、S2においてロードされた命令コー
ドから目的レジスタ番号及びNameIDを得(S
3)、NameIDを解決した値(resolvedO
ffset)を得る(S4)。
Next, the target register number and the NameID are obtained from the instruction code loaded in S2 (S2).
3), NameID resolved value (resolvedO
ffset) is obtained (S4).

【0064】次に、S4において得たNameIDを解
決した値(resolvedOffset)を目的レジ
スタ(dstReg)へ転送するコードを生成して命令
コードを書き換える(S5)。
Next, a code for transferring the value (resolvedOffset) obtained by resolving the NameID obtained in S4 to the destination register (dstReg) is generated, and the instruction code is rewritten (S5).

【0065】そして、S1においてセーブしたレジスタ
のリストアを行ない(S6)、書き換えた命令の先頭へ
ジャンプする(S7)。これにより、名前がスタティッ
クアドレスの場合の命令コード書き換え処理が終了す
る。
Then, the register saved in S1 is restored (S6), and the process jumps to the head of the rewritten instruction (S7). Thus, the instruction code rewriting process in the case where the name is a static address is completed.

【0066】なお、mipsの場合の命令のフォーマッ
トを図3に示し、名前解決処理を図4に示す。
FIG. 3 shows a format of an instruction in the case of mips, and FIG. 4 shows a name solving process.

【0067】2.スタティック変数の値をロードする場
合 この場合の名前解決処理も基本的に図2に示した名前が
スタティックアドレスの場合と略同様である。具体的に
異なる点は、図2のS5の処理が「解決した値の番地か
ら値を読み出して目的レジスタへ格納するコードを生成
し、命令コードを書きかえる」という処理になる。
2. When Loading the Value of a Static Variable The name resolution processing in this case is basically similar to the case where the name shown in FIG. 2 is a static address. A specific difference is that the process of S5 in FIG. 2 is a process of "generating a code for reading a value from the address of a resolved value, storing the value in a target register, and rewriting an instruction code".

【0068】また、この場合の処理をmips命令セッ
トで表わすと、図4に示した命令セットの第6行目及び
第7行目を図24に示す命令セットに書き換えたものと
なる。
When the processing in this case is represented by a mips instruction set, the sixth and seventh lines of the instruction set shown in FIG. 4 are rewritten to the instruction set shown in FIG.

【0069】3.スタティック変数の値をストアする場
合 この場合の名前解決処理も基本的に図2に示した名前が
スタティックアドレスの場合と略同様である。具体的に
異なる点は、図2のS5の処理が「解決した値の番地へ
ソースレジスタの値を書きこむコードを生成し、命令コ
ードを書きかえる」という処理になる。
3. When the value of a static variable is stored The name resolution processing in this case is basically similar to the case where the name shown in FIG. 2 is a static address. A specific difference is that the process of S5 in FIG. 2 is a process of “generating a code for writing the value of the source register to the address of the resolved value and rewriting the instruction code”.

【0070】また、この場合の処理をmips命令セッ
トで表わすと、図4に示した命令セットの第3行目を図
25に示す命令セットに書き換え、図4に示した命令セ
ットの第6行目及び第7行目を図26に示す命令セット
に書き換えたものとなる。
When the processing in this case is represented by a mips instruction set, the third line of the instruction set shown in FIG. 4 is rewritten to the instruction set shown in FIG. 25, and the sixth line of the instruction set shown in FIG. The seventh and seventh lines are rewritten to the instruction set shown in FIG.

【0071】B.名前がオブジェクトフィールドの場合 1. オブジェクトフィールドから値をロードするとき 名前解決処理前は、名前解決処理呼び出し命令と、ds
tReg ← baseReg op NameIDと
いう命令コードであり、名前解決処理後は、dstRe
g ← resolvedOffset(baseRe
g)というコードとなる。
B. When the name is a container field When loading a value from an object field Before the name resolution processing, a name resolution processing call instruction and ds
tReg ← baseReg op NameID is an instruction code. After name resolution processing, dstRe
g ← resolvedOffset (baseRe
g).

【0072】これは、オブジェクトのベースアドレスか
ら、解決したオフセット分を加算したアドレスからデー
タをロードしdstRegに格納する処理を行なう命令
である。ここで、baseRegは、オブジェクトのベ
ースアドレスを保持しているレジスタであり、dstR
egは、オブジェクトのフィールドの値を格納するレジ
スタである。スタティックアドレスの場合と同様、ds
tRegは、上書きされるので、名前解決処理の前に書
き壊されていても問題はない。
This is an instruction for loading data from the address obtained by adding the resolved offset from the base address of the object and storing the data in dstReg. Here, baseReg is a register holding the base address of the object, and dstR
eg is a register that stores the value of the field of the object. As with the static address, ds
Since tReg is overwritten, there is no problem even if tReg is destroyed before the name resolution processing.

【0073】図5は、名前がオブジェクトフィールドで
あって、かつオブジェクトフィールドから値をロードす
るときの名前解決処理(命令コード書き換え処理)を示
すフロチャートである。
FIG. 5 is a flowchart showing name resolution processing (instruction code rewriting processing) when a name is an object field and a value is loaded from the object field.

【0074】同図に示すように、まず、この処理で使用
する全てのレジスタをセーブする(S11)。次に、リ
ターンアドレスから命令コード(dstReg ← b
aseReg op NameID)をロードする(S
12)。
As shown in the figure, first, all registers used in this processing are saved (S11). Next, the instruction code (dstReg ← b
load asReg op NameID) (S
12).

【0075】次に、S12においてロードされた命令コ
ードから目的レジスタ番号、ベースレジスタ番号及びN
ameIDを得(S13)、NameIDを解決した値
(resolvedOffset)を得る(S14)。
Next, the target register number, base register number and N
ameID is obtained (S13), and a value (resolvedOffset) obtained by resolving the NameID is obtained (S14).

【0076】次に、S14において得たNameIDを
解決した値(resolvedOffset)とベース
レジスタ(baseReg)の値とを加算したアドレス
(ベースレジスタ+resolvedOffset)か
ら目的レジスタへデータをロードするコードを生成し、
命令コードを書きかえる(S15)。
Next, a code for loading data to the target register from an address (base register + resolvedOffset) obtained by adding the value (resolvedOffset) obtained by resolving the NameID obtained in S14 and the value of the base register (baseReg) is generated.
The instruction code is rewritten (S15).

【0077】そして、S11においてセーブしたレジス
タのリストアを行ない(S16)、書き換えた命令の先
頭へジャンプする(S17)。これにより、名前がオブ
ジェクトフィールドの場合の命令コード書き換え処理が
終了する。なお、mipsの場合の名前解決処理を図6
に示す。
Then, the register saved in S11 is restored (S16), and the program jumps to the head of the rewritten instruction (S17). Thus, the instruction code rewriting process in the case where the name is the object field ends. FIG. 6 shows the name resolution process in the case of mips.
Shown in

【0078】2. オブジェクトフィールドへ値をスト
アするとき 命令セットのアーキテクチャによって、即値オペランド
(immediate)に何ビット使えるか異なるの
で、使えるビットをNとし、レジスタ指定に使うビット
をnとする。なお、mipsの場合には、N=16、n
=5となる。
2. When Storing Values in Object Fields Depending on the architecture of the instruction set, how many bits can be used for immediate operands (immediate) depends on the number of bits that can be used. In the case of mips, N = 16, n
= 5.

【0079】図9において、srcRegNumber
は、オブジェクトフィールドへストアする値を保持する
レジスタ番号である。
In FIG. 9, srcRegNumber
Is a register number holding a value to be stored in the object field.

【0080】名前解決処理前は、名前解決処理呼び出し
命令と、zero ← baseReg op (Na
meID | (srcRegNumber <<
(N−n))という命令コードであり、名前解決処理後
はsrcReg → resolveoffset(b
aseReg)というコードになる。
Before name resolution processing, a name resolution processing call instruction and zero ← baseReg op (Na
meID | (srcRegNumber <<
(N−n)), and after the name resolution process, srcReg → resolveoffset (b
caseReg).

【0081】これは、オブジェクトのベースアドレスか
ら、解決したオフセット分を加算したアドレスへソース
レジスタが保持するデータをストアする処理を行なう命
令である。ここで、baseRegは、オブジェクトの
ベースアドレスを保持しているレジスタであり、src
Regは、オブジェクトのフィールドへストアする値を
保持するレジスタである。
This is an instruction for performing a process of storing the data held in the source register from the base address of the object to an address obtained by adding the resolved offset. Here, baseReg is a register holding the base address of the object, and src
Reg is a register that holds a value to be stored in a field of the object.

【0082】図7は、名前がオブジェクトフィールドで
あって、かつオブジェクトフィールドから値をストアす
るときの名前解決処理(命令コード書き換え処理)を示
すフロチャートである。
FIG. 7 is a flowchart showing name resolution processing (instruction code rewriting processing) when a name is an object field and a value is stored from the object field.

【0083】同図に示すように、まず、この処理で使用
する全てのレジスタをセーブする(S21)。次に、リ
ターンアドレスから命令コード(zero ← bas
eReg op (NameID | (srcReg
Number << (N−n)))をロードする(S
22)。
As shown in the figure, first, all registers used in this processing are saved (S21). Next, from the return address, the instruction code (zero ← bas)
eReg op (NameID | (srcReg
Number <<<< (N-n))) is loaded (S
22).

【0084】次に、S22においてロードされた命令コ
ードからソースレジスタ番号、ベースレジスタ番号及び
NameIDを得(S23)、NameIDを解決した
値(resolvedOffset)を得る(S2
4)。
Next, the source register number, base register number and NameID are obtained from the instruction code loaded in S22 (S23), and a value (resolvedOffset) obtained by resolving the NameID is obtained (S2).
4).

【0085】次に、S24において得たNameIDを
解決した値(resolvedOffset)とベース
レジスタ(baseReg)の値とを加算したアドレス
(ベースレジスタ+resolvedOffset)へ
ソースレジスタのデータをストアするコードを生成し、
命令コードを書きかえる(S25)。
Next, a code for storing the data of the source register at an address (base register + resolvedOffset) obtained by adding the value (resolvedOffset) obtained by resolving the NameID obtained in S24 and the value of the base register (baseReg) is generated,
The instruction code is rewritten (S25).

【0086】そして、S21においてセーブしたレジス
タのリストアを行ない(S26)、書き換えた命令の先
頭へジャンプする(S27)。これにより、名前がオブ
ジェクトフィールドの場合の命令コード書き換え処理が
終了する。なお、mipsの場合の名前解決処理を図8
に示す。
Then, the register saved in S21 is restored (S26), and the program jumps to the head of the rewritten instruction (S27). Thus, the instruction code rewriting process in the case where the name is the object field ends. Note that the name resolution process in the case of mips is shown in FIG.
Shown in

【0087】ディレイドスロットのないCPUの場合
は、call resolvenameの次の命令が実
行されない。したがって、次の命令コードに何を書いて
も、resolveNameが次の命令コードを書き換
えてしまうことが出来るので、必要な情報(目的レジス
タ番号、オブジェクトのbaseアドレスの入ったレジ
スタ番号)を、図10に示すように、適当にコード化し
て命令の代わりに埋め込むことが可能である。なお、図
10は、オブジェクトフィールドから値をロードする場
合の情報を示している。また、図10の目的レジスタを
ソースレジスタとすれば、オブジェクトフィールドへ値
をストアする場合の情報となる。
In the case of a CPU without a delayed slot, the instruction following the call resolvename is not executed. Therefore, no matter what is written in the next instruction code, the resolveName can rewrite the next instruction code. Therefore, necessary information (a target register number, a register number including a base address of an object) is stored in FIG. As shown in FIG. 7, it is possible to embed the code appropriately instead of the instruction. FIG. 10 shows information when a value is loaded from an object field. Further, if the destination register in FIG. 10 is a source register, it becomes information when a value is stored in an object field.

【0088】また、ディレイドスロットのあるCPUの
場合でも、手続き呼び出し命令の代わりに、ソフトウェ
ア割り込み命令を使えば、ディレイドスロットの命令を
実行せずに、制御を名前解決処理に渡すことが可能であ
るが、この場合は、割り込み処理の一部として、名前解
決処理を行なう必要がある。
Even in the case of a CPU having a delayed slot, if a software interrupt instruction is used instead of a procedure call instruction, control can be transferred to the name resolution processing without executing a delayed slot instruction. However, in this case, it is necessary to perform a name resolution process as a part of the interrupt process.

【0089】さらに、名前解決処理が分岐のターゲット
ではなく、その前に命令がある場合、図11に示すよう
に、その前の命令(prevInst)をディレイドス
ロットに配置すれば必要な情報を、自由にコード化する
ことが可能となる。この場合において、命令コード書き
換え処理は、図5及び図7とほぼ同じであるが、名前解
決に必要な情報を得るためのリターンアドレスが異な
る。mipsの場合のフィールドロードの名前解決処理
を図12に示し、フィールドストアの名前解決処理を図
13に示す。
Further, when the name resolution process is not the target of the branch but is preceded by an instruction, as shown in FIG. 11, if the preceding instruction (prevInst) is arranged in the delayed slot, necessary information can be freely set. Can be coded. In this case, the instruction code rewriting process is almost the same as in FIGS. 5 and 7, but the return address for obtaining information necessary for name resolution is different. FIG. 12 shows a field load name resolution process in the case of mips, and FIG. 13 shows a field store name resolution process.

【0090】以上のような名前解決処理によれば、目的
レジスタへ解決した値を直接代入することが出来るし、
オブジェクトフィールドへのアクセスも2命令で完了す
る。ただ、オブジェクトフィールドへのアクセスに関し
て、名前解決前の命令数が2であるのに対し、解決後の
命令数が1となる場合がほとんどであるのでnop命令
を挿入することとなってしまう。
According to the name resolution processing described above, the resolved value can be directly assigned to the destination register.
Access to the object field is completed by two instructions. However, regarding the access to the object field, the number of instructions before the name resolution is 2 and the number of instructions after the resolution is almost 1 in most cases, so the nop instruction is inserted.

【0091】通常のプログラムの流れにおいて、オブジ
ェクトへのアクセスは何度も繰り返えされる。また、あ
るオブジェクトの各フィールドのオフセットは、最初に
そのオブジェクトへアクセスのあったときにすべて決ま
ってしまう。この性質を利用すれば、手続きのなかで、
あるオブジェクトへの最初のアクセス時に、そのオブジ
ェクトへのその後のフィールドアクセスの名前参照を解
決することが可能である。
In a normal program flow, access to an object is repeated many times. Also, the offset of each field of an object is all determined when the object is first accessed. If you take advantage of this property,
Upon the first access to an object, it is possible to resolve the name references for subsequent field accesses to that object.

【0092】以下、あるオブジェクトへの最初のアクセ
ス時に、そのオブジェクトへのその後のフィールドアク
セスの名前参照を解決する方法について説明する。
A method for resolving a name reference in a subsequent field access to an object when the object is first accessed will be described below.

【0093】まず、最初に、本実施の形態において用い
られる用語について定義する。
First, terms used in the present embodiment will be defined.

【0094】基本ブロック:プログラムのコードセグメ
ント単位で、途中で分岐することなく直列に処理が実行
され、かつ、途中に飛込まれることもない、という条件
を満たす最大の連続領域(手続き呼び出しは分岐とみな
さない)。
Basic block: The largest continuous area that satisfies the condition that processing is executed serially without branching in the middle of each program code segment and that the program is not jumped in the middle. Is not considered).

【0095】基本ブロック間の支配関係:基本ブロック
Aが基本ブロックBを支配するとは、基本ブロックBの
入り口に到達するのは、すでに基本ブロックAを実行済
であるときのみ、という条件を満たすとき。
Dominant relationship between basic blocks: The basic block A controls the basic block B when the condition that the basic block B arrives at the entrance only when the basic block A has already been executed is satisfied. .

【0096】オブジェクトへの先行アクセス:オブジェ
クトへのアクセスXが、オブジェクトへのアクセスYに
先行するとは、XとYが同一基本ブロックにありかつX
がYに先行するか、または、Xの属する基本ブロックが
Yの属する基本ブロックを支配するとき。
Precedent access to an object: An access X to an object precedes an access Y to an object if X and Y are in the same basic block and X
Precedes Y, or the basic block to which X belongs dominate the basic block to which Y belongs.

【0097】先頭アクセス:オブジェクトOへのアクセ
スXが先頭アクセスであるとは、Oが属するクラスCに
ついて、全てのCに属するオブジェクトアクセスについ
て、Xに先行するアクセスが存在しないとき。
Top access: An access X to an object O is a top access when there is no access prior to X for an object access belonging to all the classes C to which O belongs.

【0098】リンク情報:先頭アクセスから順にフィー
ルドアクセスを辿るための情報。
Link information: information for tracing field access sequentially from the top access.

【0099】まず、コンパイラの処理について、図14
及び図15のフロチャートを参照して説明する。
First, the processing of the compiler will be described with reference to FIG.
And the flowchart of FIG.

【0100】まず、図14に示すように、各オブジェク
トフィールドアクセスについて、先頭アクセスを保持す
るデータ領域を設けておく(S31)。次に、プログラ
ムを基本ブロックに分割し(S32)、各基本ブロック
の支配関係(半順序となる)を調べる。
First, as shown in FIG. 14, for each object field access, a data area for holding a head access is provided (S31). Next, the program is divided into basic blocks (S32), and the dominant relationship (in a partial order) of each basic block is examined.

【0101】次に、プログラムを先頭から終わりまでア
ドレスの小さいほうから大きいほうへサーチし(S3
4)、サーチの結果、見つかった各オブジェクトフィー
ルドアクセスについてフィールドアクセスコードを生成
する(S35)。
Next, the program is searched from the smallest address to the largest address from the beginning to the end (S3).
4) A field access code is generated for each object field access found as a result of the search (S35).

【0102】次に、図15を参照して、フィールドアク
セスコードの生成について説明する。
Next, generation of a field access code will be described with reference to FIG.

【0103】まず、本アクセスをアクセスAとする(S
41)。次に、アクセスXのlink情報がまだなく、
アクセスXが保持する先頭アクセスが、アクセスAに先
行し、アクセスAとアクセスXとの距離がlink情報
で表現可能な数値より小さいか否かの判断を行なう(S
42)。
First, this access is referred to as access A (S
41). Next, there is no link information of access X yet,
It is determined whether the top access held by the access X precedes the access A and whether the distance between the access A and the access X is smaller than a numerical value that can be represented by the link information (S
42).

【0104】そして、S42において、アクセスAとア
クセスXとの距離がlink情報で表現可能な数値より
も小さいと判断された場合には、アクセスXのlink
情報をアクセスAとアクセスXの距離とし、アクセスA
を先頭アクセスでないアクセスとしてコード生成し、ア
クセスAの先頭アクセスをアクセスXの先頭アクセスと
同じにして、<フィールドアクセスのコード生成>から
リターンする(S43)。
If it is determined in S42 that the distance between the access A and the access X is smaller than a numerical value that can be represented by the link information, the link of the access X is determined.
The information is the distance between access A and access X, and access A
Is generated as an access other than the head access, the head access of the access A is made the same as the head access of the access X, and the process returns from the <field access code generation> (S43).

【0105】一方、S42において、アクセスAとアク
セスXとの距離がlink情報で表現可能な数値よりも
小さくない判断された場合には、アクセスAを先頭アク
セスとしてコード生成し、アクセスAの先頭アクセスを
アクセスAとする(S44)。
On the other hand, if it is determined in S42 that the distance between the access A and the access X is not smaller than a numerical value that can be represented by the link information, a code is generated with the access A as the head access, and the head access of the access A is generated. Is the access A (S44).

【0106】図16は、一度の名前解決処理呼び出しで
複数のフィールドロードアクセス処理の名前参照を解決
を説明するためのフロチャートである。
FIG. 16 is a flowchart for explaining the resolution of the name reference of a plurality of field load access processes by a single name resolution process call.

【0107】同図に示すように、まず、この処理におい
て使用される全てのレジスタをセーブする(S51)。
次に、リターンアドレスから名前解決のための情報をロ
ードする(S52)。
As shown in the figure, first, all registers used in this processing are saved (S51).
Next, information for name resolution is loaded from the return address (S52).

【0108】次に、S52においてロードされた名前解
決のための情報からリンク情報、目的レジスタ番号、ベ
ースレジスタ番号、NameIDを得(S53)、名前
を解決し、解決した名前の値を得(S54)、コード生
成を行ないコードを書き換える(S55)。
Next, link information, a target register number, a base register number, and a NameID are obtained from the information for name resolution loaded in S52 (S53), the name is resolved, and the value of the resolved name is obtained (S54). ), The code is generated and the code is rewritten (S55).

【0109】次に、リンク情報から次のフィールドアド
レスを得(S56)、次のフィールドアドレスから情報
コードをロードする(S57)。
Next, the next field address is obtained from the link information (S56), and the information code is loaded from the next field address (S57).

【0110】そして、ロードされた情報コードからリン
ク情報、目的レジスタ番号、ベースレジスタ番号及びN
ameIDを得(S58)、解決し、解決した名前の値
を得(S59)、(ベースレジスタ+解決した値)番地
から目的レジスタへデータをロードするコードを生成
し、命令コードを書き換える(S60)。
Then, from the loaded information code, link information, target register number, base register number and N
ameID is obtained (S58), resolved, the value of the resolved name is obtained (S59), a code for loading data from the address (base register + resolved value) to the destination register is generated, and the instruction code is rewritten (S60). .

【0111】次に、次のフィールドアドレスがあるか否
かの判断を行ない(S61)、あると判断された場合に
は、S56の処理に戻る。一方、S61において、次の
フィールドアドレスがないと判断された場合には、S5
1においてセーブしたレジスタの値をリストアし(S6
2)、書き換えた命令の先頭へジャンプする(S6
3)。
Next, it is determined whether or not there is a next field address (S61). If it is determined that there is, the process returns to S56. On the other hand, if it is determined in S61 that there is no next field address, the process proceeds to S5.
Restore the register value saved in step 1 (S6
2) Jump to the top of the rewritten instruction (S6)
3).

【0112】これにより、一度の名前解決処理呼び出し
で複数のフィールドロードアクセス処理の名前参照を解
決することができる。図17に、mipsの場合の名前
解決処理を示す。
As a result, it is possible to resolve the name references of a plurality of field load access processes by a single name resolution process call. FIG. 17 shows name resolution processing in the case of mips.

【0113】次に、一度の名前解決処理呼び出しで複数
のフィールドストアアクセス処理の名前参照を解決する
処理について図18を参照して説明する。
Next, the process of resolving the name reference of a plurality of field store access processes by one name resolution process call will be described with reference to FIG.

【0114】同図に示すように、まず、この処理におい
て使用される全てのレジスタをセーブする(S71)。
次に、リターンアドレスから名前解決のための情報をロ
ードする(S72)。
As shown in the figure, first, all registers used in this processing are saved (S71).
Next, information for name resolution is loaded from the return address (S72).

【0115】次に、S72においてロードされた名前解
決のための情報からリンク情報、ソースレジスタ番号、
ベースレジスタ番号、NameIDを得(S53)、名
前を解決し、解決した名前の値を得(S74)、コード
生成を行ないコードを書き換える(S75)。
Next, from the information for name resolution loaded in S72, link information, source register number,
The base register number and NameID are obtained (S53), the name is resolved, the value of the resolved name is obtained (S74), and code is generated to rewrite the code (S75).

【0116】次に、リンク情報から次のフィールドアド
レスを得(S76)、次のフィールドアドレスから情報
コードをロードする(S77)。
Next, the next field address is obtained from the link information (S76), and the information code is loaded from the next field address (S77).

【0117】そして、ロードされた情報コードからリン
ク情報、ソースレジスタ番号、ベースレジスタ番号及び
NameIDを得(S78)、解決し、解決した名前の
値を得(S79)、(ベースレジスタ+解決した値)番
地へソースレジスタのデータをストアするコードを生成
し、命令コードを書き換える(S80)。
Then, the link information, the source register number, the base register number and the NameID are obtained from the loaded information code (S78), resolved, the value of the resolved name is obtained (S79), and (base register + resolved value) ) A code for storing the data of the source register at the address is generated, and the instruction code is rewritten (S80).

【0118】次に、次のフィールドアドレスがあるか否
かの判断を行ない(S81)、あると判断された場合に
は、S76の処理に戻る。一方、S81において、次の
フィールドアドレスがないと判断された場合には、S7
1においてセーブしたレジスタの値をリストアし(S8
2)、書き換えた命令の先頭へジャンプする(S8
3)。
Next, it is determined whether or not there is a next field address (S81). When it is determined that there is a next field address, the process returns to S76. On the other hand, if it is determined in S81 that there is no next field address, the process proceeds to S7.
Restore the register value saved in step 1 (S8
2) Jump to the top of the rewritten instruction (S8)
3).

【0119】これにより、一度の名前解決処理呼び出し
で複数のフィールドストアアクセス処理の名前参照を解
決することができる。図19に、mipsの場合の名前
解決処理を示す。
As a result, the name reference of a plurality of field store access processes can be resolved by a single name resolution process call. FIG. 19 shows name resolution processing in the case of mips.

【0120】図20は、名前解決処理呼び出しを行なう
オブジェクトアクセスのうち、先頭アクセスの命令コー
ドの名前解決前及び名前解決後を示す図である。また、
図21は、名前解決処理呼び出しを行なうオブジェクト
アクセスのうち、先頭アクセスでない命令コードの名前
解決前及び名前解決後を示す図である。
FIG. 20 is a diagram showing, prior to and after name resolution, the instruction code of the first access among the object accesses for performing the name resolution processing call. Also,
FIG. 21 is a diagram showing, before the name resolution and after the name resolution, of the instruction code which is not the head access among the object accesses for calling the name resolution processing.

【0121】なお、図20及び図21においては、命令
長を32ビット、レジスタ番号を表現するビット長を5
ビット、リンク情報を表現するビット長を6ビットとし
て表わしている。図20及び図21に示すように、先頭
アクセスでないアクセスについては、名前解決後の命令
コードが1命令となることがわかる。
In FIGS. 20 and 21, the instruction length is 32 bits and the bit length representing the register number is 5 bits.
The bit length representing the bit and link information is represented as 6 bits. As shown in FIGS. 20 and 21, it can be seen that for an access other than the head access, the instruction code after name resolution is one instruction.

【0122】なお、本実施の形態においては、命令コー
ド書き換え方法について説明したが、このような命令コ
ード書き換えを行なう命令コード書き換え装置及びこの
ような命令コード書き換えを行なうプログラムを記録し
たコンピュータ読み取り可能な情報記録媒体についても
適用することができることはいうまでもない。また、上
記情報記録媒体としては、例えば、CD−ROM、DV
D、FD、MOなどを挙げることができるがこれに限ら
れるものではない。
Although the present embodiment has been described with respect to the instruction code rewriting method, an instruction code rewriting device for rewriting such an instruction code and a computer readable program recording such an instruction code rewriting program are provided. It goes without saying that the present invention can be applied to an information recording medium. Further, as the information recording medium, for example, a CD-ROM, a DV
D, FD, MO, and the like can be given, but are not limited thereto.

【0123】[0123]

【発明の効果】以上詳記したように、本発明によれば、
プログラム実行時の名前解決、命令コード書き換えの結
果生成される目的コードの実行効率が向上する。特に、
オブジェクト指向プログラムにおけるオブジェクトのフ
ィールドアクセスについて、効率的なコードを生成する
ことが可能となる。
As described above in detail, according to the present invention,
The execution efficiency of a target code generated as a result of name resolution and instruction code rewriting during program execution is improved. In particular,
Efficient code can be generated for field access of an object in an object-oriented program.

【0124】また、名前解決のための余分な情報(パッ
チ情報など)を保持する必要がなく、メモリサイズの小
さな組み込みシステムへの適用も容易となる。
Further, there is no need to hold extra information (such as patch information) for name resolution, and application to an embedded system with a small memory size is facilitated.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本実施の形態の命令コード書き換え方法の処理
の流れを示す図。
FIG. 1 is a view showing a flow of processing of an instruction code rewriting method according to an embodiment.

【図2】名前がスタティックアドレスの場合の名前解決
処理(命令コード書き換え処理)を示すフロチャート。
FIG. 2 is a flowchart showing name resolution processing (instruction code rewriting processing) when the name is a static address.

【図3】mipsの場合の命令のフォーマットを示す
図。
FIG. 3 is a diagram showing a format of an instruction in the case of mips.

【図4】名前解決処理をmips命令セットで示した
図。
FIG. 4 is a diagram showing name resolution processing by a mips instruction set.

【図5】名前がオブジェクトフィールドであって、かつ
オブジェクトフィールドから値をロードするときの名前
解決処理(命令コード書き換え処理)を示すフロチャー
ト。
FIG. 5 is a flowchart showing name resolution processing (instruction code rewriting processing) when a name is an object field and a value is loaded from the object field.

【図6】名前解決処理をmips命令セットで示した
図。
FIG. 6 is a diagram showing name resolution processing by a mips instruction set.

【図7】名前がオブジェクトフィールドであって、かつ
オブジェクトフィールドから値をストアするときの名前
解決処理(命令コード書き換え処理)を示すフロチャー
ト。
FIG. 7 is a flowchart showing name resolution processing (instruction code rewriting processing) when a name is an object field and a value is stored from the object field.

【図8】名前解決処理をmips命令セットで示した
図。
FIG. 8 is a diagram showing a name resolution process by a mips instruction set.

【図9】名前がスタティックアドレスの場合及び名前が
オブジェクトフィールドの場合の名前解決前の命令セッ
ト及び名前解決した後の命令セットを示す図。
FIG. 9 is a diagram showing an instruction set before name resolution and an instruction set after name resolution when the name is a static address and the name is an object field.

【図10】コード化された名前を解決するための必要な
情報を示す図。
FIG. 10 is a diagram showing necessary information for resolving a coded name.

【図11】オブジェクトフィールドから値をロード/ス
トアするときの名前解決前後の命令を示す図。
FIG. 11 is a diagram showing instructions before and after name resolution when a value is loaded / stored from an object field.

【図12】mipsの場合のフィールドロードの名前解
決処理を示す図。
FIG. 12 is a diagram showing a field load name resolution process in the case of mips.

【図13】mipsの場合のフィールドストアの名前解
決処理を示す図。
FIG. 13 is a diagram showing a field store name resolution process in the case of mips.

【図14】コンパイラの処理を示すフロチャート。FIG. 14 is a flowchart showing processing of a compiler.

【図15】コンパイラの処理を示すフロチャート。FIG. 15 is a flowchart showing processing of a compiler.

【図16】コンパイラの処理を示すフロチャート。FIG. 16 is a flowchart showing the processing of a compiler.

【図17】mipsの場合の名前解決処理を示す図。FIG. 17 is a diagram showing name resolution processing in the case of mips.

【図18】一度の名前解決処理呼び出しで複数のフィー
ルドストアアクセス処理の名前参照を解決する処理を示
すフロチャート。
FIG. 18 is a flowchart showing a process of resolving a name reference of a plurality of field store access processes by a single name resolution process call.

【図19】mipsの場合の名前解決処理を示す図。FIG. 19 is a diagram showing name resolution processing in the case of mips.

【図20】名前解決処理呼び出しを行なうオブジェクト
アクセスのうち、先頭アクセスの命令コードの名前解決
前及び名前解決後を示す図。
FIG. 20 is a diagram showing, before and after name resolution, of an instruction code of a head access among object accesses for performing a name resolution process call;

【図21】名前解決処理呼び出しを行なうオブジェクト
アクセスのうち、先頭アクセスでない命令コードの名前
解決前及び名前解決後を示す図。
FIG. 21 is a diagram showing before and after name resolution of an instruction code which is not the top access among object accesses for performing a name resolution process call.

【図22】スタティック変数の値をロードする場合及び
ストアする場合の名前解決前の命令セット及び名前解決
後の命令セットを示す図。
FIG. 22 is a diagram showing an instruction set before name resolution and an instruction set after name resolution when loading and storing values of static variables.

【図23】スタティック変数の値をロードする場合及び
ストアする場合の名前解決前の命令セット及び名前解決
後の命令セットをmips命令で示した図。
FIG. 23 is a diagram showing an instruction set before name resolution and an instruction set after name resolution by a mips instruction when loading and storing the value of a static variable.

【図24】スタティック変数の値をロードする場合及び
ストアする場合の名前解決処理のmips命令セットの
一部を示す図。
FIG. 24 is a diagram showing a part of a mips instruction set of a name resolution process when loading and storing a value of a static variable.

【図25】スタティック変数の値をストアする場合及び
ストアする場合の名前解決処理のmips命令セットの
一部を示す図。
FIG. 25 is a diagram showing a part of a mips instruction set of a name resolution process when a value of a static variable is stored and when the value is stored.

【図26】スタティック変数の値をストアする場合及び
ストアする場合の名前解決処理のmips命令セットの
一部を示す図。
FIG. 26 is a diagram showing a part of a mips instruction set of a name resolution process when a value of a static variable is stored and when the value is stored.

【図27】従来の名前解決処理を説明するための図。FIG. 27 is a view for explaining a conventional name resolution process.

【図28】従来の名前解決処理を説明するための図。FIG. 28 is a view for explaining a conventional name resolution process.

【図29】手続き呼び出し規則に従った名前解決処理を
説明するための図。
FIG. 29 is an exemplary view for explaining name resolution processing according to a procedure calling rule;

【図30】手続き呼び出し規則に従った名前解決処理を
説明するための図。
FIG. 30 is an exemplary view for explaining name resolution processing according to a procedure calling rule;

【符号の説明】[Explanation of symbols]

1…ソースプログラム、 2…コンパイラ、 3…名前解決前の実行プログラム、 4…命令コード書き換え処理、 5…名前解決後(命令コード書き換え後)の実行プログ
ラム。
1. Source program, 2. Compiler, 3. Execution program before name resolution, 4. Instruction code rewriting process, 5. Execution program after name resolution (after instruction code rewriting).

Claims (11)

【特許請求の範囲】[Claims] 【請求項1】 ソースプログラムを実行プログラムにコ
ンパイルするコンパイラにおいて、プログラム実行時に
しか解決することのできない名前を解決するための名前
解決手続きを呼び出す名前参照解決呼び出し命令と、前
記プログラム実行時にしか解決することのできない名前
を識別するための名前識別情報及び解決した名前をスト
アするための目的レジスタの番号を有する副作用のない
命令とを生成し、 前記コンパイラにおいて、生成された副作用のない命令
をディレイドスロットに配置し、 前記実行プログラムの実行時に、前記名前参照解決呼び
出し命令において呼び出される名前解決手続きにおい
て、前記副作用のない命令に基づいて、前記名前参照解
決呼び出し命令及び前記副作用のない命令を目的レジス
タに名前解決した値を読み込む命令に書きかえることを
特徴とする命令コード書き換え方法。
1. A compiler for compiling a source program into an execution program, a name reference resolution call instruction for calling a name resolution procedure for resolving a name that can be resolved only at the time of execution of the program, and a resolution only at the time of execution of the program. Generating an instruction having no side effect and having a target register number for storing the resolved name; and generating the instruction having no side effect in the compiler. In the name resolution procedure called by the name reference resolution call instruction at the time of execution of the execution program, the name reference resolution call instruction and the instruction having no side effect are stored in a destination register based on the instruction having no side effect. Read name resolved value Instruction code rewriting method characterized by rewriting the writing instruction.
【請求項2】 ソースプログラムを実行プログラムにコ
ンパイルするコンパイラにおいて、プログラム実行時に
しか解決することのできないオブジェクトフィールドの
名前を解決するための名前解決手続きを呼び出す名前参
照解決呼び出し命令と、前記プログラム実行時にしか解
決することのできないオブジェクトフィールドの名前を
識別するための名前識別情報、解決した名前をストアす
るための目的レジスタの番号及びオブジェクトのベース
アドレスを有する副作用のない命令とを生成し、 前記コンパイラにおいて、生成された副作用のない命令
をディレイドスロットに配置し、 前記実行プログラムの実行時に、前記名前参照解決呼び
出し命令において呼び出される名前解決手続きにおい
て、前記副作用のない命令に基づいて、前記名前参照解
決呼び出し命令及び前記副作用のない命令を、オブジェ
クトのベースアドレスに名前解決した値を加算したアド
レスのデータを目的レジスタに読み込む命令に書きかえ
ることを特徴とする命令コード書き換え方法。
2. A compiler for compiling a source program into an execution program, a name reference resolution call instruction for calling a name resolution procedure for resolving the name of an object field that can be resolved only at the time of program execution, The compiler generates name identification information for identifying the name of the object field that can only be resolved, a target register number for storing the resolved name, and an instruction having no side effect having the base address of the object. Placing the generated instruction having no side effect in a delayed slot; and executing the execution program, in the name resolution procedure called by the name reference resolution call instruction, based on the instruction having no side effect. Instruction code rewriting method characterized by rewriting the free instructions irradiation resolve call instruction and said side effect, reads data of the address obtained by adding the name resolution value to the base address of the object into the destination register instruction.
【請求項3】 ソースプログラムを実行プログラムにコ
ンパイルするコンパイラにおいて、プログラム実行時に
しか解決することのできない名前を解決するための名前
解決手続きを呼び出す名前参照解決呼び出し命令と、オ
ブジェクトのベースアドレス、前記プログラム実行時に
しか解決することのできない名前を識別するための名前
識別情報、オブジェクトフィールドへストアする値を保
持するレジスタ番号を有する副作用のない命令とを生成
し、 前記コンパイラにおいて、生成された副作用のない命令
をディレイドスロットに配置し、 前記実行プログラムの実行時に、前記名前参照解決呼び
出し命令において呼び出される名前解決手続きにおい
て、前記副作用のない命令に基づいて、前記名前参照解
決呼び出し命令及び前記副作用のない命令を、前記レジ
スタ番号のレジスタに保持されている値を前記オブジェ
クトのベースアドレスに名前解決した値を加算したアド
レスへストアする命令に書きかえることを特徴とする命
令コード書き換え方法。
3. A compiler for compiling a source program into an execution program, a name reference resolution call instruction for calling a name resolution procedure for resolving a name that can be resolved only at the time of program execution, an object base address, and the program Generates name identification information for identifying a name that can be resolved only at the time of execution, and an instruction without a side effect having a register number that holds a value to be stored in an object field. An instruction is arranged in a delayed slot, and in executing the execution program, in the name resolution procedure called by the name reference resolution call instruction, the name reference resolution call instruction and the side effect free Decree the instruction code rewriting method characterized by rewriting the values held in the register of the register number in the instruction to store to the address obtained by adding the value name resolution base address of said object.
【請求項4】 前記コンパイラは、オブジェクトフィー
ルドアクセスの先行関係を解析し、前記名前解決手続き
は、前記コンパイラによる先行関係の解析結果に基づい
て、複数の名前を解決することを特徴とする請求項2又
は請求項3記載の命令コード書き換え方法。
4. The method according to claim 1, wherein the compiler analyzes a precedence relationship of the object field access, and the name resolution procedure resolves a plurality of names based on a result of the precedence analysis performed by the compiler. An instruction code rewriting method according to claim 2 or claim 3.
【請求項5】 ソースプログラムを実行プログラムにコ
ンパイルするコンパイラにおいて、プログラム実行時に
しか解決することのできない名前を解決するための名前
解決手続きを呼び出す名前参照解決呼び出し命令と、前
記プログラム実行時にしか解決することのできない名前
を識別するための名前識別情報及び解決した名前をスト
アするための目的レジスタの番号を有する副作用のない
命令とを生成し、生成された副作用のない命令をディレ
イドスロットに配置する命令コード生成手段と、 前記実行プログラムの実行時に、前記名前参照解決呼び
出し命令において呼び出される名前解決手続きにおい
て、前記副作用のない命令に基づいて、前記名前参照解
決呼び出し命令及び前記副作用のない命令を目的レジス
タに名前解決した値をストアする命令に書きかえる書き
換え手段とを具備することを特徴とする命令コード書き
換え装置。
5. A compiler for compiling a source program into an execution program, a name reference resolution call instruction for calling a name resolution procedure for resolving a name that can be resolved only at the time of program execution, and a resolution only at the time of program execution. An instruction for generating name identification information for identifying a name that cannot be executed and an instruction having no side effect having a target register number for storing the resolved name, and placing the generated instruction having no side effect in a delayed slot. Code generating means, and in executing the execution program, in the name resolution procedure called by the name reference resolution call instruction, the name reference resolution call instruction and the instruction having no side effect based on the instruction having no side effect. Stores the value resolved to Instruction code rewriting device characterized by comprising a rewriting means for rewriting the instruction to be.
【請求項6】 ソースプログラムを実行プログラムにコ
ンパイルするコンパイラにおいて、プログラム実行時に
しか解決することのできないオブジェクトフィールドの
名前を解決するための名前解決手続きを呼び出す名前参
照解決呼び出し命令と、前記プログラム実行時にしか解
決することのできないオブジェクトフィールドの名前を
識別するための名前識別情報、解決した名前をストアす
るための目的レジスタの番号及びオブジェクトのベース
アドレスを有する副作用のない命令とを生成し、前記コ
ンパイラにおいて、生成された副作用のない命令をディ
レイドスロットに配置する命令コード生成手段と、 前記実行プログラムの実行時に、前記名前参照解決呼び
出し命令において呼び出される名前解決手続きにおい
て、前記副作用のない命令に基づいて、前記名前参照解
決呼び出し命令及び前記副作用のない命令を、オブジェ
クトのベースアドレスに名前解決した値を加算したアド
レスのデータを目的レジスタにロードする命令に書きか
える書き換え手段とを具備することを特徴とする命令コ
ード書き換え装置。
6. A compiler for compiling a source program into an execution program, a name reference resolution call instruction for calling a name resolution procedure for resolving the name of an object field that can be resolved only at the time of program execution, The compiler generates name identification information for identifying the name of an object field that can only be resolved, a target register number for storing the resolved name, and an instruction having no side effect having a base address of the object. Instruction code generating means for arranging the generated instruction having no side effect in the delayed slot; and executing the instruction having no side effect in the name resolution procedure called by the name reference resolution call instruction when the execution program is executed. Rewriting means for rewriting the name reference resolution call instruction and the instruction having no side effect into an instruction for loading data of an address obtained by adding a name resolved value to an object base address to a target register based on An instruction code rewriting device characterized by the above-mentioned.
【請求項7】 ソースプログラムを実行プログラムにコ
ンパイルするコンパイラにおいて、プログラム実行時に
しか解決することのできない名前を解決するための名前
解決手続きを呼び出す名前参照解決呼び出し命令と、オ
ブジェクトのベースアドレス、前記プログラム実行時に
しか解決することのできない名前を識別するための名前
識別情報、オブジェクトフィールドへストアする値を保
持するレジスタ番号を有する副作用のない命令とを生成
し、前記コンパイラにおいて、生成された副作用のない
命令をディレイドスロットに配置する命令コード生成手
段と、 前記実行プログラムの実行時に、前記名前参照解決呼び
出し命令において呼び出される名前解決手続きにおい
て、前記副作用のない命令に基づいて、前記名前参照解
決呼び出し命令及び前記副作用のない命令を、前記レジ
スタ番号のレジスタに保持されている値を前記オブジェ
クトのベースアドレスに名前解決した値を加算したアド
レスへストアする命令に書きかえる命令コード書き換え
手段とを具備することを特徴とする命令コード書き換え
装置。
7. A compiler for compiling a source program into an execution program, a name reference resolution call instruction for calling a name resolution procedure for resolving a name that can be resolved only at the time of program execution, an object base address, and the program The compiler generates name identification information for identifying a name that can be resolved only at the time of execution, and an instruction without a side effect having a register number holding a value to be stored in an object field. Instruction code generating means for arranging an instruction in a delayed slot; and executing a name reference resolution call instruction based on the instruction having no side effect in a name resolution procedure called by the name reference resolution call instruction when executing the execution program. And instruction code rewriting means for rewriting the instruction having no side effect to an instruction for storing a value held in the register of the register number to an address obtained by adding a value obtained by resolving a name to a base address of the object. An instruction code rewriting device characterized by the above-mentioned.
【請求項8】 ソースプログラムを実行プログラムにコ
ンパイルするコンパイラにおいて、プログラム実行時に
しか解決することのできない名前を解決するための名前
解決手続きを呼び出す名前参照解決呼び出し命令と、前
記プログラム実行時にしか解決することのできない名前
を識別するための名前識別情報及び解決した名前をスト
アするための目的レジスタの番号を有する副作用のない
命令とを生成し、生成された副作用のない命令をディレ
イドスロットに配置する命令コード生成手段と、 前記実行プログラムの実行時に、前記名前参照解決呼び
出し命令において呼び出される名前解決手続きにおい
て、前記副作用のない命令に基づいて、前記名前参照解
決呼び出し命令及び前記副作用のない命令を目的レジス
タに名前解決した値をストアする命令に書きかえる書き
換え手段とを有するプログラムを記録したコンピュータ
読み取り可能な情報記録媒体。
8. A compiler for compiling a source program into an execution program, a name reference resolution call instruction for calling a name resolution procedure for resolving a name that can be resolved only at the time of program execution, and a resolution only at the time of program execution. An instruction for generating name identification information for identifying a name that cannot be executed and an instruction having no side effect having a target register number for storing the resolved name, and placing the generated instruction having no side effect in a delayed slot. Code generating means, and in executing the execution program, in the name resolution procedure called by the name reference resolution call instruction, the name reference resolution call instruction and the instruction having no side effect based on the instruction having no side effect. Stores the value resolved to Computer-readable information recording medium storing a program and a rewriting means for rewriting the instruction to be.
【請求項9】 ソースプログラムを実行プログラムにコ
ンパイルするコンパイラにおいて、プログラム実行時に
しか解決することのできないオブジェクトフィールドの
名前を解決するための名前解決手続きを呼び出す名前参
照解決呼び出し命令と、前記プログラム実行時にしか解
決することのできないオブジェクトフィールドの名前を
識別するための名前識別情報、解決した名前をストアす
るための目的レジスタの番号及びオブジェクトのベース
アドレスを有する副作用のない命令とを生成し、前記コ
ンパイラにおいて、生成された副作用のない命令をディ
レイドスロットに配置する命令コード生成手段と、 前記実行プログラムの実行時に、前記名前参照解決呼び
出し命令において呼び出される名前解決手続きにおい
て、前記副作用のない命令に基づいて、前記名前参照解
決呼び出し命令及び前記副作用のない命令を、オブジェ
クトのベースアドレスに名前解決した値を加算したアド
レスのデータを目的レジスタにロードする命令に書きか
える書き換え手段とを有するプログラムを記録したコン
ピュータ読み取り可能な情報記録媒体。
9. A compiler for compiling a source program into an execution program, a name reference resolution call instruction for calling a name resolution procedure for resolving the name of an object field that can be resolved only at the time of program execution, The compiler generates name identification information for identifying the name of an object field that can only be resolved, a target register number for storing the resolved name, and an instruction having no side effect having a base address of the object. Instruction code generating means for arranging the generated instruction having no side effect in the delayed slot; and executing the instruction having no side effect in the name resolution procedure called by the name reference resolution call instruction when the execution program is executed. Rewriting means for rewriting the name reference resolution call instruction and the instruction having no side effect to an instruction for loading data of an address obtained by adding a name resolved value to an object base address to a target register based on A computer-readable information recording medium on which is recorded.
【請求項10】 ソースプログラムを実行プログラムに
コンパイルするコンパイラにおいて、プログラム実行時
にしか解決することのできない名前を解決するための名
前解決手続きを呼び出す名前参照解決呼び出し命令と、
オブジェクトのベースアドレス、前記プログラム実行時
にしか解決することのできない名前を識別するための名
前識別情報、オブジェクトフィールドへストアする値を
保持するレジスタ番号を有する副作用のない命令とを生
成し、前記コンパイラにおいて、生成された副作用のな
い命令をディレイドスロットに配置する命令コード生成
手段と、 前記実行プログラムの実行時に、前記名前参照解決呼び
出し命令において呼び出される名前解決手続きにおい
て、前記副作用のない命令に基づいて、前記名前参照解
決呼び出し命令及び前記副作用のない命令を、前記レジ
スタ番号のレジスタに保持されている値を前記オブジェ
クトのベースアドレスに名前解決した値を加算したアド
レスへストアする命令に書きかえる命令コード書き換え
手段とを有するプログラムを記録したコンピュータ読み
取り可能な情報記録媒体。
10. A compiler for compiling a source program into an execution program, a name reference resolution call instruction for calling a name resolution procedure for resolving a name that can be resolved only when the program is executed,
The compiler generates a base address of an object, name identification information for identifying a name that can be resolved only at the time of execution of the program, and an instruction having no side effect having a register number for holding a value to be stored in an object field. An instruction code generating means for arranging the generated instruction having no side effect in the delayed slot; and, during execution of the execution program, in a name resolution procedure called by the name reference resolution call instruction, based on the instruction having no side effect, Instruction code rewriting for rewriting the name reference resolution call instruction and the instruction having no side effect to an instruction for storing a value held in a register of the register number to an address obtained by adding a value obtained by resolving a name to a base address of the object With means A computer-readable information recording medium on which a program to be recorded is recorded.
【請求項11】 前記コンパイラは、オブジェクトフィ
ールドアクセスの先行関係を解析し、前記名前解決手続
きは、前記コンパイラによる先行関係の解析結果に基づ
いて、複数の名前を解決することを特徴とする請求項9
又は請求項10記載の情報記録媒体。
11. The method according to claim 11, wherein the compiler analyzes a precedence relationship of an object field access, and the name resolution procedure resolves a plurality of names based on a result of the precedence analysis performed by the compiler. 9
Or the information recording medium according to claim 10.
JP26834699A 1999-09-22 1999-09-22 Method and device for rewriting instruction code and information recording medium Pending JP2001092672A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP26834699A JP2001092672A (en) 1999-09-22 1999-09-22 Method and device for rewriting instruction code and information recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP26834699A JP2001092672A (en) 1999-09-22 1999-09-22 Method and device for rewriting instruction code and information recording medium

Publications (1)

Publication Number Publication Date
JP2001092672A true JP2001092672A (en) 2001-04-06

Family

ID=17457270

Family Applications (1)

Application Number Title Priority Date Filing Date
JP26834699A Pending JP2001092672A (en) 1999-09-22 1999-09-22 Method and device for rewriting instruction code and information recording medium

Country Status (1)

Country Link
JP (1) JP2001092672A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004272922A (en) * 2003-03-06 2004-09-30 Northrop Grumman Corp Direct instruction for executing emulation computer technique

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004272922A (en) * 2003-03-06 2004-09-30 Northrop Grumman Corp Direct instruction for executing emulation computer technique
JP4684571B2 (en) * 2003-03-06 2011-05-18 ノースロップ グラマン コーポレイション Direct instructions to implement emulation computer technology

Similar Documents

Publication Publication Date Title
US6243864B1 (en) Compiler for optimizing memory instruction sequences by marking instructions not having multiple memory address paths
JP4573189B2 (en) Program code conversion method
US20030093780A1 (en) Annotations to executable images for improved dynamic optimization of functions
US7386843B2 (en) Method and system for register allocation
US20090307669A1 (en) Memory management for closures
US20050028148A1 (en) Method for dynamic recompilation of a program
JPH01306923A (en) System for connecting different languages
US7337438B1 (en) Macros to support structures for an assembler that does not support structures
Journault et al. Modular static analysis of string manipulations in C programs
US6684394B1 (en) Relocation format for linking with relocation instructions containing operations for combining section data
US6810519B1 (en) Achieving tight binding for dynamically loaded software modules via intermodule copying
US6859932B1 (en) Relocation format for linking
JPH10507016A (en) System, method and compiler preprocessor for conditionally compiling software compilation units
US6687899B1 (en) Relocation format for linking
US6704928B1 (en) Relocation format for linking
US9436466B2 (en) Blank bit and processor instructions employing the blank bit
JP2850808B2 (en) Data processing device and data processing method
US20110167415A1 (en) Language processing apparatus, language processing method, and computer program product
JP2002312162A (en) Processor and processor system
JP2001092672A (en) Method and device for rewriting instruction code and information recording medium
US20080282071A1 (en) Microprocessor and register saving method
CN114020278B (en) Data processing method, device, equipment and storage medium
US7721274B1 (en) Intelligent processing of external object references for dynamic linking
US11327758B2 (en) Non-transitory computer-readable recording medium, assembly instruction conversion method and information processing apparatus
JP3705263B2 (en) Sequencer