JPS59158460A - Structure memory recovery system - Google Patents

Structure memory recovery system

Info

Publication number
JPS59158460A
JPS59158460A JP3306683A JP3306683A JPS59158460A JP S59158460 A JPS59158460 A JP S59158460A JP 3306683 A JP3306683 A JP 3306683A JP 3306683 A JP3306683 A JP 3306683A JP S59158460 A JPS59158460 A JP S59158460A
Authority
JP
Japan
Prior art keywords
area
header
memory
heap
data
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
JP3306683A
Other languages
Japanese (ja)
Inventor
Akihiko Konagaya
明彦 小長谷
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
Nippon Electric 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 NEC Corp, Nippon Electric Co Ltd filed Critical NEC Corp
Priority to JP3306683A priority Critical patent/JPS59158460A/en
Publication of JPS59158460A publication Critical patent/JPS59158460A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units

Abstract

PURPOSE:To improve the utilizing efficiency of a memory cell by dividing an area not in use into a heap and a relocate area and managing the system so that the heap area is used as a data section accumulating area of a new structure. CONSTITUTION:A heap memory 120 accumulates a data section of the structure to a continuous area and an area not in use of the memory 120 is divided into a heap area 121 and a relocate area 122. When the area 121 is used as a data accumulating area of the structure and the continuous area accumulating the data section of a new structure is not ensured, the data section 123 corresponding to the header section in use at present among the header section of the structure accumulated in the header memory 110 is relocated to the continuous area of the area 122 and the area including the area not in use of the areas 121 and 122 is taken as a new area 125 not in use. Then, the aea 125 is divided into the new heap and relocate areas, and the structure memory is managed 130 so that the heap area is used as the data section storage area of the structure produced newly.

Description

【発明の詳細な説明】[Detailed description of the invention]

本発明はプI:Ipグの構造体の実現方式ならびにメそ
りセルの回収方式に関する。 近年、知的システムへの関心の高まりとともに述語論理
m言語プロログが注目されている。その理由の1つとし
て、可変値の要素から構成される構造体が扱えることが
あげられる。例えば、プロログでは、かごの中に(りん
ご)、(なし)。 (みかん)が入っている状態を構造体者(かご)。 要素数3の構造体を使って次のよ5に表現できる。 かご(りんご、なし、みかん) さらに、太部がこのかごを持っているという事実は、構
造体者(持つ)、要素数2の構造体を用いて次のよ51
(記述できる。 持つ(太部、かご(りんご、なし、みかん))プロログ
ではこのように可変側の要素を持つ構造体を用いること
によりデータを容易に記述することができる。一方、プ
ロログを実行すると多数の構造体が動的に生成、消滅す
るため、構造体の領域として多量のメモリセルが必要で
ある。そこで、メモリセルの使用効率を高めるために、
一度、使用済となったメモリセルを回収し、再度、構造
体を実現するのに使用するいわゆるガーベージフレクシ
目ン(以下GCと略す)が行われる。しかしながら、ガ
ーベージコレクションにかかる処理コストは大きく、全
体の処理コストの30%から50%以上かかる場合があ
る。本発明は、このようなガーベージフレクションを高
速に処理できるような構造体の実現方式を提供するもの
である。 本発明の実施例について述べる前に、構造体を実現する
従来方式とその問題点について触れてお(。 構造体を実現するための良く知られた実現方式の1つは
、固定長の領域をポインタで複数個つなぐ方式である。 第1図Vc2進 リストセル10を用いて構造体 持つ(太部、かご(りんご、なし、みかん))を表現し
たときの概念図を示す。この方式の最大の特徴は、メモ
リセルを確保する単位が固定長となっているため、未使
用領域が連続領域になくても良い点にある。すなわち、
ガーベージコレクションにより使用済メモリセルを回収
する作業は不要な固定領域(2進未リストでは2連続の
メモリセル)をポインタで結ぶだけでよい。しかしなが
ら、固定長領域をポインタで接続する方式は構造体の要
素をアクセスする際のオーバーヘッドが大きいとい5問
題を持つ。例えば、構造体の4番目の要素をアクセスす
るためにはポインタを外回辿らねばならず、メモリアク
セスネックの要因となる。前記方式の欠点を解決する別
の方式としては、構造体の要素を連続領域に並べ、各要
素へのアクセスをヘッダ部からのオフセットで行う方式
が知られている。第2図は、本方式による構造体持つ(
太部、かご(りんご、なし、みかん))を表現する概念
図である。第2図において、2゜は構造体名領域、21
は要素数領域、22は構造体ヘッダ領域、23はデータ
領域を表わす。 この方式では、構造体は構造体名と要素数から構成され
る構造体ヘッダ領域22と構造体の各要素を格納するデ
ータ領域23が連続領域に割り当てられ
The present invention relates to a method for realizing a structure of a PIG and a method for recovering a mesori cell. In recent years, as interest in intelligent systems has increased, predicate logic m-language prologs have been attracting attention. One of the reasons for this is that it can handle structures composed of elements with variable values. For example, in the prolog, (apples), (none) in the basket. The structure person (basket) is the state in which (mandarin oranges) are contained. Using a structure with 3 elements, it can be expressed as follows. Basket (apples, pears, oranges) Furthermore, the fact that Abe has this basket can be expressed as follows using a structure with two elements:
(It can be written. Has (fat part, basket (apple, pear, orange)) In prolog, data can be easily written by using a structure with variable side elements like this.On the other hand, when executing prolog As a result, a large number of structures are dynamically created and destroyed, which requires a large amount of memory cells as the area for the structures.Therefore, in order to increase the efficiency of memory cell usage,
Once the used memory cells are collected, a so-called garbage conversion (hereinafter abbreviated as GC) is carried out to be used to realize a structure again. However, the processing cost associated with garbage collection is large, and may cost 30% to 50% or more of the entire processing cost. The present invention provides a method for realizing a structure that can process such garbage reflection at high speed. Before describing embodiments of the present invention, we would like to touch on the conventional methods of realizing structures and their problems (one of the well-known methods of realizing structures is to This method connects multiple items using a pointer. Figure 1 shows a conceptual diagram when expressing a structure (fat section, basket (apples, pears, oranges)) with a structure using the Vc binary list cell 10. The feature is that the unit for securing memory cells is a fixed length, so the unused area does not need to be in a continuous area.In other words,
The task of collecting used memory cells by garbage collection is simply to connect unnecessary fixed areas (two consecutive memory cells in a binary unlisted list) with a pointer. However, the method of connecting fixed-length areas with pointers has five problems, including the large overhead when accessing the elements of the structure. For example, in order to access the fourth element of the structure, the pointer must be traced externally, which causes a memory access bottleneck. As another method for solving the drawbacks of the above method, a method is known in which the elements of the structure are arranged in a continuous area and each element is accessed by offset from the header section. Figure 2 shows the structure (
It is a conceptual diagram expressing a basket (apples, pears, mandarin oranges). In Figure 2, 2° is the structure name area, 21
22 represents an element number area, 22 represents a structure header area, and 23 represents a data area. In this method, a structure has a structure header area 22 consisting of the structure name and the number of elements, and a data area 23 that stores each element of the structure, which are allocated as continuous areas.

【いる。したが
って、構造体を要素として含むときは構造体ヘッダ領域
22へのポインタを要素とすればよい。また、要素への
アクセスは構造体ヘッダ領域22からのオフセットを用
いて高速に行5ことができる。しかしながら、この方式
はガーベージコレクションのオーバーヘッドが大きいと
いう問題点を持つ。すなわち、この方式では構造体は可
変長の連続領域に格納される必要がある。また、構造体
の性質上1つの構造体を複数個の構造体が共有する可能
性がありうる。 第3図(11,(21は構造偉人と構造体Cが構造体B
を共有しているときのガーベージコレクシヲンによるヒ
ープ領域の遷移を示す概念図である。第3図において、
30はヒープメモリ、31は使用中の構造体の領域、3
2は使用済の構造体の領域を(5) 示す。また、第3図(1)はガーベージコレクションを
行う前のヒープメモリの状態、第3図(2)はガーベー
ジフレクシ冒ンを行った後のヒープメモリの状態を表わ
す。本方式によるガーベージコレクシ四ンは次のように
して実現される。始めに、現在使用中の構造体に印をつ
げる。これは次のアルゴリズムにより、現在使用中のス
タックから直接および間接に参照される構造体に印をつ
げることにより実現される。 (1)  スタックより指される全ての構造体について
(2)の処理を行う。 (2)構造体に使用中の印がすでに付いていれば何もせ
ず、ついていなげれば、前記構造体に使用中の印を付け
、前記構造体が要素としてさらIc構造体を含むときは
要素となっている全ての構造体について(2)の処理を
繰り返す。 上記のアルゴリズムで使用中の印が付けられなかった構
造体は使用済の領域として回収できる。 しかしながら、前記固定領域を用いた構造体実現方式の
ように単に使用済の領域をポインタで結ぶ(6) だけでは、次に新しい構造体の領域として連続領域を確
保することができない。したがって、未使用領域を連続
領域上に確保するためには、第3図(11、(21VC
図示しであるように、使用中の構造体領域31をすpケ
ートして使用済領域32を集めなければならない。本方
式の問題点は構造体をリロケートする際にりpケートし
た構造体を指すポインタを全て書き換えねばならない点
建ある。本発明の目的は、上記従来方式の問題点を解決
し、要素へのアクセスが高速で、かつ、ガーベージフレ
クシヲン時の構造体のりロケーションのオーバーヘッド
が最小となるような構造体を可能にする構造体メモリ回
収方式を提供することKある。 以上の目的は、構造体のエントリとなる固定長のヘッダ
部と構造体の各要素を蓄積する可変長のデータ部から構
成される構造体に対し、前記構造体のヘッダ部を蓄積す
るヘッダメモリと、前記構造体のデータ部を連続領域に
蓄積するヒープメモリと、前記ヒープメモリの未使用領
域をヒープ領域とりpケート領域とに2分割し、前記ヒ
ープ領域を構造体のデータ部蓄積領域として使用してい
るときに、新たな構造体のデータ部を蓄積する連続領域
が確保で鎗なくなると、前記ヘッダメモリに蓄積されて
いる構造体のヘッダ部のうち、現在使用中のヘッダ部に
対応するデータ部を前記リロケート領域の連続領域にリ
ロケートし、さらに前記ヒープ領域と前記リロケート領
域の未使用領域を合わせた領域を新たに未使用領域とし
、前記未使用領域を新たにヒープ領域とリロケート領域
と1’1m2分割し、前記ヒープ領域を新たに生成され
た構造体のデータ部蓄積領域として使用する動作を繰り
返す構造体メモリ管理ユニットを備えていることを特徴
とした構造体メモリ回収方式により達成される。次に本
発明の具体的実施例について述べる。 第4図は本発明の実施例の1つである構造体メモリ回収
装置のブロック図である。図忙おいて、110はヘッダ
メモリ、111はマークビット領捕、112は構造体毛
領域、113は要素数領域、114は要素を格納するデ
ータ領域へのポインタ領域である。また、120はヒー
プメモリであり、121は構造体のデータ部を蓄積する
ヒープ領域、122はすpケート領域である。さらに、
130は構造体メモリ管理ユニットであり、131はリ
ロケート領域122の先頭アドレスを示す9pケ一ト領
域先頭アドレスレジスタ、132はヒープ領域121の
未使用領域の先頭を示す未使用領域先頭アドレスレジス
タ、133はヒープ領域121の未使用領域の終端を示
す未使用領域終端アドレスレジスタである。150はプ
ロログを実行するのに使用される情報を蓄積するスタッ
クメモリである。そして、構造体メモリ管理ユニット1
30は前記ヘッダメモリ11o、前記ヒープメモリ12
0を管理し、かつ、前記スタックメモ!J1501C格
納されている構造体ヘッダへのポインタから、現在使用
中の構造体のマーキングを指示する機能を有するユニッ
トを表わし、140は前記構造体メモリ管理ユニツ) 
130.前記スタックメモリ150および図示されてい
ない外部の処理ユニットを結合する内部バスを表わす。 本実施例でばマークピット領域1111C2ビツト、構
造体毛領域1121C10ビツト、要素領域113K(
9) 8ビツト、ポインタ領域114に16ビツト用意してい
る。また、ヘッダメモリ110は9KB、ヒープ用メモ
リ120は4ビツト中のタグビットを含む20ビツト中
128KBを用意している。 したがって、本実施例では最大256個の要素を持つ構
造体を2000個取り扱うことができる。 また、構造体メモリ管理ユニツ) 130は例えば、市
販の16ビツトマイクロプpセツサと4KBの高速メモ
リICから構成される。さらに、前記構造体メモリ管理
ユニット130は内部にリロケート領域先頭アドレスレ
ジスタ131、未使用領域先頭アドレスレジスタ132
、未使用領域終端アドレスレジスタ133として16ビ
ツト巾の3つのレジスタを備えている。スタックメモリ
150は16ビツト巾の32KBのメモリで構成される
。本発明によれば、全ての構造体は構造体ヘッダを介し
てアクセスされるため、構造体のデータ領域を指すポイ
ンタの数は高々1つである。したがって、データ部をリ
ロケートしてもポインタの書き換えは構造体ヘッダのポ
インタ部のみを変更すれば良く、すp(10) ケートのオーバーヘッドを大巾に減少させることができ
る。また、構造体ヘッダ部は固定長となるので使用済の
構造体ヘッダは未使用状態を示す印を付加するだけで再
利用することができる。さらに、ヒープ領域はそのとき
の未使用領域を2分割しながら使用するのでヒープメそ
りの全てを利用することが可能である。次に本実施例で
の構造体メモリ回収方式を図を参照しつつ説明する。 第5図は本実施例における構造体メモリ回収方式を説明
する概念図である。ただし、本実施例ではマークピット
領域111がC00″のヘッダは未使用状態のヘッダを
、rlO’+のヘッダは使用中であるがデータ部が一度
もリロケートされていないヘッダを、711′は使用中
でかつデータ部がリロケートされたヘッダを、CO,’
lはデータ部は一度すpケートされたが、使用済状態に
あるヘッダを表わす。構造体が全く定義されていない状
態では全ての構造体ヘッダのマークピット領域111の
値は′001であり、リロケート領域先頭アドレスレジ
スタ131はヒープメモリ120の先頭アドレスを、未
使用領域終端アドレスレジスタ133はヒープメモリ1
20の終端のアドレスを指しており、未使用領域先端ア
ドレスレジスタ132はリロケート領域先頭アドレスレ
ジスタ131のアドレスと未使用領域終端アドレスレジ
スタ133の7ドレスを足して2で割ったアドレスがセ
ットされている。図示されていない外部の処理ユニット
(例えばプローグプロセッサ)から構造体メモリ管理ユ
ニット130に新しく構造体を作成するように要求され
ると構造体メモリ管理ユニット130は次のように動作
する。 例えば、構造体 かご(りんご、なし、みかん) をヒープ上に新しく作成する場合を考える。はじめに、
未使用領域先頭アドレスレジスタ132に要素数3を加
え、未使用領域終端アドレスレジスタ133の値を越え
たか否かを判定する。もし、越えていなげれば、ヘッダ
メモ!J 110かもマークピット領域111がC00
)のヘッダを1つ選び、前記ヘッダの構造体名領域11
2ニ構造体名(かご)を表わす値を代入し、要素数領域
113に要素数(3)を代入し、ポインタ領域114に
未使用領域先頭アドレスレジスタ132が現在指してい
るアドレスを代入し、未使用領域先端アドレスレジスタ
132のアドレスを1ずつ増やしながら、前記構造体の
要素である(りんご)、(なし)、(みかん)を表わす
値をヒープメそり120に格納し、前記ヘッダ領域のア
ドレスを構造体の値として外部の処理ユニツ)K返す。 構造体の値としては、構造体ヘッダの値がアドレスとし
て返されるので、構造体 持つ(太部、かご(りんご、
なし、みかん)) のように構造体を要素として含む構
造透体は、第5図に図示されるように、構造体ヘッダへ
のポインタをデータ領域に格納することになる。 第5図はさらに構造体 持つ(花子、かご(りんご、なし、みかん))が構造体 かご(りんご、なし、みかん) を共有し、かつ、スタックメモリ150からは構造体持
つ(太部、かご(りんご、なし、みかん))(13) と構造体 持つ(花子、かご(りんご、なし、みかん))のみが指
されている状態を表わす。このような状態で、さらに、
構造体 人間(太部、花子) を追加したときの動作を説明する。構造体メモリ管理ユ
ニツ)130は同様にして、未使用領域先頭アドレスレ
ジスタ132の値に要素数2を足した値と未使用領域終
端アドレスレジスタ133の値を比較するが、もし、未
使用領域終端アドレスレジスタ133の値の方が小さけ
れば、次に述べるガーベージコレクシ四ンのプpセスヲ
起動スル。カーヘージコレクシ冒ンが起動されると、は
じめにマークピット領域111の値を’ooう、f”、
05はC005に+’11’+、 roltはC01)
にセットする。次に下記のアルゴリズムに従って使用中
の構造体ヘッダのマーキングを行う。 (1)  スタックメモリ1501C積まれている各構
造体ヘッダに対して(2)の処理を行う。 (2)構造体ヘッダのマークピット領域の値が(10)
(14) C) か 11  ならば何もしない。Coo)または’01
’ならばそれぞれ′10)または′111にセットし、
(3)の処理を行う。 (3)構造体ヘッダのボイ/り領域114が指すアドレ
スからヒープメモリ120上のデータ部を要素数頭域1
13の値だけサーチし、構造体ヘッダを値とする要素に
対して(2)の操作を再帰的に繰り返す。 この結果、ヘッダメモ!J ll0ICおいて、現在使
用中の構造体ヘッダのマークピッ) 領域111it管
またはC11)にセットされる。次に、下記のアルゴリ
ズムに従って使用中のデータ部123のjJpケーシッ
ンを行う。 (])  ヘッダメモリ110ニおいて、マークピット
領域111の値がC10′lの構造体ヘッダについて(
2)の処理を行い、全ての構造体ヘッダについて処理し
たら(3)の処理を行う。 (2)構造体ヘッダのポインタ領域114の指すアドレ
スから前記アドレスに要素数頭域110の値を加えたア
ドレスまでのヒープメモリ120の内容をりロケート領
域先頭アドレスレジスタ131の指すアドレスからりロ
ケート領域122の連続領域にコピーし、前記りロケー
ト領域先頭アドレスレジスタ132の値に前記要素数頭
域110の値を加える。 (3)  リロケート領域先頭アドレスレジスタ131
の値と未使用領域終端アドレスレジスタ133の値を足
して2で割った値を未使用領域先頭アドレスレジスタ1
32の値としてセットする。 第6図は前記アルゴリズムによりすpケージ菅ンを行っ
た後のヒープメそりの状態を示す概念図である。リロケ
ーションにより使用済状態にあったデータ領域が圧縮さ
れるのでリロケー)領域122の残りとヒープ領域12
1が連続領域として得られる。また、ヘッダメモリ11
0においてもデータ部が回収された構造体のヘッダのマ
ークピット領域111の値は’00’ KJiされるの
で前記ヘッダ領域を再使用することが可能となる。後は
通常の場合と同様にして、新たに構成されたヒープ領域
に構造体の追加を行えばよい。ただし、すpケージ舊ン
を行った後でも必要なデータ領域およびヘッダ領域が確
保できないときはエラーメツセージを出力して処理を中
断する。なお、本実施例では一度りロケートしたデータ
領域は2度とリロケートしないよ5ICしたため、一度
lJpケートされた後に使用済となった構造体はヒープ
メモリ120に残されてしまう。このような構造体は、
マークピット領域の値がC01″のヘッダを持ち、下記
のアルゴリズムを用いれば回収することができる。 今、データ領域のリロケーションが終了した所とする。 構造体ヘッダのマーキングアルゴリズムにより、ヘッダ
メモリ1】0の構造体ヘッダのマークピット領域111
の値はCOlつかC1−かのいずれかである。この状態
において、マークピット領域111の値がCO−の構造
体のヘッダおよびデータ部を回収するアルゴリズムを示
す。 (1)  ヘッダメモリll0VCおいてマークピット
領域111の値がC01′lのヘッダのうち、ポインタ
領域114のアドレスがもっとも小さいヘッダを選びそ
のヘッダのマークピット領域111の値をCOO’lと
する。以下、選ばれたヘッダのアドレスをJで示す。 そのようなヘッダが見つからないときは処理を終(17
) 了する。 (2)  ヘッダメモリにおいて、マークピット領域1
11の値がCIりのヘッダのうち、ポインタ領域114
のアドレスがJよりも大きく、かつその中でもっとも小
さいアドレスを持つヘッダを選び、前記ヘッダに対して
(3)の処理を行う。そのようなヘッダが見つからない
ときは処理を終了し、そうでなげれば、il+の処理を
繰り返す。 (3)ヘッダのポインタ領域114が示すヒープメモリ
120のアドレスから、そのヘッダの要素数頭域110
で示される値を加えたアドレスまでのデータ部をアドレ
スJから始まる連続領域にリロケートし、前記ポインタ
領域114にアドレスJをセットする。 上記のアルゴリズムにより、マークピット領域111の
値がCo15である構造体のヘッダおよびデータ部が除
去され、空領域が連続領域に作られる。 この空領域の先頭アドレスは、ヘッダメモリ110にお
いて、マークピット領域がFllSのヘッダでポインタ
領域114のアドレスが最大のものヲ選び、(18) 前記アドレスに前記ヘッダの要素数領域113の値を加
えれば得られる。したがって、リロケート領域先頭アド
レスレジスタ131には前記空領域の先頭アドレスをセ
ットし、未使用領域先頭アドレスレジスタには前記空領
域の先頭アドレスと未使用領域終端アドレスレジスタ1
33の値を足して2で割った値をセットすればよい。
[There is. Therefore, when a structure is included as an element, a pointer to the structure header area 22 may be used as the element. Furthermore, the elements can be accessed at high speed using the offset from the structure header area 22. However, this method has a problem in that the overhead of garbage collection is large. That is, in this method, the structure needs to be stored in a continuous area of variable length. Furthermore, due to the nature of structures, there is a possibility that one structure may be shared by a plurality of structures. Figure 3 (11, (21 is the structure great and structure C is structure B
FIG. 3 is a conceptual diagram showing the transition of a heap area due to garbage collection when shared. In Figure 3,
30 is heap memory, 31 is the area of the structure in use, 3
2 indicates the area of the used structure (5). Further, FIG. 3(1) shows the state of the heap memory before performing garbage collection, and FIG. 3(2) shows the state of the heap memory after performing garbage flexi. Garbage collection according to this method is realized as follows. First, mark the structure currently in use. This is accomplished by marking directly and indirectly referenced structures from the stack currently in use using the following algorithm. (1) Perform the process (2) for all structures pointed to by the stack. (2) If the structure is already marked as in use, do nothing; if not, mark the structure as in use, and if the structure further includes an Ic structure as an element; repeats the process (2) for all structures that are elements. Structures that are not marked as in use by the above algorithm can be reclaimed as used space. However, by simply connecting used areas with pointers (6) as in the structure implementation method using fixed areas, it is not possible to secure a continuous area as the area for the next new structure. Therefore, in order to secure an unused area on a continuous area, it is necessary to
As shown, the used structure area 31 must be evicted and the used area 32 must be collected. The problem with this method is that when relocating a structure, all pointers pointing to the relocated structure must be rewritten. An object of the present invention is to solve the problems of the conventional method described above, and to provide a structure that allows high-speed access to elements and minimizes the overhead of structure allocation during garbage flexion. The present invention provides a method for retrieving body memory. The purpose of the above is to create a header memory that stores the header portion of the structure for a structure consisting of a fixed-length header section that serves as an entry for the structure and a variable-length data section that stores each element of the structure. and a heap memory for storing the data portion of the structure in a continuous area; and an unused area of the heap memory is divided into a heap area and a storage area, and the heap area is used as the data portion storage area of the structure. During use, if a contiguous area to store the data part of a new structure runs out, the header part of the structure stored in the header memory corresponding to the header part currently in use is used. The data section to be relocated is relocated to a contiguous area of the relocate area, the combined area of the heap area and the unused area of the relocate area is set as a new unused area, and the unused area is newly combined with the heap area and the relocate area. This is achieved by a structure memory recovery method characterized by having a structure memory management unit that repeats the operation of dividing the heap area into 1'1m2 and using the heap area as a data storage area of a newly generated structure. be done. Next, specific examples of the present invention will be described. FIG. 4 is a block diagram of a structure memory recovery device which is one of the embodiments of the present invention. In the figure, 110 is a header memory, 111 is a mark bit storage area, 112 is a structure area, 113 is an element number area, and 114 is a pointer area to a data area for storing elements. Further, 120 is a heap memory, 121 is a heap area for storing the data part of the structure, and 122 is a storage area. moreover,
130 is a structure memory management unit; 131 is a 9p-digit area start address register indicating the start address of the relocate area 122; 132 is an unused area start address register indicating the start of the unused area of the heap area 121; 133 is an unused area end address register indicating the end of the unused area of the heap area 121. 150 is a stack memory that stores information used to execute prologs. And structure memory management unit 1
30 is the header memory 11o, the heap memory 12
Manage 0 and Stack Memo! J1501C represents a unit having the function of instructing marking of the structure currently in use from the pointer to the stored structure header, and 140 is the structure memory management unit)
130. It represents an internal bus that couples the stack memory 150 and an external processing unit (not shown). In this embodiment, the mark pit area 1111C2 bits, the structure hair area 1121C10 bits, and the element area 113K(
9) 8 bits are prepared, and 16 bits are prepared in the pointer area 114. Further, the header memory 110 has 9 KB, and the heap memory 120 has 128 KB out of 20 bits including the tag bit out of 4 bits. Therefore, in this embodiment, 2000 structures having a maximum of 256 elements can be handled. The structure memory management unit 130 is composed of, for example, a commercially available 16-bit microprocessor and a 4KB high-speed memory IC. Furthermore, the structure memory management unit 130 internally stores a relocate area start address register 131 and an unused area start address register 132.
, three 16-bit wide registers are provided as unused area end address registers 133. Stack memory 150 consists of 32 KB of 16 bit width memory. According to the present invention, all structures are accessed via the structure header, so the number of pointers pointing to the data area of the structure is at most one. Therefore, even if the data section is relocated, only the pointer section of the structure header needs to be rewritten, and the overhead of sp(10) can be greatly reduced. Further, since the structure header portion has a fixed length, a used structure header can be reused by simply adding a mark indicating an unused state. Furthermore, since the heap area is used by dividing the unused area into two, it is possible to utilize the entire heap area. Next, the structure memory recovery method in this embodiment will be explained with reference to the drawings. FIG. 5 is a conceptual diagram illustrating the structure memory recovery method in this embodiment. However, in this embodiment, the header with mark pit area 111 C00'' is an unused header, the header with rlO'+ is in use but the data part has never been relocated, and 711' is used. The header in which the data part is relocated is CO,'
1 represents a header whose data portion has been deleted once but is in a used state. When no structure is defined at all, the value of the mark pit area 111 of all structure headers is '001, and the relocate area start address register 131 stores the start address of the heap memory 120, and the unused area end address register 133 is heap memory 1
20, and the unused area start address register 132 is set to the address obtained by adding the address of the relocate area start address register 131 and the 7 addresses of the unused area end address register 133, and dividing the result by 2. . When the structure memory management unit 130 is requested to create a new structure from an external processing unit (for example, a prologue processor) not shown, the structure memory management unit 130 operates as follows. For example, consider creating a new structure basket (apples, pears, and oranges) on the heap. Introduction,
The number of elements 3 is added to the unused area start address register 132, and it is determined whether the value exceeds the value of the unused area end address register 133. If you haven't exceeded it, please write a header memo! J 110 mark pit area 111 is C00
), and select the structure name area 11 of the header.
2. Assign a value representing the structure name (basket), assign the number of elements (3) to the element number area 113, assign the address currently pointed to by the unused area start address register 132 to the pointer area 114, While incrementing the address of the unused area end address register 132 by 1, values representing the elements of the structure (apple), (none), and (orange) are stored in the heap memory 120, and the address of the header area is Returns K as the value of the structure to the external processing unit. As the value of the structure, the value of the structure header is returned as the address, so if the structure has (fat, basket (apple, apple,
A structure transparent body that includes a structure as an element, such as (none, orange)), stores a pointer to the structure header in the data area, as shown in FIG. FIG. 5 further shows that the structure baskets (Hanako, baskets (apples, pears, oranges)) share the structure basket (apples, pears, oranges), and the stack memory 150 has structures (fatty, baskets). (apple, pear, mandarin orange)) (13) represents a state in which only the structure (hanako, basket (apple, pear, mandarin orange)) is pointed to. In this situation, furthermore,
We will explain the behavior when adding structure humans (Atabe, Hanako). Similarly, the structure memory management unit 130 compares the value of the unused area start address register 132 plus the number of elements 2 with the value of the unused area end address register 133. If the value of the address register 133 is smaller, the garbage collection process described below is started. When the Car Hage Collection is activated, the values in the mark pit area 111 are first changed to 'oo, f',
05 is C005 +'11'+, rolt is C01)
Set to . Next, the structure headers in use are marked according to the following algorithm. (1) The process (2) is performed on each structure header stacked in the stack memory 1501C. (2) The value of the mark pit area of the structure header is (10)
(14) If C) or 11, do nothing. Coo) or '01
', set to '10) or '111 respectively,
Perform the process (3). (3) Move the data section of the heap memory 120 from the address pointed to by the void area 114 of the structure header to the element number head area 1.
13 values are searched, and the operation (2) is recursively repeated for elements whose value is the structure header. As a result, header memo! In Jll0IC, the mark pit of the structure header currently in use is set to area 111it or C11). Next, jJP casing of the data section 123 in use is performed according to the following algorithm. (]) Regarding the structure header whose value in the mark pit area 111 is C10'l in the header memory 110 (
After performing the process 2) and processing all structure headers, perform the process 3). (2) Locate the contents of the heap memory 120 from the address pointed to by the pointer area 114 of the structure header to the address plus the value of the number of elements field 110.Locate area from the address pointed to by the start address register 131 122 continuous area, and add the value of the element number head area 110 to the value of the new locate area start address register 132. (3) Relocate area start address register 131
The value obtained by adding the value of the unused area end address register 133 and the value of the unused area end address register 133 and dividing the value by 2 is set as the unused area starting address register 1.
Set it as a value of 32. FIG. 6 is a conceptual diagram showing the state of the heap memory after p-cage processing is performed using the above algorithm. Since the data area that was in the used state is compressed due to relocation, the remaining area 122 and the heap area 12 are relocated.
1 is obtained as a continuous region. In addition, the header memory 11
0, the value of the mark pit area 111 of the header of the structure whose data portion has been recovered is set to '00' KJi, so that the header area can be reused. After that, just add the structure to the newly created heap area as you would normally do. However, if the necessary data area and header area cannot be secured even after executing the SP cage, an error message is output and processing is interrupted. In this embodiment, since the data area that has been located once is not relocated again, the structure that is used after being located once is left in the heap memory 120. Such a structure is
The mark pit area has a header with a value of C01'' and can be recovered using the algorithm below. Assume that the relocation of the data area has now been completed. By the marking algorithm of the structure header, header memory 1] 0 structure header mark pit area 111
The value of is either COl or C1-. In this state, an algorithm for recovering the header and data part of the structure whose mark pit area 111 value is CO- will be described. (1) Among the headers whose mark pit area 111 has a value of C01'l in the header memory ll0VC, select the header whose address in the pointer area 114 is the smallest and set the value of the mark pit area 111 of that header to COO'l. Below, the address of the selected header is indicated by J. If no such header is found, terminate the process (17
) Finish. (2) Mark pit area 1 in header memory
Among the headers whose value is CI, pointer area 114
A header whose address is larger than J and has the smallest address among them is selected, and the process (3) is performed on the header. If no such header is found, the process ends; otherwise, the il+ process is repeated. (3) From the address of the heap memory 120 indicated by the pointer area 114 of the header, the number of elements in the header area 110
The data portion up to the address to which the value shown is added is relocated to a continuous area starting from address J, and address J is set in the pointer area 114. According to the above algorithm, the header and data part of the structure whose mark pit area 111 has a value of Co15 are removed, and a vacant area is created as a continuous area. For the start address of this empty area, select the header whose mark pit area is FLLS and the address of the pointer area 114 is the largest in the header memory 110, and (18) add the value of the number of elements area 113 of the header to the address. You can get it. Therefore, the start address of the free area is set in the relocate area start address register 131, and the start address of the empty area and the unused area end address register 1 are set in the unused area start address register.
Just set the value by adding the value of 33 and dividing by 2.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図は構造体を固定領域を用いて実現したときの一例
を示す概念図、第2図は構造体を可変長の連続領域を用
いて実現したときの一例を示す概念図、第3図(1)、
(2)は構造体を可変長の連続領域を用いて実現したと
きのガーベージフレクシシンの一例を示す概念図、第4
図は本発明の一実施例である構造体メモリ回収装置のブ
ロック図である。 また、第5図、第6図は本発明のガーベージコレクシ冒
ン方式を説明する概念図である。図において、10はリ
ストセル、20は構造体毛領域、21は要素数領域、2
2は構造体のヘッダ領域、23ハ構造体のデータ領域、
30はヒープメモリ、31は使用中の構造体の領域、3
2は使用済の構造体の領域を表わす。 また、110は本発明の一実施例である構造体処理装置
のヘッダメモリ、111はマークピット領域、112は
構造体毛領域、113は要素数領域、114はデータ領
域へのポインタ領域、120はヒープメモリ、121は
ヒープ領域、122はすpケート領域、123は使用中
のデータ領域、124は使用済のデータ領域、125は
未使用領域、130は構造体メモリ管理ユニット、13
1はすpケート領域光ff17ドレスI/ジスタ、13
2は未使用領域先頭アドレスレジスタ、133は未使用
領域終端アドレスレジスタ、140は内部データバス、
150はスタックメモリを表わす。 特開昭59−158460(8)
Figure 1 is a conceptual diagram showing an example of a structure realized using a fixed area, Figure 2 is a conceptual diagram showing an example of a structure realized using variable-length continuous areas, and Figure 3. (1),
(2) is a conceptual diagram showing an example of garbage flexicin when a structure is realized using a continuous region of variable length.
The figure is a block diagram of a structure memory recovery device which is an embodiment of the present invention. 5 and 6 are conceptual diagrams explaining the garbage collection system of the present invention. In the figure, 10 is a list cell, 20 is a structure hair area, 21 is an element number area, and 2
2 is the header area of the structure, 23c is the data area of the structure,
30 is heap memory, 31 is the area of the structure in use, 3
2 represents the area of the used structure. Further, 110 is a header memory of a structure processing device which is an embodiment of the present invention, 111 is a mark pit area, 112 is a structure hair area, 113 is an element number area, 114 is a pointer area to a data area, and 120 is a heap. Memory, 121 is a heap area, 122 is a space area, 123 is a data area in use, 124 is a used data area, 125 is an unused area, 130 is a structure memory management unit, 13
1 Spkate area light ff17 dress I/distor, 13
2 is an unused area start address register, 133 is an unused area end address register, 140 is an internal data bus,
150 represents a stack memory. Japanese Patent Publication No. 59-158460 (8)

Claims (1)

【特許請求の範囲】[Claims] 構造体のエントリとなる固定長のヘッダ部と構造体の名
要素を蓄積する可変長のデータ部から構成される構造体
に対し、前記構造体のヘッダ部を蓄積するヘッダメモリ
と、前記構造体のデータ部を連続領域に蓄積するヒープ
メモリと、前記ヒープメモリの未使用領域をヒープ領域
とりpケート領域とに2分割し、前記ヒープ領域を構造
体のデータ部蓄積領域として使用しているときk、新た
な構造体のデータ部を蓄積する連続領域が確保できなく
なると、前記ヘッダメモリに蓄積されている構造体のヘ
ッダ部のうち、現在使用中のヘッダ部に対応するデータ
部を前記IJRケート領域の連続領域にリーケートし、
さらに前記ヒープ領域と前記すpケート領域の未使用領
域を合わせた領域を新たに未使用領域とし、前記未使用
領域を新たにヒープ領域とすpケート領域とに2分割し
、前記ヒープ領域を新たに生成された構造体のデータ部
蓄積領域として使用する動作を繰り返す構造体メモリ管
理ユニットを備えていることを特徴とする構造体メモリ
回収方式。
For a structure composed of a fixed-length header part that becomes an entry of the structure and a variable-length data part that stores name elements of the structure, a header memory that stores the header part of the structure, and a header memory that stores the header part of the structure, and a header memory that stores the header part of the structure; When the heap memory is divided into a heap memory that stores the data part in a continuous area, and an unused area of the heap memory is divided into a heap area and a storage area, and the heap area is used as the data part storage area of the structure. k. When a continuous area for storing the data part of a new structure cannot be secured, the data part corresponding to the header part currently in use among the header parts of the structure stored in the header memory is stored in the IJR. leakage into a continuous region of the
Furthermore, the combined area of the heap area and the unused area of the p-cate area is set as a new unused area, and the unused area is newly divided into two, the heap area and the p-cate area, and the heap area is divided into two. A structure memory recovery method characterized by comprising a structure memory management unit that repeatedly uses the structure as a data storage area of a newly generated structure.
JP3306683A 1983-03-01 1983-03-01 Structure memory recovery system Pending JPS59158460A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP3306683A JPS59158460A (en) 1983-03-01 1983-03-01 Structure memory recovery system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP3306683A JPS59158460A (en) 1983-03-01 1983-03-01 Structure memory recovery system

Publications (1)

Publication Number Publication Date
JPS59158460A true JPS59158460A (en) 1984-09-07

Family

ID=12376354

Family Applications (1)

Application Number Title Priority Date Filing Date
JP3306683A Pending JPS59158460A (en) 1983-03-01 1983-03-01 Structure memory recovery system

Country Status (1)

Country Link
JP (1) JPS59158460A (en)

Similar Documents

Publication Publication Date Title
EP0127753B1 (en) Method for executing a distribution sort
US6622226B1 (en) Method and system for using a mark-list for garbage collection
Belady A study of replacement algorithms for a virtual-storage computer
JP4043528B2 (en) Bounded downtime garbage collection system having a read barrier and a write barrier associated with partially relocated object instances and method of garbage collection thereof
Schorr et al. An efficient machine-independent procedure for garbage collection in various list structures
US7831624B2 (en) Skip list with address related table structure
US7035884B2 (en) Placement of allocation trains in the train algorithm
JP3560535B2 (en) Method and system for detecting and coalescing free space during garbage collection
EP0874316A2 (en) System and method for assisting exact garbage collection by segregating the contents of a stack into sub stacks
JP2002506550A (en) Bounded pause garbage collection systems and methods including write barriers for source and destination instances of partially relocated objects
WO2001061472A2 (en) Incremental class unloading in a train-algorithm-based garbage collector
JP2002506549A (en) Bounded downtime garbage collection system and method including write barrier associated with source instance of partially relocated object
JP2001504970A (en) Data processing device that reuses local memory
JPH0546447A (en) Idle area retrieving method
US20040088339A1 (en) Efficient encoding of references into a collection set
JPS62113234A (en) Sorting of record set
CN107391030A (en) Date storage method, device, computer-readable recording medium and computer equipment
WO1997029429A1 (en) Cam accelerated buffer management
US7155467B1 (en) Adaptive type-partitioned garbage collection
US6067607A (en) Data control system for a computer's main memory for efficiently realizing virtualization of list structure data lying across a real memory space and a virtual memory space
JPS59158460A (en) Structure memory recovery system
US7539713B2 (en) Allocation of likely popular objects in the train algorithm
US7130857B2 (en) Method for accessing a memory unit in which sequences of notes are stored, corresponding memory unit and corresponding program
JPS59158459A (en) Structure memory recovery system
Harland et al. OBJEKT—a persistent object store with an integrated garbage collector