fix accounting of phantom bytes for incremental GC

Also fixes accounting when a phantom-bytes value is
treated as potentially having a backpointer.
This commit is contained in:
Matthew Flatt 2015-11-28 08:47:11 -07:00
parent 81e0636843
commit e968cfbde4
2 changed files with 12 additions and 4 deletions

View File

@ -2593,7 +2593,12 @@ static int mark_phantom(void *p, struct NewGC *gc)
{ {
Phantom_Bytes *pb = (Phantom_Bytes *)p; Phantom_Bytes *pb = (Phantom_Bytes *)p;
gc->phantom_count = add_no_overflow(gc->phantom_count, pb->count); if (!gc->during_backpointer) {
if (gc->inc_gen1)
gc->inc_phantom_count = add_no_overflow(gc->inc_phantom_count, pb->count);
else
gc->phantom_count = add_no_overflow(gc->phantom_count, pb->count);
}
return gcBYTES_TO_WORDS(sizeof(Phantom_Bytes)); return gcBYTES_TO_WORDS(sizeof(Phantom_Bytes));
} }
@ -3612,6 +3617,7 @@ intptr_t GC_get_memory_use(void *o)
} }
#endif #endif
amt = add_no_overflow(gen0_size_in_use(gc), gc->memory_in_use); amt = add_no_overflow(gen0_size_in_use(gc), gc->memory_in_use);
amt = add_no_overflow(amt, gc->gen0_phantom_count);
#ifdef MZ_USE_PLACES #ifdef MZ_USE_PLACES
mzrt_mutex_lock(gc->child_total_lock); mzrt_mutex_lock(gc->child_total_lock);
amt = add_no_overflow(amt, gc->child_gc_total); amt = add_no_overflow(amt, gc->child_gc_total);
@ -5839,9 +5845,10 @@ static void garbage_collect(NewGC *gc, int force_full, int no_full, int switchin
gc->use_gen_half = !gc->gc_full && AGE_GEN_0_TO_GEN_HALF(gc); gc->use_gen_half = !gc->gc_full && AGE_GEN_0_TO_GEN_HALF(gc);
if (gc->gc_full) if (gc->gc_full) {
gc->phantom_count = 0; gc->phantom_count = gc->inc_phantom_count;
else if (gc->memory_in_use > gc->phantom_count) { gc->inc_phantom_count = 0;
} else if (gc->memory_in_use > gc->phantom_count) {
/* added back in repair_heap(), after any adjustments from gen0 phantom bytes */ /* added back in repair_heap(), after any adjustments from gen0 phantom bytes */
gc->memory_in_use -= gc->phantom_count; gc->memory_in_use -= gc->phantom_count;
} }

View File

@ -294,6 +294,7 @@ typedef struct NewGC {
uintptr_t phantom_count; uintptr_t phantom_count;
uintptr_t gen0_phantom_count; uintptr_t gen0_phantom_count;
uintptr_t inc_phantom_count;
Roots roots; Roots roots;
struct MMU *mmu; struct MMU *mmu;