/* Make sure the minor heap is empty by performing a minor collection
if needed.
*/
必要ならマイナーコレクションを実行して、新世代のヒープが空であることを保証する。
void caml_empty_minor_heap (void)
{
value **r;
if (caml_young_ptr != caml_young_end){
caml_young_ptr == caml_young_endが成立するのは、新世代にひとつもブロックがアロケートされていない場合。すなわち、新世代のオブジェクトがあれば、このif文の条件式は真になる。
caml_in_minor_collection = 1;
caml_gc_message (0x02, "<", 0);
caml_oldify_local_roots();
for (r = caml_ref_table.base; r < caml_ref_table.ptr; r++){
caml_oldify_one (**r, *r);
旧世代から参照されている新世代のオブジェクトを殿堂入りさせる。
}
caml_oldify_mopup ();
for (r = caml_weak_ref_table.base; r < caml_weak_ref_table.ptr; r++){
if (Is_block (**r) && Is_young (**r)){
if (Hd_val (**r) == 0){
**r = Field (**r, 0);
}else{
**r = caml_weak_none;
}
}
}
if (caml_young_ptr < caml_young_start) caml_young_ptr = caml_young_start;
caml_stat_minor_words += Wsize_bsize (caml_young_end - caml_young_ptr);
caml_young_ptr = caml_young_end;
caml_young_limit = caml_young_start;
clear_table (&caml_ref_table);
clear_table (&caml_weak_ref_table);
caml_gc_message (0x02, ">", 0);
caml_in_minor_collection = 0;
}
caml_final_empty_young ();
#ifdef DEBUG
{
value *p;
for (p = (value *) caml_young_start; p < (value *) caml_young_end; ++p){
*p = Debug_free_minor;
}
++ minor_gc_counter;
}
#endif
}