Project

General

Profile

Feature #641 ยป cache_latest_heap.diff

rogerdpack (Roger Pack), 10/12/2008 03:40 PM

View differences:

gc.c (working copy)
1109 1109
    }
1110 1110
}
1111 1111

  
1112
struct heaps_slot *cached_pointer_to_latest_heap = 0;
1113

  
1112 1114
static inline int
1113 1115
is_pointer_to_heap(rb_objspace_t *objspace, void *ptr)
1114 1116
{
......
1118 1120

  
1119 1121
    if (p < lomem || p > himem) return Qfalse;
1120 1122
    if ((VALUE)p % sizeof(RVALUE) != 0) return Qfalse;
1121

  
1123
    if( cached_pointer_to_latest_heap && (p >= cached_pointer_to_latest_heap->slot) && (p < cached_pointer_to_latest_heap->slot + cached_pointer_to_latest_heap->limit) )
1124
    {
1125
	return Qtrue;
1126
    }
1122 1127
    /* check if p looks like a pointer using bsearch*/
1123 1128
    lo = 0;
1124 1129
    hi = heaps_used;
......
1127 1132
	heap = &heaps[mid];
1128 1133
	if (heap->slot <= p) {
1129 1134
	    if (p < heap->slot + heap->limit)
1130
		return Qtrue;
1135
		{
1136
			cached_pointer_to_latest_heap = heap;
1137
			return Qtrue;
1138
		}
1131 1139
	    lo = mid + 1;
1132 1140
	}
1133 1141
	else {
......
1589 1597
{
1590 1598
    size_t i, j;
1591 1599
    RVALUE *last = 0;
1592

  
1593 1600
    for (i = j = 1; j < heaps_used; i++) {
1594 1601
	if (heaps[i].limit == 0) {
1595 1602
	    if (!last) {
......
1926 1933
    }
1927 1934
    during_gc++;
1928 1935
    objspace->count++;
1929

  
1936
    cached_pointer_to_latest_heap = 0;
1930 1937
    GC_PROF_TIMER_START;
1931 1938
    GC_PROF_MARK_TIMER_START;
1932 1939
    SET_STACK_END;