JP3596570B2 - Method of allocating classes to main storage - Google Patents

Method of allocating classes to main storage Download PDF

Info

Publication number
JP3596570B2
JP3596570B2 JP30658495A JP30658495A JP3596570B2 JP 3596570 B2 JP3596570 B2 JP 3596570B2 JP 30658495 A JP30658495 A JP 30658495A JP 30658495 A JP30658495 A JP 30658495A JP 3596570 B2 JP3596570 B2 JP 3596570B2
Authority
JP
Japan
Prior art keywords
address
class
main storage
storage device
correction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP30658495A
Other languages
Japanese (ja)
Other versions
JPH09128240A (en
Inventor
圭 加藤
俊幸 福澤
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.)
Oki Electric Industry Co Ltd
Original Assignee
Oki Electric Industry 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 Oki Electric Industry Co Ltd filed Critical Oki Electric Industry Co Ltd
Priority to JP30658495A priority Critical patent/JP3596570B2/en
Publication of JPH09128240A publication Critical patent/JPH09128240A/en
Application granted granted Critical
Publication of JP3596570B2 publication Critical patent/JP3596570B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)

Description

【0001】
【発明の属する技術分野】
本発明は、オブジェクト指向技術で開発されたプログラムのクラスの主記憶装置への配置方法に関する。
【0002】
【従来の技術】
オブジェクト指向プログラミングによって、例えばよく知られたC言語によりプログラムを作成する場合、オブジェクトの性質を抽出して宣言するためにクラス定義を行う。このクラスの内部には、ある変数のアドレスを参照するような変数を含めることができる。この変数の中に静的変数というものがあり、これはクラスから生成される全てのインスタンスより共通に参照することができる変数である。この静的変数のアドレスは、クラスの先頭アドレスを基準とした絶対アドレスで表現される。従って、クラスをコンパイル/リンクし、主記憶装置上に配置する場合、静的変数に対しては絶対アドレスが割り付けられる。
【0003】
【発明が解決しようとする課題】
ところで、上記のような従来のクラスの主記憶装置への配置方法には次のような解決すべき課題があった。
オブジェクト指向プログラミング技術で開発されたシステムにおいて、プログラムの修正や機能追加の際には、システムを停止することなく新しいクラスを動的にメモリ上の空き領域に配置する仕組みが要求される。この要求に応えるため、プログラムカウンタ相対アドレシングによる方式が知られている。この方式では、コンパイル/リンクを行うと、クラス内部で参照するアドレスは、プログラムカウンタの値をオフセット値とした相対アドレスに換算され、実行時に参照される。従って、クラスを主記憶装置上の任意の場所に再配置することが可能になる。
【0004】
ところが、クラスに上記のような静的変数が含まれている場合には、その静的変数が参照している他の静的変数のアドレスまでは補正をしない。従って、実際にはアドレスが不正となり、参照が不能になる。このため、従来はプログラムカウンタ相対アドレシング方式を採用する場合には、静的変数による参照を避けてプログラミングを行っていた。ところが、これでは例えば、アドレスを参照する木構造データを静的に作ることはできなかった。なお、この木構造データというのは、枝から順番に幹に向かって変数を辿り、目的とするデータを参照するようなデータ構造をいう。
【0005】
一方、クラスにはクラスの内部に含まれるいくつかのメソッドを選択し分岐する仕組みが含められることがある。この場合、一般のプログラムで行われているような条件文等を伴う分岐関数を設けるとよい。しかしながら、分岐するメソッドの数が多くなると、メソッドを選択して分岐するまでの手順が増えて効率が低下し、クラス定義のコードサイズが大きくなるというデメリットがある。そこで、メソッドのアドレスを参照するジャンプテーブルを用いて、該当するメソッドをコールする方が効率のよいプログラムとなる。ところが、先に説明したプログラムカウンタ相対アドレシングを用いた場合には、やはりクラスの再配置の際にジャンプテーブル中のメソッドのアドレスが補正の対象にならない。従って、絶対アドレスで表示されたメソッドの呼び出しができなくなってしまう。このため、従来このようなジャンプテーブルを静的に作ることはできなかった。
【0006】
【課題を解決するための手段】
本発明は以上の点を解決するため次の構成を採用する。
〈構成1〉
ソースコードにより記述されたクラス定義を実行可能形式ファイルにコンパイルし、クラス定義に示されているアドレスを補正して実行可能形式ファイルを主記憶装置に配置する方法において、クラス定義中で、当該クラス定義内における他の静的変数の絶対アドレスを指定して参照する静的変数を抽出し、主記憶装置上の任意の領域に実行可能形式ファイルを配置するとともに、抽出した静的変数の絶対アドレスに対し、そのクラスの先頭アドレスによって定まるオフセットアドレスを、絶対アドレスに加算する補正を行う。
【0007】
〈説明〉
プログラムカウンタ相対アドレシング方式では、クラス定義中に含まれる静的変数に対して、コンパイル、リンク時に、メモリ即ち主記憶装置上の絶対アドレスが割りつけられる。なお、静的変数とは、オブジェクト指向プログラムにおいて、あるクラスから生成される全てのインスタンスより共通に参照することができ、実記憶上では絶対アドレスにより特定されるデータセグメントに配置された変更不可能な変数のことをいう。
このようなクラスをコンパイルした実行可能形式ファイルが、主記憶装置上の任意の空き領域に再配置されると、ある静的変数が他の静的変数の絶対アドレスを指定して参照しているような場合に、参照するアドレスが不正になる。
そこで、コンパイル時に該当する静的変数を予め抽出する。
【0008】
主記憶装置上のクラスの先頭アドレスによって定まるオフセットアドレスを、絶対アドレスに加算する補正をして新たな絶対アドレスに置き換えれば、その新たな絶対アドレスにより、再配置後の静的変数が参照できるようになる。補正はコンパイル直後でも、主記憶装置への再配置後であってもよい。
これにより、個々のクラスを主記憶装置上に自由に再配置することが可能になる。また、クラス中では専ら静的なアドレス参照を採用すればよいことから、静的変数を頻繁に参照するような場合に、動的なアドレス変換を伴う参照を行う場合に比べて効率の良いプログラミングが可能となる。
【0009】
〈構成2〉
ソースコードにより記述されたクラス定義を実行可能形式ファイルにコンパイルし、クラス定義に示されているアドレスを補正して実行可能形式ファイルを主記憶装置に配置する方法において、クラス定義中で、当該クラス定義内におけるメソッドのアドレスを参照するためにジャンプテーブルを設けている場合に、ジャンブテーブルに含まれるメソッドの絶対アドレスを抽出し、メモリ上の任意の領域に実行可能形式ファイルを配置し、抽出した前記メソッドの絶対アドレスに対し、そのクラスの先頭アドレスによって定まるオフセットアドレスを、絶対アドレスに加算する補正を行う。
【0010】
〈説明〉
クラスの中で、メソッドのアドレスを参照するためにジャンプテーブルを設けている場合に、そのクラスをメモリ上の任意の領域に再配置したとき、ジャンプテーブル中の絶対アドレスは変化しない。従って、あるメソッドの絶対アドレスを指定してジャンプするような場合に、ジャンプ先アドレスが不正になる。そこで、静的変数の場合と同様にして絶対アドレスの補正を行う。その結果、この場合にも、ジャンプテーブルによる静的なアドレス指定を採用すればよいことから、条件分岐やその他の演算による動的なアドレス変換を伴う指定を行う場合に比べて効率の良いプログラミングが可能となる。
【0011】
【発明の実施の形態】
以下、本発明の実施の形態を具体例を用いて説明する。
〈具体例1〉
図1は、本発明の具体例1の方法を説明するブロック図である。
この方法では、クラス定義1をコンパイルする際に、コンパイラ/リンカ2とアドレス補正情報生成装置4とを使用する。クラス定義1はオブジェクト指向プログラミング技術により記述されたよく知られた内容のものである。コンパイラ/リンカ2はソースコードで作成されたクラス定義1をコンパイルし、実行可能形式ファイル3を生成するためのよく知られた装置から構成される。一方、アドレス補正情報生成装置4は、構文解析装置5と、意味解析装置6と、補正アドレス抽出装置7と、構文解析木情報8を備え、クラス定義1の中から静的変数の絶対アドレスを指定して参照するような静的変数を抽出する。構文解析装置5はクラス定義1の各文の要素を検出し、その構文を解析する部分で、意味解析装置6は各要素の意味を解析する部分である。補正アドレス抽出装置7は、構文解析の結果得られた構文解析木情報8を用いて、その内部に含まれる他の静的変数の絶対アドレスを指定して参照する静的変数を抽出する部分である。この具体的な説明は後で述べるが、この補正アドレス抽出装置7によってアドレス補正情報9が得られる。実行可能形式ファイル3は、配置装置11によって主記憶装置13の任意の位置に配置される。このとき、アドレス補正装置12は、アドレス補正情報9を参照しながら、主記憶装置13に配置された実行可能形式ファイル3中の先に説明した静的変数を参照する絶対アドレス部分を取り出し、これを補正する。クラス配置装置10は、このような配置装置11とアドレス補正装置12とから構成されている。
【0012】
なお、上記構文解析装置5はアドレスコードの内容を解析しないよう構文解析木情報8に変換し、構文上の誤り等をチェックする部分で、意味解析装置6は構文解析装置によって得られた構文解析木を元に意味上の誤り等をチェックする部分である。また、補正アドレス抽出装置7は、構文解析木を元に静的変数及び静的変数のアドレスを参照する静的変数の絶対アドレスを抽出し、抽出された情報をテーブル形式でアドレス補正情報としてファイルに出力する部分である。
【0013】
また、クラス配置装置10の配置装置11は実行形式モジュールをメモリ上にプログラムカウンタ相対アドレシング方式によって配置する装置である。このとき、先に説明したように、静的変数を参照する静的変数の内容は修正されずにそのまま主記憶装置上に割り付けられる。アドレス補正装置12は配置装置によって主記憶装置上に配置されたクラスの該当する静的変数部分を検出し、アドレス補正情報9及びそのクラスの主記憶装置上での先頭アドレス(オフセット)を用いて該当する部分の補正を行う装置である。
【0014】
なお、これらの具体的な動作を説明する前に、PC相対アドレシング方式とアドレス補正情報の内容、アドレス補正動作の概要等を説明する。
図2は、PC相対アドレシング方式の説明図である。
図に示すフェーズ1には、クラスAのソースファイルが表示されている。このソースファイルには、例えば変数bのアドレスを参照する静的変数aが含められているとする。フェーズ2では、これがコンパイルされて、実行可能形式ファイルに変換されている。この図を見て分かるように、実行可能形式ファイルの先頭アドレスを0番地とした場合に、変数aは変数bのアドレスを参照している。
【0015】
ここで、PC相対アドレス方式を採用し、主記憶装置上に実行可能形式ファイルを配置すると、フェーズ3に示すようになる。このとき、クラスAの先頭アドレスは、必ずしもメモリの0番地とは一致しない。従って、変数aはクラスAの先頭アドレスに変数aのアドレスを加えた位置に存在する。また、変数bはクラスAの先頭アドレスに変数bのアドレスを加えた位置に存在する。ところが、変数aは静的変数であって、こうしてメモリ上に配置される際にも内容が変更されず、フェーズ2に示した通り、変数bの絶対アドレスを表示している。これではフェーズ3においてクラスをメモリ上に配置した後、変数aは変数bを参照することができない。本発明では、この変数aを変数bのアドレスを参照するように変換する操作を行う。
【0016】
図3に、この目的のために使用するアドレス補正情報の説明図を示す。
まず、クラス定義1は先に説明したように、コンパイラ/リンカ2によって実行可能形式ファイル15に変換される。この場合の実行可能形式ファイル15の構造は図2を用いて説明したフェーズ2に示すものと同様である。
一方、図3において、クラス定義1からアドレス補正情報生成装置4によってアドレス補正情報が抽出される。これはソースコードの段階で構文解析等を行うことによって、静的変数の絶対アドレスを参照する静的変数を抽出することにより行われる。即ち、アドレス補正情報16は、他の静的変数のアドレスを参照する静的変数aの絶対アドレス等により構成される。
【0017】
図4には、アドレス補正動作の説明図を示す。
上記のように生成された実行可能形式ファイル3とアドレス補正情報9は、図1に示したクラス配置装置10に入力する。そして、配置装置11が実行可能形式ファイル3を主記憶装置の所定の場所に配置する。このとき、主記憶装置上でクラスの先頭アドレスが決定する。配置装置11はこの先頭アドレスをアドレス補正装置12に通知する。アドレス補正装置12はアドレス補正情報9を用いて、既に主記憶装置上に配置されたクラスの該当するアドレスの内容を補正する。即ち、変数aの値をクラスの先頭アドレス+bの絶対アドレスになるように書き換える。
【0018】
なお、このアドレスの補正は必ずしも主記憶装置に実行可能形式ファイルを配置してしまった後で行う必要はない。例えば、配置装置11が予め主記憶装置上にクラスを配置する際の先頭アドレスを認識していれば、これをアドレス補正装置12に通知し、アドレス補正装置12は実行可能形式ファイル3の補正を行う。そして、補正後の実行可能形式ファイル3を配置装置11が主記憶装置中に配置するという方法を採用することもできる。前者の方法を▲1▼、後者の方法を▲2▼というように区別してこの図中に示している。
【0019】
図5は、本発明の方法の具体的動作説明図である。
本発明の方法をより具体的に説明するために、この図によって静的変数のコンパイルと補正時の内容について詳細に説明する。
まず、例えばこの図の左上に示すように、クラス定義2に含まれる静的変数をa=100といった内容のものとする。これをステップS1でコンパイルすると、例えばこの図に示すように“XXXX”となるものとする。ここで、ステップS2において、先に説明したように、この静的変数aのアドレス50を抽出し、補正情報としておく。次に、ステップS3においてコンパイルされた静的変数が主記憶装置に配置される。この場合のクラスの先頭アドレスを、例えばこの図に示すように300とする。ここで、アドレス補正処理が開始されると、まずアドレスが50の静的変数aが参照する絶対アドレスの内容を先頭アドレスを用いて補正する。即ち、当初参照していた絶対アドレス100に先頭アドレス300を加算する。そして、正しいアドレスを参照する静的変数をコンパイルした“YYYY”を生成する。そして、主記憶装置上に記憶したクラスの“XXXX”を“YYYY”に置き換える補正を実行する(ステップS5)。以上のようにして静的変数の参照する絶対アドレスがクラスの配置結果に基づいて補正される。
【0020】
〈具体例1の効果〉
以上のようにしてプログラムカウンタ相対アドレシング方式を採用した場合においても、他の静的変数の絶対アドレスを参照する静的変数を適正に補正するので、このような静的変数の使用が可能となる。従って、例えば頻繁に参照のみを行う静的データのアドレスを参照するような静的変数を定義することができ、あるいは木構造のデータを採用することもでき、メソッド毎にアドレス変換等を行うダイナミックなアドレス参照を行う場合に比べて、効率よいプログラミングを実施することができる。
【0021】
〈具体例2〉
上記の例では、クラス中に存在する静的変数を問題としたが、クラス中にメソッドのアドレスを参照するジャンプテーブルが設けられることがある。このジャンプテーブルに入っているメソッドのアドレスは、そのクラスの先頭からカウントした絶対アドレスになっている。プログラムカウンタ相対アドレシングにより実行可能形式ファイルにファイル化され、主記憶装置上に配置される際にこのジャンプテーブルに表示された絶対アドレスも変換されない。そこで、上記の静的変数が参照する絶対アドレスと同様に、この具体例においてジャンプテーブルの絶対アドレスを補正する。
【0022】
図6には、具体例2の方法を説明するブロック図を示す。
クラス定義1は、具体例1と同様にコンパイラ/リンカ2によってコンパイルされ、実行可能形式ファイル3とされる。また、クラス定義1は、ジャンプテーブル補正情報生成装置20によって処理され、ジャンプテーブル補正情報22が抽出される。ジャンプテーブル補正情報生成装置20には、構文解析装置5、意味解析装置6、ジャンプテーブル抽出装置21及び構文解析木情報8が設けられる。上記ジャンプテーブル補正情報生成装置20は、クラス定義1を解析し、ジャンプテーブル上のメソッドのアドレスが格納される領域の絶対アドレスを抽出し、そのテーブルを作成する。このテーブルがジャンプテーブル補正情報22となる。これは具体例1の場合とよく類似している。構文解析装置5、意味解析装置6の構成や役割は、具体例1に示したものと同様である。ジャンプテーブル抽出装置21は、構文解析木情報8を元にテーブル上のメソッドのアドレスが格納される領域の絶対アドレスを抽出する処理を行う部分である。クラス配置装置10は、具体例1で説明したと同様の構成の配置装置11やアドレス補正装置12を備えている。その他の部分は具体例1で説明したものと同様である。
【0023】
図7に、ジャンプテーブル補正情報の説明図を示す。
図に示すように、クラス定義1はコンパイラ/リンカ2によって実行可能形式ファイル25に変換される。このとき、例えばアドレスaにはメソッドAの絶対アドレスが格納され、アドレスbにはメソッドBの絶対アドレスが格納され、アドレスcにはメソッドCの絶対アドレスが格納されているものとする。これらがジャンプテーブルを構成する。図に示すように、メソッドA,B,Cには、実行可能形式ファイル25の該当するアドレスに格納されている。ジャンプテーブル補正情報生成装置20はジャンプテーブルを参照し、図に示すようなジャンプテーブル補正情報26を生成する。その内容は、ジャンプテーブルの各部のアドレスa,b,cとなっている。このような補正情報の生成方法は具体例1と同様である。
【0024】
図8には、アドレス補正動作の説明図を示す。
上記のようにして生成された実行可能形式ファイル25とジャンプテーブル補正情報26は、この図に示すようにして主記憶装置へ配置される際の補正処理に使用される。まず、配置装置11は実行可能形式ファイル25を所定の主記憶装置上のアドレスに配置する。この場合に、アドレス補正装置12は、ジャンプテーブルにおいて指定しているメソッドAの絶対アドレス、メソッドBの絶対アドレス、メソッドCの絶対アドレスをそれぞれ補正して該当するメソッドを参照できるようにする。この場合の補正はクラスの先頭アドレスを各絶対アドレスに加算することにより行われる。
【0025】
なお、この補正動作やその具体的な処理は具体例1を用いて説明した場合と同様である。また、実行可能形式ファイルを主記憶装置上に配置した後でアドレス補正を行ってもよいし、また実行可能形式ファイル25の状態でアドレス補正を行うようにしてもよい。これも具体例1の場合と同様である。
【0026】
〈具体例2の効果〉
クラスのソースコード上で、あるメソッドへジャンプするアドレスを検出し、これを補正することによって、メソッドの絶対アドレスを持つジャンプテーブルを静的に作ることができる。そして、プログラムカウンタ相対アドレシングでクラスを再配置した場合にも、このジャンプテーブルの内容が適正に補正されるため、このような方式においてもジャンプテーブルを利用できる。従って、例えばメソッドを選択して分岐するような処理に一般的なプログラミング言語の持つ分岐機構等を記述することによってコードサイズを増加させたり、記述自体を複雑にし、プログラミングの効率を低下させるといったことを防止できる。
【図面の簡単な説明】
【図1】本発明の方法を説明するブロック図である。
【図2】PC相対アドレシング方式の説明図である。
【図3】アドレス補正情報の説明図である。
【図4】アドレス補正動作の説明図である。
【図5】本発明の方法の具体的動作説明図である。
【図6】具体例2の方法を説明するブロック図である。
【図7】ジャンプテーブル補正情報の説明図である。
【図8】アドレス補正動作の説明図である。
【符号の説明】
1 クラス定義
2 コンパイラ/リンカ
3 実行可能形式ファイル
4 アドレス補正情報生成装置
9 アドレス補正情報
10 クラス配置装置
11 配置装置
12 アドレス補正装置
13 主記憶装置
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a method of allocating a class of a program developed by the object-oriented technology to a main storage device.
[0002]
[Prior art]
When a program is created by object-oriented programming, for example, in the well-known C language, a class definition is performed to extract and declare the properties of an object. Within this class, you can include variables that reference the address of a variable. Among these variables are static variables, which are variables that can be referenced by all instances created from the class. The address of this static variable is expressed as an absolute address based on the top address of the class. Therefore, when compiling / linking a class and arranging it on the main storage device, an absolute address is assigned to a static variable.
[0003]
[Problems to be solved by the invention]
By the way, the above-mentioned conventional method of arranging a class in a main storage device has the following problems to be solved.
In a system developed by the object-oriented programming technology, when a program is modified or a function is added, a mechanism for dynamically allocating a new class to an empty area in a memory without stopping the system is required. In order to respond to this demand, a method using a program counter relative addressing is known. In this method, when compiling / linking, the address referred inside the class is converted into a relative address using the value of the program counter as an offset value, and is referred to at the time of execution. Therefore, the class can be relocated to an arbitrary location on the main storage device.
[0004]
However, when the class includes the above static variable, the correction is not performed up to the address of another static variable referred to by the static variable. Therefore, the address is actually incorrect and cannot be referenced. For this reason, conventionally, when the program counter relative addressing method is adopted, programming is performed while avoiding reference by static variables. However, in this case, for example, tree-structured data that refers to an address cannot be statically created. Note that the tree-structured data refers to a data structure in which variables are sequentially traced from the branches toward the trunk, and the target data is referred to.
[0005]
On the other hand, a class may include a mechanism for selecting and branching some methods included in the class. In this case, it is preferable to provide a branch function with a conditional statement or the like as performed in a general program. However, when the number of branching methods increases, the number of procedures for selecting a method and branching increases, resulting in a decrease in efficiency and a disadvantage that the code size of the class definition increases. Therefore, it is more efficient to call a corresponding method using a jump table that refers to the address of the method. However, when the above-described program counter relative addressing is used, the address of the method in the jump table is not to be corrected when the class is rearranged. Therefore, the method indicated by the absolute address cannot be called. For this reason, conventionally, such a jump table cannot be statically created.
[0006]
[Means for Solving the Problems]
The present invention employs the following configuration to solve the above points.
<Configuration 1>
A method of compiling a class definition described by the source code into an executable format file, place the correction to executable file addresses listed in the class definition in the main memory, in the class definition, the class Extract the static variables to be referenced by specifying the absolute addresses of other static variables in the definition, place the executable file in any area on the main storage device, and extract the absolute addresses of the extracted static variables , An offset address determined by the start address of the class is corrected to be added to the absolute address.
[0007]
<Description>
In the program counter relative addressing method, an absolute address on a memory, that is, a main memory is assigned to a static variable included in a class definition at the time of compiling and linking. In the object-oriented program, a static variable can be commonly referred to by all instances generated from a certain class, and cannot be changed in real memory if it is located in a data segment specified by an absolute address. Variables.
When an executable file that compiles such a class is relocated to an arbitrary free area on the main storage device, one static variable specifies and refers to the absolute address of another static variable. In such a case, the address referred to becomes invalid.
Therefore, at the time of compiling, a corresponding static variable is extracted in advance.
[0008]
If the offset address determined by the head address of the class on the main storage device is replaced with a new absolute address by correcting the absolute address, the static variable after the relocation can be referenced by the new absolute address. become. The correction may be performed immediately after compiling or after relocation to the main storage device.
This allows individual classes to be freely relocated on the main storage device. In addition, since it is only necessary to use static address references in a class, programming that is more efficient than when referencing with dynamic address translation is performed when static variables are frequently referenced. Becomes possible.
[0009]
<Configuration 2>
A method of compiling a class definition described by the source code into an executable format file, place the correction to executable file addresses listed in the class definition in the main memory, in the class definition, the class If a jump table is provided to refer to the address of the method in the definition, the absolute address of the method included in the jump table is extracted, and the executable file is placed in an arbitrary area on the memory and extracted. The absolute address of the method is corrected by adding an offset address determined by the head address of the class to the absolute address.
[0010]
<Description>
When a jump table is provided in a class to refer to the address of a method, when the class is relocated to an arbitrary area in the memory, the absolute address in the jump table does not change. Therefore, when jumping by specifying an absolute address of a certain method, the jump destination address becomes invalid. Therefore, the absolute address is corrected in the same manner as in the case of the static variable. As a result, in this case as well, since it is sufficient to employ static addressing using a jump table, more efficient programming can be performed than in the case of performing specification involving dynamic address translation by conditional branching or other operations. It becomes possible.
[0011]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments of the present invention will be described using specific examples.
<Specific example 1>
FIG. 1 is a block diagram illustrating a method according to a first embodiment of the present invention.
In this method, when compiling the class definition 1, the compiler / linker 2 and the address correction information generation device 4 are used. The class definition 1 has well-known contents described by the object-oriented programming technology. The compiler / linker 2 is composed of a well-known device for compiling the class definition 1 created with the source code and generating the executable file 3. On the other hand, the address correction information generation device 4 includes a syntax analysis device 5, a semantic analysis device 6, a correction address extraction device 7, and syntax analysis tree information 8, and extracts the absolute address of a static variable from the class definition 1. Extract static variables that are specified and referenced. The syntax analyzer 5 is a part that detects elements of each sentence of the class definition 1 and analyzes its syntax, and the semantic analyzer 6 is a part that analyzes the meaning of each element. The correction address extraction device 7 uses the parse tree information 8 obtained as a result of the syntax analysis to extract a static variable to be specified by referring to the absolute address of another static variable included therein. is there. As will be described later in detail, address correction information 9 is obtained by the correction address extracting device 7. The executable format file 3 is arranged in an arbitrary position of the main storage device 13 by the arrangement device 11. At this time, while referring to the address correction information 9, the address correction device 12 extracts an absolute address portion referring to the above-described static variable in the executable format file 3 arranged in the main storage device 13, and Is corrected. The class arrangement device 10 includes such an arrangement device 11 and an address correction device 12.
[0012]
The parsing device 5 converts the contents of the address code into parse tree information 8 so as not to be parsed, and checks syntax errors and the like. This part checks for semantic errors based on the tree. The correction address extracting device 7 extracts the static variable and the absolute address of the static variable referring to the address of the static variable based on the parse tree, and stores the extracted information in a file format as address correction information in a table format. This is the part to output.
[0013]
Further, the placement device 11 of the class placement device 10 is a device for placing an executable module on a memory by a program counter relative addressing method. At this time, as described above, the contents of the static variable referring to the static variable are allocated without modification to the main storage device. The address correction device 12 detects the corresponding static variable portion of the class allocated on the main storage device by the allocation device, and uses the address correction information 9 and the start address (offset) of the class on the main storage device. This is a device that corrects the corresponding part.
[0014]
Before describing these specific operations, the PC relative addressing method, the contents of address correction information, the outline of the address correction operation, and the like will be described.
FIG. 2 is an explanatory diagram of the PC relative addressing method.
In the phase 1 shown in the figure, a class A source file is displayed. It is assumed that the source file includes, for example, a static variable a that refers to the address of the variable b. In phase 2, it is compiled and converted into an executable file. As can be seen from this figure, when the start address of the executable file is set to address 0, the variable a refers to the address of the variable b.
[0015]
Here, when the PC relative address method is adopted and the executable format file is arranged on the main storage device, the phase becomes as shown in phase 3. At this time, the start address of the class A does not always match the address 0 of the memory. Therefore, the variable a exists at the position obtained by adding the address of the variable a to the head address of the class A. Further, the variable b exists at a position obtained by adding the address of the variable b to the head address of the class A. However, the variable a is a static variable, and its contents are not changed even when it is arranged on the memory in this way, and the absolute address of the variable b is displayed as shown in phase 2. In this case, after the class is arranged on the memory in the phase 3, the variable a cannot refer to the variable b. In the present invention, an operation of converting the variable a so as to refer to the address of the variable b is performed.
[0016]
FIG. 3 is an explanatory diagram of address correction information used for this purpose.
First, the class definition 1 is converted into the executable file 15 by the compiler / linker 2 as described above. The structure of the executable file 15 in this case is the same as that shown in the phase 2 described with reference to FIG.
On the other hand, in FIG. 3, the address correction information is extracted from the class definition 1 by the address correction information generation device 4. This is performed by performing a syntax analysis or the like at the stage of the source code to extract a static variable that refers to the absolute address of the static variable. That is, the address correction information 16 is composed of the absolute address of the static variable a referring to the address of another static variable.
[0017]
FIG. 4 is an explanatory diagram of the address correction operation.
The executable format file 3 and the address correction information 9 generated as described above are input to the class arrangement device 10 shown in FIG. Then, the arrangement device 11 arranges the executable format file 3 at a predetermined location in the main storage device. At this time, the head address of the class is determined on the main storage device. The arrangement device 11 notifies this address to the address correction device 12. The address correction device 12 uses the address correction information 9 to correct the contents of the corresponding address of the class already arranged on the main storage device. That is, the value of the variable a is rewritten to be the absolute address of the head address of the class + b.
[0018]
Note that this address correction does not necessarily need to be performed after the executable format file has been placed in the main storage device. For example, if the arrangement device 11 recognizes in advance the start address at the time of allocating the class on the main storage device, it notifies the address correction device 12 and the address correction device 12 corrects the executable file 3. Do. Then, a method in which the arrangement device 11 arranges the corrected executable file 3 in the main storage device can be adopted. The former method is indicated by (1), and the latter method is indicated by (2) in FIG.
[0019]
FIG. 5 is an explanatory diagram of a specific operation of the method of the present invention.
In order to explain the method of the present invention more specifically, the contents at the time of compiling and correcting the static variables will be described in detail with reference to FIG.
First, for example, as shown in the upper left of this figure, it is assumed that the static variable included in the class definition 2 has a content of a = 100. When this is compiled in step S1, it becomes, for example, "XXXX" as shown in FIG. Here, in step S2, as described above, the address 50 of the static variable a is extracted and set as correction information. Next, the static variables compiled in step S3 are stored in the main storage device. In this case, the head address of the class is, for example, 300 as shown in FIG. Here, when the address correction processing is started, first, the contents of the absolute address referred to by the static variable a having the address 50 are corrected using the head address. That is, the top address 300 is added to the absolute address 100 that was initially referred to. Then, "YYYY" is generated by compiling a static variable referring to the correct address. Then, a correction for replacing “XXXX” of the class stored on the main storage device with “YYYY” is executed (step S5). As described above, the absolute address referred to by the static variable is corrected based on the result of class arrangement.
[0020]
<Effect of Specific Example 1>
Even when the program counter relative addressing method is employed as described above, the static variable that refers to the absolute address of another static variable is appropriately corrected, so that such a static variable can be used. . Therefore, for example, it is possible to define a static variable that refers to the address of static data that is frequently referred to only, or to adopt tree-structured data. Programming can be performed more efficiently than in the case of performing a simple address reference.
[0021]
<Specific example 2>
In the above example, the static variable existing in the class has been considered as a problem. However, a jump table that refers to the address of a method may be provided in the class. The address of the method in the jump table is an absolute address counted from the top of the class. The absolute address displayed in the jump table when converted into a file by the program counter relative addressing into an executable format file and placed on the main storage device is not converted. Therefore, the absolute address of the jump table is corrected in this specific example, similarly to the absolute address referred to by the static variable.
[0022]
FIG. 6 is a block diagram illustrating the method of the second embodiment.
The class definition 1 is compiled by the compiler / linker 2 in the same manner as in the first embodiment, and becomes an executable file 3. Further, the class definition 1 is processed by the jump table correction information generating device 20, and the jump table correction information 22 is extracted. The jump table correction information generation device 20 includes a syntax analysis device 5, a semantic analysis device 6, a jump table extraction device 21, and syntax analysis tree information 8. The jump table correction information generation device 20 analyzes the class definition 1, extracts the absolute address of the area where the address of the method on the jump table is stored, and creates the table. This table becomes the jump table correction information 22. This is very similar to the case of the first embodiment. The configurations and roles of the syntax analyzer 5 and the semantic analyzer 6 are the same as those shown in the first embodiment. The jump table extracting device 21 is a part that performs processing for extracting the absolute address of the area where the address of the method on the table is stored, based on the parse tree information 8. The class placement device 10 includes a placement device 11 and an address correction device 12 having the same configuration as described in the first embodiment. Other parts are the same as those described in the first embodiment.
[0023]
FIG. 7 is an explanatory diagram of the jump table correction information.
As shown in the figure, the class definition 1 is converted into an executable file 25 by the compiler / linker 2. At this time, for example, it is assumed that the absolute address of the method A is stored in the address a, the absolute address of the method B is stored in the address b, and the absolute address of the method C is stored in the address c. These constitute a jump table. As shown in the figure, the methods A, B, and C are stored at the corresponding addresses of the executable format file 25. The jump table correction information generating device 20 refers to the jump table and generates jump table correction information 26 as shown in FIG. The contents are the addresses a, b, and c of each part of the jump table. The method of generating such correction information is the same as in the first embodiment.
[0024]
FIG. 8 is an explanatory diagram of the address correction operation.
The executable format file 25 and the jump table correction information 26 generated as described above are used for correction processing when the file is arranged in the main storage device as shown in FIG. First, the arrangement device 11 arranges the executable format file 25 at a predetermined address on the main storage device. In this case, the address correction device 12 corrects the absolute address of the method A, the absolute address of the method B, and the absolute address of the method C specified in the jump table so that the corresponding method can be referred to. The correction in this case is performed by adding the head address of the class to each absolute address.
[0025]
The correction operation and the specific processing are the same as those described with reference to the first embodiment. Further, the address correction may be performed after the executable format file is placed on the main storage device, or the address correction may be performed in the state of the executable format file 25. This is also the same as in the first embodiment.
[0026]
<Effect of Specific Example 2>
By detecting the address jumping to a certain method in the class source code and correcting this, a jump table having the absolute address of the method can be statically created. Then, even when the classes are rearranged by the program counter relative addressing, the contents of the jump table are appropriately corrected, so that the jump table can be used in such a method. Therefore, for example, by describing the branching mechanism of a general programming language in the process of selecting and branching a method, the code size is increased, the description itself is complicated, and the programming efficiency is reduced. Can be prevented.
[Brief description of the drawings]
FIG. 1 is a block diagram illustrating a method of the present invention.
FIG. 2 is an explanatory diagram of a PC relative addressing method.
FIG. 3 is an explanatory diagram of address correction information.
FIG. 4 is an explanatory diagram of an address correction operation.
FIG. 5 is a diagram illustrating a specific operation of the method of the present invention.
FIG. 6 is a block diagram illustrating a method of a specific example 2.
FIG. 7 is an explanatory diagram of jump table correction information.
FIG. 8 is an explanatory diagram of an address correction operation.
[Explanation of symbols]
1 Class Definition 2 Compiler / Linker 3 Executable Format File 4 Address Correction Information Generator 9 Address Correction Information 10 Class Placement Device 11 Placement Device 12 Address Correction Device 13 Main Storage

Claims (2)

ソースコードにより記述されたクラス定義を実行可能形式ファイルにコンパイルし、前記クラス定義に示されているアドレスを補正して実行可能形式ファイルを主記憶装置に配置する方法において、
前記クラス定義中で、当該クラス定義内における他の静的変数の絶対アドレスを指定して参照する静的変数を抽出し、
主記憶装置上の任意の領域に前記実行可能形式ファイルを配置するとともに、
抽出した前記静的変数の絶対アドレスに対し、そのクラスの先頭アドレスによって定まるオフセットアドレスを、前記絶対アドレスに加算する補正を行うことを特徴とするクラスの主記憶装置への配置方法。
A method of compiling a class definition described by source code into an executable file, correcting the address indicated in the class definition, and placing the executable file in a main storage device,
In the class definition, extract a static variable to refer to by specifying an absolute address of another static variable in the class definition ,
While placing the executable file in an arbitrary area on the main storage device,
A method of allocating a class to a main storage device, wherein a correction is performed to add an offset address determined by a leading address of the class to the absolute address of the extracted static variable to the absolute address.
ソースコードにより記述されたクラス定義を実行可能形式ファイルにコンパイルし、前記クラス定義に示されているアドレスを補正して実行可能形式ファイルを主記憶装置に配置する方法において、
前記クラス定義中で、当該クラス定義内におけるメソッドの絶対アドレスを参照するためにジャンプテーブルを設けている場合に、前記ジャンブテーブルに含まれるメソッドの絶対アドレスを抽出し、
メモリ上の任意の領域に前記実行可能形式ファイルを配置し、
抽出した前記メソッドの絶対アドレスに対し、そのクラスの先頭アドレスによって定まるオフセットアドレスを、前記絶対アドレスに加算する補正を行うことを特徴とするクラスの主記憶装置への配置方法。
A method of compiling a class definition described by source code into an executable file, correcting the address indicated in the class definition, and placing the executable file in a main storage device,
In the class definition, when a jump table is provided to refer to an absolute address of a method in the class definition, extracting an absolute address of a method included in the jumbe table,
Placing the executable file in any area on the memory,
A method of allocating a class to a main storage device, wherein a correction is performed by adding an offset address determined by a leading address of the class to the extracted absolute address of the method, to the absolute address.
JP30658495A 1995-10-31 1995-10-31 Method of allocating classes to main storage Expired - Fee Related JP3596570B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP30658495A JP3596570B2 (en) 1995-10-31 1995-10-31 Method of allocating classes to main storage

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP30658495A JP3596570B2 (en) 1995-10-31 1995-10-31 Method of allocating classes to main storage

Publications (2)

Publication Number Publication Date
JPH09128240A JPH09128240A (en) 1997-05-16
JP3596570B2 true JP3596570B2 (en) 2004-12-02

Family

ID=17958830

Family Applications (1)

Application Number Title Priority Date Filing Date
JP30658495A Expired - Fee Related JP3596570B2 (en) 1995-10-31 1995-10-31 Method of allocating classes to main storage

Country Status (1)

Country Link
JP (1) JP3596570B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2117585C (en) * 1993-09-14 2001-06-05 Edward T. Shawl Cement composition

Also Published As

Publication number Publication date
JPH09128240A (en) 1997-05-16

Similar Documents

Publication Publication Date Title
USRE38104E1 (en) Method and apparatus for resolving data references in generated code
US6381737B1 (en) Automatic adapter/stub generator
US5361351A (en) System and method for supporting run-time data type identification of objects within a computer program
US5287444A (en) Message processing system
US8813047B2 (en) Yet another transformation language (YATL)
US6434742B1 (en) Symbol for automatically renaming symbols in files during the compiling of the files
US5884083A (en) Computer system to compile non-incremental computer source code to execute within an incremental type computer system
US7308680B2 (en) Intermediate representation for multiple exception handling models
KR20060041228A (en) Method and apparatus for performing native binding
CA2170939A1 (en) Method and apparatus for displaying locations of errors detected inside software macro calls
US20230367569A1 (en) Method of generating a representation of a program logic, decompilation apparatus, recompilation system and computer program products
US5758163A (en) Method and apparatus for record fields usage checking at compile time
EP0520708A2 (en) Method and apparatus for converting high level form abstract syntaxes into an intermediate form
US7207036B2 (en) Preprocessing of interfaces to allow fast call through
JP3596570B2 (en) Method of allocating classes to main storage
JP3266097B2 (en) Automatic reentrant method and system for non-reentrant program
JPS5922140A (en) Interactive compiling system
Nadera et al. The varying faces of a program transformation systems
JP2003050700A (en) Program converting method
JP2807162B2 (en) Program translator
JPS6326730A (en) Program correction system
JP2001005655A (en) Device and method for aiding development of application generator
JP2001014172A (en) Program converting device
JPH06266562A (en) Object code size optimizing system in object-oriented language processing system
JPH0196741A (en) Common section system in debugger

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20040608

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20040727

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

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20040824

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20040831

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20070917

Year of fee payment: 3

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

Free format text: PAYMENT UNTIL: 20080917

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20080917

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20090917

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20090917

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20100917

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20110917

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20110917

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20120917

Year of fee payment: 8

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

Free format text: PAYMENT UNTIL: 20120917

Year of fee payment: 8

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

Free format text: PAYMENT UNTIL: 20130917

Year of fee payment: 9

LAPS Cancellation because of no payment of annual fees