From c123129b95cada301c3b3e173877cf05263db2fb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 10 May 2008 00:42:26 -0500 Subject: [PATCH] Faster GC --- vm/data_gc.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++-- vm/layouts.h | 2 +- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/vm/data_gc.c b/vm/data_gc.c index 6e32e14991..a52f2490e9 100755 --- a/vm/data_gc.c +++ b/vm/data_gc.c @@ -648,12 +648,63 @@ void do_code_slots(CELL scan) } } +/* This function is performance-critical */ CELL collect_next(CELL scan) { - do_slots(scan,copy_handle); + CELL *obj = (CELL *)scan; + CELL *end = (CELL *)(scan + binary_payload_start(scan)); + + obj++; + + CELL newspace_start = newspace->start; + CELL newspace_end = newspace->end; + + if(HAVE_NURSERY_P && collecting_gen == NURSERY) + { + CELL nursery_start = nursery.start; + CELL nursery_end = nursery.end; + + for(; obj < end; obj++) + { + CELL pointer = *obj; + + if(!immediate_p(pointer) + && (pointer >= nursery_start && pointer < nursery_end)) + *obj = copy_object(pointer); + } + } + else if(HAVE_AGING_P && collecting_gen == AGING) + { + F_ZONE *tenured = &data_heap->generations[TENURED]; + + CELL tenured_start = tenured->start; + CELL tenured_end = tenured->end; + + for(; obj < end; obj++) + { + CELL pointer = *obj; + + if(!immediate_p(pointer) + && !(pointer >= newspace_start && pointer < newspace_end) + && !(pointer >= tenured_start && pointer < tenured_end)) + *obj = copy_object(pointer); + } + } + else if(collecting_gen == TENURED) + { + for(; obj < end; obj++) + { + CELL pointer = *obj; + + if(!immediate_p(pointer) + && !(pointer >= newspace_start && pointer < newspace_end)) + *obj = copy_object(pointer); + } - if(collecting_gen == TENURED) do_code_slots(scan); + } + else + critical_error("Bug in collect_next",0); return scan + untagged_object_size(scan); } diff --git a/vm/layouts.h b/vm/layouts.h index ff938309e7..89af0a306c 100755 --- a/vm/layouts.h +++ b/vm/layouts.h @@ -64,7 +64,7 @@ typedef signed long long s64; INLINE bool immediate_p(CELL obj) { - return (TAG(obj) == FIXNUM_TYPE || obj == F); + return (obj == F || TAG(obj) == FIXNUM_TYPE); } INLINE F_FIXNUM untag_fixnum_fast(CELL tagged)