add new debug_counters about is_pointer_to_heap().

is_pointer_to_heap() is used for conservative marking. To analyze
this function's behavior, introduce some debug_counters.
This commit is contained in:
Koichi Sasada 2019-05-07 14:06:25 +09:00
Родитель 7e72ce0f73
Коммит 4dc5d3c5dd
2 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -143,6 +143,11 @@ RB_DEBUG_COUNTER(gc_major_shady)
RB_DEBUG_COUNTER(gc_major_force) RB_DEBUG_COUNTER(gc_major_force)
RB_DEBUG_COUNTER(gc_major_oldmalloc) RB_DEBUG_COUNTER(gc_major_oldmalloc)
RB_DEBUG_COUNTER(gc_isptr_trial)
RB_DEBUG_COUNTER(gc_isptr_range)
RB_DEBUG_COUNTER(gc_isptr_align)
RB_DEBUG_COUNTER(gc_isptr_maybe)
/* object allocation counts: /* object allocation counts:
* *
* * obj_newobj: newobj counts * * obj_newobj: newobj counts

6
gc.c
Просмотреть файл

@ -2191,8 +2191,13 @@ is_pointer_to_heap(rb_objspace_t *objspace, void *ptr)
register struct heap_page *page; register struct heap_page *page;
register size_t hi, lo, mid; register size_t hi, lo, mid;
RB_DEBUG_COUNTER_INC(gc_isptr_trial);
if (p < heap_pages_lomem || p > heap_pages_himem) return FALSE; if (p < heap_pages_lomem || p > heap_pages_himem) return FALSE;
RB_DEBUG_COUNTER_INC(gc_isptr_range);
if ((VALUE)p % sizeof(RVALUE) != 0) return FALSE; if ((VALUE)p % sizeof(RVALUE) != 0) return FALSE;
RB_DEBUG_COUNTER_INC(gc_isptr_align);
/* check if p looks like a pointer using bsearch*/ /* check if p looks like a pointer using bsearch*/
lo = 0; lo = 0;
@ -2202,6 +2207,7 @@ is_pointer_to_heap(rb_objspace_t *objspace, void *ptr)
page = heap_pages_sorted[mid]; page = heap_pages_sorted[mid];
if (page->start <= p) { if (page->start <= p) {
if (p < page->start + page->total_slots) { if (p < page->start + page->total_slots) {
RB_DEBUG_COUNTER_INC(gc_isptr_maybe);
return TRUE; return TRUE;
} }
lo = mid + 1; lo = mid + 1;