l l Copying Garbage Collection l Cheneys BreadthFirst
発表の内容 l l 私の研究について。なにを目指しているか。 古典的な Copying Garbage Collection – l Cheney’s Breadth-First Copying Algorithm Bartlett’s Mostly-Copying Collection
Copy GC での Fast Allocation l Copy GC はAllocation が速い! From_space void* allocate(size_t size){ prev = free; free = free + size; free if(free < limit){ return prev; }else{ ・・・ } } Allocation 要求 limit
Copy GC の概略(1) 1. Object は From_space より 端から順に allocate From_space To_space
古典的 Copying Garbage Collector 詳細 Cheney’s Breadth-First Copying Algorithm
Cheney’s Breadth-first Copying アルゴリズム(オブジェクトのコピー) object* copy(object* p) { if ( p is already copied) { return p->forwarding_addr; } object* newaddr = free; memcpy(newaddr, p, p->size); free = free + p->size; p->forwarding_addr = newaddr; return newaddr; }
Cheney’s Breadth-first Copying アルゴリズム(オブジェクトのコピー) From_space ポインタの更新 From_space To_space scan free Forwarding pointer - コピー前 - オブジェクトのコピー - コピー後 -
Cheney’s Breadth-first Copying アルゴリズム(GC のメインループ) gc(){ // 1. foreach r in rootset { r = copy(r); } // object* r; // 2. scan = free = (To_space の先頭); while(scan < free){ foreach p in scan. children{ // object* p; p = copy(p); 3. 4. } scan = scan + p->size; } swap(To_space, From_space); } // 5.
Bartlett’s Mostly Copying Collector ~ Compacting Garbage Collection with Ambiguous Roots~ Root set の型が分からない 状況下での Copying GC
Bartlett’s Mostly Copying Collector 本来の Root set 新しいRootset 内には、曖昧 なポインタが 存在しない。 Ø普通のCopy GC が可能。
Bartlett’s Mostly-Copying Collector Root set キュー
Bartlett’s Mostly-Copying Collector のコピー操作(2) object* copy(object* p){ if(p belongs to next_space || p == NULL){ return p; } if(p is already copied){ return p->forwarding_addr; } object* newobj = move(p); p->forwarding_addr = newobj; return newobj; }
Bartlett’s Mostly Copying Collector void gc(){ next_space = current_space + 1; queue = empty; // 1. // 2. foreach r in rootset{ promote_page(page pointed by r); } while(queue is not empty){ block = queue. dequeue(); foreach obj in block{ 3. foreach q in obj. children{ q = copy (q); } } } current_space = next_space: } 4.
Bartlett’s Mostly Copying Collector void promote_page(page* p){ if(p->space. ID == current_space){ p->space. ID = next_space; 2. queue. enqueue(p); } }
Bartlett’s Mostly-Copying Collector キュー 4. 以上を、キューの最後 まで続ける。
関連研究 l l l [Appel 1988] Copying Garbage Collection in the Presence of Ambiguous References (http: //research. microsoft. com/~drh/pubs/tr-162 -88. pdf) [Yip 1991] Incremental, Generational Mostly-Copying Garbage Collection in Uncooperative Environments (http: //www. research. compaq. com/wrl/techreports/abstracts/91. 8. html) [田中 1998] 卒業論文, Copying Garbage Collection in the Presence of Uncertain Pointers (/home/yl 2/y-tanaka/ise-env/work/98 winter/senior-thesis/thesis)
References [Bartlett 1988] Joel. F. Bartlett, Compacting Garbage Collection with Ambiguous Roots (http: //www. research. compaq. com/wrl/techreports/abstracts/88. 2. html) l Garbage Collection, Algorithm for Automatic Dynamic Memory Management, Richard Jones, Rafael Lins (青い本) l
- Slides: 52