JPH0728691A - Garbage collection efficiency increasing method - Google Patents

Garbage collection efficiency increasing method

Info

Publication number
JPH0728691A
JPH0728691A JP16944993A JP16944993A JPH0728691A JP H0728691 A JPH0728691 A JP H0728691A JP 16944993 A JP16944993 A JP 16944993A JP 16944993 A JP16944993 A JP 16944993A JP H0728691 A JPH0728691 A JP H0728691A
Authority
JP
Japan
Prior art keywords
control flow
garbage collection
procedure
program
memory
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
JP16944993A
Other languages
Japanese (ja)
Inventor
Kazuo Otake
和雄 大竹
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.)
NEC Corp
Original Assignee
NEC 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 NEC Corp filed Critical NEC Corp
Priority to JP16944993A priority Critical patent/JPH0728691A/en
Publication of JPH0728691A publication Critical patent/JPH0728691A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To improve the execution efficiency of a program by recovering many memory areas without making garbage collection trace reference which is not used afterward when garbage collection is started. CONSTITUTION:A control flow analytic procedure 1 statically analyzes the control flow of a program before execution and generates a control flow graph 11. A memory allocation analytic procedure 2 analyzes memory arrangement at every node, and generates a control flow graph 12 to which the memory allocation is added. A reference analytic procedure 3 finds reference which is alive at the entrances of respective nodes and not alive at the exits and generates a control flow graph 13 which has life/death kinds added to reference in the memory arrangement. A mark insertion procedure 4 gives marks in the program so that the garbage collection do not trace the reference back.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は、ガーベージコレクショ
ン効率化方法に関し、特に、メモリを要求に応じて割当
てることを必要とする記号処理言語およびオブジェクト
指向言語などの言語処理系により作成したプログラムの
実行時に実施されるガーベージコレクションを効率的に
行うためのガーベージコレクション効率化方法に関す
る。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a method for improving the efficiency of garbage collection, and more particularly to executing a program created by a language processing system such as a symbol processing language or an object-oriented language which requires allocating memory on demand. The present invention relates to a garbage collection efficiency method for efficiently performing garbage collection sometimes performed.

【0002】[0002]

【従来の技術】従来のガーベージコレクション効率化方
法は、参照をたどりメモリ領域の単位であるセルの各々
にたどりつくことができるかどうかを調べて、たどりつ
くことができるセルであるときには、そのセルが使用中
であり回収することができないと判断していた。
2. Description of the Related Art A conventional method for improving the efficiency of garbage collection checks whether a reference can be reached to each cell which is a unit of a memory area, and when the cell can be reached, the cell is used. It was decided that it could not be recovered because it was inside.

【0003】しかしながら、それらの参照は、必ずしも
それ以後にも使われるとは限らず、使われない参照によ
ってのみ指されているセルは、それ以後に使用されない
こととなる。すなわち、従来のガーベージコレクション
効率化方法では、それ以後に使用されない参照を判断す
ることは、プログラムの動作情報を持っていないので原
理的に不可能であり、実際には回収可能であるセルの回
収がそのような使われない参照によって阻害されてい
た。
However, those references are not always used after that, and cells that are only pointed to by references that are not used will not be used thereafter. That is, in the conventional garbage collection efficiency method, it is theoretically impossible to judge a reference that will not be used after that, because it does not have the operation information of the program, and it is actually possible to collect the cells. Was hampered by such unused references.

【0004】また、従来のガーベージコレクション効率
化方法は、手続をパラメータとして他の手続に渡すこと
ができるとともにメモリ領域を実行時に割当ててその内
容を変更することができる言語により作成したプログラ
ムに対しては、プログラムの静的解析に必須のコントロ
ールフロー解析を実施するための有効な方法を持ってい
なかった。
Further, the conventional method for improving the efficiency of garbage collection is applied to a program created in a language in which a procedure can be passed as a parameter to another procedure and a memory area can be allocated at the time of execution to change the content. Did not have an effective way to perform the control flow analysis required for static analysis of programs.

【0005】[0005]

【発明が解決しようとする課題】上述の従来のガーベー
ジコレクション効率化方法は、ガーベージコレクション
を起動したときに、実際にはそれ以後に使われない参照
をたどってしまうことになるために、一回のガーベージ
コレクションを行う実行時間が余計にかかる上に回収で
きるセルも少なくなるために、ガーベージコレクション
が、プログラムの実行中により多く起動されることとな
り、全体のプログラムの実行効率を落してしまうという
欠点を有している。
The conventional method for improving the efficiency of the garbage collection described above has a problem that when the garbage collection is started, the reference which is not actually used thereafter is traced. Since it takes an extra time to perform the garbage collection and the number of cells that can be collected is reduced, the garbage collection is activated more during the execution of the program, which reduces the execution efficiency of the entire program. have.

【0006】さらに、従来のガーベージコレクション効
率化方法は、セルの回収効率が低いために、プログラム
の実行に際して必要となる総メモリの最大値が大きくな
ってしまい、特に、仮想記憶を持つ実行形態では、より
多くの仮想記憶単位が必要となって主記憶と補助記憶と
の間で交換が生ずる可能性が増えるので、プログラムの
実行効率の低下が大きくなるという欠点を有している。
Further, in the conventional garbage collection efficiency improving method, since the cell recovery efficiency is low, the maximum value of the total memory required for executing the program becomes large, and especially in the execution mode having virtual memory. However, there is a drawback in that the execution efficiency of the program is greatly reduced because more virtual memory units are required and the possibility of exchanging between the main memory and the auxiliary memory increases.

【0007】[0007]

【課題を解決するための手段】第1の発明のガーベージ
コレクション効率化方法は、対象のプログラムの実行時
に効率的ガーベージコレクションを行うためのガーベー
ジコレクション効率化方法において、(A)実行前のプ
ログラムに対するコントロールフローを静的に解析し
て、処理単位をノードとして、コントロールフローをア
ークとする木構造のコントロールフローグラフを作成す
るコントロールフロー解析手順と、(B)前記コントロ
ールフローグラフの各ノードごとにメモリ配置の解析を
行うことにより、各ノードのメモリ配置を付加するメモ
リ配置解析手順と、(C)メモリ配置を付加した前記コ
ントロールフローグラフの各ノードごとに、入口で生き
ていて出口で生きていないために後に使われない参照を
見つける参照解析手順と、(D)前記参照解析手順で見
つけた使われない参照をガーベージコレクションでたど
ることのないように、前記プログラム内の該参照にマー
クづけをするマーク挿入手順と、を含むことにより、ガ
ーベージコレクションが起動されたときには、前記マー
ク挿入手順でマーク付けをした前記プログラム内の該参
照をたどらないようにすることを含んでいる。
According to a first aspect of the present invention, there is provided a garbage collection efficiency improving method for efficiently performing garbage collection at the time of executing a target program. A control flow analysis procedure for statically analyzing the control flow and creating a tree-structured control flow graph with the processing unit as a node and the control flow as an arc, and (B) a memory for each node of the control flow graph. By performing the layout analysis, the memory layout analysis procedure for adding the memory layout of each node, and (C) each node of the control flow graph with the memory layout added is alive at the entrance but not alive at the exit. Reference analysis hand to find references that are not used later for And (D) a mark insertion procedure for marking the unused reference found in the reference analysis procedure so that the reference is not traced by garbage collection. When invoked, it includes avoiding following the reference in the program marked in the mark insertion procedure.

【0008】また、第2の発明のガーベージコレクショ
ン効率化方法は、対象のプログラムの実行時に効率的ガ
ーベージコレクションを行うためのガーベージコレクシ
ョン効率化方法において、(A)実行前のプログラムに
対するコントロールフローを静的に解析して、処理単位
をノードとして、コントロールフローをアークとする木
構造のコントロールフローグラフを作成するコントロー
ルフロー解析手順と、(B)前記コントロールフローグ
ラフの各ノードごとにメモリ配置の解析を行うことによ
り、各ノードのメモリ配置を付加するメモリ配置解析手
順と、(C)メモリ配置を付加した前記コントロールフ
ローグラフの各ノードごとに、入口で生きていて出口で
生きていないために後に使われない参照を見つける参照
解析手順と、(D)前記参照解析手順で見つけた使われ
ない参照をガーベージコレクションでたどることのない
ように、前記プログラム内の該参照に何も指していない
ことを表す空ポインタを代入する空ポインタ代入手順
と、を含むことにより、ガーベージコレクションが起動
されたときには、前記空ポインタ代入手順で空ポインタ
を代入された前記プログラム内の該参照をたどらないこ
とを含んでいる。
The garbage collection efficiency improving method of the second aspect of the invention is a garbage collection efficiency improving method for performing efficient garbage collection at the time of execution of a target program. Control flow analysis procedure for creating a tree-structured control flow graph having a control flow as an arc and a processing unit as a node, and (B) analysis of memory allocation for each node of the control flow graph. By doing so, the memory layout analysis procedure for adding the memory layout of each node and (C) each node of the control flow graph with the memory layout added are used later because they are alive at the entrance and not at the exit. A reference analysis procedure for finding unresolved references, (D A null pointer assignment procedure for assigning a null pointer indicating that nothing is pointing to the reference in the program so that the unused reference found in the reference analysis procedure is not traced by garbage collection. This includes not following the reference in the program that has been assigned a null pointer in the null pointer assignment procedure when garbage collection is activated.

【0009】さらに、第3の発明のガーベージコレクシ
ョン効率化方法は、第1,2の発明のガーベージコレク
ション効率化方法において、第1,2の発明のコントロ
ールフロー解析手順が、対象のプログラムの静的な解析
を行うために、ガーベージコレクションで回収する各々
のメモリ領域を操作する基本機能である、前記メモリ領
域を新しく割当てる操作と、前記メモリ領域の値を読出
す操作と、前記メモリ領域の値を変更する操作とを拡張
したラムダ表現を、解析用表現形式として使用すること
を含んでいる。
Furthermore, the garbage collection efficiency improving method of the third invention is the garbage collection efficiency improving method of the first and second inventions, wherein the control flow analysis procedure of the first and second inventions is a static program of the target program. In order to perform a detailed analysis, the basic function of operating each memory area to be collected by garbage collection, the operation of newly allocating the memory area, the operation of reading the value of the memory area, and the value of the memory area It includes using the lambda expression, which is an extension of the modifying operation, as a parsing expression format.

【0010】[0010]

【実施例】次に、本発明の実施例について、図面を参照
して説明する。図1は、本発明のガーベージコレクショ
ン効率化方法の第1の実施例を示す流れ図である。第1
の実施例のガーベージコレクション効率化方法は、図1
に示しているように、まず、コントロールフロー解析手
順1では、実行前のプログラムに対して、そのコントロ
ールフローを静的に解析し、処理単位をノードとしてコ
ントロールフローをアークとする木構造のコントロール
フローグラフ11を作成している。
Embodiments of the present invention will now be described with reference to the drawings. FIG. 1 is a flow chart showing a first embodiment of the garbage collection efficiency improving method of the present invention. First
The method for improving the efficiency of garbage collection in the embodiment of FIG.
As shown in FIG. 1, first, in the control flow analysis procedure 1, a control flow of a pre-execution program is statically analyzed, and a control flow of a tree structure in which a processing unit is a node and the control flow is an arc. Graph 11 is created.

【0011】そして、メモリ配置解析手順2で、コント
ロールフローグラフ11の各ノードごとに、メモリ配置
の解析を行って、メモリ配置を付加したコントロールフ
ローグラフ12を作成している。そこで、参照解析手順
3は、メモリ配置を付加したコントロールフローグラフ
12の各ノードごとに、入口で生きていて出口で生きて
いない参照を見つけて、メモリ配置中の参照に生き死に
の種別を付加したコントロールフローグラフ13を作成
している。
Then, in the memory layout analysis procedure 2, the memory layout is analyzed for each node of the control flow graph 11 to create the control flow graph 12 to which the memory layout is added. Therefore, the reference analysis procedure 3 finds a reference that is alive at the entrance and not alive at the exit for each node of the control flow graph 12 to which the memory allocation is added, and adds the type of life or death to the reference in the memory allocation. The created control flow graph 13 is created.

【0012】また、マーク挿入手順4は、そのメモリ配
置中の参照に生き死にの種別を付加したコントロールフ
ローグラフ13に従って、ガーベージコレクションがそ
れらの参照をたどらないように、対象のプログラム内に
マークづけをしている。この中で、特に、コントロール
フロー解析手順1とメモリ配置解析手順2とに対しては
様々な実施方法が考えられる。以下に、上記のそれぞれ
の手順についての実施方法を説明する。
Further, the mark insertion procedure 4 marks in the target program according to the control flow graph 13 in which the reference in the memory allocation is added with the type of life or death so that the garbage collection does not follow these references. Are doing Of these, various implementation methods are conceivable particularly for the control flow analysis procedure 1 and the memory allocation analysis procedure 2. The implementation method for each of the above procedures will be described below.

【0013】まず、コントロールフロー解析手順1で作
成されるコントロールフローグラフ11は、有向グラフ
であって、処理単位であるノードaからノードbへアー
クが存在するときには、ノードbの処理が、ノードaの
処理に続いて行われる候補であることを表している。ま
た、各ノードの処理は、その処理の途中から飛び出した
り、その処理の途中に飛び込んで来たりはしないという
条件を満たせば、どのように定義しても良いこととして
いる。
First, the control flow graph 11 created in the control flow analysis procedure 1 is a directed graph, and when an arc exists from the node a as a processing unit to the node b, the processing of the node b is performed by the node a. This indicates that the candidate is a candidate that is performed after the processing. Further, the process of each node may be defined in any way as long as the condition that it does not jump out from the middle of the process or jump into the middle of the process is satisfied.

【0014】なお、コントロールフロー解析は、手続の
実引数として手続を渡さず、手続へのポインタも持たな
いプログラムに対しては、簡単な作業である。しかし、
手続の実引数として手続を渡したり、手続へのポインタ
変数を持つプログラムに関しては、簡単ではないことと
なる。その理由は、そのような引数やポインタ変数の値
である手続を呼出すと、それにより実行される処理を決
定するためには、そのような引数や変数が値として持つ
可能性のあるすべての手続を求めなければならないから
である。
The control flow analysis is a simple operation for a program that does not pass a procedure as an actual argument of the procedure and does not have a pointer to the procedure. But,
It is not easy for a program to pass a procedure as an actual argument of a procedure, or for a program that has a pointer variable to the procedure. The reason is that when a procedure that is the value of such an argument or pointer variable is called, all the procedures that such argument or variable may have as a value in order to determine the processing to be performed by it. Because I have to ask.

【0015】例えば、代表的な言語であるLISP言語
により作成されたプログラムでは、ガーベージコレクシ
ョン機能を備えており、手続(LISP言語では関数と
呼んでいる)を引数として渡す記述を含むことが多い。
一般的に、ある変数の値となるすべての可能性を完全に
解析することは、計算不能な問題となってしまうので、
安全な近似解を求めることになる。この安全とは、最終
的に使用される参照を使用されないと誤って判定するこ
とがないことである。逆に、使用されない変数の値を使
用される可能性があると判断することはかまわないこと
である。
For example, a program created in the LISP language, which is a typical language, has a garbage collection function and often includes a description of passing a procedure (called a function in the LISP language) as an argument.
In general, a complete analysis of all possible values of a variable is an uncomputable problem, so
We will seek a safe approximate solution. This safety means that the reference that is finally used is not erroneously determined not to be used. Conversely, it is acceptable to determine the value of an unused variable as likely to be used.

【0016】このことは、コントロールフロー解析で
は、ある位置から続いて行われる可能性がある処理を多
めにとる解に相当する。なお、実際に行われる処理を落
すことがあると安全ではないこととなる。近似解には、
計算のしやすさと近似の精度とによって、多くの実施方
法が有り得ることとなる。最も簡単な近似は、変数の値
である手続を呼出していたときには、そこからすべての
手続を呼出す可能性があるとする方法である。そのよう
な変数の値である手続呼出しが、プログラムの中で限ら
れていれば、この方法も、有効な近似となり得る。この
方法の改良として、手続呼出しのパラメータの個数や型
情報などから、呼ばれる可能性がある手続を絞り込む方
法が考えられる。
In the control flow analysis, this corresponds to a solution that takes a lot of processing that may be performed subsequently from a certain position. It should be noted that it is not safe if the actual processing is dropped. The approximate solution is
There are many possible implementations, depending on the ease of calculation and the accuracy of the approximation. The simplest approximation is to call all procedures from a procedure that is the value of a variable. If the procedure call that is the value of such a variable is limited in the program, this method can also be a valid approximation. As an improvement of this method, a method of narrowing down the procedures that may be called can be considered based on the number of parameters and the type information of the procedure call.

【0017】安全なコントロールフローグラフ11を求
めたら、次に、メモリ配置解析手順2により、コントロ
ールフローグラフ11の各ノードごとに、メモリ配置の
解析を行う。これにも安全な解析として幾つかの実施方
法が考えられる。図2は、対象のプログラム内の参照と
メモリのセルとの一例を示す図である。図2に示すよう
に、プログラム内の参照21がメモリのセル24を指し
ており、そのセル24にあるプログラム内の参照22,
23がセル25,26を指す場合には、本実施例のメモ
リ配置解析手順2は、マークを付ける参照の候補とし
て、参照21を選び、参照22,23を見つけることを
考えない。
After obtaining the safe control flow graph 11, the memory layout analysis procedure 2 analyzes the memory layout for each node of the control flow graph 11. There are several possible methods for implementing this as a safe analysis. FIG. 2 is a diagram showing an example of a reference in a target program and a memory cell. As shown in FIG. 2, the reference 21 in the program points to a cell 24 of the memory, and the reference 22 in the program in the cell 24,
When 23 indicates the cells 25 and 26, the memory layout analysis procedure 2 of the present embodiment does not consider selecting the reference 21 and finding the references 22 and 23 as candidates for the reference to be marked.

【0018】このように制限する理由は、一つには処理
が容易であることと、もう一つには実行時にマーク付け
を実行することは少ないながらもオーバヘッドになるの
で、あまり細かくマーク付けを行うとかえってプログラ
ム全体の実行時間を長くしてしまうことがあるからであ
る。このように限定することにより、最も簡単なメモリ
配置解析の実施方法としてある変数からたどることがで
きるすべてのセルをこの変数の値であるセルに代表させ
て圧縮してしまうことが考えられる。
The reason for limiting in this way is that processing is easy on the one hand, and marking is executed at the time of execution at a small amount, but it is an overhead. This is because the execution time of the entire program may be lengthened if this is done. By limiting in this way, it is conceivable that all the cells that can be traced from a certain variable are compressed by being represented by the cell that is the value of this variable, as the simplest method for implementing memory allocation analysis.

【0019】図3は、第1の実施例におけるメモリ構成
の圧縮方法の一例を示す図である。実際のメモリ配置
が、図3(a)に示すように、セル31,32,33を
有している場合に、図3(b)に示すように、変数から
一回の参照だけによりたどれるメモリのセル31,32
のみになるように、セル33をセル32により代表させ
ている。このような方法のより精度の高い解析方法に関
する参考文献として、Horwitz,S.,et al. Dependence A
nalysis for Pointer Variables. Proceedings of theS
IGPLAN '89 pp28-40,1989がある。
FIG. 3 is a diagram showing an example of a compression method of the memory configuration in the first embodiment. When the actual memory arrangement has cells 31, 32, and 33 as shown in FIG. 3A, as shown in FIG. 3B, a memory that can be traced from a variable by only one reference. Cells 31, 32
The cell 33 is represented by the cell 32 so that only the cell 33 is shown. As a reference for a more accurate analysis method of such a method, Horwitz, S., et al. Dependence A
nalysis for Pointer Variables. Proceedings of theS
There is IGPLAN '89 pp28-40,1989.

【0020】このようにして安全なコントロール解析と
安全なメモリ配置とを行った後で、参照解析手順3は、
生きている変数の解析としては、良く知られている方程
式の不動点を求める方法を用いて解析する。この具体的
な方法の参考文献としては、Aho,and Ullman. Principl
es of Compiler design. Addison-Wesley(1977) 邦訳コ
ンパイラI II,原田訳 サイエンス社がある。
After performing the safe control analysis and the safe memory allocation in this way, the reference analysis procedure 3
As a live variable analysis, a well-known method for finding a fixed point of an equation is used. For references on this specific method, see Aho, and Ullman. Principl.
es of Compiler design. Addison-Wesley (1977) Japanese translation compiler I II, Harada translation science company.

【0021】そして、各ノードごとに、入口で生きてい
て出口で生きていない参照を見つけて、最後に、マーク
挿入手順4は、プログラム内で、参照が生きている状態
から生きていない状態になる場所の後に、ガーベージコ
レクションがそれらの参照をたどらないように、タグを
付けてマークづけをしている。なお、このマークづけに
代る方法としては、何も指してはいないことを表す空ポ
インタを代入する方法がある。この方法は、ガーベージ
コレクションの動作に全く変更を加えることなく実施す
ることができるという利点がある。
Then, for each node, a reference that is alive at the entrance and not alive at the exit is found, and finally, the mark insertion procedure 4 changes from the state where the reference is alive to the state where the reference is not alive in the program. After that, we mark it with tags so that garbage collection does not follow those references. As an alternative to this marking, there is a method of substituting an empty pointer indicating that nothing is being pointed to. This method has the advantage that it can be implemented without any changes to the garbage collection behavior.

【0022】次に、LISP系の言語に対して有効なよ
り精度の高いコントロールフローの近似を求める方法を
用いる第2の実施例について説明する。変数への代入を
持っていないLISP系言語のコントロールフロー解析
方法の参考文献としては、Shivers,O. The semantics o
f scheme control-flow analysis. the first ACM SIG
PLAN and IFIP Symposium on Partial Evaluation andS
emantics-Based Program Manipulation,June 1991があ
るが、この第2の実施例は、これに代入を扱えるよう
に、拡張を加えたものである。
Next, a second embodiment using a method of obtaining a more accurate control flow approximation effective for a LISP language will be described. As a reference for control flow analysis methods for LISP languages that do not have substitutions for variables, see Shivers, O. The semantics o.
f scheme control-flow analysis.the first ACM SIG
PLAN and IFIP Symposium on Partial Evaluation andS
There is emantics-Based Program Manipulation, June 1991, but this second embodiment is an extension of this so as to handle substitution.

【0023】まず、プログラム中の参照であるコールc
は、コントロールフロー解析の内部表現として、次の6
つの何れかの形式をとる。 (f v12 ……vn ) (if v f12 ) (set m v f) (val m f) (new v f) (rec x v c)
First, the call c which is a reference in the program
Is the internal representation of the control flow analysis.
One of the two forms. (F v 1 v 2 ... V n ) (if v f 1 f 2 ) (set m v f) (val m f) (new v f) (rec x v c)

【0024】ここで、mはメモリのセルかセルを値とす
る変数かであって、vはラムダ式か数値などの基本デー
タかメモリのセルかこれらを値とする変数かであって、
fはラムダ式か適当なプリミティブ関数かこれらを値と
する変数かである。そして、プリミティブ関数の一例と
して、ここでは加算だけを行う+を用いる。
Here, m is a memory cell or a variable having a cell as a value, and v is basic data such as a lambda expression or a numerical value, a memory cell or a variable having these as values,
f is a lambda expression, an appropriate primitive function, or a variable whose value is these. Then, as an example of the primitive function, + that performs only addition is used here.

【0025】また、ラムダ式は、次の形式を持ってい
る。 λx12 ……xn.c ここで、コールcは、上記の6つの形式の何れかの一つ
であり、メモリのセルは、ラベルとその値とのペアであ
る。ここでは、場合分けを減らして効率化をはかるため
に、CPS(ContinuationPassing Style)ラムダ形式
を用いている。CPSラムダ形式は、すべての関数の呼
出しがリターンしないで計算が進んでいく形式であっ
て、LISP系言語の内部形式として用いられる場合も
ある。
The lambda expression has the following form. λx 1 x 2 ...... x n. c , where the call c is one of the six types of the above, cells of the memory is the pair with the label and its value. Here, a CPS (Continuation Passing Style) lambda format is used in order to reduce cases and improve efficiency. The CPS lambda format is a format in which calculation proceeds without returning all function calls, and may be used as an internal format of LISP languages.

【0026】このような記述の参考文献としては、Kran
z,D. et al. ORBIT: An optimizingcompiler for Schem
e. SIGPLAN Notices 21(7), pp 219-223. Association
ofComputing Machinery, July 1986がある。なお、この
文献には、LISP系言語のプログラムをCPSラムダ
形式に変換する方法についても記述している。
As a reference for such a description, Kran
z, D. et al. ORBIT: An optimizing compiler for Schem
e. SIGPLAN Notices 21 (7), pp 219-223. Association
There is of Computing Machinery, July 1986. Note that this document also describes a method of converting a program of a LISP system language into a CPS lambda format.

【0027】このような内部形式に変換するコントロー
ルフローの問題の核心は、 (f v12 ……vn ) のコールにおけるfが変数であったときに、このコール
が実行される時点でfの値として可能性のあるすべての
プリミティブ関数やラムダ式の集合を求めることに帰着
する。このような集合を完全に求めることは、計算不能
な問題となるので安全な解を求めている。すなわち、実
際にfの値となり得る値は、必ず、集合に含まれるよう
にするが、実際には、値とはならない値が集合に含まれ
ていることがある。
The core of the control flow problem of converting to such an internal format is at the time when this call is executed when f is a variable in the call of (f v 1 v 2 ... V n ). Reduce to finding the set of all possible primitive functions and lambda expressions as the value of f. Since finding such a set completely becomes a problem that cannot be calculated, a safe solution is sought. That is, the value that can actually be the value of f is always included in the set, but in reality, a value that is not a value may be included in the set.

【0028】そこで、コントロールフロー解析は、以下
の手順で行われる。この解析の中心は、プログラム中の
すべての変数とメモリセルの値とのすべての可能性を求
めることである。これらの値は、数値などの基本データ
であるかプリミティブ関数かラムダ式かメモリのセルか
の何れかである。それが基本データであった場合は、例
えば、それが1であるか2であるかは結果に影響しない
ので、1も2もすべての基本データ型の値は、単一の○
で代表して表現する。
Therefore, the control flow analysis is performed in the following procedure. The heart of this analysis is to find all the possibilities for all variables and memory cell values in the program. These values are either basic data such as numbers, primitive functions, lambda expressions or memory cells. If it is elementary data, for example, whether it is 1 or 2 does not affect the result, so both 1 and 2 values of all elementary data types have a single
Will be represented on behalf of.

【0029】図4は、第2の実施例のコントロールフロ
ーグラフの一例を示した図である。図4に示すように、
内部形式に変換されたプログラムは、木構造と見なすこ
とができる。木の節点であるノードは、コールc1,c
2,c3か、ラムダ式r1,r2,r3かに対応してい
る。そこで、この木からすべてのnewを呼出して、ノ
ードの(new v f)に対して異なるメモリセルの
ラベルmを割当てる。なお、以下の説明は、簡単のため
に異なる変数が同じ名前を持つことがない場合について
述べている。
FIG. 4 is a diagram showing an example of the control flow graph of the second embodiment. As shown in FIG.
The program converted into the internal format can be regarded as a tree structure. The nodes that are the nodes of the tree are calls c1 and c
2, c3 or lambda expressions r1, r2, r3. Therefore, all the news are called from this tree, and the label m of a different memory cell is assigned to the node (new v f). Note that the following description describes the case where different variables do not have the same name for simplicity.

【0030】まず、すべての変数を示す変数テーブル4
1を作り、その中の各々の値の初期値として空集合を割
当てる。そして、すべてのメモリセルに対するラベルを
示すセルテーブル42を作って、その中の各々の値の初
期値として空集合を割当てている。図5は、第2の実施
例の変数テーブル41に関する内容変化の第1の例を示
す図である。また、図6は、第2の実施例のセルテーブ
ル42に関する内容変化の第1の例を示す図である。一
方、図7は、セルテーブル42に関する内容変化の第2
の例を示す図である。さらに、図8は、変数テーブル4
1に関する内容変化の第2の例を示す図である。
First, a variable table 4 showing all variables
Create 1 and assign an empty set as the initial value for each value in it. Then, a cell table 42 showing labels for all memory cells is created, and an empty set is assigned as an initial value of each value in the cell table 42. FIG. 5 is a diagram showing a first example of content changes regarding the variable table 41 of the second embodiment. In addition, FIG. 6 is a diagram showing a first example of content changes regarding the cell table 42 of the second embodiment. On the other hand, FIG.
It is a figure which shows the example of. Further, FIG. 8 shows the variable table 4
It is a figure which shows the 2nd example of the content change regarding 1).

【0031】次に、図4の木をトップダウンにたどりな
がら、以下の動作を行って、すべてのDefとValと
に変化がなくなるまで繰返す。 (1)節点が(f v12 ……vn )というコール
のときには、図5に示すように、Def(f)に含まれ
るラムダ式(λx12 ……xn.c)に対して、変数テ
ーブル41のx1 の値の集合にDef(v1 )を追加
し、x2 の値の集合にDef(v2 )を追加し、以下同
様にxn の値の集合にDef(vn )を追加する。な
お、vが変数以外の場合に、Def(v)は、{v}を
表している。
Next, while following the tree of FIG. 4 from top to bottom, the following operation is performed and repeated until all Def and Val are unchanged. (1) When the node is called (f v 1 v 2 ...... v n ), as shown in FIG. 5, the lambda expression (λx 1 x 2 ...... x n. C) included in Def (f) is used . On the other hand, Def (v 1 ) is added to the set of values of x 1 of the variable table 41, Def (v 2 ) is added to the set of values of x 2 , and Def is added to the set of values of x n. (V n ) is added. When v is other than a variable, Def (v) represents {v}.

【0032】(2)節点が(new v f)というコ
ールのときには、図6に示すように、このnewに割当
てられたメモリセルmに対して、Val(m)にDef
(v)を加える。ここで、Val(m)は、ラベルがm
のメモリセルの値の集合を表している。また、Def
(f)に含まれるすべてのラムダ式(λx.c)に対
し、変数テーブル41のxの値の集合にメモリセルmを
追加する。 (3)節点が(set m v f)というコールのと
きには、図7に示すように、Def(m)に含まれるす
べてのメモリセルnに対して、セルテーブル42のnの
値の集合にDef(v)を加える。
(2) When the node is called (new v f), as shown in FIG. 6, Def is set to Val (m) for the memory cell m assigned to this new.
Add (v). Here, the label of Val (m) is m
Represents a set of values of memory cells. Also, Def
A memory cell m is added to the set of values of x in the variable table 41 for all lambda expressions (λx.c) included in (f). (3) When the node is called (set m v f), as shown in FIG. 7, for all memory cells n included in Def (m), Def is set to the set of values of n in the cell table 42. Add (v).

【0033】(4)節点が(val m f)というコ
ールのときには、図8に示すように、集合Def(f)
に含まれているすべてのラムダ式(λx.c)に対し
て、変数テーブル41のxの値の集合にVal(m)を
追加する。 (5)節点が(rec x v c)というコールのと
きには、Def(x)にDef(v)を追加して、コー
ルcの形によって以上のどれかの動作を行う。
(4) When the node is called (val m f), as shown in FIG. 8, the set Def (f)
Val (m) is added to the set of values of x in the variable table 41 for all lambda expressions (λx.c) included in. (5) When the call has the node (rec x v c), Def (x) is added to Def (x) and any of the above operations is performed depending on the form of the call c.

【0034】(6)節点が(if v f12 )と
いうコールのときには、このノードの位置に(f1 ○)
と(f2 ○)という二つのコールが存在するものと見な
して、これらの両方の動作を行う。 (7)節点がラムダ式の場合には、何も行わない。上記
によって、DefもValも単調に増えて行くととも
に、集合に含まれる要素としては○かプログラムに存在
するラムダ式か最初に与えられたメモリセルかの何れか
なので、個数が有限であることから必ず上記の繰返しは
終了する。
(6) When the node is a call (if v f 1 f 2 ), (f 1 ○) is placed at the position of this node.
It is assumed that there are two calls, and (f 2 ○), and both of these operations are performed. (7) If the node is a lambda expression, do nothing. Due to the above, Def and Val monotonically increase, and the number of elements included in the set is either ◯, the lambda expression existing in the program, or the first given memory cell, so the number is finite. Be sure to finish the above repetition.

【0035】そして、コントロールフロー解析の結果
は、以下の通りである。 (1)(f v12 ……vn )からは、Def
(f)の中からどれかが実行される。 (2)(if v f12 )からは、Def(f
1 )かDef(f2 )かのどれかが実行される。 (3)(set m v f)からは、Def(f)の
どれかが実行される。
The results of the control flow analysis are as follows. (1) From (f v 1 v 2 ... V n ), Def
Any one of (f) is executed. (2) From (if v f 1 f 2 ), Def (f
Either 1 ) or Def (f 2 ) is executed. (3) From (set m v f), one of Def (f) is executed.

【0036】(4)(val m f)からは、Def
(f)のどれかが実行される。 (5)(new v f)からは、Def(f)のどれ
かが実行される。 (6)(+ v v f)からは、Def(f)のどれ
かが実行される。 (7)(rec x v c)からは、cが実行され
る。 (8)(λx12 ……xn.c)からは、cが実行され
る。
(4) From (val m f), Def
Any of (f) is executed. (5) One of Def (f) is executed from (new v f). (6) From (+ vvf), one of Def (f) is executed. (7) From (rec x v c), c is executed. (8) from (λx 1 x 2 ...... x n . C) is, c is executed.

【0037】[0037]

【発明の効果】以上説明したように、本発明のガーベー
ジコレクション効率化方法は、もはやたどることがなく
なった参照を指摘するので、ガーベージコレクション実
行時の負荷が僅かに増えるけれども、もはや使用される
可能性のない参照をたどることを減らすことができるの
で、一度のガーベージコレクションの実行でより多くの
メモリ領域を回収することができるようになるという効
果を有している。従って、本発明のガーベージコレクシ
ョン効率化方法は、実行時にガーベージコレクションを
起動する回数を減らしてプログラム全体の実行時間を短
かくするという効果を有している。
As described above, the method for improving the efficiency of garbage collection of the present invention points out references that are no longer traced, so that the load at the time of executing garbage collection is slightly increased, but it can be used any longer. Since it is possible to reduce the tracing of non-relevant references, it is possible to collect more memory area by executing garbage collection once. Therefore, the garbage collection efficiency improving method of the present invention has the effect of reducing the number of times garbage collection is started at the time of execution and shortening the execution time of the entire program.

【0038】さらに、本発明のガーベージコレクション
効率化方法は、必要とするメモリの最大値を小さくする
ので、特に仮想記憶方式の実行環境における実行時間の
短縮に有利であり、また、ガーベージコレクションに良
く使われているマークアンドスウィープ方式でもコピー
方式でも、参照をたどるメモリ領域の数が少ない方がガ
ーベージコレクションの実行時間も短かくなるので、こ
の点においても有利であるという効果を有している。
Furthermore, the method for improving the efficiency of garbage collection according to the present invention reduces the maximum value of the required memory, which is particularly advantageous for shortening the execution time in the execution environment of the virtual memory system, and is good for garbage collection. Regardless of the mark-and-sweep method or the copy method used, the smaller the number of memory areas that follow the reference, the shorter the execution time of garbage collection, which is also advantageous in this respect.

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

【図1】本発明のガーベージコレクション効率化方法に
関する第1の実施例を示す流れ図である。
FIG. 1 is a flow chart showing a first embodiment of a method for improving the efficiency of garbage collection of the present invention.

【図2】対象のプログラム内の参照とメモリのセルとの
一例を示す図である。
FIG. 2 is a diagram showing an example of a reference in a target program and a memory cell.

【図3】第1の実施例におけるメモリ構成の圧縮方法の
一例を示す図である。
FIG. 3 is a diagram showing an example of a compression method of a memory configuration in the first embodiment.

【図4】第2の実施例のコントロールフローグラフの一
例を示した図である。
FIG. 4 is a diagram showing an example of a control flow graph of the second embodiment.

【図5】第2の実施例の変数テーブル41の内容変化の
第1の例を示す図である。
FIG. 5 is a diagram showing a first example of a change in contents of a variable table 41 of the second embodiment.

【図6】第2の実施例のセルテーブル42の内容変化の
第1の例を示す図である。
FIG. 6 is a diagram showing a first example of changes in contents of the cell table 42 of the second embodiment.

【図7】セルテーブル42に関する内容変化の第2の例
を示す図である。
FIG. 7 is a diagram showing a second example of content changes regarding the cell table 42.

【図8】変数テーブル41に関する内容変化の第2の例
を示す図である。
FIG. 8 is a diagram showing a second example of content changes regarding the variable table 41.

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

1 コントロールフロー解析手順 2 メモリ配置解析手順 3 参照解析手順 4 マーク挿入手順 11 コントロールフローグラフ 12 メモリ配置を付加したコントロールフローグラ
フ 13 メモリ配置中の参照に生き死にの種別を付加し
たコントロールフローグラフ 21,22,23 参照 24,25,26,31,32,33 セル 41 変数テーブル 42 セルテーブル c1,c2,c3 コール r1,r2,r3 ラムダ式
1 Control Flow Analysis Procedure 2 Memory Allocation Analysis Procedure 3 Reference Analysis Procedure 4 Mark Insertion Procedure 11 Control Flow Graph 12 Control Flow Graph with Memory Allocation 13 Control Flow Graph with Reference to Life in Memory Allocation 21 22, 23 Reference 24, 25, 26, 31, 32, 33 Cell 41 Variable table 42 Cell table c1, c2, c3 Call r1, r2, r3 Lambda expression

Claims (3)

【特許請求の範囲】[Claims] 【請求項1】 対象のプログラムの実行時に効率的ガー
ベージコレクションを行うためのガーベージコレクショ
ン効率化方法において、(A)実行前のプログラムに対
するコントロールフローを静的に解析して、処理単位を
ノードとして、コントロールフローをアークとする木構
造のコントロールフローグラフを作成するコントロール
フロー解析手順と、(B)前記コントロールフローグラ
フの各ノードごとにメモリ配置の解析を行うことによ
り、各ノードのメモリ配置を付加するメモリ配置解析手
順と、(C)メモリ配置を付加した前記コントロールフ
ローグラフの各ノードごとに、入口で生きていて出口で
生きていないために後に使われない参照を見つける参照
解析手順と、(D)前記参照解析手順で見つけた使われ
ない参照をガーベージコレクションでたどることのない
ように、前記プログラム内の該参照にマークづけをする
マーク挿入手順と、を含むことにより、ガーベージコレ
クションが起動されたときには、前記マーク挿入手順で
マーク付けをした前記プログラム内の該参照をたどらな
いようにすることを特徴とするガーベージコレクション
効率化方法。
1. A garbage collection efficiency method for performing efficient garbage collection when a target program is executed, comprising: (A) statically analyzing a control flow of a program before execution, and setting a processing unit as a node. A control flow analysis procedure for creating a control flow graph having a tree structure with a control flow as an arc, and (B) analysis of memory allocation for each node of the control flow graph to add the memory allocation of each node. A memory allocation analysis procedure, and (C) a reference analysis procedure for finding a reference that is not used later because it is alive at the entrance and not at the exit for each node of the control flow graph with the memory allocation added, ) Garbage unused references found in the reference analysis procedure above By including a mark insertion procedure for marking the reference in the program so that it is not traced in the collection, and when garbage collection is activated, in the program marked by the mark insertion procedure. The method for improving the efficiency of garbage collection, characterized in that the reference is not traced.
【請求項2】 対象のプログラムの実行時に効率的ガー
ベージコレクションを行うためのガーベージコレクショ
ン効率化方法において、(A)実行前のプログラムに対
するコントロールフローを静的に解析して、処理単位を
ノードとして、コントロールフローをアークとする木構
造のコントロールフローグラフを作成するコントロール
フロー解析手順と、(B)前記コントロールフローグラ
フの各ノードごとにメモリ配置の解析を行うことによ
り、各ノードのメモリ配置を付加するメモリ配置解析手
順と、(C)メモリ配置を付加した前記コントロールフ
ローグラフの各ノードごとに、入口で生きていて出口で
生きていないために後に使われない参照を見つける参照
解析手順と、(D)前記参照解析手順で見つけた使われ
ない参照をガーベージコレクションでたどることのない
ように、前記プログラム内の該参照に何も指していない
ことを表す空ポインタを代入する空ポインタ代入手順
と、を含むことにより、ガーベージコレクションが起動
されたときには、前記空ポインタ代入手順で空ポインタ
を代入された前記プログラム内の該参照をたどらないこ
とを特徴とするガーベージコレクション効率化方法。
2. In a garbage collection efficiency method for performing efficient garbage collection at the time of execution of a target program, (A) statically analyzing a control flow for a program before execution, and processing units as nodes, A control flow analysis procedure for creating a control flow graph having a tree structure with a control flow as an arc, and (B) analysis of memory allocation for each node of the control flow graph to add the memory allocation of each node. A memory allocation analysis procedure, and (C) a reference analysis procedure for finding a reference that is not used later because it is alive at the entrance and not at the exit for each node of the control flow graph with the memory allocation added, ) Garbage unused references found in the reference analysis procedure above A null pointer assignment procedure that assigns an empty pointer indicating that the reference in the program is pointing to nothing so that it is not followed by a collection. A method for improving the efficiency of garbage collection, characterized in that the reference in the program assigned an empty pointer in the pointer assignment procedure is not followed.
【請求項3】 請求項1,2記載のコントロールフロー
解析手順は、対象のプログラムの静的な解析を行うため
に、ガーベージコレクションで回収する各々のメモリ領
域を操作する基本機能である、前記メモリ領域を新しく
割当てる操作と、前記メモリ領域の値を読出す操作と、
前記メモリ領域の値を変更する操作とを拡張したラムダ
表現を解析用表現形式として使用することを特徴とする
請求項1,2記載のガーベージコレクション効率化方
法。
3. The control flow analysis procedure according to claim 1, wherein the memory is a basic function of operating each memory area collected by garbage collection in order to perform static analysis of a target program. An operation of newly allocating an area, an operation of reading the value of the memory area,
3. The method of improving garbage collection efficiency according to claim 1, wherein a lambda expression that is an extension of the operation of changing the value of the memory area is used as an expression format for analysis.
JP16944993A 1993-07-09 1993-07-09 Garbage collection efficiency increasing method Pending JPH0728691A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP16944993A JPH0728691A (en) 1993-07-09 1993-07-09 Garbage collection efficiency increasing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP16944993A JPH0728691A (en) 1993-07-09 1993-07-09 Garbage collection efficiency increasing method

Publications (1)

Publication Number Publication Date
JPH0728691A true JPH0728691A (en) 1995-01-31

Family

ID=15886814

Family Applications (1)

Application Number Title Priority Date Filing Date
JP16944993A Pending JPH0728691A (en) 1993-07-09 1993-07-09 Garbage collection efficiency increasing method

Country Status (1)

Country Link
JP (1) JPH0728691A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005100402A (en) * 2003-09-23 2005-04-14 Microsoft Corp Area based memory management for object-oriented program

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005100402A (en) * 2003-09-23 2005-04-14 Microsoft Corp Area based memory management for object-oriented program

Similar Documents

Publication Publication Date Title
US5428793A (en) Method and apparatus for compiling computer programs with interproceduural register allocation
Chambers et al. Customization: Optimizing compiler technology for SELF, a dynamically-typed object-oriented programming language
US5828883A (en) Call path refinement profiles
US7571427B2 (en) Methods for comparing versions of a program
JP3311462B2 (en) Compile processing unit
US7784039B2 (en) Compiler, compilation method, and compilation program
US20030196196A1 (en) Program interpreter
US20070226720A1 (en) System and Method for Efficiently Passing Information Between Compiler and Post-Compile-Time Software
US20020056078A1 (en) Program optimization
JP2000132408A (en) Computer architecture emulation system
US6925639B2 (en) Method and system for register allocation
US8056061B2 (en) Data processing device and method using predesignated register
JP3437932B2 (en) Code generation method and apparatus for array range check, and versioning method and apparatus
US6735761B1 (en) Compile method frame detection method and device code discarding method and computer
US20030172194A1 (en) Global constant pool to allow deletion of constant pool entries
JP3318051B2 (en) Translation processing method
CN112416313A (en) Compiling method supporting large integer data type and operator
CN112527304A (en) Self-adaptive node fusion compiling optimization method based on heterogeneous platform
JPH0728691A (en) Garbage collection efficiency increasing method
JP3049814B2 (en) Microcomputer language processor
JP3045083B2 (en) Storage area management device
JPH02236638A (en) Register allocation managing system
Tick A Prolog Emulator
JPH1195995A (en) Device and method for analyzing data flow, and recording medium recording computer program therefor
JPH06282443A (en) Method and device for editing program

Legal Events

Date Code Title Description
A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 19960910