JPH01136239A - Program translation processing system - Google Patents
Program translation processing systemInfo
- Publication number
- JPH01136239A JPH01136239A JP62295876A JP29587687A JPH01136239A JP H01136239 A JPH01136239 A JP H01136239A JP 62295876 A JP62295876 A JP 62295876A JP 29587687 A JP29587687 A JP 29587687A JP H01136239 A JPH01136239 A JP H01136239A
- Authority
- JP
- Japan
- Prior art keywords
- translation
- procedure
- recursive
- unit
- program
- 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
Links
- 238000000034 method Methods 0.000 claims abstract description 109
- 238000003672 processing method Methods 0.000 claims description 8
- 238000005457 optimization Methods 0.000 abstract description 5
- 230000003068 static effect Effects 0.000 abstract description 4
- 238000010586 diagram Methods 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 2
- 239000000284 extract Substances 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
Description
【発明の詳細な説明】
〔概 要〕
再帰的な手続き呼出しを許す手続き型プログラム言語の
プログラム翻訳処理方式に関し。[Detailed Description of the Invention] [Summary] This invention relates to a program translation processing method for a procedural programming language that allows recursive procedure calls.
プログラム翻訳時に決定可能な非再帰的手続きを認識し
、これを利用して最適化した翻訳処理を行うことを目的
とし。The purpose is to recognize non-recursive procedures that can be determined during program translation, and to use these to perform optimized translation processing.
再帰的な手続き呼出しを許す手続き型プログラム言語で
記述されたソースプログラムを翻訳処理する翻訳部を有
するプログラム翻訳処理方式において、ソースプログラ
ム中の各手続きが呼出している手続き名を抽出する処理
を行う仮翻訳部と。In a program translation processing method that has a translation unit that translates a source program written in a procedural programming language that allows recursive procedure calls, a temporary procedure that extracts the name of the procedure called by each procedure in the source program is used. With the translation department.
前記仮翻訳部の処理結果に基づいて、所定のルールに従
って、呼出し構造グラフを作成するグラフ作成部と、前
記呼出し構造グラフに基づいて、非再帰的な手続きを認
識する認識部とを備え、前記翻訳部における前記ソース
プログラムの翻訳処理の際に、前記認識部の認識結果を
参照することによって、前記ソースプログラムの中の非
再帰的な手続きについて最適化された処理を行うように
構成する。a graph creation unit that creates a call structure graph according to a predetermined rule based on the processing result of the temporary translation unit; and a recognition unit that recognizes a non-recursive procedure based on the call structure graph; When the source program is translated by the translation unit, the recognition result of the recognition unit is referred to so that non-recursive procedures in the source program are optimized.
本発明はプログラム翻訳処理方式に関し、更に詳しくは
、再帰的な手続き呼出しを許す手続き型プログラム言語
のプログラム翻訳処理方式に関する。The present invention relates to a program translation processing method, and more particularly to a program translation processing method for a procedural programming language that allows recursive procedure calls.
手続き型プログラム言語には、C言語の如く。For procedural programming languages, such as C language.
再帰的な手続き呼出しく再帰呼出し)、即ち、ある手続
きにおいて直接または間接にその手続き自体を呼出すこ
とを認めている言語がある。Some languages allow a procedure to call itself directly or indirectly.
再帰的な手続き呼出しの実現のためには、実行後に制御
を戻すべき番地(帰り番地)を保持する必要がある。こ
のために、スタック上にある領域が割当てられる。そし
て、他の必要とされる情報は、スタック上に、帰り番地
に対応させられた形で保持される。In order to implement recursive procedure calls, it is necessary to hold the address to which control should be returned after execution (return address). For this purpose, some space on the stack is allocated. Other required information is held on the stack in a form that corresponds to the return address.
ところで、再帰的手続き呼出しを許す言語で記述されて
いるからといって、そのプログラムに含まれる手続き全
てが再帰的に呼出されるものであるとは限らない。By the way, just because a program is written in a language that allows recursive procedure calls does not necessarily mean that all procedures included in the program are called recursively.
しかし、従来のプログラム翻訳処理方式においては、た
とえある手続きが非再帰的であったとしても、再帰的手
続きと同様の方法によって実現していた。即ち、その手
続きの番地に対応するようにして、他の必要な情報がス
タック上に置かれる。However, in conventional program translation processing methods, even if a certain procedure is non-recursive, it is realized using the same method as a recursive procedure. That is, other necessary information is placed on the stack so as to correspond to the address of the procedure.
非再帰的な手続き(再帰的手続き呼出しを含まない手続
き)は、前記従来技術によらずに、スタック上に静的に
領域を割当てることによっても実現できる。即ち、再帰
的な手続きと異なり、非再帰的手続きにあっては、同じ
変数であれば参照すべき実体はどの参照の時点でも同じ
であるから。Non-recursive procedures (procedures that do not include recursive procedure calls) can also be realized by statically allocating an area on the stack, instead of using the prior art described above. That is, unlike recursive procedures, in non-recursive procedures, if the variable is the same, the entity to be referenced is the same at any point of reference.
スタック上に静的に割当てた領域のうちその時点で参照
すべき領域を参照するようにすることができる。Of the statically allocated areas on the stack, the area that should be referenced at that time can be referenced.
ところで、プログラムの実行時の効率や最適化の観点か
らみると5静的に領域を割当てた方が有利な場合が多い
。Incidentally, from the viewpoint of efficiency and optimization during program execution, it is often more advantageous to statically allocate areas.
したがって、前述した従来技術によれば、静的領域割当
てが可能な非再帰的な手続きであるにも拘らず、実行時
に余分な負担が生じてしまうことになる。即ち、再帰的
手続きではないのに再帰的手続きと同様の処理をするた
めの余分な処理や。Therefore, according to the above-mentioned conventional technology, although it is a non-recursive procedure that allows static area allocation, an extra burden is generated at the time of execution. In other words, extra processing to perform processing similar to a recursive procedure even though it is not a recursive procedure.
このような処理を行うことによって最適化が不十分とな
ったために生ずる余分な処理によって、再帰呼出しの処
理がオーバーヘッドしたり、プログラムの実行の最適化
ができないという問題があった。Due to the insufficient optimization resulting from such processing, there are problems in that the recursive call processing causes overhead and program execution cannot be optimized.
本発明は、プログラム翻訳時に決定可能な非再帰的手続
きを認識し、これを利用して最適化した翻訳処理を行う
ことが可能なプログラム翻訳処理方式を提供することを
目的とする。SUMMARY OF THE INVENTION An object of the present invention is to provide a program translation processing method that can recognize non-recursive procedures that can be determined at the time of program translation and perform optimized translation processing using these procedures.
c問題点を解決するための手段〕
第1図は本発明の原理構成図であり5本発明によるプロ
グラム翻訳(支援)システムを示している。c. Means for Solving Problems] FIG. 1 is a diagram showing the principle structure of the present invention, and shows a program translation (support) system according to the present invention.
第1図において、lは処理装置、2は翻訳処理部、3は
翻訳処理部2における最適な翻訳を支援する翻訳補助(
支援)部、4は仮翻訳部、5はグラフ作成部、6は認識
部、7はプログラムの翻訳(コンパイル)を実際に行う
翻訳部(コンパイラ)、8はソースプログラム、9はオ
ブジェクトモジュールである。In FIG. 1, l is a processing device, 2 is a translation processing unit, and 3 is a translation assistant (3) that supports optimal translation in the translation processing unit 2.
4 is a temporary translation unit, 5 is a graph creation unit, 6 is a recognition unit, 7 is a translation unit (compiler) that actually translates (compiles) the program, 8 is a source program, and 9 is an object module. .
再帰的な手続き呼出しを許す手続き型プログラム言語で
記述されたソースプログラム8は、翻訳処理部2の仮翻
訳部4および翻訳部7に入力される。A source program 8 written in a procedural programming language that allows recursive procedure calls is input to the temporary translation section 4 and the translation section 7 of the translation processing section 2 .
仮翻訳部4は、ソースプログラム8に含まれる手続き呼
出しを伴う全ての手続きについて、各年続きが呼出して
いる手続き名を抽出し、これを呼出し情報テーブルとす
る。The temporary translation unit 4 extracts the name of the procedure called by each year's continuation for all procedures involving a procedure call included in the source program 8, and uses this as a call information table.
グラフ作成部5は、呼出し情報テーブルに基づいて、前
記呼出し構造を解析し、呼出し構造グラフを作成する。The graph creation unit 5 analyzes the call structure based on the call information table and creates a call structure graph.
この呼出し構造グラフは、解析結果に基づいて、予め定
められた所定のルールに従って作成される。This call structure graph is created according to predetermined rules based on the analysis results.
認識部6は、呼出し構造グラフに基づいて、非再帰的手
続きを認識し、非再帰的手続きリストを作成する。この
認識は、呼出し構造グラフが所定の形状(構造)を有し
ていない場合、非再帰的手続きであると認識するように
して行なわれる。なお、ここで所定の構造とは、ある手
続きが呼出した他の手続きにおいて当該手続きが呼出さ
れている場合に、呼出し構造グラフにおいて表われるル
ープ構造をいう(後述する)。The recognition unit 6 recognizes non-recursive procedures based on the call structure graph and creates a non-recursive procedure list. This recognition is performed in such a way that if the call structure graph does not have a predetermined shape (structure), it is recognized as a non-recursive procedure. Note that the predetermined structure here refers to a loop structure that appears in a call structure graph when a procedure is called by another procedure called by another procedure (described later).
翻訳部7は、ソースプログラム8について、これを解析
してオブジェクトコードを生成し、これを編集してオブ
ジェクトモジュール9を作成する。The translation unit 7 analyzes the source program 8 to generate an object code, and edits this to create an object module 9.
この時、非再帰的手続きリストによって非再帰的手続き
は再帰的手続きと区別され、各々、最適なオブジェクト
コードが生成される。At this time, non-recursive procedures are distinguished from recursive procedures by the non-recursive procedure list, and optimal object codes are generated for each.
プログラムの翻訳時においては1手続き呼出しを含まな
い手続き等特殊な場合を除いて、ある手続きについてそ
の定義(宣言)を見ただけではその手続きが再帰的に呼
出されるかどうかは認識することができない。When translating a program, it is impossible to tell whether a procedure is called recursively just by looking at its definition (declaration), except in special cases such as procedures that do not include a single procedure call. Can not.
そこで、翻訳補助部3を設け、この翻訳補助部3が、ソ
ースプログラム8に含まれる全ての手続きについてその
呼出し構造(甚平続きが互いにどのような呼出しの関係
にあるかを示す構造)を解析し、これによって非再帰的
手続きを認識できるようにする。そして、この非再帰約
手続きについての情報が翻訳補助部3から翻訳処理部2
(の翻訳部7)へ提供されることによって、最適化され
たオブジェクトモジュール9が得られるようにされる。Therefore, a translation auxiliary unit 3 is provided, and this translation auxiliary unit 3 analyzes the call structure (structure that indicates the calling relationship of Jinbei continuations to each other) for all procedures included in the source program 8. , which allows us to recognize non-recursive procedures. Then, information about this non-recursive contracting procedure is transmitted from the translation assisting section 3 to the translation processing section 2.
(translation unit 7), an optimized object module 9 can be obtained.
即ち、翻訳部7は、非再帰的な手続きに対しては、スタ
ック上において静的な領域割当てを行うような翻訳処理
を行う。一方、再帰的な手続きに対しては、スタック上
において割当てられた領域が帰り番地に対応させられる
ような翻訳処理を行う。That is, the translation unit 7 performs translation processing such as static area allocation on the stack for non-recursive procedures. On the other hand, for recursive procedures, translation processing is performed such that the area allocated on the stack corresponds to the return address.
このような翻訳部7における処理によって、非再帰的な
手続きの部分についての最適化処理が可能となり、プロ
グラム全体の実行効率を改善することができる。Such processing in the translation unit 7 makes it possible to optimize the non-recursive procedure portion, thereby improving the execution efficiency of the entire program.
なお1手続き呼出しを含まない手続きについては容易に
非再帰的手続きであると認識できるので。Note that a procedure that does not include one procedure call can be easily recognized as a non-recursive procedure.
その認識は、他と同じく認識部6において行ってもよく
、また、翻訳部7のみにおいて行ってもよく、最適な翻
訳処理の支障となることはない。The recognition may be performed in the recognition unit 6 like the others, or it may be performed only in the translation unit 7, without interfering with optimal translation processing.
第2図は一実施例説明図であり1本発明に従うプログラ
ム翻訳処理の一例を示している。FIG. 2 is an explanatory diagram of an embodiment, and shows an example of program translation processing according to the present invention.
第2図において、10は呼出し情報テーブル、 11は
呼出し構造グラフ、 12は非再帰的手続きリストであ
る。In FIG. 2, 10 is a call information table, 11 is a call structure graph, and 12 is a non-recursive procedure list.
ソースプログラム8は、再帰的な手続き呼出しを許す手
続き型プログラム言語9例えば、C言語で1図示の如く
記述されている。The source program 8 is written in a procedural programming language 9, for example C language, which allows recursive procedure calls, as shown in FIG.
仮關訳部4において2人力されたソースプログラム8は
、その全ての手続きについて1手続き呼出しを伴ってい
るか、および5手続き呼出しがある場合その呼び出して
いる手続き名は何かが調べられる。この処理により、仮
翻訳部4は、呼出し情報テーブル10を作成する。In the temporary translation section 4, it is checked whether all procedures in the source program 8 created by two people involve one procedure call, and if there are five procedure calls, what are the names of the procedures being called. Through this process, the temporary translation unit 4 creates the call information table 10.
ソースプログラム8において2手続きproc Oは手
続きproc lを呼出しているので、呼出し情報テー
ブル10において、 rprocO:proclJの
如く示される(他の手続きについても同様である)、−
方1手続きproc 2は、他の手続きを呼出していな
いので、呼出し情報テーブルlOにおいて1手続きpr
oc 2が呼出す手続きについての記述はなされない。In the source program 8, the procedure proc O calls the procedure proc l, so it is indicated in the call information table 10 as rprocO:proclJ (the same applies to other procedures), -
Since method 1 procedure proc 2 does not call any other procedure, procedure 1 procedure pr in the call information table IO
No description is given of the procedures that oc2 calls.
グラフ作成部5は、入力された呼出し情報テーブルIO
から呼出し構造グラフ11を作成する。The graph creation unit 5 uses the input call information table IO
A call structure graph 11 is created from
呼出し構造グラフ11は、以下の所定のルール即ち定義
に従う有向グラフである。Call structure graph 11 is a directed graph that follows the following predetermined rules or definitions.
(i)手続きはノード(点)に対応させられる(第2図
において、各ノードは手続き名で示す)。(i) Procedures are associated with nodes (in Figure 2, each node is indicated by a procedure name).
(ii)あるノードAに対応する手続きが他のノードB
に対応する手続きを呼出している場合。(ii) A procedure corresponding to a certain node A is executed by another node B.
If the procedure corresponding to is called.
ノードAからノードBに向けた矢(アーク)を記入する
。Write an arrow (arc) pointing from node A to node B.
呼出し情報テーブル10における2つの記述。Two descriptions in the call information table 10.
rproc O: proc I Jおよびrproc
1 : proc OJに従って、呼出し構造グラフ
11において、procoとproc 1との間にルー
プ構造が形成される。一方。rproc O: proc I J and rproc
1: A loop structure is formed between proco and proc 1 in the call structure graph 11 according to proc OJ. on the other hand.
proc 2については、proc2がproc Oま
たはproc 1を呼出していないので、ループ構造は
形成されない。For proc 2, no loop structure is formed because proc 2 does not call proc O or proc 1.
認識部6は、適当な内部表現の形で入力された呼出し構
造グラフ11を基にして、非再帰約手続きりスト12を
作成する。The recognition unit 6 creates a non-recursive reduction procedure list 12 based on the call structure graph 11 input in the form of an appropriate internal representation.
認識部6における非再帰的手続きの認識は、以下のよう
に行なわれる。Recognition of non-recursive procedures in the recognition unit 6 is performed as follows.
(i)呼出し構造グラフ11中に存在するループ構造(
強連結域、 5CR)を認識する(再帰的手続きである
と認識する)。(i) A loop structure existing in the call structure graph 11 (
strongly connected region (5CR) (recognizes it as a recursive procedure).
(ii)どのループ構造にも含まれない点に対応する手
続きを、非再帰的手続きであると認識する。(ii) A procedure corresponding to a point not included in any loop structure is recognized as a non-recursive procedure.
呼出し構造グラフ11においてループ構造を形成しない
点に対応する手続きproc 2が非再帰的手続きであ
ることを、認識部6が認識する。そして。The recognition unit 6 recognizes that the procedure proc 2 corresponding to the point in the call structure graph 11 that does not form a loop structure is a non-recursive procedure. and.
この手続きproc 2の手続き名を非再帰的手続きリ
ストに登録する(出力する)。The procedure name of this procedure proc 2 is registered (output) in the non-recursive procedure list.
翻訳部7において5人力されたソースプログラム8につ
いて、同様に入力された非再帰的手続きリス目2を参照
しつつ、翻訳処理が行なわれる。Translation processing is performed on the source program 8 written by five people in the translation section 7 while referring to the non-recursive procedure list 2 input in the same manner.
ソースプログラム8中の手続きproc Oおよびpr
oc 1について、非再帰的手続きりスト12にその手
続き名が存在しないことを知った翻訳部7は。Procedure proc O and pr in source program 8
Regarding oc 1, the translation unit 7 learns that the procedure name does not exist in the non-recursive procedure list 12.
これらを再帰的手続きと見なす。そして、前述した如き
、再帰的手続きの実行に適した翻訳処理(オブジェクト
コードの生成)を行う。一方、ソースプログラム8中の
手続きproc 2については。Consider these as recursive procedures. Then, as described above, translation processing (object code generation) suitable for executing the recursive procedure is performed. On the other hand, regarding procedure proc 2 in source program 8.
非再帰的手続きりスト12中にその手続き名が存在する
ので、翻訳部7はこれを非再帰的手続きと見なす。そし
て、前述の如く、スタック上での静的な領域割当てを行
うと共に、これに対応した翻訳処理(オブジェクトコー
ドの生成)を行う。Since the procedure name exists in the non-recursive procedure list 12, the translation unit 7 regards this as a non-recursive procedure. Then, as described above, static area allocation on the stack is performed, and corresponding translation processing (object code generation) is performed.
以上により&I集されたオブジェクトモジュールは、非
再帰的手続きについて最適化処理を施したものとされる
。The object modules collected as described above are considered to have been subjected to optimization processing for non-recursive procedures.
以上説明したように1本発明によれば、再帰的手続き呼
出しを許すプログラム言語で記述されたプログラムの翻
訳処理において、非再帰的手続きに対しては、これを翻
訳時に認識し、最適化処理をすることができ、再帰呼出
しの処理のオーバーヘッドを改善し、プログラム全体の
実行時間を短縮することができる。As explained above, according to the present invention, in the translation process of a program written in a programming language that allows recursive procedure calls, non-recursive procedures are recognized at the time of translation and optimization processing is performed. This can improve the processing overhead of recursive calls and shorten the overall program execution time.
第1図は本発明の原理構成図。
第2図は一実施例説明図。
Iは処理装置、2は翻訳処理部、3は翻訳補助部、4は
仮翻訳部、5はグラフ作成部、6は認識部、7は翻訳部
、8はソースプログラム99はオブジェクトモジュール
、10は呼出しfi lテーブル。
11は呼出し構造グラフ、12は非再帰的手続きリスト
。FIG. 1 is a diagram showing the principle configuration of the present invention. FIG. 2 is an explanatory diagram of one embodiment. I is a processing device, 2 is a translation processing unit, 3 is a translation assisting unit, 4 is a temporary translation unit, 5 is a graph creation unit, 6 is a recognition unit, 7 is a translation unit, 8 is a source program 99 is an object module, 10 is a Call file table. 11 is a call structure graph, and 12 is a non-recursive procedure list.
Claims (1)
記述されたソースプログラム(8)を翻訳処理する翻訳
部(7)を有するプログラム翻訳処理方式において、 ソースプログラム(8)中の各手続きが呼出している手
続き名を抽出する処理を行う仮翻訳部(4)と、 前記仮翻訳部(4)の処理結果に基づいて、所定のルー
ルに従って、呼出し構造グラフを作成するグラフ作成部
(5)と。 前記呼出し構造グラフに基づいて、非再帰的な手続きを
認識する認識部(6)とを備え、 前記翻訳部(7)における前記ソースプログラム(8)
の翻訳処理の際に、前記認識部(6)の認識結果を参照
することによって、前記ソースプログラム(8)の中の
非再帰的な手続きについて最適化された処理を行うよう
にした ことを特徴とするプログラム翻訳処理方式。[Claims] In a program translation processing method having a translation unit (7) that translates a source program (8) written in a procedural programming language that allows recursive procedure calls, a temporary translation unit (4) that performs processing to extract the procedure name called by each procedure; and a graph creation unit that creates a call structure graph according to predetermined rules based on the processing results of the temporary translation unit (4). (5) and. a recognition unit (6) that recognizes a non-recursive procedure based on the call structure graph, the source program (8) in the translation unit (7);
When performing the translation process, by referring to the recognition result of the recognition unit (6), the non-recursive procedures in the source program (8) are optimized. A program translation processing method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP62295876A JPH01136239A (en) | 1987-11-24 | 1987-11-24 | Program translation processing system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP62295876A JPH01136239A (en) | 1987-11-24 | 1987-11-24 | Program translation processing system |
Publications (1)
Publication Number | Publication Date |
---|---|
JPH01136239A true JPH01136239A (en) | 1989-05-29 |
Family
ID=17826322
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP62295876A Pending JPH01136239A (en) | 1987-11-24 | 1987-11-24 | Program translation processing system |
Country Status (1)
Country | Link |
---|---|
JP (1) | JPH01136239A (en) |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS62205434A (en) * | 1986-03-05 | 1987-09-10 | Fujitsu Ltd | Compiling processing system for program capable of recursive call |
-
1987
- 1987-11-24 JP JP62295876A patent/JPH01136239A/en active Pending
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS62205434A (en) * | 1986-03-05 | 1987-09-10 | Fujitsu Ltd | Compiling processing system for program capable of recursive call |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JPH01136239A (en) | Program translation processing system | |
CN114444032A (en) | Method and device for self-defining rule confusion code | |
JPH03240837A (en) | Debug information generating device | |
JPH0414144A (en) | Compiling processing method | |
JPH02163831A (en) | Object program reduction system | |
JPH0695890A (en) | Name replacement system in compiler | |
JPS6365530A (en) | Code optimizing system | |
JPH0358232A (en) | Preprocessor calling system | |
JPS61169936A (en) | Automatic generation system of job control language | |
JP2539070B2 (en) | Compiler processor | |
JPH02205930A (en) | Interface check processing method | |
JPH02282830A (en) | Compiling process system | |
JPH02130637A (en) | Source code translating system | |
JPH01269133A (en) | Translating system for data base operation instruction | |
JPH0358136A (en) | Compiler operation system in machine different in character code system | |
JPH0385639A (en) | Program language translator | |
JPH0417028A (en) | System for translating and editing program language | |
JPH0342727A (en) | System for generating name by pre-compiler | |
JPH02120935A (en) | Program translation converting system | |
JPS58166455A (en) | Relational type data base system | |
JPH0250730A (en) | Language converting system based upon common machine word | |
JPH01128136A (en) | Compiling process system | |
JPH0340033A (en) | Recognizing/processing system for code system of call origin | |
JPS62264333A (en) | Processing method for optimization of program | |
JPH0279127A (en) | Fortran compile processing system |